Skip to content

Commit

Permalink
Merge pull request #1 from socfortress/initial-commit
Browse files Browse the repository at this point in the history
Initial commit
  • Loading branch information
taylorwalton authored Jul 10, 2023
2 parents 6e0682d + a2bf7c0 commit 61dd380
Show file tree
Hide file tree
Showing 58 changed files with 7,498 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
end_of_line = lf

# 2 spaces for YAML
[*.{yml,yaml}]
indent_size = 2

# 2 spaces for web things
[*.{js,vue,html,json}]
indent_size = 2

# Windows, windows, windows
[*.{bat,cmd,ps1}]
indent_style = tab
end_of_line = crlf

# Makefile, tabs are a must
[Makefile]
indent_style = tab
22 changes: 22 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* eslint-env node */
require("@rushstack/eslint-patch/modern-module-resolution")

module.exports = {
root: true,
extends: [
"plugin:vue/vue3-essential",
"eslint:recommended",
"@vue/eslint-config-typescript",
"@vue/eslint-config-prettier"
],
overrides: [
{
files: ["cypress/e2e/**.{cy,spec}.{js,ts,jsx,tsx}"],
extends: ["plugin:cypress/recommended"]
}
],
parserOptions: {
ecmaVersion: "latest",
sourceType: "module"
}
}
12 changes: 12 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[flake8]
#max-complexity = 18
max-line-length = 120
#select = B,C,E,F,W,T4,B9
#ignore = E203, E266, E501, W503, F403, F401
ignore = W503, E231, W605
# W503, # line break before binary operator
# E231, # missing whitespace after ',' (caused by black style)
# W605, # invalid escape sequence (caused by regex)
extend-ignore = E203
exclude =
.venv
16 changes: 16 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: pre-commit

on:
pull_request:
push:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.9"
- uses: pre-commit/action@v3.0.0
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
.DS_Store
dist
dist-ssr
coverage
*.local

/cypress/videos/
/cypress/screenshots/

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# Python Virtualenv
__pycache__/
*.py[cod]
build/
.venv/
wheels/
*.egg-info/
*.egg

# Local development artifacts
*.db
.env
4 changes: 4 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[settings]
profile=black
force_single_line=True
src_paths=backend
62 changes: 62 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-merge-conflict
- id: check-yaml
args: ["--unsafe"]
- id: end-of-file-fixer
- id: check-json
- id: trailing-whitespace
- id: check-added-large-files
- id: detect-private-key
- id: requirements-txt-fixer
args: ["backend/requirements.txt", "backend/requirements.in"]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
name: Sort python imports (shows diff)
args: ["-c", "--diff"]
- id: isort
name: Sort python imports (fixes files)

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
language_version: python3.9

- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.3.0
hooks:
- id: setup-cfg-fmt

- repo: https://github.com/asottile/add-trailing-comma
rev: v2.4.0
hooks:
- id: add-trailing-comma

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
name: Check project styling

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.0-alpha.6"
hooks:
- id: prettier

- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.41.0
hooks:
- id: eslint
files: \.([cjt]sx?|[cm]ts|[cm]js|cvue)$ # *.js, *.jsx, *.ts, *.tsx and *.vue
additional_dependencies:
- "@rushstack/eslint-patch@1.2.0"
- eslint@8.39.0
- "@vue/eslint-config-prettier@7.1.0"
- "@vue/eslint-config-typescript@11.0.2"
- eslint-plugin-cypress@2.13.3
- eslint-plugin-vue@9.11.1
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"arrowParens": "avoid",
"printWidth": 120,
"semi": false,
"tabWidth": 4,
"trailingComma": "none",
"useTabs": false
}
16 changes: 16 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"recommendations": [
"ms-python.python",
"ms-python.black-formatter",
"editorconfig.editorconfig",
"github.vscode-github-actions",
"ecmel.vscode-html-css",
"george-alison.html-preview-vscodes",
"esbenp.prettier-vscode",
"octref.vetur",
"ms-vscode.remtoe-remote-wsl",
"dbaeumer.vscode-eslint",
"Vue.volar",
"Vue.vscode-typescript-vue-plugin"
]
}
3 changes: 3 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Vagrant.configure("2") do |config|
config.vm.box = "debian/bullseye64"
end
168 changes: 168 additions & 0 deletions backend/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# DB Modals

```mermaid
classDiagram
class ConnectorsAvailable {
+int id
+str connector_name
+str connector_description
+str connector_supports
+bool connector_configured
+bool connector_verified
}
class Connectors {
+int id
+str connector_name
+str connector_type
+str connector_url
+DateTime connector_last_updated
+str connector_username
+str connector_password
+str connector_api_key
}
class DisabledRules {
+int id
+str rule_id
+str previous_level
+str new_level
+str reason_for_disabling
+DateTime date_disabled
+int length_of_time
}
class WazuhIndexerAllocation {
+int id
+str node
+float disk_used
+float disk_available
+float disk_total
+float disk_percent
+DateTime timestamp
}
class GraylogMetricsAllocation {
+int id
+float input_usage
+float output_usage
+float processor_usage
+float input_1_sec_rate
+float output_1_sec_rate
+float total_input
+float total_output
+DateTime timestamp
}
class AgentMetadata {
+int id
+str agent_id
+str ip_address
+str os
+str hostname
+bool critical_asset
+DateTime last_seen
}
class Case {
+int id
+int case_id
+str case_name
+str agents
}
class Artifact {
+int id
+str artifact_name
+JSONB artifact_results
+str hostname
}
```


# Connector Classes

```mermaid
classDiagram
class Connector {
+attributes: dict
+verify_connection()
+get_connector_info_from_db(connector_name: str)
}
class WazuhIndexerConnector {
+verify_connection()
}
Connector <|-- WazuhIndexerConnector
class GraylogConnector {
+verify_connection()
}
Connector <|-- GraylogConnector
class WazuhManagerConnector {
+verify_connection()
}
Connector <|-- WazuhManagerConnector
class ShuffleConnector {
+verify_connection()
}
Connector <|-- ShuffleConnector
class DfirIrisConnector {
+verify_connection()
}
Connector <|-- DfirIrisConnector
class VelociraptorConnector {
+verify_connection()
}
Connector <|-- VelociraptorConnector
class RabbitMQConnector {
+verify_connection()
}
Connector <|-- RabbitMQConnector
class ConnectorFactory {
-_creators: dict
+register_creator(key: str, creator: str)
+create(key: str, connector_name: str)
}
```

# Routes

```mermaid
graph TD;
A["/connectors (GET)"] --> B["list_connectors_available()"]
C["/connectors/wazuh-manager (GET)"] --> D["get_wazuh_manager_connector()"]
E["/connectors/<id> (PUT)"] --> F["update_connector_route(id)"]
```

# Responses

```mermaid
graph TD;
A[update_connector_in_db] --> B[Return Data]
C[update_connector] --> D[Return Data]
E[process_connector] --> F[Return Data]
G[ConnectorFactory.create] --> H[Connector Instance]
H --> I[WazuhIndexerConnector.verify_connection]
H --> J[GraylogConnector.verify_connection]
H --> K[WazuhManagerConnector.verify_connection]
H --> L[DfirIrisConnector.verify_connection]
H --> M[VelociraptorConnector.verify_connection]
H --> N[RabbitMQConnector.verify_connection]
H --> O[ShuffleConnector.verify_connection]
I --> P[Return Data]
J --> Q[Return Data]
K --> R[Return Data]
L --> S[Return Data]
M --> T[Return Data]
N --> U[Return Data]
O --> V[Return Data]
```

Loading

0 comments on commit 61dd380

Please sign in to comment.