XRAY: Generate Report With All Repositories Included Using REST API
Both the Due Diligence Report and the Vulnerabilities Report can be generated using the Xray REST API guide.
This article explains how to produce an output of all currently indexed repositories so that we can use the REST API to generate a report on all repositories in our Artifactory.
Using the “Get Repos Indexing Configuration” REST API to generate the output
To get the required information about what repositories are indexed and can be provided as a payload to our “Generate Reports” APIs, we can use the Get Repos Indexing Configuration REST API.
For the purposes of this example, we are going to modify the output using "JQ". however, you are able to use another json parser if it is more convenient for you to use.
The goal is to alter the outcome so that it can be directly added to the payload:
curl -uadmin:password 'http://{artifactory-id}/xray/api/v1/binMgr/{artifactory-id}/repos' |jq '.indexed_repos | map({name: .name})'
Running the above will result in the output listed below:
[
{
"name": "repo"
},
{
"name": "repo"
},
{
"name": "repo"
},
{
"name": "repo"
}
]
The following output can be added later as the complete value of "repositories" in the payload to the "Generate Vulnerabilities Report"/"Generate Due Diligence Report" REST APIs:
"resources": {
"repositories": [
{
"name": "example-main-docker-local"
},
{
"name": "example-main-npm-local"
}
]
By doing this, you will be able to use the REST API and, if necessary, incorporate all indexed repositories.