# keryn sca import

Describes Keryn 0.5.2 and keryn-rules 0.8.0.

> keryn sca import: OSV-Scanner execution, SCA report intake with completion receipts, complete-package inventory, offline advisory assessment, Deno inventory, SBOM-to-files comparison

Source: https://keryn.dev/docs/reference/cli/sca-import/

> **Caution: Next release: keryn sca import**
> On main; not in Keryn 0.5.2, the latest release.

OSV-Scanner execution, SCA report intake with completion receipts, complete-package inventory, offline advisory assessment, Deno inventory, SBOM-to-files comparison.

```text
keryn sca import <report> --out <new-directory> [--parser <id>] [--completion complete|partial|unknown|failed] [--vex <file> --vex-identity <profile>]
```

## Options

```text
Usage: keryn sca fix [directory] --out <new-directory> [--from <result.json> | --advisories <OSV-array.json>]
         [--run-package-manager [--online]] [--github <owner/repo> | --gitlab <group/project>] [--dry-run | --create-pr]
       keryn sca malicious <directory|package.tar.gz> --out <new-directory> [--base <hook-snapshot.json|directory>] [--online]
       keryn sca image <oci-layout|docker-archive.tar> --out <new-directory> [--advisories <OSV-record-array.json> | --online] [--fail-on error|warning|info|none]
       keryn sca db update --from <directory | https URL> [--ecosystems <name,...>] [--check] | keryn sca db status
       keryn sca image <registry/repository[:tag|@sha256:digest]> --pull [--platform <os/arch>] [--pull-redirects] --out <new-directory> [...]
       keryn sca collect <target> --out <new-directory> [--context <deployment.json>|--bindings <bindings.json>] [--snapshot <snapshot.json>] [--online]
       keryn sca scan <directory|lockfile|sbom> --out <new-directory> [--online] [--executable <osv-scanner>] [--repo-root <dir>]
         [--config <.keryn.yml> | --no-config]
       keryn sca import <report> --out <new-directory> [--parser <id>] [--completion complete|partial|unknown|failed]
       keryn sca inventory <osv.json|cyclonedx.json|spdx.json> --out <new-directory> [--bindings <bindings.json>] [--complete]
         [--base <inventory.json> --fail-on-change] [--snapshot <snapshot.json> --as-of <UTC-ISO>]
       keryn sca assess <batch.json> --out <new-directory> [--json]
       keryn sca deno <directory> --out <new-directory> [--root <repository>] [--online]
       keryn sca sbom <release.cdx.json> <file-or-folder>... --out <new-directory> [--cargo-lock <Cargo.lock>]... [--notices <file>]... [--sbom-identity <profile>]
  fix proposes direct npm, pinned requirements, Cargo and Go manifest changes in a copied tree. Nothing executes by default.
  It scans before/after with identical loaded rules and pinned OSV records; an unknown, unsupported requirement or stale lock stays visible.
  --run-package-manager separately opts into fixed script-free manager commands; --online permits their registry access only.
  --github/--gitlab plan a payload; --dry-run needs no token/network. --create-pr explicitly creates a draft (also required in CI),
  using GITHUB_TOKEN/GITLAB_TOKEN only. Origin/base/source must match; the authenticated personal or organization/group owner must
  own the destination. Third-party collaborator/admin/maintainer access is insufficient. No forks or upstream substitutions.
  Artifacts include upgrade.patch, manifest.patch, plan.json, before/after reports, pinned advisories and comparison context.
  sbom compares a release's CycloneDX SBOM with what its files contain: Rust crates from the <crate>-<version>/src/ paths in
  binaries, npm packages from bundler node_modules/<package>/ keys, a Node runtime's release marker (and a Cargo.lock's registry
  packages when given). Lists undeclared components, other versions, and components a notices file does not name. Archives are
  named, not unpacked. Local only. Exit 1 undeclared/mismatch/missing from notices, 3 nothing observed, 0 otherwise.
  deno reads a Deno project's deno.lock files and the imports of Deno code without one (Keryn's matcher, as keryn scan does), plus
  the deno.lock/deno.json(c) between <directory> and --root; raw-report is the inventory; --online asks OSV.dev (names, versions).
  assess runs the checked offline assessment batch (keryn/sca-assessment-batch/1: OSV records + package queries) through keryn-sca:
  per package affected / not affected / unknown and whether every advisory range was decided. Exit 1 affected, 3 coverage incomplete.
  inventory imports all supplied packages including those without advisories, preserves provenance, and records explicit AI roles.
  --complete is a caller assertion about collection of the input report; otherwise inventory returns incomplete (3).
  --fail-on-change gates inventory/binding/snapshot changes, independently of vulnerability severity. Runtime reachability remains unknown.
  --snapshot supplies an advisory database id and optional generatedAt; --as-of enables deterministic age calculation.
  With sca import and --vex, use --vex-identity keryn-package-id/1 to replay original
  package URLs using the installed identity module. Use --vex-identity legacy to
  restore the default matching policy in a separate output directory.

  All sca commands accept repeatable --vex <local-file> and optional --vex-product <root-purl|url>. Attributed producer assertions
  never clear unknown coverage or independent inventory/SBOM identity gates; attribution and unmatched statements are retained.
  scan uses an already installed OSV-Scanner v2. Default offline requires its local advisory database; --online explicitly
  permits advisory requests. Manifest resolution and call-analysis builds are disabled. No scanner is installed automatically.
  OSV-Scanner has no Deno extractor: scan and collect name every deno.lock under the target it did not read (diagnostics and
  limitations); 'keryn sca deno' and 'keryn scan --online' read them.
  A directory target inside a folder its enclosing git repository ignores is still read (ignore filtering disabled, recorded in coverage).
  scan labels each finding with its manifest folder's role; test, research and vendored ones go to "suppressed", counted, not gated.
  Roles are judged on the manifest path relative to the target, or with --repo-root <dir> relative to that repository (keryn ci
  profile stages pass it, so scripts/** is tooling there as in keryn scan). .keryn.yml roles.suppress picks the set-aside roles: from
  --config, else <repo-root>/.keryn.yml, else ./.keryn.yml (--no-config: the defaults).
  Durations and raw stderr go to timing.json, outside run.json's digests.
  import reads a report locally; completion defaults unknown (exit 3), even when no findings were exported.
  --out must be new or empty. Artifacts: raw-report, run.json, and when parseable result.json, results.sarif, summary.md.
  --timeout <seconds> (scan, default 300, max 3600); --fail-on error|warning|info|none (default error); --json prints the receipt.
  Exit 0 pass | 1 findings | 2 usage | 3 incomplete/unknown completion | 4 execution/normalization failure.
```

## Examples

```sh
# Gate OSV-Scanner SARIF you ran elsewhere (scan with --format sarif).
keryn sca import osv.sarif --out out/sca --completion complete
```

## Exit codes

| Code | Meaning |
|---|---|
| 0 | pass |
| 1 | findings or a requested change gate |
| 2 | usage error or invalid input |
| 3 | incomplete or unknown completion |
| 4 | execution or normalization failure |

## Environment

| Variable | Meaning | Default |
|---|---|---|
| `GITHUB_TOKEN` | Token for keryn decide export --github. There is no flag for it. | unset |
| `GITLAB_TOKEN` | Token for keryn decide export --gitlab. There is no flag for it. | unset |
