Skip to main content

Python wrapper for JFROG Xray REST API

Project description

Python wrapper for JFROG Xray REST API

jfrog-xray-api is a live python package for JFrog Xray REST API.

jfrog-xray-api on PyPI jfrog-xray-api license jfrog-xray-api downloads jfrog-xray-api downloads/month

Tables of Contents

Install

pip install jfrog-xray-api

Usage

Authentication

# User and password OR API_KEY
from xray import XrayRestClient
xray_rest_client = XrayRestClient(
    base_url="http://localhost:8082/xray",
    username='USERNAME',
    password='PASSWORD or API_KEY'
)

SYSTEM

Create Bundle

system = xray_rest_client.system
response = system.create_bundle("bundle-2023-001")
print(response.json())

Ping Request

system = xray_rest_client.system
response = system.system.send_ping()
print(response.json())

Get Version

system = xray_rest_client.system
response = system.get_version()
print(response.json())

Metrics

system = xray_rest_client.system
response = system.get_metrics()
print(response.json())

Components

Find Component by Name

components = xray_rest_client.components
response = components.find_component_by_name("jenkinsapi")
print(response.json())

Find Components by CVEs

components = xray_rest_client.components
cve_list = ['CVE-2021-4104']
response = components.find_components_by_cves(cve_list)
print(response.json())

Find CVEs by Components

components = xray_rest_client.components
components_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

# TODO

Get Artifact Dependency Graph

components = xray_rest_client.components
artifact_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 Artifacts

components = xray_rest_client.components
source_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 Graph

components = xray_rest_client.components
artifactory_instance = "myInstance",
build_name = "someBuild",
build_number = "someNumber"
response = components.get_build_dependency_graph(artifactory_instance, build_name, build_number)
print(response.json())

Compare Builds

components = xray_rest_client.components
response = components.compare_builds(
    "my-instance", "someOriginBuild", "111",
    "my-instance", "someTargetBuild", "222",
)
print(response.json())

Export Component Details

# TODO

SUMMARY

Build Summary

summary = xray_rest_client.summary
response = summary.get_build_summary("build_name", "123")
print(response.json())

Artifact Summary

summary = xray_rest_client.summary
response = 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())

Issues

Create Issue Event

from xray.common import PackageType
issues = xray_rest_client.issues
response = issues.create_issue_event(
    issue_id='test-2023-0221',
    summary='test-2023-0221',
    description='test-2023-0221',
    package_type=PackageType.MAVEN,
    component_id='com.test:test',
    vulnerable_versions=["[1.0.10.2,)"],
)
print(response.json())

Update Issue Event

from xray.common import PackageType
issues = xray_rest_client.issues
response = issues.update_issue_event(
    issue_id='test-2023-0221',
    summary='test-2023-0221',
    description='test-2023-0221 update',
    package_type=PackageType.MAVEN,
    component_id='com.test:test',
    vulnerable_versions=["[1.0.10.2,)"],
)
print(response.content)

Get Issue Event

issues = xray_rest_client.issues
# get issue event v1
# Note: This API is deprecated in Xray version 3.51.0
response = issues.get_issue_event("test-2023-0221")
# get issue event v2
# Since: Xray  3.51.0
response = issues.get_issue_event("test-2023-0221", api_version="v2")
print(response.json())

SCANNING

Scan Artifact

scanning = xray_rest_client.scanning
response = scanning.scan_artifact("docker://image_name:image_tag")
print(response.json())

Scan Build

scanning = xray_rest_client.scanning
# scan build v1
response = scanning.scan_build("build_name", "build_number")
# scan build v2
# Starting from Xray version 3.42.3
response = scanning.scan_build("build_name", "build_number", api_version='v2')
print(response.json())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jfrog-xray-api-0.0.3.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

jfrog_xray_api-0.0.3-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file jfrog-xray-api-0.0.3.tar.gz.

File metadata

  • Download URL: jfrog-xray-api-0.0.3.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for jfrog-xray-api-0.0.3.tar.gz
Algorithm Hash digest
SHA256 fdd86a2b374a280b27b2808aa55e2b2cff02f243960a0d2ccf6d4fbb76ef77ca
MD5 10c3d03c6f97778273f4835c39c6943f
BLAKE2b-256 82a6c1dcb1452ec0353b5811c5b7626183f5c5da4a7c8889a0d74edff75e33d7

See more details on using hashes here.

File details

Details for the file jfrog_xray_api-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for jfrog_xray_api-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ad244fb782957e2f9b33bb3c60856ff6efd0a16da64455895216b881f7a6e98a
MD5 85cda01f431807e95acc43cefda2c9ae
BLAKE2b-256 eb33b328cbfb2d63f24f0deb40622f47588c9aa4572be3c4205f1e086c1bf95b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page