Skip to content

Commit

Permalink
Fix README (#16)
Browse files Browse the repository at this point in the history
* lint

* Adds windows and linux development details

* Remove ignored file
  • Loading branch information
00willo authored Jul 12, 2023
1 parent 7fa2509 commit ffa4b10
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[flake8]
#max-complexity = 18
max-line-length = 180
max-line-length = 140
#select = B,C,E,F,W,T4,B9
#ignore = E203, E266, E501, W503, F403, F401
ignore = E402, W503, E231, W605
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"arrowParens": "avoid",
"printWidth": 120,
"printWidth": 140,
"semi": false,
"tabWidth": 4,
"trailingComma": "none",
Expand Down
44 changes: 39 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,41 @@
# CoPilot

SOCFortress CoPilot
SOCFortress CoPilot is developed using python 3.11. It'll likely work in earlier versions, but we're targeting
3.11 for the extra error reporting featurest that dropped in 3.10 and later.

# Development

SOCFortress CoPilot is developed using python 3.11. It'll likely work in earlier versions, but we're targeting
3.11 for the extra error reporting featurest that dropped in 3.10 and later.

## Local development of backend

Setup the env vars, adjust if required.
Setup the env vars, adjust if required, such as the `UPLOAD_FOLDER` environment variable.

```
cd backend
cp .env.example .env
```

Create and activate python, installing dependencies
Create and activate python.

### macOS/Linux

```
python3.11 -m venv.venv --copies
python3.11 -m venv .venv --copies
source .venv/bin/activate
```

### Windows

```
python.exe -m venv .venv --copies
.venv\Scripts\activate
```

Installing dependencies

```
pip install -U pip setuptools wheel
pip install -r requirements.in
```
Expand All @@ -28,12 +46,28 @@ Create a DB and apply any pending DB migrations
FLASK_APP=copilot.py flask db upgrade
```

If requiring to connect to the

```
sqlite3 copilot.db < insert_data.sql
```

Start local dev server

```
python3 app.py
python app.py
```

## Test local backend

Show configured connectors

```
curl http://localhost:5000/connectors
```

## Database changes

If there any changes made to the model run the migrate command (example commment)
and if any changes were detected, update your local DB instance.

Expand Down
6 changes: 4 additions & 2 deletions backend/app/routes/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def disable_rule() -> str:
This endpoint accepts a POST request with a JSON body containing the rule to be disabled.
Returns:
str: A JSON string response containing the updated rule information. The actual content of the response depends on the implementation of `DisableRuleService.disable_rule`.
str: A JSON string response containing the updated rule information. The actual content of the response depends on the
implementation of `DisableRuleService.disable_rule`.
Example Request Body:
{
Expand All @@ -48,7 +49,8 @@ def enable_rule() -> str:
This endpoint accepts a POST request with a JSON body containing the rule to be enabled.
Returns:
str: A JSON string response containing the updated rule information. The actual content of the response depends on the implementation of `EnableRuleService.enable_rule`.
str: A JSON string response containing the updated rule information. The actual content of the response depends on the
implementation of `EnableRuleService.enable_rule`.
Example Request Body:
{
Expand Down
6 changes: 4 additions & 2 deletions backend/app/services/DFIR_IRIS/universal.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def collect_iris_details(
connector_name (str): The name of the DFIR-IRIS connector.
Returns:
tuple: A tuple containing the connection URL and API key. If the connection is not successful, both elements of the tuple are None.
tuple: A tuple containing the connection URL and API key. If the connection is not successful, both elements of the tuple are
None.
"""
connector_instance = connector_factory.create(connector_name, connector_name)
connection_successful = connector_instance.verify_connection()
Expand All @@ -66,7 +67,8 @@ def create_session(self) -> Dict[str, Union[bool, Optional[ClientSession], str]]
Creates a session with DFIR-IRIS.
This method creates a session with DFIR-IRIS and returns a dictionary with a success status and the session object.
If a session cannot be established, an error is logged and a dictionary with "success" set to False and an error message is returned.
If a session cannot be established, an error is logged and a dictionary with "success" set to False and an error message is
returned.
Returns:
dict: A dictionary containing the success status and either the session object or an error message.
Expand Down
6 changes: 4 additions & 2 deletions backend/app/services/WazuhIndexer/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def _collect_node_allocation(self) -> Dict[str, object]:

def _format_node_allocation(self, node_allocation):
"""
Format the node allocation details into a list of dictionaries. Each dictionary contains disk used, disk available, total disk, disk usage percentage, and node name.
Format the node allocation details into a list of dictionaries. Each dictionary contains disk used, disk available, total disk, disk
usage percentage, and node name.
Args:
node_allocation: Node allocation details from Elasticsearch.
Expand Down Expand Up @@ -201,7 +202,8 @@ def _collect_shards(self) -> Dict[str, object]:

def _format_shards(self, shards):
"""
Format the shard details into a list of dictionaries. Each dictionary contains index name, shard number, shard state, shard size, and node name.
Format the shard details into a list of dictionaries. Each dictionary contains index name, shard number, shard state, shard size,
and node name.
Args:
shards: Shard details from Elasticsearch.
Expand Down
3 changes: 2 additions & 1 deletion backend/app/services/WazuhIndexer/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def collect_indices_summary(self) -> Dict[str, object]:

def _format_indices_summary(self, indices: Dict[str, object]) -> Dict[str, object]:
"""
Format the indices summary into a list of dictionaries. Each dictionary contains index name, health status, document count, store size, and replica count.
Format the indices summary into a list of dictionaries. Each dictionary contains index name, health status, document count, store
size, and replica count.
Args:
indices (dict): Indices summary from Elasticsearch.
Expand Down
6 changes: 4 additions & 2 deletions backend/app/services/WazuhManager/disabled_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ def disable_rule(
Disable a rule in Wazuh Manager.
Args:
request (Dict[str, Union[str, int]]): The request to disable a rule. It should contain 'rule_id', 'reason', and 'length_of_time'.
request (Dict[str, Union[str, int]]): The request to disable a rule. It should contain 'rule_id', 'reason', and
'length_of_time'.
Returns:
Dict[str, Union[str, bool]]: A dictionary indicating the success or failure of the operation.
Expand Down Expand Up @@ -249,7 +250,8 @@ def _set_level_1(
rule_id (str): The id of the rule to be disabled.
Returns:
Tuple[str, Union[Dict[str, str], List[Dict[str, str]]]]: A tuple containing the previous level of the rule and the updated file content.
Tuple[str, Union[Dict[str, str], List[Dict[str, str]]]]: A tuple containing the previous level of the rule and the updated file
content.
"""
logger.info(
f"Setting rule {rule_id} level to 1 for file_content: {file_content}",
Expand Down
1 change: 0 additions & 1 deletion backend/copilot.sqbpro

This file was deleted.

0 comments on commit ffa4b10

Please sign in to comment.