Cortex CLI Cortex Cloud Application Security command line reference
Use these command-line flags to configure Cortex Cloud Application Security scans. They are scoped to the `code scan` command and define what to scan and how results are reported. Their environment variables use the `CORTEX_CODE_` prefix. The Application Security CLI also accepts flags that apply across modules, including authentication, TLS, proxy, logging, upload behavior, and exit-code policy.
`--upload-mode` and `--no-fail-on-crash` are the only flags supported in both global and command positions. They use the global variables `$CORTEX_UPLOAD_MODE` and `$CORTEX_NO_FAIL_ON_CRASH`, not `CORTEX_CODE_` variables. Command-position support is retained for backward compatibility.
For global and common CLI commands, refer to [Cortex CLI common command line reference guide](../cortex-cli-common-command-line-reference-guide).
### Important
The Cortex CLI Cortex Cloud Application Security only supports single occurrences of each flag. If the same flag is passed multiple times, only the last provided value will be used. For example, in the following command, only TF CloudFormation will be the scanned framework.
EXAMPLE
`cortexcli --api-base-url <YOUR_API_URL> --api-key <YOUR_API_KEY> --api-key-id <YOUR_API_KEY_ID> code scan --framework terraform --framework "terraform cloudformation`
| Command/Variable | Description |
| ---------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>--source</code></p><p><code>$CORTEX_CODE_SOURCE</code></p> | <p>(Optional, default <code>CORTEX_CLI</code>)</p><p>The execution environment that launched the scan.</p><p>Use one of the following values: <code>CORTEX_CLI</code>, <code>IDE_VSCODE</code>, <code>JENKINS</code>, <code>GITHUB_ACTIONS</code>, <code>CIRCLE_CI</code>, <code>AWS_CODE_BUILD</code>, <code>GIT_HOOK</code>, <code>GIT_HOOK_COMMITS</code>.</p><p>EXAMPLE: In a GitHub Actions pipeline, pass <code>--source GITHUB_ACTIONS</code></p> |
| <p><code>--repo-id</code></p><p><code>$CORTEX_CODE_REPO_ID</code></p> | <p>The unique identifier used to associate scan results with the correct repository in Cortex.</p><ul><li><strong>Value:</strong> <code>owner/repo</code> (for example, <code>my-org/my-repo</code>). Value must contain a forward slash <code>/</code></li><li><strong>Requirement:</strong> Required for upload mode; otherwise, optional</li><li><strong>Auto-detection</strong>: If omitted, the CLI automatically extracts this value from your Git remote URL using the last two segments of the path</li><li><strong>Do not</strong> use the tenant Asset ID hash, as it will fail validation.<br>For more information on how to retrieve the repository ID, refer to <a data-mention href="#how-to-retrieve-the-repository-id">#how-to-retrieve-the-repository-id</a></li></ul> |
| <p><code>--repo-url</code><br><code>$CORTEX_CODE_REPO_URL</code></p> | Optional: URL of the repository being scanned (for example, `https://github.com/org/repo`). If omitted, the CLI attempts to auto-detect the URL from the local Git remote of the scanned directory |
| <p><code>--branch</code></p><p><code>$CORTEX_CODE_BRANCH</code></p> | <p>The branch name associated with the scan.</p><p>Default: The branch detected from your local Git checkout in <code>upload</code> mode when upload permissions are valid</p> |
| <p><code>--directory</code></p><p><code>$CORTEX_CODE_DIRECTORY</code></p> | <p>Required.</p><p>The directory path to scan. Cannot be used together with <code>--file</code></p> |
| <p><code>--file</code></p><p><code>$CORTEX_CODE_FILE</code></p> | The file path to scan. Cannot be used together with `--directory`. When using this option, the Cortex CLI will filter runners based on the file type provided. For example, if you specify a `.tf` file, only the Terraform and secrets frameworks will be included. You can further limit this (for example; skip secrets) by using the `--skip-framework` argument |
| <p><code>--var-file</code></p><p><code>$CORTEX_CODE_VAR_FILE</code></p> | Variable files to load in addition to the default files. This feature is currently supported for both source Terraform (.tfvars files) and Helm chart scans (for providing custom values or variable overrides). Refer to [https://www.terraform.io/docs/language/values/variables.html#variable-definitions-tfvars-files](https://www.terraform.io/docs/language/values/variables.html#variable-definitions-tfvars-files)) below for more information |
| <p><code>--framework</code></p><p><code>$CORTEX_CODE_FRAMEWORK</code></p> | <p>Filter to scan specific frameworks. Example: <code>--framework arm</code>.</p><p>Syntax: Use a single flag with comma-separated values for multiple frameworks. Both quoted (<code>"arm,ansible"</code>) and unquoted (<code>arm,ansible</code>) formats are supported. Example: <code>--framework arm,ansible</code>.</p><p>Constraint: <strong>Do not</strong> use multiple --framework flags: <code>--framework terraform --framework sca_package</code>.</p><p>Environment variables: <code>export CORTEX_CODE_FRAMEWORK=arm,ansible</code>.</p><p>Supported frameworks: <code>ARM</code>, <code>ANSIBLE</code>, <code>BICEP</code>, <code>CLOUDFORMATION</code>, <code>DOCKER</code>, <code>DOCKERFILE</code>, <code>HELM</code>, <code>KUBERNETES</code>, <code>KUSTOMIZE</code>, <code>OPENAPI</code>, <code>SCA</code>, <code>SECRETS</code>, <code>SERVERLESS</code>, <code>TERRAFORM</code>, <code>TERRAFORMJSON</code>, <code>TERRAFORMPLAN</code></p> |
| <p><code>--skip-framework</code></p><p><code>$CORTEX_CODE_SKIP_FRAMEWORK</code></p> | <p>Skip specific frameworks. Example: <code>--skip-framework terraform</code>.</p><p>Syntax: Use a single flag with comma-separated values for multiple frameworks. Both quoted (<code>"arm,ansible"</code>) and unquoted (<code>arm,ansible</code>) formats are supported. Example: <code>--skip-framework terraform, sca_package</code>.</p><p>Constraint: <strong>Do not</strong> use multiple skip --framework flags: <code>--skip-framework terraform --skip-framework sca_package</code>.</p><p>Environment variables: <code>export CORTEX_CODE_SKIP_FRAMEWORK="tf,sca"</code></p> |
| <p><code>--rule</code></p><p><code>$CORTEX_CODE_RULE</code></p> | Restrict the scan to specific check IDs; all other checks are skipped. Enter one or more comma-separated check IDs, for example `--rule APPSEC_AWS_79,APPSEC_SECRET_80` |
| <p><code>--severity</code><br><code>$CORTEX_CODE_SEVERITY</code></p> | <p>Filters scan results by severity level. Accepts one or more comma-separated values: unknown, low, medium, high, critical. Repeat the flag or use comma separation to specify multiple levels (for example, <code>--severity high,critical</code>).</p><p><strong>Constraint</strong>: Only effective when <code>--upload-mode</code> is set to <code>no-upload</code>. When upload mode is active, the flag is ignored and an informational message is displayed</p> |
| <p><code>--ignore-existing-secrets</code></p><p><code>$CORTEX_CODE_IGNORE_EXISTING_SECRETS</code></p> | In CI/CD scans, report only newly introduced secrets. This flag filters out secret findings whose fingerprints already exist in the Cortex Cloud findings backlog, which a periodic baseline scan populates. This flag is ignored during pull request scans |
| <p><code>--blocked-only</code></p><p><code>$CORTEX_CODE_BLOCKED_ONLY</code></p> | Boolean flag. When set, shows only blocked findings in the output. Available only in `upload` mode |
| <p><code>--summary-position</code></p><p><code>$CORTEX_CODE_SUMMARY_POSITION</code></p> | Sets the position for displaying the summary information relative to the findings. Values: `top`, `bottom` |
| <p><code>--upload-mode</code></p><p><code>$CORTEX_UPLOAD_MODE</code></p> | Upload mode determines the method or mode used to upload data. See common flags for more information |
| <p><code>--download-external-modules</code><br><em><code>$</code></em><code>CORTEX_CODE_DOWNLOAD_EXTERNAL_MODULES</code></p> | <p>(Optional, default <code>False</code>)<br>Download external Terraform modules from public Git repositories and the Terraform Registry so they are included in the IaC scan. . Use <code>--external-modules-download-path</code> to control the download location (defaults to <code>.external_modules</code>). Requires outbound network access</p> |
| <p><code>--external-modules-download-path</code></p><p><code>$CORTEX_CODE_EXTERNAL_MODULES_DOWNLOAD_PATH</code></p> | Specifies the directory to download external modules to. Defaults to `.external_modules` |
| <p><code>--external-checks-dir</code></p><p><code>$CORTEX_CODE_EXTERNAL_CHECKS_DIR</code></p> | Local directory containing [custom Cortex Python (`.py`) checks](cortex-cli-application-security-command-line-reference/custom-cortex-checks-and-signature-verification). The directory must be a Python package. This flag is repeatable and cannot be used with `--external-checks-git`. |
| <p><code>--external-checks-git</code></p><p><code>$CORTEX_CODE_EXTERNAL_CHECKS_GIT</code></p> | Git URL containing [custom Cortex Python (`.py`) checks](cortex-cli-application-security-command-line-reference/custom-cortex-checks-and-signature-verification). Supports `//subdir` and `?ref=...`. This flag cannot be used with `--external-checks-dir`. |
| <p><code>--external-checks-public-key</code></p><p><code>$CORTEX_CODE_EXTERNAL_CHECKS_PUBLIC_KEY</code></p> | <p>Path to a PEM-encoded ECDSA P-256 public key used to verify signatures for <a href="cortex-cli-application-security-command-line-reference/custom-cortex-checks-and-signature-verification">custom Cortex Python (<code>.py</code>) checks</a>.</p><p>When set, any tampered or unsigned file <strong>aborts the scan with exit code 2</strong> before any check runs. When unset, verification is disabled for backward compatibility.</p><p>See <a href="custom-cortex-checks-and-signature-verification#workflow-sign-and-verify-custom-checks">Workflow: Sign and verify custom checks</a>.</p> |
| <p><code>--output</code></p><p><code>$CORTEX_CODE_OUTPUT</code></p> | <p>Output format for reporting.</p><p>Supported formats: <code>cli</code>, <code>json</code>, <code>spdx</code>, <code>junitxml</code>, <code>sarif</code>, <code>cyclonedx</code>, <code>cyclonedx_json</code></p> |
| <p><code>--output-file-path</code></p><p><code>$CORTEX_CODE_OUTPUT_FILE_PATH</code></p> | Specifies the output path for the scan result file |
| <p><code>--deep-analysis</code></p><p><code>$CORTEX_CODE_DEEP_ANALYSIS</code></p> | Enables or disables deep analysis of the Terraform plan and related files |
| <p><code>--repo-root-for-plan-enrichment</code></p><p><code>$CORTEX_CODE_REPO_ROOT_FOR_PLAN_ENRICHMENT</code></p> | Enriches Terraform plan findings by mapping them to their original `.tf` files |
| <p><code>--skip-path</code></p><p><code>$CORTEX_CODE_SKIP_PATH</code></p> | Specifies a path (file or directory) that should be skipped during the scanning process. This option is useful for excluding specific files or directories that are not relevant to the scanning analysis, increasing the efficiency and accuracy of scan results |
| <p><code>--compact</code></p><p><code>$CORTEX_CODE_COMPACT</code></p> | Do not display code blocks in the output |
| <p><code>--no-fail-on-crash</code></p><p><code>$CORTEX_NO_FAIL_ON_CRASH</code></p> | See common flags for a description |
| <p><code>--validate-secrets</code></p><p><code>CORTEX_APPSEC_VALIDATE_SECRETS</code></p> | Validate detected secrets against their respective services to confirm they are active. By default, this feature is disabled. Set `CORTEX_APPSEC_VALIDATE_SECRETS = true` to enable it |
| <p><code>--timeout</code><br><code>$CORTEX_CODE_TIMEOUT</code></p> | <p>Sets the maximum time the Cortex CLI will wait for triggered local scan processes to complete. Default value: 15 minutes.</p><p>Syntax:</p><ul><li><strong>To specify a duration</strong>: Use a numeric value followed by a unit (for example <code>--timeout 10m</code>)</li><li><strong>Default unit</strong>: Numeric values entered without a unit are interpreted as seconds. For example, <code>30</code> is equal to 30 seconds.</li><li><strong>Supported units</strong>: Milliseconds, seconds, minutes and hours</li></ul> |
| `--start-commit` | Starting commit hash for git history scanning (Git Hook flag). No environment-variable equivalent is available. |
| `--commit-list` | Comma-separated list of commit hashes to scan (Git Hook flag). No environment-variable equivalent is available. |
| `--hook-event` | Git hook event type, such as `pre-commit` (Git Hook flag). No environment-variable equivalent is available. |
| `--help` | See common flags for a description |
## How to retrieve the repository ID
### Option 1: From the local repository checkout (Recommended)
`git config --get remote.origin.url`
Remove any trailing `.git` and take the final two path segments. For example, [https://github.com/my-org/my-repo.git](https://github.com/my-org/my-repo.git) yields `my-org/my-repo`. This matches the exact logic the CLI uses to auto-derive the value.
### Option 2: From the Cortex Cloud console
1. Navigate to **Inventory → All Assets → Repositories**.
2. Select the repository row to open the side card.
3. Copy the title displayed at the top of the side card (in `owner/repo` format).
> Note: Two console fields are commonly mistaken for this value and neither is valid:
>
> * Asset ID (in the side card _Properties_ section) is an internal platform hash, not a repository path. Passing it will fail validation
> * Repository Name (in the table column) is only the repository name without the owner
### Option 3: From the Public API
`GET /public_api/appsec/v1/repositories`
In the response, locate your repository and join the `owner` and `name` fields with a forward slash (`owner/name`).
#### **EXAMPLES**
#### Explicitly defining the repository path and branch
Use this pattern for local scans or custom builds. It sets the repository and branch manually.
```bash
cortexcli code scan \
--directory . \
--branch main \
--repo-id my-org/my-repo \
--upload-mode upload
```
Providing `--repo-id` and `--branch` explicitly associates results with the correct platform asset. This works regardless of local Git status or API key permission levels.
#### Auto-deriving values from the local Git checkout
Use this minimal syntax from a developer workstation inside an active Git working tree.
```bash
# Auto-derive the repository path and branch from the local Git remote
cortexcli code scan \
--directory . \
--upload-mode upload
```
When omitted, the CLI derives `--repo-id` from the origin remote URL. It derives `--branch` from the local `HEAD` checkout. Auto-derivation requires an API key with write or upload permissions. With a read-only API key, pass both values explicitly.
#### Running in GitHub Actions workflows
Use native GitHub Actions context variables to set the repository and branch dynamically.
```bash
# In GitHub Actions workflows
cortexcli code scan \
--directory . \
--branch ${{ github.ref_name }} \
--repo-id ${{ github.repository }} \
--upload-mode upload
```
Always pass `--repo-id` and `--branch` explicitly in CI. GitHub Actions checkouts often use a detached `HEAD`. Auto-derivation can resolve the branch as `HEAD`, rather than the target branch.
#### Running in GitLab CI pipelines
Use predefined GitLab CI variables to populate the repository path and branch.
```bash
# In GitLab CI pipelines
cortexcli code scan \
--directory . \
--branch $CI_COMMIT_BRANCH \
--repo-id $CI_PROJECT_PATH \
--upload-mode upload
```
GitLab CI supports multi-segment subgroup paths, such as `my-group/my-subgroup/my-repo`. `$CI_PROJECT_PATH` provides the complete forward-slash-delimited path required by `--repo-id`.