-
-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added service_api_key parameter and migrations * Added mb_get and mb_google * Added logging for api key * Fix deepsource warning * WAD Analyzer, Closes #814 (#2655) * WAD Analyzer, Closes #814 * Remove WAD from FREE_TO_USE_ANALYZERS playbook * Update WAD maximum_tlp to CLEAR * Fix WAD monkeypatch * Update WAD error message to a more generic one * Update migration number and dependencies * Added service_api_key parameter and migrations * Added mb_get and mb_google * Added logging for api key * Fix deepsource warning * Fixed migration number * Removed wrongly duplicated migration * Added other analyzers to reverse_migrate * Added common mixin and updated code accordingly * Solved MRO * Deepsource * Made mixin compatible with ingestors * Removed inheritance from analyzers * Added missing return statement * Removed old configs and used a property * Left behind values * Added explainatory comment --------- Co-authored-by: Pragati Raj <basedBaba@proton.me>
- Loading branch information
1 parent
5644d55
commit 704d9b0
Showing
12 changed files
with
265 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
...yzers_manager/migrations/0147_alter_analyzer_config_feodo_yaraify_urlhaus_yaraify_scan.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
from django.db import migrations | ||
|
||
|
||
def migrate(apps, schema_editor): | ||
Parameter = apps.get_model("api_app", "Parameter") | ||
PythonModule = apps.get_model("api_app", "PythonModule") | ||
|
||
# observables | ||
observable_analyzers = [ | ||
"urlhaus.URLHaus", | ||
"yaraify.YARAify", | ||
"feodo_tracker.Feodo_Tracker", | ||
"threatfox.ThreatFox", | ||
"mb_get.MB_GET", | ||
"mb_google.MB_GOOGLE", | ||
] | ||
for observable_analyzer in observable_analyzers: | ||
module = PythonModule.objects.get( | ||
module=observable_analyzer, | ||
base_path="api_app.analyzers_manager.observable_analyzers", | ||
) | ||
Parameter.objects.create( | ||
name="service_api_key", | ||
type="str", | ||
description="Optional API key to connect to abuse.ch services.", | ||
is_secret=True, | ||
required=False, | ||
python_module=module, | ||
) | ||
|
||
# files | ||
yaraify_scan_module = PythonModule.objects.get( | ||
module="yaraify_file_scan.YARAifyFileScan", | ||
base_path="api_app.analyzers_manager.file_analyzers", | ||
) | ||
Parameter.objects.create( | ||
name="service_api_key", | ||
type="str", | ||
description="Optional API key to connect to abuse.ch services.", | ||
is_secret=True, | ||
required=False, | ||
python_module=yaraify_scan_module, | ||
) | ||
|
||
|
||
def reverse_migrate(apps, schema_editor): | ||
Parameter = apps.get_model("api_app", "Parameter") | ||
PythonModule = apps.get_model("api_app", "PythonModule") | ||
|
||
# observables | ||
observable_analyzers = [ | ||
"urlhaus.URLHaus", | ||
"yaraify.YARAify", | ||
"feodo_tracker.Feodo_Tracker", | ||
"threatfox.ThreatFox", | ||
"mb_get.MB_GET", | ||
"mb_google.MB_GOOGLE", | ||
] | ||
for observable_analyzer in observable_analyzers: | ||
module = PythonModule.objects.get( | ||
module=observable_analyzer, | ||
base_path="api_app.analyzers_manager.observable_analyzers", | ||
) | ||
Parameter.objects.get( | ||
name="service_api_key", | ||
type="str", | ||
description="Optional API key to connect to abuse.ch services.", | ||
is_secret=True, | ||
required=False, | ||
python_module=module, | ||
).delete() | ||
|
||
# files | ||
yaraify_scan_module = PythonModule.objects.get( | ||
module="yaraify_file_scan.YARAifyFileScan", | ||
base_path="api_app.analyzers_manager.file_analyzers", | ||
) | ||
Parameter.objects.get( | ||
name="service_api_key", | ||
type="str", | ||
description="Optional API key to connect to abuse.ch services.", | ||
is_secret=True, | ||
required=False, | ||
python_module=yaraify_scan_module, | ||
).delete() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
atomic = False | ||
dependencies = [ | ||
("api_app", "0065_job_mpnodesearch"), | ||
( | ||
"analyzers_manager", | ||
"0146_analyzer_config_wad", | ||
), | ||
] | ||
|
||
operations = [migrations.RunPython(migrate, reverse_migrate)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.