From e5e7e44ed4b7d67c1eb6d5bfd5f3305aec9ede81 Mon Sep 17 00:00:00 2001 From: Daniel Loureiro Date: Mon, 5 Jul 2021 14:21:33 +0100 Subject: [PATCH] When creating a new Engagement and uploading Scan results 'id' is not presend in self.data. Changed to check if 'id' exists, else it will return Engagement ID. Traceback (most recent call last): File "d.py", line 280, in create_findings(dd, engagement_id, args.scanner, args.scan_file_name) File "d.py", line 248, in create_findings test_id = upload_scan.id() File "python/dojotools/v-dd/lib/python3.9/site-packages/defectdojo_api/defectdojo_apiv2.py", line 1339, in id return int(self.data["id"]) KeyError: 'id' --- defectdojo_api/defectdojo_apiv2.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/defectdojo_api/defectdojo_apiv2.py b/defectdojo_api/defectdojo_apiv2.py index 394dc14..c89d603 100644 --- a/defectdojo_api/defectdojo_apiv2.py +++ b/defectdojo_api/defectdojo_apiv2.py @@ -1336,7 +1336,10 @@ def id(self): self.logger.debug("response_code" + str(self.response_code)) if self.response_code == 400: #Bad Request raise ValueError('Object not created:' + json.dumps(self.data, sort_keys=True, indent=4, separators=(',', ': '))) - return int(self.data["id"]) + if "id" in self.data.keys(): + return int(self.data["id"]) + else: + return int(self.data["engagement"]) def count(self): return self.data["count"]