@@ -111,10 +111,11 @@ def get_user(self, user_id):
111111 return self ._request ('GET' , 'users/' + str (user_id ) + '/' )
112112
113113 ###### Engagements API #######
114- def list_engagements (self , status = None , product_in = None ,limit = 20 ):
114+ def list_engagements (self , status = None , product_in = None , name_contains = None , limit = 20 ):
115115 """Retrieves all the engagements.
116116
117117 :param product_in: List of product ids (1,2).
118+ :param name_contains: Engagement name
118119 :param limit: Number of records to return.
119120
120121 """
@@ -129,6 +130,9 @@ def list_engagements(self, status=None, product_in=None,limit=20):
129130 if status :
130131 params ['status' ] = status
131132
133+ if name_contains :
134+ params ['name_contains' ] = name_contains
135+
132136 return self ._request ('GET' , 'engagements/' , params )
133137
134138 def get_engagement (self , engagement_id ):
@@ -404,7 +408,7 @@ def set_test(self, test_id, engagement_id=None, test_type=None, environment=None
404408 ###### Findings API #######
405409 def list_findings (self , active = None , duplicate = None , mitigated = None , severity = None , verified = None , severity_lt = None ,
406410 severity_gt = None , severity_contains = None , title_contains = None , url_contains = None , date_lt = None ,
407- date_gt = None , date = None , product_id_in = None , engagement_id_in = None , test_id_in = None , limit = 20 ):
411+ date_gt = None , date = None , product_id_in = None , engagement_id_in = None , test_id_in = None , build = None , limit = 20 ):
408412
409413 """Returns filtered list of findings.
410414
@@ -424,6 +428,7 @@ def list_findings(self, active=None, duplicate=None, mitigated=None, severity=No
424428 :param product_id_in: Product id(s) associated with a finding. (1,2 or 1)
425429 :param engagement_id_in: Engagement id(s) associated with a finding. (1,2 or 1)
426430 :param test_in: Test id(s) associated with a finding. (1,2 or 1)
431+ :param build_id: User specified build id relating to the build number from the build server. (Jenkins, Travis etc.).
427432 :param limit: Number of records to return.
428433
429434 """
@@ -480,6 +485,9 @@ def list_findings(self, active=None, duplicate=None, mitigated=None, severity=No
480485 if test_id_in :
481486 params ['test__id__in' ] = test_id_in
482487
488+ if build :
489+ params ['build_id__contains' ] = build
490+
483491 return self ._request ('GET' , 'findings/' , params )
484492
485493 def get_finding (self , finding_id ):
@@ -490,7 +498,7 @@ def get_finding(self, finding_id):
490498 return self ._request ('GET' , 'findings/' + str (finding_id ) + '/' )
491499
492500 def create_finding (self , title , description , severity , cwe , date , product_id , engagement_id , test_id , user_id ,
493- impact , active , verified , mitigation , references = None ):
501+ impact , active , verified , mitigation , references = None , build = None ):
494502
495503 """Creates a finding with the given properties.
496504
@@ -508,7 +516,7 @@ def create_finding(self, title, description, severity, cwe, date, product_id, en
508516 :param verified: Finding has been verified.
509517 :param mitigation: Steps to mitigate the finding.
510518 :param references: Details on finding.
511-
519+ :param build: User specified build id relating to the build number from the build server. (Jenkins, Travis etc.).
512520 """
513521
514522 data = {
@@ -525,7 +533,8 @@ def create_finding(self, title, description, severity, cwe, date, product_id, en
525533 'active' : active ,
526534 'verified' : verified ,
527535 'mitigation' : mitigation ,
528- 'references' : references
536+ 'references' : references ,
537+ 'build_id' : build
529538 }
530539
531540 return self ._request ('POST' , 'findings/' , data = data )
@@ -550,6 +559,7 @@ def set_finding(self, finding_id, product_id, engagement_id, test_id, title=None
550559 :param verified: Finding has been verified.
551560 :param mitigation: Steps to mitigate the finding.
552561 :param references: Details on finding.
562+ :param build: User specified build id relating to the build number from the build server. (Jenkins, Travis etc.).
553563
554564 """
555565
@@ -597,25 +607,34 @@ def set_finding(self, finding_id, product_id, engagement_id, test_id, title=None
597607 if references :
598608 data ['references' ] = references
599609
610+ if build :
611+ data ['build_id' ] = build
612+
600613 return self ._request ('PUT' , 'findings/' + str (finding_id ) + '/' , data = data )
601614
602615 ##### Upload API #####
603616
604- def upload_scan (self , engagement_id , scan_type , file , active , scan_date , tags = None ):
617+ def upload_scan (self , engagement_id , scan_type , file , active , scan_date , tags = None , build = None ):
605618 """Uploads and processes a scan file.
606619
607620 :param application_id: Application identifier.
608621 :param file_path: Path to the scan file to be uploaded.
609622
610623 """
624+ if tags is None :
625+ tags = ''
626+
627+ if build is None :
628+ build = ''
611629
612630 data = {
613631 'file' : open (file , 'rb' ),
614632 'engagement' : ('' , self .get_engagement_uri (engagement_id )),
615633 'scan_type' : ('' , scan_type ),
616634 'active' : ('' , active ),
617635 'scan_date' : ('' , scan_date ),
618- 'tags' : ('' , tags )
636+ 'tags' : ('' , tags ),
637+ 'build_id' : ('' , build )
619638 }
620639
621640 return self ._request (
@@ -725,6 +744,9 @@ def id(self):
725744 raise ValueError ('Object not created:' + json .dumps (self .data , sort_keys = True , indent = 4 , separators = (',' , ': ' )))
726745 return int (self .data )
727746
747+ def count (self ):
748+ return self .data ["meta" ]["total_count" ]
749+
728750 def data_json (self , pretty = False ):
729751 """Returns the data as a valid JSON string."""
730752 if pretty :
0 commit comments