Package: jfrog-xray-api
Python wrapper for JFROG Xray REST APIjfrog-xray-apiis a live python package for JFrog Xray REST API.Tables of ContentsInstallUsageAuthenticationSYSTEMCreate BundlePing RequestGet VersionMetricsComponentsFind Component by NameFind Components by CVEsFind CVEs by ComponentsGet Component List Per WatchGet Artifact Dependency GraphCompare ArtifactsGet Build Dependency GraphCompare BuildsExport Component DetailsSUMMARYBuild SummaryArtifact SummaryISSUESCreate Issue EventUpdate Issue EventGet Issue EventSCANNINGScan ArtifactScan BuildScan StatusScan NowInstallpip install jfrog-xray-apiUsageAuthentication# User and password OR API_KEYfromxrayimportXrayRestClientxray_rest_client=XrayRestClient(base_url="http://localhost:8082/xray",username='USERNAME',password='PASSWORD or API_KEY')SYSTEMCreate Bundlesystem=xray_rest_client.systemresponse=system.create_bundle("bundle-2023-001")print(response.json())Ping Requestsystem=xray_rest_client.systemresponse=system.system.send_ping()print(response.json())Get Versionsystem=xray_rest_client.systemresponse=system.get_version()print(response.json())Metricssystem=xray_rest_client.systemresponse=system.get_metrics()print(response.json())ComponentsFind Component by Namecomponents=xray_rest_client.componentsresponse=components.find_component_by_name("jenkinsapi")print(response.json())Find Components by CVEscomponents=xray_rest_client.componentscve_list=['CVE-2021-4104']response=components.find_components_by_cves(cve_list)print(response.json())Find CVEs by Componentscomponents=xray_rest_client.componentscomponents_id_list=['gav://commons-collections:commons-collections:3.2.1','gav://commons-collections:commons-collections:3.2.2']response=components.find_cves_by_components(components_id_list)print(response.json())Get Component List Per Watch# TODOGet Artifact Dependency Graphcomponents=xray_rest_client.componentsartifact_path='/Artifactory/pnnl/goss/goss-core-client/0.1.7/goss-core-client-0.1.7-sources.jar'response=components.get_artifact_dependency_graph(artifact_path)print(response.json())Compare Artifactscomponents=xray_rest_client.componentssource_artifact_path='/Artifactory/pnnl/goss/goss-core-client/0.1.7/goss-core-client-0.1.7-sources.jar'target_artifact_path='/Artifactory/pnnl/goss/goss-core-client/0.1.8/goss-core-client-0.1.8-sources.jar'response=components.compare_artifacts(source_artifact_path,target_artifact_path)print(response.json())Get Build Dependency Graphcomponents=xray_rest_client.componentsartifactory_instance="myInstance",build_name="someBuild",build_number="someNumber"response=components.get_build_dependency_graph(artifactory_instance,build_name,build_number)print(response.json())Compare Buildscomponents=xray_rest_client.componentsresponse=components.compare_builds("my-instance","someOriginBuild","111","my-instance","someTargetBuild","222",)print(response.json())Export Component Details# TODOSUMMARYBuild Summarysummary=xray_rest_client.summaryresponse=summary.get_build_summary("build_name","123")print(response.json())Artifact Summarysummary=xray_rest_client.summaryresponse=summary.get_artifact_summary(paths=["/Artifactory/pnnl/goss/goss-core-client/0.1.7/goss-core-client-0.1.7-sources.jar"])print(response.json())IssuesCreate Issue Eventfromxray.commonimportPackageTypeissues=xray_rest_client.issuesresponse=issues.create_issue_event(issue_id='test-2023-0221',summary='test-2023-0221',description='test-2023-0221',package_type=PackageType.MAVEN.value,component_id='com.test:test',vulnerable_versions=["[1.0.10.2,)"],)print(response.json())Update Issue Eventfromxray.commonimportPackageTypeissues=xray_rest_client.issuesresponse=issues.update_issue_event(issue_id='test-2023-0221',summary='test-2023-0221',description='test-2023-0221 update',package_type=PackageType.MAVEN.value,component_id='com.test:test',vulnerable_versions=["[1.0.10.2,)"],)print(response.content)Get Issue Eventissues=xray_rest_client.issues# get issue event v1# Note: This API is deprecated in Xray version 3.51.0response=issues.get_issue_event("test-2023-0221")# get issue event v2# Since: Xray  3.51.0response=issues.get_issue_event("test-2023-0221",api_version="v2")print(response.json())SCANNINGScan Artifactscanning=xray_rest_client.scanningresponse=scanning.scan_artifact("docker://image_name:image_tag")print(response.json())Scan Buildscanning=xray_rest_client.scanning# scan build v1response=scanning.scan_build("build_name","build_number")# scan build v2# Starting from Xray version 3.42.3response=scanning.scan_build("build_name","build_number",api_version='v2')print(response.json())Scan Statusfromxray.commonimportPackageTypescanning=xray_rest_client.scanning# get scan status for artifactresponse=scanning.get_scan_status_for_artifact(PackageType.NPM.value,'npm-local/static-module-3.0.4.tar.gz','b0a887f6e5c16134b7d1280c2150d38811357642d56c622c6f7f6b239f668608')print(response.json())# get scan status for buildscanning=xray_rest_client.scanningresponse=scanning.get_scan_status_for_build("test-build","1")print(response.json())# get scan status for build with projectscanning=xray_rest_client.scanningresponse=scanning.get_scan_status_for_build("test-build","1",project="proj1")print(response.json())Scan Nowfromxray.commonimportPackageTypescanning=xray_rest_client.scanning# scan nowresponse=scanning.scan_now("local-maven-repo/org/jenkins-ci/main/jenkins-war/2.289.1/jenkins-war-2.289.1.war")print(response.json())