Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

EXPORTING TO CSV

Overview

Export AttackForge data to a CSV file, so you can analyse it in a spreadsheet, build your own reports or import it into other tools. You fetch the data with the Self-Service RESTful API, then convert it to CSV with jq, a free command-line JSON processor.

This page uses the getVulnerabilities API method, but the same approach works for any Self-Service API method.

Why it matters

Benefit

What it means

Choose your columns

Export only the fields you need, in the order you want

Filter first

Export only the vulnerabilities that match a filter, such as Open

Repeatable

Run the same command whenever you need a fresh export, or schedule it

Works anywhere

jq is free, runs on Linux, macOS and Windows, and has no dependencies

Feeds other tools

Open the CSV in Excel or Google Sheets, or import it into BI and ticketing tools

Who uses it

Role

Typical use

Security and project managers

Export open or closed vulnerabilities for status reports

Analysts

Pull data into spreadsheets and BI tools

Remediation teams

Import vulnerabilities into their own trackers

Developers and integration engineers

Script regular exports

Other ways to get data out

  • AI MCP: ask an AI assistant to build a spreadsheet or table from your vulnerabilities, without writing jq.

  • Report automation: generate formatted reports automatically.

  • Flows: send data to another system when something changes in AttackForge.

Before you start

You need:

  • access to the getVulnerabilities API method. See Give users access to API methods.

  • your API key, from Profile > Secrets

  • your AttackForge hostname, such as demo.attackforge.com

  • jq and cURL

Install jq on Linux

Run:

For other ways to install jq, see Download jq.

Install jq on Windows

Run:

For other ways to install jq, see Download jq.

Choose where to run the commands

The commands on this page are written for Windows Command Prompt:

  • Linux and macOS (bash or zsh): they also work, except for the filter commands. Put a backslash before $eq, writing \$eq, so the shell doesn't treat it as a variable.

  • PowerShell: use curl.exe instead of curl, because curl can run a different PowerShell command.

Export vulnerabilities to CSV

  1. Open a command window or terminal.

  2. Run this command. Replace <YOUR-TENANT> with your AttackForge hostname and <YOUR-API-KEY> with your API key.

This creates filtered_vulns.csv in the current folder, with one row for each vulnerability you can access.

What the command does

Part

What it does

curl -X GET "https://<YOUR-TENANT>/api/ss/vulnerabilities"

Calls the getVulnerabilities API method

-H "X-SSAPI-KEY: <YOUR-API-KEY>"

Sends your API key

| jq -r "…"

Passes the response to jq, which outputs raw text

.vulnerabilities[] | [ … ]

Makes one row for each vulnerability, from the fields in the brackets

if(try(.vulnerability_affected_assets)) then … end

Joins the names of grouped assets with a comma, or leaves the cell empty

@csv

Formats each row as CSV

> filtered_vulns.csv

Saves the output to a file

The columns

Column

Field

Example

Id

.vulnerability_id

Title

.vulnerability_title

Blind SQL Injection

Created

.vulnerability_created

A date and time

Priority

.vulnerability_priority

Critical, High, Medium, Low or Info

Status

.vulnerability_status

Open or Closed

Status Updated

.vulnerability_status_updated

A date and time

Affected Asset Name

.vulnerability_affected_asset_name

attackforge.com

Affected Assets

.vulnerability_affected_assets[].asset.name

Each asset's name, when you use grouped assets

Retest

.vulnerability_retest

Yes or No

Project Name

.vulnerability_project_name

Web App Pentest

Description

.vulnerability_description

Attack Scenario

.vulnerability_attack_scenario

Remediation Recommendation

.vulnerability_remediation_recommendation

Steps to Reproduce

.vulnerability_steps_to_reproduce

Change or reorder the columns

Edit the list of fields inside the square brackets, after .vulnerabilities[] |. Change the order to change the column order, or remove fields you don't need.

Add more fields

You can add any field the API returns. For the fields, see getVulnerabilities.

This example adds the vulnerability's SLA (.vulnerability_sla) after the project name:

Add column names

To add a header row, put an array of column names before the data:

Note: Keep the backslash before each quotation mark (\") around the column names. Without it, jq may fail with a compile error.

Filter the vulnerabilities

Use an Advanced Query Filter in the q_vulnerability parameter to export only some vulnerabilities. This example exports only Open vulnerabilities:

-G and --data-urlencode add the filter to the URL, encoded correctly.

Important: On Linux and macOS, write \$eq instead of $eq. Otherwise the shell removes it and the filter doesn't work.

Example: closed vulnerabilities and why they were closed

This example exports Closed vulnerabilities, with the reason, date and person from the last remediation note that contains "Issue Closed".

Example output:

Vulnerability Id

Created

Priority

Title

Status

Status Last Updated

Affected Asset

Affected Assets

Project Name

Project Id

Last Closed Reason

Last Closed On

Last Closed By

65bc9d9a4534bd000e50db3f

2024-02-02T07:45:30.179Z

Critical

Out-of-date Version

Closed

2024-02-02T09:36:41.513Z

https://attackforge.com

Test Project 1

65af64ec07bd34000fbac60d

Issue Closed: Risk accepted

2024-02-02T09:36:41.513Z

Admin Test

65b56ceff8b879000f887c7e

2024-01-27T20:51:59.346Z

Critical

Out-of-date Version

Closed

2024-02-02T05:33:38.928Z

https://portal.attackforge.com, https://app.attackforge.com

Test Project 1

65af64ec07bd34000fbac60d

Issue Closed: Issue has been fixed

2024-02-02T05:33:38.928Z

Admin Test

Troubleshooting

If the export doesn't work, run these checks in order to find the step that fails.

1. Check jq is installed

You should see jq's help text.

2. Check cURL works and can pass JSON to jq

You should see JSON data.

The jq repository has moved to jqlang/jq. This request now returns a redirect message, so step 3 fails. Use https://api.github.com/repos/jqlang/jq/commits?per_page=5 in steps 2 to 4.

3. Check @csv works

You should see the URL of a commit in the jq repository.

4. Check you can write to a CSV file

This should create output.csv in the current folder, containing the commit URL.

5. Save AttackForge data as JSON

This should create vulns.json in the current folder, containing your vulnerabilities. If it contains an error, check your hostname, API key and access to getVulnerabilities.

6. Run jq on vulns.json

You should see CSV data.

7. Export vulns.json to CSV

This should create filtered_vulns.csv in the current folder.

If step 7 works, the full command should work too:

Tips

  • Save the JSON first. Save the API response to a file (troubleshooting step 5), then experiment with jq on the file. You won't call the API every time you change a column.

  • Filter in the API, not in jq. A q_vulnerability filter returns less data, so exports are faster.

  • Always add column names. A header row makes the CSV easier to read and import.

  • Keep your API key out of scripts. Read it from an environment variable instead of typing it into the command.

  • Watch the quoting. Command Prompt, PowerShell and bash treat quotes and $ differently. If jq reports a compile error, check the escaped quotes first.

  • Open the CSV with the right encoding. If special characters look wrong in Excel, import the file as UTF-8.

  • Use AI for one-off exports. For a quick table or spreadsheet, asking an AI assistant through AI MCP can be faster than writing jq.

FAQ

Can I export data other than vulnerabilities? Yes. The same approach works with any Self-Service API method. Change the URL and the fields to match that method's response.

Which fields can I export? Any field the API returns. See the method's documentation in the API documentation.

Why is my CSV empty? Check that you have access to getVulnerabilities, that your API key and hostname are correct, and that your filter matches some vulnerabilities. Then work through the troubleshooting steps.

Why do I get a jq compile error? Usually the quotation marks around column names or strings aren't escaped (\"), or your shell has changed the command. See Choose where to run the commands.

Why does my filter return every vulnerability, or none? On Linux and macOS, $eq inside double quotes is read as a shell variable. Write \$eq instead.

How are grouped assets exported? The Affected Assets column lists each asset's name, separated by a comma.

Can I schedule the export? Yes. Save the command in a script, and run it with your scheduler, such as cron or Windows Task Scheduler.

Last updated