@@ -85,6 +85,16 @@ def version_url(self):
8585 """
8686 return self .api_version
8787
88+ def get_id_from_url (self , url ):
89+ """Returns the ID from the DefectDojo API.
90+
91+ :param url: URL returned by the API
92+
93+ """
94+ url = url .split ('/' )
95+ return url [len (url )- 2 ]
96+
97+
8898 ###### User API #######
8999 def list_users (self , username = None , limit = 20 ):
90100 """Retrieves all the users.
@@ -642,6 +652,166 @@ def upload_scan(self, engagement_id, scan_type, file, active, scan_date, tags=No
642652 files = data
643653 )
644654
655+ ##### Credential API #####
656+
657+ def list_credentials (self , name = None , username = None , limit = 20 ):
658+ """Retrieves all the globally configured credentials.
659+
660+ :param name_contains: Search by credential name.
661+ :param username: Search by username
662+ :param limit: Number of records to return.
663+
664+ """
665+
666+ params = {}
667+ if limit :
668+ params ['limit' ] = limit
669+
670+ if name :
671+ params ['name__contains' ] = name
672+
673+ if username :
674+ params ['username__contains' ] = username
675+
676+ return self ._request ('GET' , 'credentials/' , params )
677+
678+ def get_credential (self , cred_id , limit = 20 ):
679+ """
680+ Retrieves a credential using the given credential id.
681+ :param credential_id: Credential identification.
682+ """
683+ return self ._request ('GET' , 'credentials/' + str (cred_id ) + '/' )
684+
685+ ##### Credential Mapping API #####
686+
687+ def list_credential_mappings (self , name = None , product_id_in = None , engagement_id_in = None , test_id_in = None , finding_id_in = None , limit = 20 ):
688+ """Retrieves mapped credentials.
689+
690+ :param name_contains: Search by credential name.
691+ :param username: Search by username
692+ :param limit: Number of records to return.
693+
694+ """
695+
696+ params = {}
697+ if limit :
698+ params ['limit' ] = limit
699+
700+ if name :
701+ params ['name' ] = name
702+
703+ if product_id_in :
704+ params ['product__id__in' ] = product_id_in
705+
706+ if engagement_id_in :
707+ params ['engagement__id__in' ] = engagement_id_in
708+
709+ if test_id_in :
710+ params ['test__id__in' ] = test_id_in
711+
712+ if finding_id_in :
713+ params ['finding__id__in' ] = finding_id_in
714+
715+ return self ._request ('GET' , 'credential_mappings/' , params )
716+
717+ def get_credential_mapping (self , cred_mapping_id , limit = 20 ):
718+ """
719+ Retrieves a credential using the given credential id.
720+ :param cred_mapping_id: Credential identification.
721+ """
722+ return self ._request ('GET' , 'credential_mappings/' + str (cred_mapping_id ) + '/' )
723+
724+ ##### Container API #####
725+
726+ def list_containers (self , name = None , container_type = None , limit = 20 ):
727+ """Retrieves all the globally configured credentials.
728+
729+ :param name_contains: Search by credential name.
730+ :param username: Search by username
731+ :param limit: Number of records to return.
732+
733+ """
734+
735+ params = {}
736+ if limit :
737+ params ['limit' ] = limit
738+
739+ if name :
740+ params ['name__contains' ] = name
741+
742+ if container_type :
743+ params ['container_type__contains' ] = container_type
744+
745+ return self ._request ('GET' , 'container/' , params )
746+
747+ def get_container (self , container_id , limit = 20 ):
748+ """
749+ Retrieves a finding using the given container id.
750+ :param container_id: Container identification.
751+ """
752+ return self ._request ('GET' , 'container/' + str (container_id ) + '/' )
753+
754+ ###### Tool API #######
755+
756+ def list_tool_types (self , name = None , limit = 20 ):
757+ """Retrieves all the tool types.
758+
759+ :param name_contains: Search by tool type name.
760+ :param limit: Number of records to return.
761+
762+ """
763+
764+ params = {}
765+ if limit :
766+ params ['limit' ] = limit
767+
768+ if name :
769+ params ['name__contains' ] = name
770+
771+ return self ._request ('GET' , 'tool_types/' , params )
772+
773+ def list_tools (self , name = None , tool_type_id = None , limit = 20 ):
774+ """Retrieves all the tools.
775+
776+ :param name_contains: Search by tool name.
777+ :param tool_type_id: Search by tool type id
778+ :param limit: Number of records to return.
779+
780+ """
781+
782+ params = {}
783+ if limit :
784+ params ['limit' ] = limit
785+
786+ if name :
787+ params ['name__contains' ] = name
788+
789+ if tool_type_id :
790+ params ['tool_type__id' ] = tool_type_id
791+
792+ return self ._request ('GET' , 'tools/' , params )
793+
794+ def list_tool_products (self , name = None , tool_configuration_id = None , limit = 20 ):
795+ """Retrieves all the tools.
796+
797+ :param name_contains: Search by tool name.
798+ :param tool_type_id: Search by tool type id
799+ :param limit: Number of records to return.
800+
801+ """
802+
803+ params = {}
804+ if limit :
805+ params ['limit' ] = limit
806+
807+ if name :
808+ params ['name__contains' ] = name
809+
810+ if tool_configuration_id :
811+ params ['tool_configuration__id' ] = tool_configuration_id
812+
813+ return self ._request ('GET' , 'tool_configs/' , params )
814+
645815 # Utility
646816
647817 @staticmethod
0 commit comments