HashiCorp Cloud Platform
Combine multiple scan results
It might be useful to create a single file with results from multiple different scans. The combined file can be used to look at all scan results in a single view, or can be passed to other commands as well.
How to combine the results depends on the format of the resulted file.
JSON
If the output file format is JSON, combining multiple results is simple. As the format is a json-lines, each line is completely independent, and you can concatenate all the result files:
$ cat results-1.jsonl results-2.jsonl > combined-results.jsonl
Example
Scan two different vault clusters and create a combined index. See index vault for information about creating an index.
Scan a Vault cluster and store the result in
vault-index-1.jsonl.$ VAULT_ADDR=[ADDR1] VAULT_TOKEN=[TOKEN1] vault-radar index vault \ -o vault-index-1.jsonl --indexScan another Vault cluster and store the result in
vault-index-2.jsonl.$ VAULT_ADDR=[ADDR2] VAULT_TOKEN=[TOKEN2] vault-radar index vault \ -o vault-index-2.jsonl --indexCombine the two scan results.
$ cat vault-index-1.jsonl vault-index-2.jsonl > combined-vault-index.jsonl
CSV
Each CSV file has a header line, so just combining files will not properly work.
To combine a combination of head and tail commands can be used.
$ head -n 1 result-1.csv > combined-results.csv && \
tail -n+2 -q results-1.csv results-2.csv >> combined-results.csv
Example
Scan two git repositories and create a combined file.
Scan a git repository and store the result in
scan-repo-results-1.csv.$ vault-radar scan repo -u <REPO-URL-1> -o scan-repo-results-1.csvScan another git repository and store the result in
scan-repo-results-12.csv.$ vault-radar scan repo -u <REPO-URL-2> -o scan-repo-results-2.csvCombine the two scan results.
$ head -n 1 scan-repo-results-1.csv > combined-results.csv && \ tail -n+2 -q scan-repo-results-1.csv scan-repo-results-2.csv >> combined-results.csv