Commit bb9aea3a authored by Elger Jonker's avatar Elger Jonker

allow creating task by type

Former-commit-id: d5f6e104
parent 37e2a239
......@@ -153,6 +153,9 @@ class ScannerTaskCommand(TaskCommand):
self.mutual_group.add_argument('-u', '--url_addresses', nargs='*',
help="Perform scans on these urls (default is all).")
self.mutual_group.add_argument('-y', '--organization_type', nargs='*',
help="Perform scans on these organization types (default is all).")
def compose(self, *args, **options):
"""Compose set of tasks based on provided arguments."""
......@@ -171,6 +174,11 @@ class ScannerTaskCommand(TaskCommand):
regex = '^(' + '|'.join(options['url_addresses']) + ')$'
urls_filter = {'url__iregex': regex}
if options['organization_type']:
# create a case-insensitive filter to match organizations by name
regex = '^(' + '|'.join(options['organization_type']) + ')$'
organizations_filter = {'type__name__iregex': regex}
# compose set of tasks to be executed
return self.scanner_module.compose_task(organizations_filter=organizations_filter,
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment