forked from intelowlproject/IntelOwl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added IP and subdomain support for DNS0_rrsets_data (intelowlproject#…
…2042) * Added IP support for DNS0_rrsets_data analyzer * Added include_subdomain parameter * Typo * Restore original state * Added alter migration to add a new supported type and new parameter * fix deepsource
- Loading branch information
1 parent
0e85ad1
commit aefb8bb
Showing
2 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
api_app/analyzers_manager/migrations/0056_alter_analyzer_config_dns0_rrsets_data.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,62 @@ | ||
from django.db import migrations | ||
|
||
from api_app.analyzers_manager.constants import ObservableTypes | ||
|
||
|
||
def migrate(apps, schema_editor): | ||
AnalyzerConfig = apps.get_model("analyzers_manager", "AnalyzerConfig") | ||
config = AnalyzerConfig.objects.get(name="DNS0_rrsets_data") | ||
config.observable_supported = [ | ||
ObservableTypes.DOMAIN, | ||
ObservableTypes.URL, | ||
ObservableTypes.GENERIC, | ||
ObservableTypes.IP, | ||
] | ||
config.full_clean() | ||
config.save() | ||
|
||
PythonModule = apps.get_model("api_app", "PythonModule") | ||
Parameter = apps.get_model("api_app", "Parameter") | ||
pm = PythonModule.objects.get( | ||
module="dns0.dns0_rrsets.DNS0Rrsets", | ||
base_path="api_app.analyzers_manager.observable_analyzers", | ||
) | ||
p = Parameter( | ||
name="include_subdomain", | ||
type="bool", | ||
description="Search for subdomains.", | ||
is_secret=False, | ||
required=False, | ||
python_module=pm, | ||
) | ||
p.full_clean() | ||
p.save() | ||
|
||
|
||
def reverse_migrate(apps, schema_editor): | ||
AnalyzerConfig = apps.get_model("analyzers_manager", "AnalyzerConfig") | ||
config = AnalyzerConfig.objects.get(name="DNS0_rrsets_data") | ||
config.observable_supported = [ | ||
ObservableTypes.DOMAIN, | ||
ObservableTypes.URL, | ||
ObservableTypes.GENERIC, | ||
] | ||
config.full_clean() | ||
config.save() | ||
|
||
PythonModule = apps.get_model("api_app", "PythonModule") | ||
Parameter = apps.get_model("api_app", "Parameter") | ||
pm = PythonModule.objects.get( | ||
module="dns0.dns0_rrsets.DNS0Rrsets", | ||
base_path="api_app.analyzers_manager.observable_analyzers", | ||
) | ||
Parameter(name="include_subdomain", python_module=pm).delete() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("api_app", "0052_periodic_task_bi"), | ||
("analyzers_manager", "0055_analyzerreport_sent_to_bi"), | ||
] | ||
|
||
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