Import third-party security findings

If you already use third-party static analysis or vulnerability scanning tools, you can import findings directly into CodeMender to proceed immediately to verification and patching.

Import security reports

CodeMender parses external security reports and registers findings in its local database.

Import a JSON findings file

To import findings from a JSON file, use the --file (or -f) flag. The JSON file contains an array of findings, such as the following:

[
  {
    "file_path": "src/auth/session_manager.py",
    "start_line": 42,
    "end_line": 47,
    "snippet": "cursor.execute(\"SELECT * FROM users WHERE id = \" + user_id)",
    "title": "SQL Injection",
    "message": "Raw user input concatenated in SQL query",
    "severity": "HIGH",
    "vuln_type": "CWE-89"
  }
]

Each finding has the following fields:

  • file_path (required): the path to the affected file.
  • start_line and end_line: the first and last lines of the vulnerable code. A finding can span several lines. For a single line, you can set line instead of start_line and end_line.
  • snippet: the vulnerable code. If a finding has neither a line range nor a snippet, it covers the whole file, and cm fix searches the file for the vulnerable code.
  • title, message, analysis, and vuln_type: a description of the finding. Each finding needs at least one of these fields.
  • severity: CRITICAL, HIGH, MEDIUM, or LOW. The default is MEDIUM.

You can also import a SARIF 2.1.0 report. For the formats that your CLI release supports, run cm report import --help.

Run the import command:

cm report import --file ./findings.json

Interactive import mode

If you don't have a JSON file, you can run the import command without the --file flag to enter an interactive wizard in your terminal:

cm report import

Follow the prompts to enter the path, line number, severity, and description for each finding. Enter q at any prompt to finish and save.

Process imported findings

After importing external findings:

  1. Run cm report to view the list of registered findings and obtain their generated <finding-id> values.
  2. Execute verification on an imported finding to generate a proof-of-concept exploit:
    cm verify FINDING_ID
  3. Generate and validate a security patch for the finding:
    cm fix FINDING_ID