jfrog-xray-api


Namejfrog-xray-api JSON
Version 0.0.6 PyPI version JSON
download
home_page
SummaryPython wrapper for JFROG Xray REST API
upload_time2023-03-15 14:43:56
maintainer
docs_urlNone
author
requires_python>=3.7
license
keywords jfrog xray jfrog-xray devsecops
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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](https://img.shields.io/pypi/v/jfrog-xray-api.svg)][1]
[![jfrog-xray-api license](https://img.shields.io/pypi/l/jfrog-xray-api.svg)][2]
[![jfrog-xray-api downloads](https://pepy.tech/badge/jfrog-xray-api)][3]
[![jfrog-xray-api downloads/month](https://static.pepy.tech/badge/jfrog-xray-api/month)][3]
![pylint](https://github.com/donhui/jfrog-xray-api/actions/workflows/pylint.yml/badge.svg)


[1]: https://pypi.python.org/pypi/jfrog-xray-api
[2]: https://github.com/donhui/jfrog-xray-api/blob/master/LICENSE
[3]: https://pepy.tech/project/jfrog-xray-api


# Tables of Contents

<!-- toc -->
- [Install](#install)
- [Usage](#usage)
  * [Authentication](#authentication)
  * [SYSTEM](#system)
    + [Create Bundle](#create-bundle)
    + [Ping Request](#ping-request)  
    + [Get Version](#get-version)
    + [Metrics](#metrics)
  * [Components](#components)
    + [Find Component by Name](#find-component-by-name)
    + [Find Components by CVEs](#find-components-by-cves)
    + [Find CVEs by Components](#find-cves-by-components)
    + [Get Component List Per Watch](#get-component-list-per-watch)
    + [Get Artifact Dependency Graph](#get-artifact-dependency-graph)
    + [Compare Artifacts](#compare-artifacts)
    + [Get Build Dependency Graph](#get-build-dependency-graph)
    + [Compare Builds](#compare-builds)
    + [Export Component Details](#export-component-details)
  * [SUMMARY](#summary)
    + [Build Summary](#build-summary)
    + [Artifact Summary](#artifact-summary)
  * [ISSUES](#issues)   
    + [Create Issue Event](#create-issue-event)
    + [Update Issue Event](#update-issue-event)
    + [Get Issue Event](#get-issue-event)
  * [SCANNING](#scanning)   
    + [Scan Artifact](#scan-artifact)  
    + [Scan Build](#scan-build)
    + [Scan Status](#scan-status)
    + [Scan Now](#scan-now)
<!-- tocstop -->

# Install
```
pip install jfrog-xray-api
```
# Usage

## Authentication
```python
# 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
```python
system = xray_rest_client.system
response = system.create_bundle("bundle-2023-001")
print(response.json())
```
### Ping Request
```python
system = xray_rest_client.system
response = system.system.send_ping()
print(response.json())
```
### Get Version
```python
system = xray_rest_client.system
response = system.get_version()
print(response.json())
```
### Metrics
```python
system = xray_rest_client.system
response = system.get_metrics()
print(response.json())
```

## Components
### Find Component by Name
```python
components = xray_rest_client.components
response = components.find_component_by_name("jenkinsapi")
print(response.json())
```
### Find Components by CVEs
```python
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
```python
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
```python
# TODO
```
### Get Artifact Dependency Graph
```python
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
```python
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
```python
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
```python
components = xray_rest_client.components
response = components.compare_builds(
    "my-instance", "someOriginBuild", "111",
    "my-instance", "someTargetBuild", "222",
)
print(response.json())
```
### Export Component Details
```python
# TODO
```

## SUMMARY
### Build Summary
```python
summary = xray_rest_client.summary
response = summary.get_build_summary("build_name", "123")
print(response.json())
```
### Artifact Summary
```python
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
```python
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.value,
    component_id='com.test:test',
    vulnerable_versions=["[1.0.10.2,)"],
)
print(response.json())
```

### Update Issue Event
```python
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.value,
    component_id='com.test:test',
    vulnerable_versions=["[1.0.10.2,)"],
)
print(response.content)
```
### Get Issue Event
```python
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
```python
scanning = xray_rest_client.scanning
response = scanning.scan_artifact("docker://image_name:image_tag")
print(response.json())
```
### Scan Build
```python
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())
```

### Scan Status
```python
from xray.common import PackageType
scanning = xray_rest_client.scanning
# get scan status for artifact
response = 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 build
scanning = xray_rest_client.scanning
response = scanning.get_scan_status_for_build("test-build", "1")
print(response.json())
# get scan status for build with project
scanning = xray_rest_client.scanning
response = scanning.get_scan_status_for_build("test-build", "1", project="proj1")
print(response.json())
```

### Scan Now
```python
from xray.common import PackageType
scanning = xray_rest_client.scanning
# scan now
response = scanning.scan_now("local-maven-repo/org/jenkins-ci/main/jenkins-war/2.289.1/jenkins-war-2.289.1.war")
print(response.json())
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "jfrog-xray-api",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "jfrog,xray,jfrog-xray,devsecops",
    "author": "",
    "author_email": "Donghui Wang <977675308@qq.com>",
    "download_url": "https://files.pythonhosted.org/packages/e5/21/4fe6338dec0ab93f50b43d391337542f469de1924cd09f3508094d6d3a40/jfrog-xray-api-0.0.6.tar.gz",
    "platform": null,
    "description": "# Python wrapper for JFROG Xray REST API\n`jfrog-xray-api` is a live python package for JFrog Xray REST API. \n\n[![jfrog-xray-api on PyPI](https://img.shields.io/pypi/v/jfrog-xray-api.svg)][1]\n[![jfrog-xray-api license](https://img.shields.io/pypi/l/jfrog-xray-api.svg)][2]\n[![jfrog-xray-api downloads](https://pepy.tech/badge/jfrog-xray-api)][3]\n[![jfrog-xray-api downloads/month](https://static.pepy.tech/badge/jfrog-xray-api/month)][3]\n![pylint](https://github.com/donhui/jfrog-xray-api/actions/workflows/pylint.yml/badge.svg)\n\n\n[1]: https://pypi.python.org/pypi/jfrog-xray-api\n[2]: https://github.com/donhui/jfrog-xray-api/blob/master/LICENSE\n[3]: https://pepy.tech/project/jfrog-xray-api\n\n\n# Tables of Contents\n\n<!-- toc -->\n- [Install](#install)\n- [Usage](#usage)\n  * [Authentication](#authentication)\n  * [SYSTEM](#system)\n    + [Create Bundle](#create-bundle)\n    + [Ping Request](#ping-request)  \n    + [Get Version](#get-version)\n    + [Metrics](#metrics)\n  * [Components](#components)\n    + [Find Component by Name](#find-component-by-name)\n    + [Find Components by CVEs](#find-components-by-cves)\n    + [Find CVEs by Components](#find-cves-by-components)\n    + [Get Component List Per Watch](#get-component-list-per-watch)\n    + [Get Artifact Dependency Graph](#get-artifact-dependency-graph)\n    + [Compare Artifacts](#compare-artifacts)\n    + [Get Build Dependency Graph](#get-build-dependency-graph)\n    + [Compare Builds](#compare-builds)\n    + [Export Component Details](#export-component-details)\n  * [SUMMARY](#summary)\n    + [Build Summary](#build-summary)\n    + [Artifact Summary](#artifact-summary)\n  * [ISSUES](#issues)   \n    + [Create Issue Event](#create-issue-event)\n    + [Update Issue Event](#update-issue-event)\n    + [Get Issue Event](#get-issue-event)\n  * [SCANNING](#scanning)   \n    + [Scan Artifact](#scan-artifact)  \n    + [Scan Build](#scan-build)\n    + [Scan Status](#scan-status)\n    + [Scan Now](#scan-now)\n<!-- tocstop -->\n\n# Install\n```\npip install jfrog-xray-api\n```\n# Usage\n\n## Authentication\n```python\n# User and password OR API_KEY\nfrom xray import XrayRestClient\nxray_rest_client = XrayRestClient(\n    base_url=\"http://localhost:8082/xray\",\n    username='USERNAME',\n    password='PASSWORD or API_KEY'\n)\n```\n\n## SYSTEM\n### Create Bundle\n```python\nsystem = xray_rest_client.system\nresponse = system.create_bundle(\"bundle-2023-001\")\nprint(response.json())\n```\n### Ping Request\n```python\nsystem = xray_rest_client.system\nresponse = system.system.send_ping()\nprint(response.json())\n```\n### Get Version\n```python\nsystem = xray_rest_client.system\nresponse = system.get_version()\nprint(response.json())\n```\n### Metrics\n```python\nsystem = xray_rest_client.system\nresponse = system.get_metrics()\nprint(response.json())\n```\n\n## Components\n### Find Component by Name\n```python\ncomponents = xray_rest_client.components\nresponse = components.find_component_by_name(\"jenkinsapi\")\nprint(response.json())\n```\n### Find Components by CVEs\n```python\ncomponents = xray_rest_client.components\ncve_list = ['CVE-2021-4104']\nresponse = components.find_components_by_cves(cve_list)\nprint(response.json())\n```\n### Find CVEs by Components\n```python\ncomponents = xray_rest_client.components\ncomponents_id_list = ['gav://commons-collections:commons-collections:3.2.1', 'gav://commons-collections:commons-collections:3.2.2']\nresponse = components.find_cves_by_components(components_id_list)\nprint(response.json())\n```\n### Get Component List Per Watch\n```python\n# TODO\n```\n### Get Artifact Dependency Graph\n```python\ncomponents = xray_rest_client.components\nartifact_path = '/Artifactory/pnnl/goss/goss-core-client/0.1.7/goss-core-client-0.1.7-sources.jar'\nresponse = components.get_artifact_dependency_graph(artifact_path)\nprint(response.json())\n```\n### Compare Artifacts\n```python\ncomponents = xray_rest_client.components\nsource_artifact_path = '/Artifactory/pnnl/goss/goss-core-client/0.1.7/goss-core-client-0.1.7-sources.jar'\ntarget_artifact_path = '/Artifactory/pnnl/goss/goss-core-client/0.1.8/goss-core-client-0.1.8-sources.jar'\nresponse = components.compare_artifacts(source_artifact_path, target_artifact_path)\nprint(response.json())\n```\n### Get Build Dependency Graph\n```python\ncomponents = xray_rest_client.components\nartifactory_instance = \"myInstance\",\nbuild_name = \"someBuild\",\nbuild_number = \"someNumber\"\nresponse = components.get_build_dependency_graph(artifactory_instance, build_name, build_number)\nprint(response.json())\n```\n### Compare Builds\n```python\ncomponents = xray_rest_client.components\nresponse = components.compare_builds(\n    \"my-instance\", \"someOriginBuild\", \"111\",\n    \"my-instance\", \"someTargetBuild\", \"222\",\n)\nprint(response.json())\n```\n### Export Component Details\n```python\n# TODO\n```\n\n## SUMMARY\n### Build Summary\n```python\nsummary = xray_rest_client.summary\nresponse = summary.get_build_summary(\"build_name\", \"123\")\nprint(response.json())\n```\n### Artifact Summary\n```python\nsummary = xray_rest_client.summary\nresponse = summary.get_artifact_summary(paths=[\"/Artifactory/pnnl/goss/goss-core-client/0.1.7/goss-core-client-0.1.7-sources.jar\"])\nprint(response.json())\n```\n\n## Issues\n### Create Issue Event\n```python\nfrom xray.common import PackageType\nissues = xray_rest_client.issues\nresponse = issues.create_issue_event(\n    issue_id='test-2023-0221',\n    summary='test-2023-0221',\n    description='test-2023-0221',\n    package_type=PackageType.MAVEN.value,\n    component_id='com.test:test',\n    vulnerable_versions=[\"[1.0.10.2,)\"],\n)\nprint(response.json())\n```\n\n### Update Issue Event\n```python\nfrom xray.common import PackageType\nissues = xray_rest_client.issues\nresponse = issues.update_issue_event(\n    issue_id='test-2023-0221',\n    summary='test-2023-0221',\n    description='test-2023-0221 update',\n    package_type=PackageType.MAVEN.value,\n    component_id='com.test:test',\n    vulnerable_versions=[\"[1.0.10.2,)\"],\n)\nprint(response.content)\n```\n### Get Issue Event\n```python\nissues = xray_rest_client.issues\n# get issue event v1\n# Note: This API is deprecated in Xray version 3.51.0\nresponse = issues.get_issue_event(\"test-2023-0221\")\n# get issue event v2\n# Since: Xray  3.51.0\nresponse = issues.get_issue_event(\"test-2023-0221\", api_version=\"v2\")\nprint(response.json())\n```\n\n## SCANNING\n### Scan Artifact\n```python\nscanning = xray_rest_client.scanning\nresponse = scanning.scan_artifact(\"docker://image_name:image_tag\")\nprint(response.json())\n```\n### Scan Build\n```python\nscanning = xray_rest_client.scanning\n# scan build v1\nresponse = scanning.scan_build(\"build_name\", \"build_number\")\n# scan build v2\n# Starting from Xray version 3.42.3\nresponse = scanning.scan_build(\"build_name\", \"build_number\", api_version='v2')\nprint(response.json())\n```\n\n### Scan Status\n```python\nfrom xray.common import PackageType\nscanning = xray_rest_client.scanning\n# get scan status for artifact\nresponse = scanning.get_scan_status_for_artifact(\n    PackageType.NPM.value,\n    'npm-local/static-module-3.0.4.tar.gz',\n    'b0a887f6e5c16134b7d1280c2150d38811357642d56c622c6f7f6b239f668608'\n)\nprint(response.json())\n# get scan status for build\nscanning = xray_rest_client.scanning\nresponse = scanning.get_scan_status_for_build(\"test-build\", \"1\")\nprint(response.json())\n# get scan status for build with project\nscanning = xray_rest_client.scanning\nresponse = scanning.get_scan_status_for_build(\"test-build\", \"1\", project=\"proj1\")\nprint(response.json())\n```\n\n### Scan Now\n```python\nfrom xray.common import PackageType\nscanning = xray_rest_client.scanning\n# scan now\nresponse = scanning.scan_now(\"local-maven-repo/org/jenkins-ci/main/jenkins-war/2.289.1/jenkins-war-2.289.1.war\")\nprint(response.json())\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python wrapper for JFROG Xray REST API",
    "version": "0.0.6",
    "split_keywords": [
        "jfrog",
        "xray",
        "jfrog-xray",
        "devsecops"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "765dc3529bf414ea30f3e7ab74dbbbb3ad40ac3c5ddc57d7795a87d22db76664",
                "md5": "0706722e0a321a9ff8b548b0b8d4df95",
                "sha256": "d5f770be0088b1347d0dfd9c3847b93e33c5d9e3cfa21e7bf9474316ef11792b"
            },
            "downloads": -1,
            "filename": "jfrog_xray_api-0.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0706722e0a321a9ff8b548b0b8d4df95",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 11266,
            "upload_time": "2023-03-15T14:43:54",
            "upload_time_iso_8601": "2023-03-15T14:43:54.595342Z",
            "url": "https://files.pythonhosted.org/packages/76/5d/c3529bf414ea30f3e7ab74dbbbb3ad40ac3c5ddc57d7795a87d22db76664/jfrog_xray_api-0.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e5214fe6338dec0ab93f50b43d391337542f469de1924cd09f3508094d6d3a40",
                "md5": "575a81188146321bc337f1bb2809b8a1",
                "sha256": "a531f7554872f1a6a16c692aecb8aa44aac201f44cf7c4fb833f6842e004c57d"
            },
            "downloads": -1,
            "filename": "jfrog-xray-api-0.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "575a81188146321bc337f1bb2809b8a1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 8177,
            "upload_time": "2023-03-15T14:43:56",
            "upload_time_iso_8601": "2023-03-15T14:43:56.370990Z",
            "url": "https://files.pythonhosted.org/packages/e5/21/4fe6338dec0ab93f50b43d391337542f469de1924cd09f3508094d6d3a40/jfrog-xray-api-0.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-15 14:43:56",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "jfrog-xray-api"
}
        
Elapsed time: 0.05816s