コード例 #1
0
def test_get_osa_scan_vulnerabilities_by_id():
    project_id = get_project_id()
    osa_api = OsaAPI()
    scan_id = osa_api.get_last_osa_scan_id_of_a_project(project_id)
    vulnerabilities = osa_api.get_osa_scan_vulnerabilities_by_id(
        scan_id, page=1, items_per_page=10)
    assert vulnerabilities is not None
コード例 #2
0
def test_get_osa_scan_vulnerability_comments_by_id():
    project_id = get_project_id()
    osa_api = OsaAPI()
    scan_id = osa_api.get_last_osa_scan_id_of_a_project(project_id)
    vulnerability_id = osa_api.get_first_vulnerability_id(scan_id)
    comment = osa_api.get_osa_scan_vulnerability_comments_by_id(
        vulnerability_id, project_id)
    assert comment is not None
コード例 #3
0
def test_create_an_osa_scan_request():
    project_id = get_project_id()
    osa_api = OsaAPI()
    parent_folder = dirname(__file__)
    path = normpath(join(parent_folder, "JavaVulnerableLab-master.zip"))
    scan_id = osa_api.create_an_osa_scan_request(project_id,
                                                 zipped_source_path=str(path))
    assert scan_id is not None
コード例 #4
0
def test_get_osa_scan_libraries():
    project_id = get_project_id()
    osa_api = OsaAPI()
    scan_id = osa_api.get_last_osa_scan_id_of_a_project(project_id)
    libraries = osa_api.get_osa_scan_libraries(scan_id,
                                               page=1,
                                               items_per_page=2,
                                               api_version="3.0")
    assert libraries is not None
コード例 #5
0
def osa_scan():
    team_full_name = "/CxServer"
    project_name = "OSA_demo"

    projects_api = ProjectsAPI()
    team_api = TeamAPI()
    osa_api = OsaAPI()

    # 1. create project
    projects_api.delete_project_if_exists_by_project_name_and_team_full_name(
        project_name, team_full_name)

    # 2. get team id
    team_id = team_api.get_team_id_by_team_full_name(team_full_name)

    # 3. create project with default configuration, will get project id
    project = projects_api.create_project_with_default_configuration(
        project_name=project_name, team_id=team_id)
    project_id = project.id

    # 4. create an OSA scan
    scan_id = osa_api.create_an_osa_scan_request(
        project_id=project_id,
        zipped_source_path=zip_file_path,
        origin="REST API")

    # 5. check scan status
    while True:
        osa_scan_detail = osa_api.get_osa_scan_by_scan_id(scan_id)
        osa_scan_state = osa_scan_detail.state.name
        if osa_scan_state == "Succeeded":
            break
        elif osa_scan_state == "Failed":
            print("OSA scan failed")
            return
        else:
            time.sleep(1)

    # 6. get summary report
    summary_report = osa_api.get_osa_scan_summary_report(scan_id=scan_id)

    print(summary_report)
コード例 #6
0
def test_get_first_vulnerability_id():
    project_id = get_project_id()
    osa_api = OsaAPI()
    scan_id = osa_api.get_last_osa_scan_id_of_a_project(project_id)
    vulnerability_id = osa_api.get_first_vulnerability_id(scan_id)
    assert vulnerability_id is not None
コード例 #7
0
def test_get_osa_licenses_by_id():
    project_id = get_project_id()
    osa_api = OsaAPI()
    scan_id = osa_api.get_last_osa_scan_id_of_a_project(project_id)
    licenses = osa_api.get_osa_licenses_by_id(scan_id)
    assert licenses is not None
コード例 #8
0
def test_get_all_osa_file_extensions():
    osa_api = OsaAPI()
    extensions = osa_api.get_all_osa_file_extensions()
    assert extensions is not None
コード例 #9
0
def test_get_osa_scan_by_scan_id():
    project_id = get_project_id()
    osa_api = OsaAPI()
    scan_id = osa_api.get_last_osa_scan_id_of_a_project(project_id)
    osa_scan = osa_api.get_osa_scan_by_scan_id(scan_id)
    assert osa_scan is not None
コード例 #10
0
def test_get_all_osa_scan_details():
    project_id = get_project_id()
    osa_api = OsaAPI()
    all_osa_scan = osa_api.get_all_osa_scan_details_for_project(
        project_id, page=1, items_per_page=1)
    assert all_osa_scan is not None
コード例 #11
0
def test_get_osa_scan_summary_report():
    project_id = get_project_id()
    osa_api = OsaAPI()
    scan_id = osa_api.get_last_osa_scan_id_of_a_project(project_id)
    report = osa_api.get_osa_scan_summary_report(scan_id)
    assert report is not None