@cryptotaxi247 / CoPilot / commits / b9543974

wazuh-manager mkdocs

Taylor committed Jul 11, 2023 at 18:01 UTC b954397465b81d71cc64adbcc84988da085467b4
3 files changed +824 -8
backend/docs/wazuhmanager.md
+215 -2
@@ -1,8 +1,48 @@
1 ## Wazuh-Manager Overview
2
3 -### <span style="color:blue">Wazuh-Manager Model</span>
3 +### <span style="color:blue">Wazuh-Manager Model Rules</span>
4 +
5 +## rules.py Markdown Explanation
6 +
7 +The `rules.py` file appears to be a Python module that defines a SQLAlchemy model and a Marshmallow schema for representing and serializing/deserializing disabled rules in a system.
8 +
9 +### Imports
10 +
11 +The script imports necessary modules at the beginning:
12 +
13 +- `datetime`: A standard Python module for handling dates and times.
14 +- `sqlalchemy`: A popular SQL toolkit and ORM for Python.
15 +- `app`: The application module, presumably containing the SQLAlchemy and Marshmallow instances.
16 +
17 +### Class Definition: DisabledRules
18 +
19 +The `DisabledRules` class is a SQLAlchemy model that represents disabled rules in a system. It includes the following fields:
20 +
21 +- `id`: Unique integer ID of the rule.
22 +- `rule_id`: ID of the rule.
23 +- `previous_level`: Previous level configuration of the rule.
24 +- `new_level`: New level configuration of the rule.
25 +- `reason_for_disabling`: Reason for disabling the rule.
26 +- `date_disabled`: Date when the rule was disabled.
27 +- `length_of_time`: Length of time the rule will be disabled for.
28 +
29 +The `__init__` method initializes a new instance of the `DisabledRules` class, and the `__repr__` method returns a string representation of the `DisabledRules` instance.
30 +
31 +### Class Definition: DisabledRulesSchema
32 +
33 +The `DisabledRulesSchema` class is a Marshmallow schema that is used to serialize and deserialize instances of the `DisabledRules` class. The `Meta` inner class defines the fields to be included in the serialized/deserialized data.
34 +
35 +The script also defines two instances of the `DisabledRulesSchema` class:
36 +
37 +- `disabled_rule_schema`: Used for serializing/deserializing a single `DisabledRules` instance.
38 +- `disabled_rules_schema`: Used for serializing/deserializing a list of `DisabledRules` instances.
39 +
40 +This script follows good practices for defining SQLAlchemy models and Marshmallow schemas. Each class and method is well-documented with a docstring that describes its purpose, the arguments it accepts (if any), and what it returns.
41
42 ::: app.models.rules
43 +
44 +### <span style="color:blue">Wazuh-Manager Model Agents</span>
45 +
46 ::: app.models.agents
47 <br>
48
@@ -13,10 +53,183 @@
53 ::: app.routes.agents.get_agent_vulnerabilities
54 <br>
55
16 -### <span style="color:red">Wazuh-Manager Services</span>
56 +### <span style="color:red">Wazuh-Manager Services Agents</span>
57 +
58 +## agent.py Markdown Explanation
59 +
60 +The `agent.py` file appears to be a Python module that defines two classes: `WazuhHttpRequests` and `WazuhManagerAgentService`. These classes encapsulate the functionality for interacting with the Wazuh Manager agent system.
61 +
62 +### Imports
63 +
64 +The script imports necessary modules at the beginning:
65 +
66 +- `requests`: A popular Python library used for making HTTP requests.
67 +- `loguru`: A third-party library providing a more convenient and powerful logger for Python.
68 +- `typing`: A standard Python library for support of type hints.
69 +- `app.services.WazuhManager.universal.UniversalService`: The `UniversalService` class from the `app.services.WazuhManager.universal` module.
70 +
71 +### Class Definition: WazuhHttpRequests
72 +
73 +The `WazuhHttpRequests` class handles HTTP requests to the Wazuh API. It is initialized with the URL for the Wazuh connector and an authentication token. It provides a method to make HTTP DELETE requests to the specified Wazuh API endpoint.
74 +
75 +### Class Definition: WazuhManagerAgentService
76 +
77 +The `WazuhManagerAgentService` class encapsulates the logic for handling agent-related operations in the Wazuh Manager. It uses the `UniversalService` to get authentication tokens and URLs, and `WazuhHttpRequests` to make HTTP requests.
78 +
79 +It provides methods to:
80 +
81 +- Collect all agents from Wazuh Manager (`collect_agents` method).
82 +- Delete a specific agent (`delete_agent` method).
83 +
84 +Helper Methods
85 +
86 +Several private methods are also defined to support the main functionality:
87 +
88 +- `_get_agent_data`: Retrieves agent data from the Wazuh Manager.
89 +- `_build_agent_list`: Builds a list of dictionaries with agent data.
90 +
91 +Error Handling
92 +
93 +The script includes error handling using try/except blocks. When an error occurs, the error message is logged using loguru's `logger.error` function, and a dictionary with a failure message and success status set to False is returned.
94 +
95 +The `WazuhHttpRequests` and `WazuhManagerAgentService` classes appear to be well-structured and follow good practices for encapsulating functionality related to Wazuh's agent system. Each class and method is well-documented with a docstring that describes its purpose, the arguments it accepts (if any), and what it returns.
96
97 ::: app.services.WazuhManager.agent
98 +
99 +### <span style="color:red">Wazuh-Manager Services Disabled Rule</span>
100 +
101 +## disabled_rule.py Markdown Explanation
102 +
103 +The `disabled_rule.py` file appears to be a Python module that defines two classes: `WazuhHttpRequests` and `DisableRuleService`. These classes encapsulate the functionality for interacting with the Wazuh Manager rules system, specifically for disabling rules.
104 +
105 +### Imports
106 +
107 +The script imports necessary modules at the beginning:
108 +
109 +- `requests`: A popular Python library used for making HTTP requests.
110 +- `loguru`: A third-party library providing a more convenient and powerful logger for Python.
111 +- `typing`: A standard Python library for support of type hints.
112 +- `xmltodict`: A Python module that makes working with XML feel like you are working with JSON.
113 +- `app.models.rules.DisabledRules`: The `DisabledRules` class from the `app.models.rules` module.
114 +- `app.services.WazuhManager.universal.UniversalService`: The `UniversalService` class from the `app.services.WazuhManager.universal` module.
115 +
116 +### Class Definition: WazuhHttpRequests
117 +
118 +The `WazuhHttpRequests` class handles HTTP requests to the Wazuh API. It is initialized with the URL for the Wazuh connector and an authentication token. It provides methods to make HTTP GET and PUT requests to the specified Wazuh API endpoint.
119 +
120 +### Class Definition: DisableRuleService
121 +
122 +The `DisableRuleService` class encapsulates the logic for handling rule-disabling operations in the Wazuh Manager. It uses the `UniversalService` to get authentication tokens and URLs, and `WazuhHttpRequests` to make HTTP requests.
123 +
124 +It provides a method to disable a specific rule in the Wazuh Manager (`disable_rule` method).
125 +
126 +Helper Methods
127 +
128 +Several private methods are also defined to support the main functionality:
129 +
130 +- `_validate_request`: Validates the request to disable a rule.
131 +- `_fetch_filename`: Fetches the filename from the Wazuh-Manager that contains the rule to be disabled.
132 +- `_fetch_file_content`: Fetches the content of the file that contains the rule to be disabled.
133 +- `_set_level_1`: Sets the level of the rule to 1.
134 +- `_convert_to_xml`: Converts the updated file content to XML format.
135 +- `_store_disabled_rule_info`: Stores information about the disabled rule in the database.
136 +- `_upload_updated_rule`: Uploads the updated rule to the Wazuh Manager.
137 +
138 +Error Handling
139 +
140 +The script includes error handling using try/except blocks. When an error occurs, the error message is logged using loguru's `logger.error` function, and a dictionary with a failure message and success status set to False is returned.
141 +
142 +The `WazuhHttpRequests` and `DisableRuleService` classes appear to be well-structured and follow good practices for encapsulating functionality related to Wazuh's rules system. Each class and method is well-documented with a docstring that describes its purpose, the arguments it accepts (if any), and what it returns.
143 +
144 ::: app.services.WazuhManager.disabled_rule
145 +
146 +### <span style="color:red">Wazuh-Manager Services Enabled Rule</span>
147 +
148 +## enabled_rule.py Markdown Explanation
149 +
150 +The `enabled_rule.py` file appears to be a Python module that defines two classes: `WazuhHttpRequests` and `EnableRuleService`. These classes encapsulate the functionality for interacting with the Wazuh Manager rules system, specifically for enabling rules.
151 +
152 +### Imports
153 +
154 +The script imports necessary modules at the beginning:
155 +
156 +- `requests`: A popular Python library used for making HTTP requests.
157 +- `loguru`: A third-party library providing a more convenient and powerful logger for Python.
158 +- `typing`: A standard Python library for support of type hints.
159 +- `xmltodict`: A Python module that makes working with XML feel like you are working with JSON.
160 +- `app.models.rules.DisabledRules`: The `DisabledRules` class from the `app.models.rules` module.
161 +- `app.services.WazuhManager.universal.UniversalService`: The `UniversalService` class from the `app.services.WazuhManager.universal` module.
162 +
163 +### Class Definition: WazuhHttpRequests
164 +
165 +The `WazuhHttpRequests` class handles HTTP requests to the Wazuh API. It is initialized with the URL for the Wazuh connector and an authentication token. It provides methods to make HTTP GET and PUT requests to the specified Wazuh API endpoint.
166 +
167 +### Class Definition: EnableRuleService
168 +
169 +The `EnableRuleService` class encapsulates the logic for handling rule-enabling operations in the Wazuh Manager. It uses the `UniversalService` to get authentication tokens and URLs, and `WazuhHttpRequests` to make HTTP requests.
170 +
171 +It provides a method to enable a specific rule in the Wazuh Manager (`enable_rule` method).
172 +
173 +Helper Methods
174 +
175 +Several private methods are also defined to support the main functionality:
176 +
177 +- `_validate_request`: Validates the request to enable a rule.
178 +- `_fetch_filename`: Fetches the filename from the Wazuh-Manager that contains the rule to be enabled.
179 +- `_fetch_file_content`: Fetches the content of the file that contains the rule to be enabled.
180 +- `_get_previous_level`: Fetches the previous level of a rule from the `disabled_rules` table.
181 +- `_set_level_previous`: Sets the level of the rule to its previous level in the file content.
182 +- `_json_to_xml`: Converts the updated file content to XML format.
183 +- `_delete_rule_from_db`: Deletes a rule from the `disabled_rules` table.
184 +- `_put_updated_rule`: Uploads the updated rule to the Wazuh Manager.
185 +
186 +Error Handling
187 +
188 +The script includes error handling using try/except blocks. When an error occurs, the error message is logged using loguru's `logger.error` function, and a dictionary with a failure message and success status set to False is returned.
189 +
190 +The `WazuhHttpRequests` and `EnableRuleService` classes appear to be well-structured and follow good practices for encapsulating functionality related to Wazuh's rules system. Each class and method is well-documented with a docstring that describes its purpose, the arguments it accepts (if any), and what it returns.
191 +
192 ::: app.services.WazuhManager.enabled_rule
193 +
194 +### <span style="color:red">Wazuh-Manager Services Universal</span>
195 +
196 ::: app.services.WazuhManager.universal
197 +
198 +### <span style="color:red">Wazuh-Manager Services Vulnerability</span>
199 +
200 +## vulnerability.py Markdown Explanation
201 +
202 +The `vulnerability.py` file appears to be a Python module that defines two classes: `WazuhHttpRequests` and `VulnerabilityService`. These classes encapsulate the functionality for interacting with the Wazuh Manager's vulnerability system.
203 +
204 +### Imports
205 +
206 +The script imports necessary modules at the beginning:
207 +
208 +- `requests`: A popular Python library used for making HTTP requests.
209 +- `loguru`: A third-party library providing a more convenient and powerful logger for Python.
210 +- `typing`: A standard Python library for support of type hints.
211 +- `app.services.WazuhManager.universal.UniversalService`: The `UniversalService` class from the `app.services.WazuhManager.universal` module.
212 +
213 +### Class Definition: WazuhHttpRequests
214 +
215 +The `WazuhHttpRequests` class handles HTTP requests to the Wazuh API. It is initialized with the URL for the Wazuh connector and an authentication token. It provides a method to make HTTP GET requests to the specified Wazuh API endpoint.
216 +
217 +### Class Definition: VulnerabilityService
218 +
219 +The `VulnerabilityService` class encapsulates the logic for handling vulnerability-related operations in the Wazuh Manager. It uses the `UniversalService` to get authentication tokens and URLs, and `WazuhHttpRequests` to make HTTP requests.
220 +
221 +It provides a method to retrieve and process vulnerabilities for a specified agent (`agent_vulnerabilities` method).
222 +
223 +Helper Method
224 +
225 +A private method is also defined to support the main functionality:
226 +
227 +- `_process_agent_vulnerabilities`: Processes the raw vulnerabilities data for an agent.
228 +
229 +Error Handling
230 +
231 +The script includes error handling using try/except blocks. When an error occurs, the error message is logged using loguru's `logger.error` function.
232 +
233 +The `WazuhHttpRequests` and `VulnerabilityService` classes appear to be well-structured and follow good practices for encapsulating functionality related to Wazuh's vulnerability system. Each class and method is well-documented with a docstring that describes its purpose, the arguments it accepts (if any), and what it returns.
234 +
235 ::: app.services.WazuhManager.vulnerability
backend/site/sitemap.xml.gz
Binary files a/backend/site/sitemap.xml.gz and b/backend/site/sitemap.xml.gz differ
backend/site/wazuhmanager/index.html
+609 -6
@@ -253,8 +253,45 @@
253 <nav class="md-nav" aria-label="Wazuh-Manager Overview">
254 <ul class="md-nav__list">
255 <li class="md-nav__item">
256 - <a href="#wazuh-manager-model" class="md-nav__link">
257 - Wazuh-Manager Model
256 + <a
257 + href="#wazuh-manager-model-rules"
258 + class="md-nav__link"
259 + >
260 + Wazuh-Manager Model Rules
261 + </a>
262 + </li>
263 + </ul>
264 + </nav>
265 + </li>
266 +
267 + <li class="md-nav__item">
268 + <a href="#rulespy-markdown-explanation" class="md-nav__link">
269 + rules.py Markdown Explanation
270 + </a>
271 +
272 + <nav class="md-nav" aria-label="rules.py Markdown Explanation">
273 + <ul class="md-nav__list">
274 + <li class="md-nav__item">
275 + <a href="#imports" class="md-nav__link">
276 + Imports
277 + </a>
278 + </li>
279 +
280 + <li class="md-nav__item">
281 + <a
282 + href="#class-definition-disabledrules"
283 + class="md-nav__link"
284 + >
285 + Class Definition: DisabledRules
286 + </a>
287 + </li>
288 +
289 + <li class="md-nav__item">
290 + <a
291 + href="#class-definition-disabledrulesschema"
292 + class="md-nav__link"
293 + >
294 + Class Definition: DisabledRulesSchema
295 </a>
296 </li>
297 </ul>
@@ -313,6 +350,15 @@
350 Meta
351 </a>
352 </li>
353 +
354 + <li class="md-nav__item">
355 + <a
356 + href="#wazuh-manager-model-agents"
357 + class="md-nav__link"
358 + >
359 + Wazuh-Manager Model Agents
360 + </a>
361 + </li>
362 </ul>
363 </nav>
364 </li>
@@ -436,10 +482,44 @@
482 <ul class="md-nav__list">
483 <li class="md-nav__item">
484 <a
439 - href="#wazuh-manager-services"
485 + href="#wazuh-manager-services-agents"
486 + class="md-nav__link"
487 + >
488 + Wazuh-Manager Services Agents
489 + </a>
490 + </li>
491 + </ul>
492 + </nav>
493 + </li>
494 +
495 + <li class="md-nav__item">
496 + <a href="#agentpy-markdown-explanation" class="md-nav__link">
497 + agent.py Markdown Explanation
498 + </a>
499 +
500 + <nav class="md-nav" aria-label="agent.py Markdown Explanation">
501 + <ul class="md-nav__list">
502 + <li class="md-nav__item">
503 + <a href="#imports_1" class="md-nav__link">
504 + Imports
505 + </a>
506 + </li>
507 +
508 + <li class="md-nav__item">
509 + <a
510 + href="#class-definition-wazuhhttprequests"
511 class="md-nav__link"
512 >
442 - Wazuh-Manager Services
513 + Class Definition: WazuhHttpRequests
514 + </a>
515 + </li>
516 +
517 + <li class="md-nav__item">
518 + <a
519 + href="#class-definition-wazuhmanageragentservice"
520 + class="md-nav__link"
521 + >
522 + Class Definition: WazuhManagerAgentService
523 </a>
524 </li>
525 </ul>
@@ -519,6 +599,55 @@
599 delete_agent()
600 </a>
601 </li>
602 +
603 + <li class="md-nav__item">
604 + <a
605 + href="#wazuh-manager-services-disabled-rule"
606 + class="md-nav__link"
607 + >
608 + Wazuh-Manager Services Disabled Rule
609 + </a>
610 + </li>
611 + </ul>
612 + </nav>
613 + </li>
614 +
615 + <li class="md-nav__item">
616 + <a
617 + href="#disabled_rulepy-markdown-explanation"
618 + class="md-nav__link"
619 + >
620 + disabled_rule.py Markdown Explanation
621 + </a>
622 +
623 + <nav
624 + class="md-nav"
625 + aria-label="disabled_rule.py Markdown Explanation"
626 + >
627 + <ul class="md-nav__list">
628 + <li class="md-nav__item">
629 + <a href="#imports_2" class="md-nav__link">
630 + Imports
631 + </a>
632 + </li>
633 +
634 + <li class="md-nav__item">
635 + <a
636 + href="#class-definition-wazuhhttprequests_1"
637 + class="md-nav__link"
638 + >
639 + Class Definition: WazuhHttpRequests
640 + </a>
641 + </li>
642 +
643 + <li class="md-nav__item">
644 + <a
645 + href="#class-definition-disableruleservice"
646 + class="md-nav__link"
647 + >
648 + Class Definition: DisableRuleService
649 + </a>
650 + </li>
651 </ul>
652 </nav>
653 </li>
@@ -599,6 +728,55 @@
728 put_request()
729 </a>
730 </li>
731 +
732 + <li class="md-nav__item">
733 + <a
734 + href="#wazuh-manager-services-enabled-rule"
735 + class="md-nav__link"
736 + >
737 + Wazuh-Manager Services Enabled Rule
738 + </a>
739 + </li>
740 + </ul>
741 + </nav>
742 + </li>
743 +
744 + <li class="md-nav__item">
745 + <a
746 + href="#enabled_rulepy-markdown-explanation"
747 + class="md-nav__link"
748 + >
749 + enabled_rule.py Markdown Explanation
750 + </a>
751 +
752 + <nav
753 + class="md-nav"
754 + aria-label="enabled_rule.py Markdown Explanation"
755 + >
756 + <ul class="md-nav__list">
757 + <li class="md-nav__item">
758 + <a href="#imports_3" class="md-nav__link">
759 + Imports
760 + </a>
761 + </li>
762 +
763 + <li class="md-nav__item">
764 + <a
765 + href="#class-definition-wazuhhttprequests_2"
766 + class="md-nav__link"
767 + >
768 + Class Definition: WazuhHttpRequests
769 + </a>
770 + </li>
771 +
772 + <li class="md-nav__item">
773 + <a
774 + href="#class-definition-enableruleservice"
775 + class="md-nav__link"
776 + >
777 + Class Definition: EnableRuleService
778 + </a>
779 + </li>
780 </ul>
781 </nav>
782 </li>
@@ -679,6 +857,15 @@
857 put_request()
858 </a>
859 </li>
860 +
861 + <li class="md-nav__item">
862 + <a
863 + href="#wazuh-manager-services-universal"
864 + class="md-nav__link"
865 + >
866 + Wazuh-Manager Services Universal
867 + </a>
868 + </li>
869 </ul>
870 </nav>
871 </li>
@@ -737,6 +924,55 @@
924 restart_service()
925 </a>
926 </li>
927 +
928 + <li class="md-nav__item">
929 + <a
930 + href="#wazuh-manager-services-vulnerability"
931 + class="md-nav__link"
932 + >
933 + Wazuh-Manager Services Vulnerability
934 + </a>
935 + </li>
936 + </ul>
937 + </nav>
938 + </li>
939 +
940 + <li class="md-nav__item">
941 + <a
942 + href="#vulnerabilitypy-markdown-explanation"
943 + class="md-nav__link"
944 + >
945 + vulnerability.py Markdown Explanation
946 + </a>
947 +
948 + <nav
949 + class="md-nav"
950 + aria-label="vulnerability.py Markdown Explanation"
951 + >
952 + <ul class="md-nav__list">
953 + <li class="md-nav__item">
954 + <a href="#imports_4" class="md-nav__link">
955 + Imports
956 + </a>
957 + </li>
958 +
959 + <li class="md-nav__item">
960 + <a
961 + href="#class-definition-wazuhhttprequests_3"
962 + class="md-nav__link"
963 + >
964 + Class Definition: WazuhHttpRequests
965 + </a>
966 + </li>
967 +
968 + <li class="md-nav__item">
969 + <a
970 + href="#class-definition-vulnerabilityservice"
971 + class="md-nav__link"
972 + >
973 + Class Definition: VulnerabilityService
974 + </a>
975 + </li>
976 </ul>
977 </nav>
978 </li>
@@ -833,7 +1069,67 @@
1069 <h1>Wazuh-Manager</h1>
1070
1071 <h2 id="wazuh-manager-overview">Wazuh-Manager Overview</h2>
836 - <h3 id="wazuh-manager-model"><span style="color: blue">Wazuh-Manager Model</span></h3>
1072 + <h3 id="wazuh-manager-model-rules">
1073 + <span style="color: blue">Wazuh-Manager Model Rules</span>
1074 + </h3>
1075 + <h2 id="rulespy-markdown-explanation">rules.py Markdown Explanation</h2>
1076 + <p>
1077 + The <code>rules.py</code> file appears to be a Python module that defines a SQLAlchemy
1078 + model and a Marshmallow schema for representing and serializing/deserializing disabled
1079 + rules in a system.
1080 + </p>
1081 + <h3 id="imports">Imports</h3>
1082 + <p>The script imports necessary modules at the beginning:</p>
1083 + <ul>
1084 + <li><code>datetime</code>: A standard Python module for handling dates and times.</li>
1085 + <li><code>sqlalchemy</code>: A popular SQL toolkit and ORM for Python.</li>
1086 + <li>
1087 + <code>app</code>: The application module, presumably containing the SQLAlchemy and
1088 + Marshmallow instances.
1089 + </li>
1090 + </ul>
1091 + <h3 id="class-definition-disabledrules">Class Definition: DisabledRules</h3>
1092 + <p>
1093 + The <code>DisabledRules</code> class is a SQLAlchemy model that represents disabled
1094 + rules in a system. It includes the following fields:
1095 + </p>
1096 + <ul>
1097 + <li><code>id</code>: Unique integer ID of the rule.</li>
1098 + <li><code>rule_id</code>: ID of the rule.</li>
1099 + <li><code>previous_level</code>: Previous level configuration of the rule.</li>
1100 + <li><code>new_level</code>: New level configuration of the rule.</li>
1101 + <li><code>reason_for_disabling</code>: Reason for disabling the rule.</li>
1102 + <li><code>date_disabled</code>: Date when the rule was disabled.</li>
1103 + <li><code>length_of_time</code>: Length of time the rule will be disabled for.</li>
1104 + </ul>
1105 + <p>
1106 + The <code>__init__</code> method initializes a new instance of the
1107 + <code>DisabledRules</code> class, and the <code>__repr__</code> method returns a string
1108 + representation of the <code>DisabledRules</code> instance.
1109 + </p>
1110 + <h3 id="class-definition-disabledrulesschema">Class Definition: DisabledRulesSchema</h3>
1111 + <p>
1112 + The <code>DisabledRulesSchema</code> class is a Marshmallow schema that is used to
1113 + serialize and deserialize instances of the <code>DisabledRules</code> class. The
1114 + <code>Meta</code> inner class defines the fields to be included in the
1115 + serialized/deserialized data.
1116 + </p>
1117 + <p>The script also defines two instances of the <code>DisabledRulesSchema</code> class:</p>
1118 + <ul>
1119 + <li>
1120 + <code>disabled_rule_schema</code>: Used for serializing/deserializing a single
1121 + <code>DisabledRules</code> instance.
1122 + </li>
1123 + <li>
1124 + <code>disabled_rules_schema</code>: Used for serializing/deserializing a list of
1125 + <code>DisabledRules</code> instances.
1126 + </li>
1127 + </ul>
1128 + <p>
1129 + This script follows good practices for defining SQLAlchemy models and Marshmallow
1130 + schemas. Each class and method is well-documented with a docstring that describes its
1131 + purpose, the arguments it accepts (if any), and what it returns.
1132 + </p>
1133
1134 <div class="doc doc-object doc-module">
1135 <a id="app.models.rules"></a>
@@ -1300,6 +1596,9 @@
1596 </div>
1597 </div>
1598 </div>
1599 + <h3 id="wazuh-manager-model-agents">
1600 + <span style="color: blue">Wazuh-Manager Model Agents</span>
1601 + </h3>
1602
1603 <div class="doc doc-object doc-module">
1604 <a id="app.models.agents"></a>
@@ -2246,7 +2545,69 @@
2545 </div>
2546 </div>
2547 <p><br /></p>
2249 - <h3 id="wazuh-manager-services"><span style="color: red">Wazuh-Manager Services</span></h3>
2548 + <h3 id="wazuh-manager-services-agents">
2549 + <span style="color: red">Wazuh-Manager Services Agents</span>
2550 + </h3>
2551 + <h2 id="agentpy-markdown-explanation">agent.py Markdown Explanation</h2>
2552 + <p>
2553 + The <code>agent.py</code> file appears to be a Python module that defines two classes:
2554 + <code>WazuhHttpRequests</code> and <code>WazuhManagerAgentService</code>. These classes
2555 + encapsulate the functionality for interacting with the Wazuh Manager agent system.
2556 + </p>
2557 + <h3 id="imports_1">Imports</h3>
2558 + <p>The script imports necessary modules at the beginning:</p>
2559 + <ul>
2560 + <li><code>requests</code>: A popular Python library used for making HTTP requests.</li>
2561 + <li>
2562 + <code>loguru</code>: A third-party library providing a more convenient and powerful
2563 + logger for Python.
2564 + </li>
2565 + <li><code>typing</code>: A standard Python library for support of type hints.</li>
2566 + <li>
2567 + <code>app.services.WazuhManager.universal.UniversalService</code>: The
2568 + <code>UniversalService</code> class from the
2569 + <code>app.services.WazuhManager.universal</code> module.
2570 + </li>
2571 + </ul>
2572 + <h3 id="class-definition-wazuhhttprequests">Class Definition: WazuhHttpRequests</h3>
2573 + <p>
2574 + The <code>WazuhHttpRequests</code> class handles HTTP requests to the Wazuh API. It is
2575 + initialized with the URL for the Wazuh connector and an authentication token. It
2576 + provides a method to make HTTP DELETE requests to the specified Wazuh API endpoint.
2577 + </p>
2578 + <h3 id="class-definition-wazuhmanageragentservice">
2579 + Class Definition: WazuhManagerAgentService
2580 + </h3>
2581 + <p>
2582 + The <code>WazuhManagerAgentService</code> class encapsulates the logic for handling
2583 + agent-related operations in the Wazuh Manager. It uses the
2584 + <code>UniversalService</code> to get authentication tokens and URLs, and
2585 + <code>WazuhHttpRequests</code> to make HTTP requests.
2586 + </p>
2587 + <p>It provides methods to:</p>
2588 + <ul>
2589 + <li>Collect all agents from Wazuh Manager (<code>collect_agents</code> method).</li>
2590 + <li>Delete a specific agent (<code>delete_agent</code> method).</li>
2591 + </ul>
2592 + <p>Helper Methods</p>
2593 + <p>Several private methods are also defined to support the main functionality:</p>
2594 + <ul>
2595 + <li><code>_get_agent_data</code>: Retrieves agent data from the Wazuh Manager.</li>
2596 + <li><code>_build_agent_list</code>: Builds a list of dictionaries with agent data.</li>
2597 + </ul>
2598 + <p>Error Handling</p>
2599 + <p>
2600 + The script includes error handling using try/except blocks. When an error occurs, the
2601 + error message is logged using loguru's <code>logger.error</code> function, and a
2602 + dictionary with a failure message and success status set to False is returned.
2603 + </p>
2604 + <p>
2605 + The <code>WazuhHttpRequests</code> and <code>WazuhManagerAgentService</code> classes
2606 + appear to be well-structured and follow good practices for encapsulating functionality
2607 + related to Wazuh's agent system. Each class and method is well-documented with a
2608 + docstring that describes its purpose, the arguments it accepts (if any), and what it
2609 + returns.
2610 + </p>
2611
2612 <div class="doc doc-object doc-module">
2613 <a id="app.services.WazuhManager.agent"></a>
@@ -3297,6 +3658,92 @@
3658 </div>
3659 </div>
3660 </div>
3661 + <h3 id="wazuh-manager-services-disabled-rule">
3662 + <span style="color: red">Wazuh-Manager Services Disabled Rule</span>
3663 + </h3>
3664 + <h2 id="disabled_rulepy-markdown-explanation">disabled_rule.py Markdown Explanation</h2>
3665 + <p>
3666 + The <code>disabled_rule.py</code> file appears to be a Python module that defines two
3667 + classes: <code>WazuhHttpRequests</code> and <code>DisableRuleService</code>. These
3668 + classes encapsulate the functionality for interacting with the Wazuh Manager rules
3669 + system, specifically for disabling rules.
3670 + </p>
3671 + <h3 id="imports_2">Imports</h3>
3672 + <p>The script imports necessary modules at the beginning:</p>
3673 + <ul>
3674 + <li><code>requests</code>: A popular Python library used for making HTTP requests.</li>
3675 + <li>
3676 + <code>loguru</code>: A third-party library providing a more convenient and powerful
3677 + logger for Python.
3678 + </li>
3679 + <li><code>typing</code>: A standard Python library for support of type hints.</li>
3680 + <li>
3681 + <code>xmltodict</code>: A Python module that makes working with XML feel like you
3682 + are working with JSON.
3683 + </li>
3684 + <li>
3685 + <code>app.models.rules.DisabledRules</code>: The <code>DisabledRules</code> class
3686 + from the <code>app.models.rules</code> module.
3687 + </li>
3688 + <li>
3689 + <code>app.services.WazuhManager.universal.UniversalService</code>: The
3690 + <code>UniversalService</code> class from the
3691 + <code>app.services.WazuhManager.universal</code> module.
3692 + </li>
3693 + </ul>
3694 + <h3 id="class-definition-wazuhhttprequests_1">Class Definition: WazuhHttpRequests</h3>
3695 + <p>
3696 + The <code>WazuhHttpRequests</code> class handles HTTP requests to the Wazuh API. It is
3697 + initialized with the URL for the Wazuh connector and an authentication token. It
3698 + provides methods to make HTTP GET and PUT requests to the specified Wazuh API endpoint.
3699 + </p>
3700 + <h3 id="class-definition-disableruleservice">Class Definition: DisableRuleService</h3>
3701 + <p>
3702 + The <code>DisableRuleService</code> class encapsulates the logic for handling
3703 + rule-disabling operations in the Wazuh Manager. It uses the
3704 + <code>UniversalService</code> to get authentication tokens and URLs, and
3705 + <code>WazuhHttpRequests</code> to make HTTP requests.
3706 + </p>
3707 + <p>
3708 + It provides a method to disable a specific rule in the Wazuh Manager (<code
3709 + >disable_rule</code
3710 + >
3711 + method).
3712 + </p>
3713 + <p>Helper Methods</p>
3714 + <p>Several private methods are also defined to support the main functionality:</p>
3715 + <ul>
3716 + <li><code>_validate_request</code>: Validates the request to disable a rule.</li>
3717 + <li>
3718 + <code>_fetch_filename</code>: Fetches the filename from the Wazuh-Manager that
3719 + contains the rule to be disabled.
3720 + </li>
3721 + <li>
3722 + <code>_fetch_file_content</code>: Fetches the content of the file that contains the
3723 + rule to be disabled.
3724 + </li>
3725 + <li><code>_set_level_1</code>: Sets the level of the rule to 1.</li>
3726 + <li><code>_convert_to_xml</code>: Converts the updated file content to XML format.</li>
3727 + <li>
3728 + <code>_store_disabled_rule_info</code>: Stores information about the disabled rule
3729 + in the database.
3730 + </li>
3731 + <li>
3732 + <code>_upload_updated_rule</code>: Uploads the updated rule to the Wazuh Manager.
3733 + </li>
3734 + </ul>
3735 + <p>Error Handling</p>
3736 + <p>
3737 + The script includes error handling using try/except blocks. When an error occurs, the
3738 + error message is logged using loguru's <code>logger.error</code> function, and a
3739 + dictionary with a failure message and success status set to False is returned.
3740 + </p>
3741 + <p>
3742 + The <code>WazuhHttpRequests</code> and <code>DisableRuleService</code> classes appear to
3743 + be well-structured and follow good practices for encapsulating functionality related to
3744 + Wazuh's rules system. Each class and method is well-documented with a docstring that
3745 + describes its purpose, the arguments it accepts (if any), and what it returns.
3746 + </p>
3747
3748 <div class="doc doc-object doc-module">
3749 <a id="app.services.WazuhManager.disabled_rule"></a>
@@ -4932,6 +5379,97 @@
5379 </div>
5380 </div>
5381 </div>
5382 + <h3 id="wazuh-manager-services-enabled-rule">
5383 + <span style="color: red">Wazuh-Manager Services Enabled Rule</span>
5384 + </h3>
5385 + <h2 id="enabled_rulepy-markdown-explanation">enabled_rule.py Markdown Explanation</h2>
5386 + <p>
5387 + The <code>enabled_rule.py</code> file appears to be a Python module that defines two
5388 + classes: <code>WazuhHttpRequests</code> and <code>EnableRuleService</code>. These
5389 + classes encapsulate the functionality for interacting with the Wazuh Manager rules
5390 + system, specifically for enabling rules.
5391 + </p>
5392 + <h3 id="imports_3">Imports</h3>
5393 + <p>The script imports necessary modules at the beginning:</p>
5394 + <ul>
5395 + <li><code>requests</code>: A popular Python library used for making HTTP requests.</li>
5396 + <li>
5397 + <code>loguru</code>: A third-party library providing a more convenient and powerful
5398 + logger for Python.
5399 + </li>
5400 + <li><code>typing</code>: A standard Python library for support of type hints.</li>
5401 + <li>
5402 + <code>xmltodict</code>: A Python module that makes working with XML feel like you
5403 + are working with JSON.
5404 + </li>
5405 + <li>
5406 + <code>app.models.rules.DisabledRules</code>: The <code>DisabledRules</code> class
5407 + from the <code>app.models.rules</code> module.
5408 + </li>
5409 + <li>
5410 + <code>app.services.WazuhManager.universal.UniversalService</code>: The
5411 + <code>UniversalService</code> class from the
5412 + <code>app.services.WazuhManager.universal</code> module.
5413 + </li>
5414 + </ul>
5415 + <h3 id="class-definition-wazuhhttprequests_2">Class Definition: WazuhHttpRequests</h3>
5416 + <p>
5417 + The <code>WazuhHttpRequests</code> class handles HTTP requests to the Wazuh API. It is
5418 + initialized with the URL for the Wazuh connector and an authentication token. It
5419 + provides methods to make HTTP GET and PUT requests to the specified Wazuh API endpoint.
5420 + </p>
5421 + <h3 id="class-definition-enableruleservice">Class Definition: EnableRuleService</h3>
5422 + <p>
5423 + The <code>EnableRuleService</code> class encapsulates the logic for handling
5424 + rule-enabling operations in the Wazuh Manager. It uses the
5425 + <code>UniversalService</code> to get authentication tokens and URLs, and
5426 + <code>WazuhHttpRequests</code> to make HTTP requests.
5427 + </p>
5428 + <p>
5429 + It provides a method to enable a specific rule in the Wazuh Manager (<code
5430 + >enable_rule</code
5431 + >
5432 + method).
5433 + </p>
5434 + <p>Helper Methods</p>
5435 + <p>Several private methods are also defined to support the main functionality:</p>
5436 + <ul>
5437 + <li><code>_validate_request</code>: Validates the request to enable a rule.</li>
5438 + <li>
5439 + <code>_fetch_filename</code>: Fetches the filename from the Wazuh-Manager that
5440 + contains the rule to be enabled.
5441 + </li>
5442 + <li>
5443 + <code>_fetch_file_content</code>: Fetches the content of the file that contains the
5444 + rule to be enabled.
5445 + </li>
5446 + <li>
5447 + <code>_get_previous_level</code>: Fetches the previous level of a rule from the
5448 + <code>disabled_rules</code> table.
5449 + </li>
5450 + <li>
5451 + <code>_set_level_previous</code>: Sets the level of the rule to its previous level
5452 + in the file content.
5453 + </li>
5454 + <li><code>_json_to_xml</code>: Converts the updated file content to XML format.</li>
5455 + <li>
5456 + <code>_delete_rule_from_db</code>: Deletes a rule from the
5457 + <code>disabled_rules</code> table.
5458 + </li>
5459 + <li><code>_put_updated_rule</code>: Uploads the updated rule to the Wazuh Manager.</li>
5460 + </ul>
5461 + <p>Error Handling</p>
5462 + <p>
5463 + The script includes error handling using try/except blocks. When an error occurs, the
5464 + error message is logged using loguru's <code>logger.error</code> function, and a
5465 + dictionary with a failure message and success status set to False is returned.
5466 + </p>
5467 + <p>
5468 + The <code>WazuhHttpRequests</code> and <code>EnableRuleService</code> classes appear to
5469 + be well-structured and follow good practices for encapsulating functionality related to
5470 + Wazuh's rules system. Each class and method is well-documented with a docstring that
5471 + describes its purpose, the arguments it accepts (if any), and what it returns.
5472 + </p>
5473
5474 <div class="doc doc-object doc-module">
5475 <a id="app.services.WazuhManager.enabled_rule"></a>
@@ -6551,6 +7089,9 @@
7089 </div>
7090 </div>
7091 </div>
7092 + <h3 id="wazuh-manager-services-universal">
7093 + <span style="color: red">Wazuh-Manager Services Universal</span>
7094 + </h3>
7095
7096 <div class="doc doc-object doc-module">
7097 <a id="app.services.WazuhManager.universal"></a>
@@ -7288,6 +7829,68 @@
7829 </div>
7830 </div>
7831 </div>
7832 + <h3 id="wazuh-manager-services-vulnerability">
7833 + <span style="color: red">Wazuh-Manager Services Vulnerability</span>
7834 + </h3>
7835 + <h2 id="vulnerabilitypy-markdown-explanation">vulnerability.py Markdown Explanation</h2>
7836 + <p>
7837 + The <code>vulnerability.py</code> file appears to be a Python module that defines two
7838 + classes: <code>WazuhHttpRequests</code> and <code>VulnerabilityService</code>. These
7839 + classes encapsulate the functionality for interacting with the Wazuh Manager's
7840 + vulnerability system.
7841 + </p>
7842 + <h3 id="imports_4">Imports</h3>
7843 + <p>The script imports necessary modules at the beginning:</p>
7844 + <ul>
7845 + <li><code>requests</code>: A popular Python library used for making HTTP requests.</li>
7846 + <li>
7847 + <code>loguru</code>: A third-party library providing a more convenient and powerful
7848 + logger for Python.
7849 + </li>
7850 + <li><code>typing</code>: A standard Python library for support of type hints.</li>
7851 + <li>
7852 + <code>app.services.WazuhManager.universal.UniversalService</code>: The
7853 + <code>UniversalService</code> class from the
7854 + <code>app.services.WazuhManager.universal</code> module.
7855 + </li>
7856 + </ul>
7857 + <h3 id="class-definition-wazuhhttprequests_3">Class Definition: WazuhHttpRequests</h3>
7858 + <p>
7859 + The <code>WazuhHttpRequests</code> class handles HTTP requests to the Wazuh API. It is
7860 + initialized with the URL for the Wazuh connector and an authentication token. It
7861 + provides a method to make HTTP GET requests to the specified Wazuh API endpoint.
7862 + </p>
7863 + <h3 id="class-definition-vulnerabilityservice">Class Definition: VulnerabilityService</h3>
7864 + <p>
7865 + The <code>VulnerabilityService</code> class encapsulates the logic for handling
7866 + vulnerability-related operations in the Wazuh Manager. It uses the
7867 + <code>UniversalService</code> to get authentication tokens and URLs, and
7868 + <code>WazuhHttpRequests</code> to make HTTP requests.
7869 + </p>
7870 + <p>
7871 + It provides a method to retrieve and process vulnerabilities for a specified agent
7872 + (<code>agent_vulnerabilities</code> method).
7873 + </p>
7874 + <p>Helper Method</p>
7875 + <p>A private method is also defined to support the main functionality:</p>
7876 + <ul>
7877 + <li>
7878 + <code>_process_agent_vulnerabilities</code>: Processes the raw vulnerabilities data
7879 + for an agent.
7880 + </li>
7881 + </ul>
7882 + <p>Error Handling</p>
7883 + <p>
7884 + The script includes error handling using try/except blocks. When an error occurs, the
7885 + error message is logged using loguru's <code>logger.error</code> function.
7886 + </p>
7887 + <p>
7888 + The <code>WazuhHttpRequests</code> and <code>VulnerabilityService</code> classes appear
7889 + to be well-structured and follow good practices for encapsulating functionality related
7890 + to Wazuh's vulnerability system. Each class and method is well-documented with a
7891 + docstring that describes its purpose, the arguments it accepts (if any), and what it
7892 + returns.
7893 + </p>
7894
7895 <div class="doc doc-object doc-module">
7896 <a id="app.services.WazuhManager.vulnerability"></a>