@@ -80,13 +80,21 @@ def get_test_uri(self, test_id):
8080 return "/api/" + self .api_version + "/tests/" + str (test_id ) + "/"
8181
8282 def get_language_uri (self , language_type_id ):
83- """Returns the DefectDojo API URI for a test .
83+ """Returns the DefectDojo API URI for a langauge .
8484
85- :param test_id: Id of the test
85+ :param test_id: Id of the language
8686
8787 """
8888 return "/api/" + self .api_version + "/language_types/" + str (language_type_id ) + "/"
8989
90+ def get_tool_configuration_uri (self , tool_configuration_id ):
91+ """Returns the DefectDojo API URI for a tool.
92+
93+ :param tool_configurations_id: Id of the test
94+
95+ """
96+ return "/api/" + self .api_version + "/tool_configurations/" + str (tool_configuration_id ) + "/"
97+
9098 def version_url (self ):
9199 """Returns the DefectDojo API version.
92100
@@ -162,8 +170,9 @@ def get_engagement(self, engagement_id):
162170 return self ._request ('GET' , 'engagements/' + str (engagement_id ) + '/' )
163171
164172 def create_engagement (self , name , product_id , lead_id , status , target_start , target_end , active = 'True' ,
165- pen_test = 'False' , check_list = 'False' , threat_model = 'False' , risk_path = "" , test_strategy = "" , progress = "" ,
166- done_testing = 'False' ):
173+ pen_test = 'False' , check_list = 'False' , threat_model = 'False' , risk_path = "" ,test_strategy = "" , progress = "" ,
174+ done_testing = 'False' , engagement_type = "CI/CD" , build_id = None , commit_hash = None , branch_tag = None , build_server = None ,
175+ source_code_management_server = None , source_code_management_uri = None , orchestration_engine = None , description = None ):
167176 """Creates an engagement with the given properties.
168177
169178 :param name: Engagement name.
@@ -179,6 +188,14 @@ def create_engagement(self, name, product_id, lead_id, status, target_start, tar
179188 :param risk_path: risk_path
180189 :param test_strategy: Test Strategy URLs
181190 :param progress: Engagement progresss measured in percent.
191+ :param engagement_type: Interactive or CI/CD
192+ :param build_id: Build id from the build server
193+ :param commit_hash: Commit hash from source code management
194+ :param branch_tag: Branch or tag from source code management
195+ :param build_server: Tool Configuration id of build server
196+ :param source_code_management_server: URL of source code management
197+ :param source_code_management_uri: Link to source code commit
198+ :param orchestration_engine: URL of orchestration engine
182199
183200 """
184201
@@ -196,9 +213,34 @@ def create_engagement(self, name, product_id, lead_id, status, target_start, tar
196213 'risk_path' : risk_path ,
197214 'test_strategy' : test_strategy ,
198215 'progress' : progress ,
199- 'done_testing' : done_testing
216+ 'done_testing' : done_testing ,
217+ 'engagement_type' : engagement_type
200218 }
201219
220+ if description :
221+ data .update ({'description' : description })
222+
223+ if build_id :
224+ data .update ({'build_id' : build_id })
225+
226+ if commit_hash :
227+ data .update ({'commit_hash' : commit_hash })
228+
229+ if branch_tag :
230+ data .update ({'branch_tag' : branch_tag })
231+
232+ if build_server :
233+ data .update ({'build_server' : self .get_tool_configuration_uri (build_server )})
234+
235+ if source_code_management_server :
236+ data .update ({'source_code_management_server' : self .get_tool_configuration_uri (source_code_management_server )})
237+
238+ if source_code_management_uri :
239+ data .update ({'source_code_management_uri' : source_code_management_uri })
240+
241+ if orchestration_engine :
242+ data .update ({'orchestration_engine' : self .get_tool_configuration_uri (orchestration_engine )})
243+
202244 return self ._request ('POST' , 'engagements/' , data = data )
203245
204246 def close_engagement (self , id , user_id = None ):
@@ -207,19 +249,13 @@ def close_engagement(self, id, user_id=None):
207249 :param id: Engagement id.
208250 :param user_id: User from the user table.
209251 """
210- engagement = self .get_engagement (id ).data
211-
212- #if user isn't provided then close with the lead ID
213- if user_id is None :
214- user_id = self .get_id_from_url (engagement ["lead" ])
215252
216- product_id = engagement ["product_id" ]
217-
218- self .set_engagement (id , name = engagement ["name" ], lead_id = user_id , product_id = product_id , status = "Completed" , active = False )
253+ self .set_engagement (id , status = "Completed" , active = False )
219254
220255 def set_engagement (self , id , product_id = None , lead_id = None , name = None , status = None , target_start = None ,
221256 target_end = None , active = None , pen_test = None , check_list = None , threat_model = None , risk_path = None ,
222- test_strategy = None , progress = None , done_testing = None ):
257+ test_strategy = None , progress = None , done_testing = None , engagement_type = "CI/CD" , build_id = None , commit_hash = None , branch_tag = None , build_server = None ,
258+ source_code_management_server = None , source_code_management_uri = None , orchestration_engine = None , description = None ):
223259
224260 """Updates an engagement with the given properties.
225261
@@ -237,7 +273,14 @@ def set_engagement(self, id, product_id=None, lead_id=None, name=None, status=No
237273 :param risk_path: risk_path
238274 :param test_strategy: Test Strategy URLs
239275 :param progress: Engagement progresss measured in percent.
240-
276+ :param engagement_type: Interactive or CI/CD
277+ :param build_id: Build id from the build server
278+ :param commit_hash: Commit hash from source code management
279+ :param branch_tag: Branch or tag from source code management
280+ :param build_server: Tool Configuration id of build server
281+ :param source_code_management_server: URL of source code management
282+ :param source_code_management_uri: Link to source code commit
283+ :param orchestration_engine: URL of orchestration engine
241284 """
242285
243286 data = {}
@@ -284,7 +327,7 @@ def set_engagement(self, id, product_id=None, lead_id=None, name=None, status=No
284327 if done_testing :
285328 data ['done_testing' ] = done_testing
286329
287- return self ._request ('PUT ' , 'engagements/' + str (id ) + '/' , data = data )
330+ return self ._request ('PATCH ' , 'engagements/' + str (id ) + '/' , data = data )
288331
289332 ###### Product API #######
290333 def list_products (self , name = None , name_contains = None , limit = 20 ):
0 commit comments