Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed addition of a base pre-commit hook using pre-commit framework #290

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[flake8]
max-line-length = 99
ignore = E203, E501, W503
max-complexity = 10

# E203: whitespace before ':' (conflict with black)
# E501: line too long (conflict with black)
# W503: line break before binary operator (conflict with black)
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,23 @@ jobs:
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Use below configuration for ghcr.io
# with:
# registry: ghcr.io
# username: ${{ github.repository_owner }}
# password: ${{ secrets.CR_PAT }}
# password: ${{ secrets.CR_PAT }}
-
name: Build and push Master
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
id: docker_build_master
uses: docker/build-push-action@v2
with:
context: ${{ matrix.app }}/${{ matrix.version }}
file: ${{ matrix.app }}/${{ matrix.version }}/Dockerfile
file: ${{ matrix.app }}/${{ matrix.version }}/Dockerfile
platforms: linux/amd64,linux/arm64,linux/386
push: true
tags: |
Expand All @@ -77,7 +77,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ${{ matrix.app }}/${{ matrix.version }}
file: ${{ matrix.app }}/${{ matrix.version }}/Dockerfile
file: ${{ matrix.app }}/${{ matrix.version }}/Dockerfile
platforms: linux/amd64,linux/arm64,linux/386
push: true
tags: |
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
.DS_Store
*.pyc
*__pycache__*

47 changes: 47 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
repos:
# See https://pre-commit.com/hooks.html
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: check-merge-conflict
- id: check-yaml
- id: end-of-file-fixer
- id: debug-statements
- id: trailing-whitespace
- id: check-added-large-files
- id: detect-private-key
- id: check-case-conflict
- id: requirements-txt-fixer
- id: check-ast
- id: mixed-line-ending
args: ['--fix=lf']
# - id: check-toml

# - repo: https://github.com/asottile/reorder_python_imports
# rev: v3.0.1
# hooks:
# - id: reorder-python-imports
# args: [--py37-plus]
#
# - repo: https://github.com/asottile/add-trailing-comma
# rev: v2.2.2
# hooks:
# - id: add-trailing-comma
#
# - repo: https://github.com/psf/black
# rev: 22.3.0
# hooks:
# - id: black
#
# - repo: https://github.com/PyCQA/flake8
# rev: 4.0.1
# hooks:
# - id: flake8
# args: [--config=.flake8]
# additional_dependencies: [flake8-bugbear]
#
# - repo: https://github.com/PyCQA/bandit
# rev: 1.7.1
# hooks:
# - id: bandit
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ This is a repository for apps to be used in [Shuffle](https://github.com/frikky/

**PS:** These apps should be valid with WALKOFF, but the SDK is different, meaning you have to change the FIRST line in each Dockerfile (FROM frikky/shuffle:app_sdk).

## App Creation
App creation can be done with the Shuffle App Creator (exports as OpenAPI) or Python, which makes it possible to connect _literally_ any tool. Always prioritize using the App Creator when applicable.
## App Creation
App creation can be done with the Shuffle App Creator (exports as OpenAPI) or Python, which makes it possible to connect _literally_ any tool. Always prioritize using the App Creator when applicable.

![Shuffle-workflow-categories](https://github.com/frikky/shuffle-workflows/blob/master/images/categories_circle_dark.png)

### References
### References
* [App Development Process](https://github.com/frikky/shuffle-docs/blob/master/handbook/engineering/app_development.md)
* [Python app documentation](https://shuffler.io/docs/app_creation)
* [Apps in progress](https://github.com/frikky/Shuffle-apps/projects/1)

### Categories
### Categories
We have defined eight (8) "major" categories of tools that are necessary to any cybersecurity threat. Most security-related tools can fit into one of these eight.
1. [Communication](https://github.com/frikky/Shuffle-apps/issues/26) - Any way to chat; WhatsApp, SMS, Email etc.
1. [Communication](https://github.com/frikky/Shuffle-apps/issues/26) - Any way to chat; WhatsApp, SMS, Email etc.
2. [Case Management](https://github.com/frikky/Shuffle-apps/issues/22) - The central hub for operation teams.
3. [SIEM](https://github.com/frikky/Shuffle-apps/issues/21) - Search engine for logs in an enterprise. Used to find evil.
4. [Assets](https://github.com/frikky/Shuffle-apps/issues/25) - Discover endpoint information. Vulnerabilities, owners, departments etc.
Expand Down
4 changes: 2 additions & 2 deletions active-directory/1.0.0/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ contact_info:
email: [email protected]
tags:
- activedirectory
- ldap
- ldap
- ldaps
- Azure AD
categories:
- IAM
- assets
- assets
authentication:
required: true
parameters:
Expand Down
2 changes: 1 addition & 1 deletion active-directory/1.0.0/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
requests==2.25.1
ldap3
requests==2.25.1
13 changes: 6 additions & 7 deletions active-directory/1.0.0/src/app.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import asyncio
import json

import ldap3
import asyncio
from ldap3 import (
Server,
Connection,
MODIFY_REPLACE,
ALL_ATTRIBUTES,
)
from ldap3 import ALL_ATTRIBUTES
from ldap3 import Connection
from ldap3 import MODIFY_REPLACE
from ldap3 import Server
from walkoff_app_sdk.app_base import AppBase

class ActiveDirectory(AppBase):
Expand Down
8 changes: 4 additions & 4 deletions ad-ldap/1.0.0/api.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
app_version: 1.0.0
name: AD LDAP
name: AD LDAP
description: A simple app to query Active Directory and LDAP
contact_info:
name: "@arnydo"
url: https://kyleparrish.com
email: [email protected]
tags:
- activedirectory
- ldap
- ldap
categories:
- IAM
- assets
- assets
authentication:
required: true
parameters:
Expand Down Expand Up @@ -60,7 +60,7 @@ actions:
description: Port to to BIND to
required: true
multiline: false
example: 3269
example: 3269
schema:
type: string
- name: use_ssl
Expand Down
2 changes: 1 addition & 1 deletion ad-ldap/1.0.0/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
requests==2.25.1
ldap3
requests==2.25.1
16 changes: 14 additions & 2 deletions ad-ldap/1.0.0/src/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import asyncio
import json

import ldap3
import asyncio
from ldap3 import Server, Connection, AUTO_BIND_NO_TLS, SUBTREE, BASE, ALL_ATTRIBUTES, ObjectDef, AttrDef, Reader, Entry, Attribute, OperationalAttribute
from ldap3 import ALL_ATTRIBUTES
from ldap3 import AttrDef
from ldap3 import Attribute
from ldap3 import AUTO_BIND_NO_TLS
from ldap3 import BASE
from ldap3 import Connection
from ldap3 import Entry
from ldap3 import ObjectDef
from ldap3 import OperationalAttribute
from ldap3 import Reader
from ldap3 import Server
from ldap3 import SUBTREE
from walkoff_app_sdk.app_base import AppBase


Expand Down
7 changes: 4 additions & 3 deletions analyze.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import yaml
import os
import subprocess

import yaml

basedir = "."
dirs = os.listdir(basedir)
#print(dirs)
Expand Down Expand Up @@ -66,7 +67,7 @@
pythondata = tmp.read()
for action_name in action_names:
if not action_name in pythondata:
print(f"===> Couldn't find action \"{action_name}\" from {apifile} in script {pythonfile}")
print(f"===> Couldn't find action \"{action_name}\" from {apifile} in script {pythonfile}")

code = f"python3 {pythonfile}"
process = subprocess.Popen(
Expand Down Expand Up @@ -94,4 +95,4 @@
#break


#for item in
#for item in
11 changes: 5 additions & 6 deletions archive-org/1.0.0/api.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion archive-org/1.0.0/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
requests==2.25.1
savepagenow==1.1.1
savepagenow==1.1.1
6 changes: 3 additions & 3 deletions archive-org/1.0.0/src/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import time
import asyncio
import json
import socket
import asyncio
import time

import requests
import savepagenow

from walkoff_app_sdk.app_base import AppBase

class ArchiveOrg(AppBase):
Expand Down
6 changes: 3 additions & 3 deletions archive-today/1.0.0/api.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
walkoff_version: 1.0.0
app_version: 1.0.0
name: Archive.today
description: Archive.Today app
description: Archive.Today app
environment: cloud
tags:
- archive
- archive
categories:
- archive
- archive
contact_info:
name: Peter Clemenko
url: https://github.com/peter-clemenko
Expand Down
2 changes: 1 addition & 1 deletion archive-today/1.0.0/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
archiveis==0.0.9
requests==2.25.1
archiveis==0.0.9
10 changes: 5 additions & 5 deletions archive-today/1.0.0/src/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import time
import asyncio
import json
import socket
import asyncio
import requests
import archiveis
import time

import archiveis
import requests
from walkoff_app_sdk.app_base import AppBase

class ArchiveToday(AppBase):
Expand Down Expand Up @@ -32,7 +32,7 @@ def archive_target(self, target):
# This logs to the docker logs
self.logger.info(message)
return archive_url

# return target

if __name__ == "__main__":
Expand Down
9 changes: 4 additions & 5 deletions aws-cloudwatch/1.0.0/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## AWS Cloudwatch logs
AWS Cloudwatch app to interact with Amazon CLoudswatch from Shuffle. For more information check out [Cloudwatch logs documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html)
AWS Cloudwatch app to interact with Amazon CLoudswatch from Shuffle. For more information check out [Cloudwatch logs documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html)

## Actions
Parameters written in **Bold** are required. <br />
Parameters written in **Bold** are required. <br />
access_key, secret_key and region are used for authentication.

| No. | Action | Description | Parameters |
Expand All @@ -19,8 +19,8 @@ access_key, secret_key and region are used for authentication.
## Requirements

1. AWS account.
2. Make sure you have edequate permissions. Refer [this](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/permissions-reference-cwl.html) for more information on persmissions required.
3. Access key, Secret key and region of the user.
2. Make sure you have edequate permissions. Refer [this](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/permissions-reference-cwl.html) for more information on persmissions required.
3. Access key, Secret key and region of the user.

- __How to find access key & secret key ?__
1. Open https://console.aws.amazon.com/
Expand All @@ -29,4 +29,3 @@ access_key, secret_key and region are used for authentication.
4. To see the new access key, choose Show. Your credentials resemble the following:
- Access key ID: AKIAIOSFODNN7EXAMPLE
- Secret access key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

Loading