defectdojo_api package

Submodules

defectdojo_api.defectdojo module

class defectdojo_api.defectdojo.DefectDojoAPI(host, api_key, user, api_version='v1', verify_ssl=True, timeout=60, proxies=None, user_agent=None, cert=None, debug=False)

Bases: object

An API wrapper for DefectDojo.

build_details(engagement_id, json)

Uploads commit file changes to an engagement.

Parameters:
  • engagement_id – Engagement identifier.
  • file – File/Json with meta data to be uploaded.
close_engagement(id, user_id=None)

Closes an engagement with the given properties. :param id: Engagement id. :param user_id: User from the user table.

create_app_analysis(product_id, user_id, name, confidence, version, icon, website)

Create a application analysis to product mapping. :param id: Language identification.

create_engagement(name, product_id, lead_id, status, target_start, target_end, active='True', pen_test='False', check_list='False', threat_model='False', risk_path='', test_strategy='', progress='', done_testing='False', engagement_type='CI/CD', build_id=None, commit_hash=None, branch_tag=None, build_server=None, source_code_management_server=None, source_code_management_uri=None, orchestration_engine=None, description=None)

Creates an engagement with the given properties.

Parameters:
  • name – Engagement name.
  • product_id – Product key id..
  • lead_id – Testing lead from the user table.
  • status – Engagement Status: In Progress, On Hold, Completed.
  • target_start – Engagement start date.
  • target_end – Engagement end date.
  • active – Active
  • pen_test – Pen test for engagement.
  • check_list – Check list for engagement.
  • threat_model – Thread Model for engagement.
  • risk_path – risk_path
  • test_strategy – Test Strategy URLs
  • progress – Engagement progresss measured in percent.
  • engagement_type – Interactive or CI/CD
  • build_id – Build id from the build server
  • commit_hash – Commit hash from source code management
  • branch_tag – Branch or tag from source code management
  • build_server – Tool Configuration id of build server
  • source_code_management_server – URL of source code management
  • source_code_management_uri – Link to source code commit
  • orchestration_engine – URL of orchestration engine
create_finding(title, description, severity, cwe, date, product_id, engagement_id, test_id, user_id, impact, active, verified, mitigation, references=None, build=None, line=0, file_path=None, static_finding='False', dynamic_finding='False', false_p='False', duplicate='False', out_of_scope='False', under_review='False', under_defect_review='False', numerical_severity=None)

Creates a finding with the given properties.

Parameters:
  • title – Finding title
  • description – Finding detailed description.
  • severity – Finding severity: Low, Medium, High and Critical
  • cwe – CWE (int)
  • date – Discovered Date.
  • product_id – Product finding should be associated with.
  • engagement_id – Engagement finding should be associated with.
  • test_id – Test finding should be associated with.
  • user_id – Reporter of finding.
  • impact – Detailed impact of finding.
  • active – Finding active and reported on.
  • verified – Finding has been verified.
  • mitigation – Steps to mitigate the finding.
  • references – Details on finding.
  • build – User specified build id relating to the build number from the build server. (Jenkins, Travis etc.).
create_language(product_id, user_id, files, code, blank, comment, language_type_id=None, language_name=None)

Create a language to product mapping. :param product_id: Product identification.

create_product(name, description, prod_type, lifecycle=None)

Creates a product with the given properties.

Parameters:
  • name – Product name.
  • description – Product key id..
  • prod_type – Product type.
  • lifecycle – Lifecycle type.
create_test(engagement_id, test_type, environment, target_start, target_end, percent_complete=None)

Creates a product with the given properties.

Parameters:
  • engagement_id – Engagement id.
  • test_type – Test type key id.
  • target_start – Test start date.
  • target_end – Test end date.
  • percent_complete – Percentage until test completion.
delete_all_app_analysis_product(product_id)

Delete all app analysis using the given id. :product_id id: Product to remove

delete_all_languages_product(product_id)

Delete all languages for a given product id. :param id: Language identification.

delete_app_analysis(id)

Deletes an app analysis using the given id. :param id: Language identification.

delete_language(id)

Deletes a language using the given id. :param id: Language identification.

get_credential(cred_id, limit=20)

Retrieves a credential using the given credential id. :param credential_id: Credential identification.

get_credential_mapping(cred_mapping_id, limit=20)

Retrieves a credential using the given credential id. :param cred_mapping_id: Credential identification.

get_engagement(engagement_id)

Retrieves an engagement using the given engagement id.

Parameters:engagement_id – Engagement identification.
get_engagement_uri(engagement_id)

Returns the DefectDojo API URI for an engagement.

Parameters:engagement_id – Id of the engagement
get_finding(finding_id)

Retrieves a finding using the given finding id. :param finding_id: Finding identification.

get_id_from_url(url)

Returns the ID from the DefectDojo API.

Parameters:url – URL returned by the API
get_language_uri(language_type_id)

Returns the DefectDojo API URI for a langauge.

Parameters:test_id – Id of the language
get_product(product_id)

Retrieves a product using the given product id.

Parameters:product_id – Product identification.
get_product_uri(product_id)

Returns the DefectDojo API URI for a product.

Parameters:product_id – Id of the product
get_test(test_id)

Retrieves a test using the given test id.

Parameters:test_id – Test identification.
get_test_uri(test_id)

Returns the DefectDojo API URI for a test.

Parameters:test_id – Id of the test
get_tool_configuration_uri(tool_configuration_id)

Returns the DefectDojo API URI for a tool.

Parameters:tool_configurations_id – Id of the test
get_user(user_id)

Retrieves a user using the given user id.

Parameters:user_id – User identification.
get_user_uri(user_id)

Returns the DefectDojo API URI for a user.

Parameters:user_id – Id of the user
list_app_analysis(id=None, product_id=None, name=None, limit=20)

Retrieves source code languages.

Parameters:
  • id – Search by lanaguage id.
  • product – Search by product id
  • language_name – Search by language name
  • limit – Number of records to return.
list_credential_mappings(name=None, product_id_in=None, engagement_id_in=None, test_id_in=None, finding_id_in=None, limit=20)

Retrieves mapped credentials.

Parameters:
  • name_contains – Search by credential name.
  • username – Search by username
  • limit – Number of records to return.
list_credentials(name=None, username=None, limit=20)

Retrieves all the globally configured credentials. :param name_contains: Search by credential name. :param username: Search by username :param limit: Number of records to return.

list_engagements(status=None, product=None, name_contains=None, limit=20)

Retrieves all the engagements.

Parameters:
  • product_in – List of product ids (1,2).
  • name_contains – Engagement name
  • limit – Number of records to return.
list_findings(active=None, duplicate=None, mitigated=None, severity=None, verified=None, severity_lt=None, severity_gt=None, severity_contains=None, title_contains=None, url_contains=None, date_lt=None, date_gt=None, date=None, product_id_in=None, engagement_id_in=None, test_id_in=None, build=None, limit=20)

Returns filtered list of findings.

Parameters:
  • active – Finding is active: (true or false)
  • duplicate – Duplicate finding (true or false)
  • mitigated – Mitigated finding (true or false)
  • severity – Severity: Low, Medium, High and Critical.
  • verified – Finding verified.
  • severity_lt – Severity less than Low, Medium, High and Critical.
  • severity_gt – Severity greater than Low, Medium, High and Critical.
  • severity_contains – Severity contains: (Medium, Critical)
  • title_contains – Filter by title containing the keyword.
  • url_contains – Filter by URL containing the keyword.
  • date_lt – Date less than.
  • date_gt – Date greater than.
  • date – Return findings for a particular date.
  • product_id_in – Product id(s) associated with a finding. (1,2 or 1)
  • engagement_id_in – Engagement id(s) associated with a finding. (1,2 or 1)
  • test_in – Test id(s) associated with a finding. (1,2 or 1)
  • build_id – User specified build id relating to the build number from the build server. (Jenkins, Travis etc.).
  • limit – Number of records to return.
list_language_types(id=None, language_name=None, limit=20)

Retrieves source code languages.

Parameters:
  • id – Search by lanaguage id.
  • language_name – Search by language name
  • limit – Number of records to return.
list_languages(id=None, product_id=None, language_name=None, limit=20)

Retrieves source code languages.

Parameters:
  • id – Search by lanaguage id.
  • product – Search by product id
  • language_name – Search by language name
  • limit – Number of records to return.
list_products(name=None, name_contains=None, limit=20)

Retrieves all the products.

Parameters:
  • name – Search by product name.
  • name_contains – Search by product name.
  • limit – Number of records to return.
list_tests(name=None, engagement_in=None, limit=20, title=None, engagement=None)

Retrieves all the tests.

Parameters:
  • name_contains – Search by product name.
  • limit – Number of records to return.
list_tool_products(resource_id=None, url=None, name=None, tool_configuration_id=None, tool_project_id=None, product_id=None, limit=20)

Retrieves all the tools.

Parameters:
  • url_contains – Search by url.
  • name_contains – Search by tool name.
  • tool_configuration_id – Search by tool_configuration_id
  • tool_project_id – Search by tool_project_id
  • product_id – Search by product_id
  • limit – Number of records to return.
list_tool_types(resource_id=None, name=None, limit=20)

Retrieves all the tool types.

Parameters:
  • name_contains – Search by tool type name.
  • limit – Number of records to return.
list_tools(resource_id=None, name=None, tool_type_id=None, url=None, name_icontains=None, limit=20)

Retrieves all the tool configurations.

Parameters:
  • name_contains – Search by tool name.
  • tool_type_id – Search by tool type id
  • url – Search by url
  • limit – Number of records to return.
list_users(username=None, limit=20)

Retrieves all the users.

Parameters:
  • username – Search by username.
  • limit – Number of records to return.
reupload_scan(test_id, scan_type, file, active, scan_date, tags=None, build=None, minimum_severity='Info')

Re-uploads and processes a scan file.

Parameters:
  • test_id – Test identifier.
  • file – Path to the scan file to be uploaded.
set_engagement(id, product_id=None, lead_id=None, name=None, status=None, target_start=None, target_end=None, active=None, pen_test=None, check_list=None, threat_model=None, risk_path=None, test_strategy=None, progress=None, done_testing=None, engagement_type='CI/CD', build_id=None, commit_hash=None, branch_tag=None, build_server=None, source_code_management_server=None, source_code_management_uri=None, orchestration_engine=None, description=None)

Updates an engagement with the given properties.

Parameters:
  • id – Engagement id.
  • name – Engagement name.
  • product_id – Product key id..
  • lead_id – Testing lead from the user table.
  • status – Engagement Status: In Progress, On Hold, Completed.
  • target_start – Engagement start date.
  • target_end – Engagement end date.
  • active – Active
  • pen_test – Pen test for engagement.
  • check_list – Check list for engagement.
  • threat_model – Thread Model for engagement.
  • risk_path – risk_path
  • test_strategy – Test Strategy URLs
  • progress – Engagement progresss measured in percent.
  • engagement_type – Interactive or CI/CD
  • build_id – Build id from the build server
  • commit_hash – Commit hash from source code management
  • branch_tag – Branch or tag from source code management
  • build_server – Tool Configuration id of build server
  • source_code_management_server – URL of source code management
  • source_code_management_uri – Link to source code commit
  • orchestration_engine – URL of orchestration engine
set_finding(finding_id, product_id, engagement_id, test_id, title=None, description=None, severity=None, cwe=None, date=None, user_id=None, impact=None, active=None, verified=None, mitigation=None, references=None)

Updates a finding with the given properties.

Parameters:
  • title – Finding title
  • description – Finding detailed description.
  • severity – Finding severity: Low, Medium, High and Critical
  • cwe – CWE (int)
  • date – Discovered Date.
  • product_id – Product finding should be associated with.
  • engagement_id – Engagement finding should be associated with.
  • test_id – Test finding should be associated with.
  • user_id – Reporter of finding.
  • impact – Detailed impact of finding.
  • active – Finding active and reported on.
  • verified – Finding has been verified.
  • mitigation – Steps to mitigate the finding.
  • references – Details on finding.
  • build – User specified build id relating to the build number from the build server. (Jenkins, Travis etc.).
set_product(product_id, name=None, description=None, prod_type=None, lifecycle=None)

Updates a product with the given properties.

Parameters:
  • product_id – Product ID
  • name – Product name.
  • description – Product key id..
  • prod_type – Product type.
  • lifecycle – Lifecycle type.
set_test(test_id, engagement_id=None, test_type=None, environment=None, target_start=None, target_end=None, percent_complete=None)

Creates a product with the given properties.

Parameters:
  • engagement_id – Engagement id.
  • test_type – Test type key id.
  • target_start – Test start date.
  • target_end – Test end date.
  • percent_complete – Percentage until test completion.
upload_scan(engagement_id, scan_type, file, active, scan_date, tags=None, build=None, minimum_severity='Info')

Uploads and processes a scan file.

Parameters:
  • application_id – Application identifier.
  • file_path – Path to the scan file to be uploaded.
version_url()

Returns the DefectDojo API version.

class defectdojo_api.defectdojo.DefectDojoResponse(message, success, data=None, response_code=-1)

Bases: object

Container for all DefectDojo API responses, even errors.

count()
data_json(pretty=False)

Returns the data as a valid JSON string.

id()

Module contents