-
-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
* 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
There are no files selected for viewing
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 = [ | ||
Check warning on line 39 in api_app/analyzers_manager/migrations/0056_alter_analyzer_config_dns0_rrsets_data.py Codecov / codecov/patchapi_app/analyzers_manager/migrations/0056_alter_analyzer_config_dns0_rrsets_data.py#L37-L39
|
||
ObservableTypes.DOMAIN, | ||
ObservableTypes.URL, | ||
ObservableTypes.GENERIC, | ||
] | ||
config.full_clean() | ||
config.save() | ||
Check warning on line 45 in api_app/analyzers_manager/migrations/0056_alter_analyzer_config_dns0_rrsets_data.py Codecov / codecov/patchapi_app/analyzers_manager/migrations/0056_alter_analyzer_config_dns0_rrsets_data.py#L44-L45
|
||
|
||
PythonModule = apps.get_model("api_app", "PythonModule") | ||
Parameter = apps.get_model("api_app", "Parameter") | ||
pm = PythonModule.objects.get( | ||
Check warning on line 49 in api_app/analyzers_manager/migrations/0056_alter_analyzer_config_dns0_rrsets_data.py Codecov / codecov/patchapi_app/analyzers_manager/migrations/0056_alter_analyzer_config_dns0_rrsets_data.py#L47-L49
|
||
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)] |