> [!WARNING]
>
> **Preview**
>
>
> This product or feature is
>
> subject to the "Pre-GA Offerings Terms" in the General Service Terms section
> of the [Service Specific
> Terms](https://docs.cloud.google.com/terms/service-terms#1).
>
> Pre-GA products and features are available "as is" and might have limited support.
>
> For more information, see the
> [launch stage descriptions](https://cloud.google.com/products/#product-launch-stages).

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:

```json
[
  {
    "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 or a CSV file. A CSV file needs a
header row that includes `file_path` and at least one of the other fields, such
as a file that you exported with `cm report --format csv`. For the formats that
your CLI release supports, run `cm report import --help`.

Run the import command:

```bash
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:

```bash
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:

   ```bash
   cm verify FINDING_ID
   ```
3. Generate and validate a security patch for the finding:

   ```bash
   cm fix FINDING_ID
   ```