Fix README (#16)
* lint * Adds windows and linux development details * Remove ignored file
Graham Williamson committed
Jul 13, 2023 at 07:47 UTC
ffa4b107eab00a46e5dad97e6facf756151eb7a2
9 files changed
+59
-17
.flake8
+1
-1
@@ -1,6 +1,6 @@
1
[flake8]
2
#max-complexity = 18
3
-max-line-length = 180
3
+max-line-length = 140
4
#select = B,C,E,F,W,T4,B9
5
#ignore = E203, E266, E501, W503, F403, F401
6
ignore = E402, W503, E231, W605
.prettierrc.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"arrowParens": "avoid",
3
- "printWidth": 120,
3
+ "printWidth": 140,
4
"semi": false,
5
"tabWidth": 4,
6
"trailingComma": "none",
README.md
+39
-5
@@ -1,23 +1,41 @@
1
# CoPilot
2
3
-SOCFortress CoPilot
3
+SOCFortress CoPilot is developed using python 3.11. It'll likely work in earlier versions, but we're targeting
4
+3.11 for the extra error reporting featurest that dropped in 3.10 and later.
5
6
# Development
7
8
+SOCFortress CoPilot is developed using python 3.11. It'll likely work in earlier versions, but we're targeting
9
+3.11 for the extra error reporting featurest that dropped in 3.10 and later.
10
+
11
## Local development of backend
12
9
-Setup the env vars, adjust if required.
13
+Setup the env vars, adjust if required, such as the `UPLOAD_FOLDER` environment variable.
14
15
```
16
cd backend
17
cp .env.example .env
18
```
19
16
-Create and activate python, installing dependencies
20
+Create and activate python.
21
+
22
+### macOS/Linux
23
24
```
19
-python3.11 -m venv.venv --copies
25
+python3.11 -m venv .venv --copies
26
source .venv/bin/activate
27
+```
28
+
29
+### Windows
30
+
31
+```
32
+python.exe -m venv .venv --copies
33
+.venv\Scripts\activate
34
+```
35
+
36
+Installing dependencies
37
+
38
+```
39
pip install -U pip setuptools wheel
40
pip install -r requirements.in
41
```
@@ -28,12 +46,28 @@ Create a DB and apply any pending DB migrations
46
FLASK_APP=copilot.py flask db upgrade
47
```
48
49
+If requiring to connect to the
50
+
51
+```
52
+sqlite3 copilot.db < insert_data.sql
53
+```
54
+
55
Start local dev server
56
57
```
34
-python3 app.py
58
+python app.py
59
+```
60
+
61
+## Test local backend
62
+
63
+Show configured connectors
64
+
65
+```
66
+curl http://localhost:5000/connectors
67
```
68
69
+## Database changes
70
+
71
If there any changes made to the model run the migrate command (example commment)
72
and if any changes were detected, update your local DB instance.
73
backend/app/routes/rules.py
+4
-2
@@ -23,7 +23,8 @@ def disable_rule() -> str:
23
This endpoint accepts a POST request with a JSON body containing the rule to be disabled.
24
25
Returns:
26
- str: A JSON string response containing the updated rule information. The actual content of the response depends on the implementation of `DisableRuleService.disable_rule`.
26
+ str: A JSON string response containing the updated rule information. The actual content of the response depends on the
27
+ implementation of `DisableRuleService.disable_rule`.
28
29
Example Request Body:
30
{
@@ -48,7 +49,8 @@ def enable_rule() -> str:
49
This endpoint accepts a POST request with a JSON body containing the rule to be enabled.
50
51
Returns:
51
- str: A JSON string response containing the updated rule information. The actual content of the response depends on the implementation of `EnableRuleService.enable_rule`.
52
+ str: A JSON string response containing the updated rule information. The actual content of the response depends on the
53
+ implementation of `EnableRuleService.enable_rule`.
54
55
Example Request Body:
56
{
backend/app/services/DFIR_IRIS/universal.py
+4
-2
@@ -48,7 +48,8 @@ class UniversalService:
48
connector_name (str): The name of the DFIR-IRIS connector.
49
50
Returns:
51
- tuple: A tuple containing the connection URL and API key. If the connection is not successful, both elements of the tuple are None.
51
+ tuple: A tuple containing the connection URL and API key. If the connection is not successful, both elements of the tuple are
52
+ None.
53
"""
54
connector_instance = connector_factory.create(connector_name, connector_name)
55
connection_successful = connector_instance.verify_connection()
@@ -66,7 +67,8 @@ class UniversalService:
67
Creates a session with DFIR-IRIS.
68
69
This method creates a session with DFIR-IRIS and returns a dictionary with a success status and the session object.
69
- If a session cannot be established, an error is logged and a dictionary with "success" set to False and an error message is returned.
70
+ If a session cannot be established, an error is logged and a dictionary with "success" set to False and an error message is
71
+ returned.
72
73
Returns:
74
dict: A dictionary containing the success status and either the session object or an error message.
backend/app/services/WazuhIndexer/cluster.py
+4
-2
@@ -97,7 +97,8 @@ class ClusterService:
97
98
def _format_node_allocation(self, node_allocation):
99
"""
100
- 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.
100
+ Format the node allocation details into a list of dictionaries. Each dictionary contains disk used, disk available, total disk, disk
101
+ usage percentage, and node name.
102
103
Args:
104
node_allocation: Node allocation details from Elasticsearch.
@@ -201,7 +202,8 @@ class ClusterService:
202
203
def _format_shards(self, shards):
204
"""
204
- Format the shard details into a list of dictionaries. Each dictionary contains index name, shard number, shard state, shard size, and node name.
205
+ Format the shard details into a list of dictionaries. Each dictionary contains index name, shard number, shard state, shard size,
206
+ and node name.
207
208
Args:
209
shards: Shard details from Elasticsearch.
backend/app/services/WazuhIndexer/index.py
+2
-1
@@ -80,7 +80,8 @@ class IndexService:
80
81
def _format_indices_summary(self, indices: Dict[str, object]) -> Dict[str, object]:
82
"""
83
- Format the indices summary into a list of dictionaries. Each dictionary contains index name, health status, document count, store size, and replica count.
83
+ Format the indices summary into a list of dictionaries. Each dictionary contains index name, health status, document count, store
84
+ size, and replica count.
85
86
Args:
87
indices (dict): Indices summary from Elasticsearch.
backend/app/services/WazuhManager/disabled_rule.py
+4
-2
@@ -141,7 +141,8 @@ class DisableRuleService:
141
Disable a rule in Wazuh Manager.
142
143
Args:
144
- request (Dict[str, Union[str, int]]): The request to disable a rule. It should contain 'rule_id', 'reason', and 'length_of_time'.
144
+ request (Dict[str, Union[str, int]]): The request to disable a rule. It should contain 'rule_id', 'reason', and
145
+ 'length_of_time'.
146
147
Returns:
148
Dict[str, Union[str, bool]]: A dictionary indicating the success or failure of the operation.
@@ -249,7 +250,8 @@ class DisableRuleService:
250
rule_id (str): The id of the rule to be disabled.
251
252
Returns:
252
- Tuple[str, Union[Dict[str, str], List[Dict[str, str]]]]: A tuple containing the previous level of the rule and the updated file content.
253
+ Tuple[str, Union[Dict[str, str], List[Dict[str, str]]]]: A tuple containing the previous level of the rule and the updated file
254
+ content.
255
"""
256
logger.info(
257
f"Setting rule {rule_id} level to 1 for file_content: {file_content}",
backend/copilot.sqbpro
deleted
-1
@@ -1 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?><sqlb_project><db path="C:/Users/walto/Desktop/GitHub/CoPilot/backend/copilot.db" readonly="0" foreign_keys="1" case_sensitive_like="0" temp_store="0" wal_autocheckpoint="1000" synchronous="2"/><attached/><window><main_tabs open="structure browser pragmas query" current="0"/></window><tab_structure><column_width id="0" width="300"/><column_width id="1" width="0"/><column_width id="2" width="100"/><column_width id="3" width="1981"/><column_width id="4" width="0"/><expanded_item id="0" parent="1"/><expanded_item id="1" parent="1"/><expanded_item id="2" parent="1"/><expanded_item id="3" parent="1"/></tab_structure><tab_browse><current_table name="4,14:mainagent_metadata"/><default_encoding codec=""/><browse_table_settings><table schema="main" name="agent_metadata" show_row_id="0" encoding="" plot_x_axis="" unlock_view_pk="_rowid_"><sort/><column_widths><column index="1" value="40"/><column index="2" value="65"/><column index="3" value="271"/><column index="4" value="300"/><column index="5" value="205"/><column index="6" value="95"/><column index="7" value="175"/></column_widths><filter_values/><conditional_formats/><row_id_formats/><display_formats/><hidden_columns/><plot_y_axes/><global_filter/></table><table schema="main" name="sublime_alerts" show_row_id="0" encoding="" plot_x_axis="" unlock_view_pk="_rowid_"><sort><column index="3" mode="0"/></sort><column_widths><column index="1" value="40"/><column index="2" value="84"/><column index="3" value="76"/></column_widths><filter_values/><conditional_formats/><row_id_formats/><display_formats/><hidden_columns/><plot_y_axes/><global_filter/></table></browse_table_settings></tab_browse><tab_sql><sql name="SQL 1"></sql><current_tab id="0"/></tab_sql></sqlb_project>