Skip to content

Commit d324742

Browse files
improve command
1 parent e3a9517 commit d324742

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

dojo/management/commands/import_unittest_scan.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ def add_arguments(self, parser):
6666
default=False,
6767
help="Mark findings as verified (default: False)",
6868
)
69+
parser.add_argument(
70+
"--tags",
71+
action="append",
72+
default=[],
73+
help=(
74+
"Tag(s) to apply to the imported Test (repeat --tags to add multiple). "
75+
"Example: --tags perf --tags jfrog"
76+
),
77+
)
6978

7079
def get_test_admin(self):
7180
return User.objects.get(username="admin")
@@ -138,7 +147,7 @@ def deduce_scan_type_from_path(self, scan_file_path):
138147
raise CommandError(msg)
139148

140149
def import_unittest_scan(self, scan_file, product_name, engagement_name, product_type_name,
141-
minimum_severity, active, verified):
150+
minimum_severity, active, verified, tags):
142151
"""
143152
Import a specific unittest scan file.
144153
@@ -173,13 +182,18 @@ def import_unittest_scan(self, scan_file, product_name, engagement_name, product
173182
"version": "1.0.1",
174183
"active": active,
175184
"verified": verified,
185+
"apply_tags_to_findings": True,
186+
"apply_tags_to_endpoints": True,
176187
"auto_create_context": True,
177188
"product_type_name": product_type_name,
178189
"product_name": product_name,
179190
"engagement_name": engagement_name,
180191
"close_old_findings": False,
181192
}
182193

194+
if tags:
195+
payload["tags"] = tags
196+
183197
result = self.import_scan(payload)
184198

185199
logger.info(f"Successfully imported scan. Test ID: {result.get('test_id')}")
@@ -195,6 +209,7 @@ def handle(self, *args, **options):
195209
minimum_severity = options["minimum_severity"]
196210
active = options["active"]
197211
verified = options["verified"]
212+
tags = options["tags"]
198213

199214
start_time = time.time()
200215

@@ -207,6 +222,7 @@ def handle(self, *args, **options):
207222
minimum_severity=minimum_severity,
208223
active=active,
209224
verified=verified,
225+
tags=tags,
210226
)
211227

212228
end_time = time.time()

0 commit comments

Comments
 (0)