Files
codex-security/docs/scanner-imports/crowdstrike.md
Carlos Matos 4822a9cbc4 feat(imports): import CrowdStrike FCS IaC findings locally (#2589)
* feat(imports): import CrowdStrike FCS IaC findings locally

Add a crowdstrike file reader for saved FCS CLI 4.x IaC JSON reports
(rule_detections). Each detection becomes one iac or secret finding with
typed rule, configuration and remediation details. Like Tenable, the
reader is local only and binds findings to --source-repository-url,
which must match a fetch remote of the selected checkout.

FCS writes detection paths relative to its working directory, so the
guide asks users to scan from the checkout root. Paths that are absolute
or leave the checkout are excluded. The source finding ID includes the
line, because detections of one rule on one resource can differ only by
line.

* fix(imports): import CrowdStrike reports without a Git checkout

An FCS IaC report describes files relative to the directory where the CLI
ran and names no repository, so requiring a matching Git remote did not
bind the report to anything. Import into any directory instead, and check
that every detection's file exists there. A supplied
--source-repository-url still records the repository, adds typed details
and must match a fetch remote when the directory is a Git checkout.

Detections in registry or Git modules name the calling file with a line
from inside the module. Use the call line that FCS states in
module_remediation, or no line, and include the module path in the
finding ID.

* docs(plugin): describe CrowdStrike FCS imports in the publish-findings skill

Tell Codex when to use --provider crowdstrike, how to run an installed FCS CLI from the import directory, which report to import after a nonzero exit, and to ask for a report instead of installing FCS or passing Falcon credentials.

* fix(imports): read the CrowdStrike module call line in linear time

Search module_remediation for the detection file's exact call phrase instead of a lazy regex. A crafted report could make the regex quadratic: a 2 MB module_remediation took about two minutes to read.

* fix(imports): stop CrowdStrike imports when a scanned file changed

FCS records each scanned file's SHA-256 as file_sha256. Compare it with
the file in the selected directory and stop, naming the file, when they
differ. Before, a report of another commit imported without an error and
could store lines that no longer point at the detected configuration.
The check follows file symlinks, as FCS does, and reads only regular
files.

* docs(imports): add CrowdStrike scan examples and Codex validation steps

Fix the FCS scan command: FCS needs an existing output directory whose
name has no dot. Show a remote git:: scan pinned with ?ref= and a
checkout of the same commit, and note that a //subdir URL gives paths
from that subdirectory. Add a shortened sample report, and show how to
pass imported findings to codex-security validate, for all findings or
for one scan.

* docs(imports): link CrowdStrike imports to the shared imported finding workflow

Other provider pages do not describe validation or patching. Remove the
CrowdStrike validation section and link the readback step to the shared
section on working with imported findings.

* fix(imports): keep CrowdStrike module lines in git:: reports

In a git:: report, FCS writes the detection file, its module_source and
the calling file in module_remediation with a leading slash. The reader
removed the slash from the file before it compared the three, so every
module detection lost its line. Compare them as FCS wrote them. In a
git:: scan of a public Terraform repository, 102 of 396 findings had no
line before this change and none after.

* fix(imports): record and check the repository of CrowdStrike git:: reports

A git:: report names the repository that FCS cloned, but the reader
ignored it. A report of one repository could be saved under another one
whose files were identical. For a git::https:// scan, record that
repository without its //subdirectory and ?ref=, and keep the scan path
in the report and in each finding's source data. When
--source-repository-url is given, it must name the same repository, on
import and on replay. Without it, the scanned repository gives typed
details but does not bind the checkout to a fetch remote, so clones from
self-hosted servers over SSH keep importing. Other git:: URL forms
import as before.

* fix(imports): import CrowdStrike git:: reports of URLs with a user name

When the scanned URL has a user name, FCS writes each detection file,
module source and calling file after the scanned URL instead of after a
slash, and the reader excluded every detection. Remove that prefix. FCS
removes the user name and token from the report's path and keeps them
only in flags.path, which the reader does not read.

* fix(imports): check replayed CrowdStrike locations against the native detection

A replayed preview with cleared or edited locations skipped the file
check, and saved findings without the scanned location. Rebuild the
location from the retained FCS detection, require each finding to show
exactly that location, and check that file and its hash.
2026-11-12 13:09:36 -08:00

6.4 KiB

Import CrowdStrike findings locally

Use a saved JSON report from fcs scan iac in the CrowdStrike Falcon Cloud Security (FCS) CLI 4.x. The reader imports each detection in rule_detections as one misconfiguration or secret finding. It works offline and does not run the FCS CLI. Reports in the older violations format and image scan reports are not supported. CrowdStrike reports support local import only.

Create the report

FCS writes each detection's file relative to the directory where the CLI runs, not relative to --path. Run the scan from the root of the directory you will import into, and write the report outside it. The output directory must exist, and its name must not contain a dot.

cd /path/to/project
reports=$(mktemp -d "${TMPDIR:-/tmp}/fcs-report-XXXXXX")
fcs scan iac --path . --report-formats json --output-path "$reports"
report=$(find "$reports" -name '*-scan-results.json')

FCS exits with a nonzero code when detections match --fail-on, which by default is any detection. The report is saved if the output shows Results saved to file. A scan of a subdirectory, such as --path infra, also gives correct paths when it runs from the root.

The FCS GitHub Action runs the CLI from the workspace root. When path is a directory in a checkout at the workspace root, its JSON report matches a checkout of the same commit. Set report_formats: json and an output_path, upload that directory as a workflow artifact, and download it outside your checkout.

Scan a remote repository

A git:: scan clones the default branch, and the report does not record the commit. FCS has no branch or commit option, but the URL accepts ?ref= with a branch, tag or commit. Pin the scan to a commit and check out the same commit.

repository_url=https://github.com/example/project
checkout=/path/to/project
reports=$(mktemp -d "${TMPDIR:-/tmp}/fcs-report-XXXXXX")
commit=$(git ls-remote "$repository_url.git" HEAD | cut -f1)
fcs scan iac --path "git::$repository_url.git?ref=$commit" \
  --report-formats json --output-path "$reports"
report=$(find "$reports" -name '*-scan-results.json')
git clone --quiet "$repository_url.git" "$checkout"
git -C "$checkout" checkout --quiet --detach "$commit"

To scan another branch, replace HEAD with refs/heads/BRANCH. Paths start at the repository root. If the URL ends with a subdirectory, such as .git//infra?ref=..., paths start at that subdirectory. Use "$checkout/infra" as --repository. If the checkout is at a different commit, the import stops at the first file that changed.

A report of a git::https:// URL names its repository. The import records that URL, without the subdirectory or ?ref=, as the findings' repository. If you also pass --source-repository-url, both must name the same repository, or the import stops. If the scanned URL has a user name and token, FCS keeps them in the report's flags.path. The import does not store that field, but keep the report private.

Preview, save and read back

The project does not need to be a Git checkout.

codex-security publish findings "$report" --provider crowdstrike --to local \
  --repository /path/to/project --source-key example/project/main \
  --dry-run --format json

Every detection's file must exist in --repository with the content that FCS scanned, which the report records as file_sha256. If a file is missing or changed, the import stops and names it, because the reported lines might no longer be correct. Select the directory and commit that FCS scanned, or scan again from its root. Different line endings also count as a change, for example in a Windows checkout of a report from a Linux CI runner.

Add --source-repository-url https://github.com/example/project to record the repository of a local scan. With a repository URL, findings get typed iac or secret details. If you pass the URL and --repository is a Git checkout, the URL must match one of its fetch remotes. Without a URL, each finding has a title, severity, description and location, and evidence.source_data keeps the native FCS rule and detection.

Remove --dry-run and confirm to save. Run codex-security findings imported /path/to/project --format json to read back the findings and their initial not_assessed Codex assessment. To check a finding against the code, see Work with imported findings.

Read the evidence

This shortened report has one detection. The reader keeps its file and line as the finding location.

{
  "fcs_version": "4.3.0",
  "path": ".",
  "scan_uuid": "00000000-0000-4000-8000-000000000001",
  "rule_detections": [
    {
      "rule_name": "Sensitive Port Is Exposed To Entire Network",
      "rule_uuid": "00000000-0000-4000-8000-000000000002",
      "rule_category": "Networking and Firewall",
      "severity": "High",
      "platform": "Terraform",
      "detections": [
        {
          "file": "infra/main.tf",
          "line": 4,
          "resource_type": "aws_security_group",
          "resource_name": "example",
          "reason": "aws_security_group[example] 'SSH' (Port:22) is public",
          "recommendation": "aws_security_group[example] 'SSH' (Port:22) should not be public"
        }
      ]
    }
  ]
}
  • With a repository URL, details.kind is secret for the Secret Management rule category and iac for all others. details.configuration.actual is the FCS reason, and details.configuration.expected is its recommendation. FCS names the attribute that holds a secret, not its value.
  • A detection in a local Terraform module points to the module file. FCS also reports a copy at the module call, and both are imported.
  • A detection in a registry or Git module names the calling file. Its location is the call line from module_remediation, or no line if FCS does not state one.
  • evidence.source_data keeps the FCS version, the native rule without its detection list, and the one detection. For a git:: scan, it also keeps the scanned URL without ?ref=. A saved preview imports only if each finding's location matches its retained detection.

Repeat an import

FCS has no stable detection ID. The reader identifies a detection by rule UUID, file, line, resource type and name, reason and module path. Keep the same source key for one project and branch. When a later scan reports a detection on a different line, it is imported as a new finding, and the earlier finding stays stored.