tc-scanner
v0.12.3
Published
CI security scanner and controls runner. Scan Dockerfiles, images, dependencies, and secrets. Run all security controls with one command.
Maintainers
Readme
tc-scanner
A CI security scanner for Dockerfiles, container images, dependencies, and secrets. Powered by Trivy.
Requirements
Docker is required. The scanner runs Trivy inside a container, so no additional installation is needed. All major CI platforms (Bitbucket Pipelines, GitHub Actions, GitLab CI) have Docker available by default.
Installation
No installation required. Use directly with npx:
npx tc-scanner scan ./DockerfileOr install globally:
npm install -g tc-scanner
tc-scan scan ./DockerfileQuick Start
# Scan a Dockerfile for misconfigurations
npx tc-scanner scan ./Dockerfile
# Scan project dependencies for known vulnerabilities
npx tc-scanner deps .
# Scan code for hardcoded secrets
npx tc-scanner secrets ./src
# Scan a container image
npx tc-scanner image nginx:latestCommands
scan - Dockerfile Security
Scans Dockerfiles for security misconfigurations.
npx tc-scanner scan ./Dockerfile
npx tc-scanner scan ./Dockerfile --severity HIGH
npx tc-scanner scan ./Dockerfile --output ./reports/dockerfile-scanWhat it detects:
- Running as root user
- Missing HEALTHCHECK instruction
- Using
latesttag instead of pinned versions - Insecure
ADDinstead ofCOPY - Exposed sensitive ports
- Missing USER instruction
deps - Dependency Vulnerabilities
Scans package lockfiles for known CVEs (similar to Snyk/npm audit).
npx tc-scanner deps .
npx tc-scanner deps ./backend --severity CRITICAL
npx tc-scanner deps . --include-devSupported lockfiles:
package-lock.json(npm)yarn.lock(Yarn)pnpm-lock.yaml(pnpm)Gemfile.lock(Ruby)requirements.txt/Pipfile.lock(Python)go.sum(Go)composer.lock(PHP)pom.xml(Maven / Java, Kotlin)
secrets - Secret Detection
Scans code for hardcoded secrets and sensitive data.
npx tc-scanner secrets .
npx tc-scanner secrets ./src --output ./reports/secretsWhat it detects:
- AWS access keys and secrets
- API tokens (Stripe, GitHub, Slack, etc.)
- Private keys (RSA, SSH, PGP)
- Database connection strings
- Hardcoded passwords
- JWT secrets
image - Container Image Scanning
Scans container images for OS and application vulnerabilities.
npx tc-scanner image nginx:latest
npx tc-scanner image myapp:v1.2.3 --severity HIGH,CRITICALWhat it detects:
- OS package vulnerabilities (Alpine, Debian, Ubuntu, RHEL, etc.)
- Application dependencies inside the image
- Embedded secrets and misconfigurations
sbom - SBOM before deploy
Makes a CycloneDX SBOM of what the pipeline deploys and asks coda-secure for a verdict. Run it directly before the deploy command.
npx [email protected] sbom . --environment production
npx [email protected] sbom . --environment production --image europe-docker.pkg.dev/acme/api:1.4.0- With
--image, Trivy reads the image. Without it, Trivy reads the lockfiles under the path. - The file stays in
tc-sbom.cdx.jsonfor the pipeline artifacts. - The scanner posts package URLs, names and versions only. It posts no source code, no file paths and no environment values.
- Exit
1: coda-secure blocks the deploy. A package is malicious (an OSVMAL-id), or it has a vulnerability on the CISA KEV list. - Exit
0with a warning: coda-secure gives no verdict. Add--fail-closedto exit1instead. - Exit
0with a warning: no SBOM can be made, for example when Trivy fails or neither Trivy nor Docker is on the path, or Trivy lists no packages although the path has lockfiles (Trivy skips files it cannot read without an error). The scanner records aSEC_SBOMERROR run for the environment and sends no package list, so the stored list stays. Add--fail-closedto exit1instead. - Exit
2:--environmentis missing or invalid, or--commitnames no commit in the repository.
SBOM of one commit: --commit <sha, tag or branch> makes the SBOM from the lockfiles of that
commit instead of the checkout. The scanner checks the commit out in a temporary git worktree,
fetches it from origin when a shallow clone does not have it, and removes the worktree after.
The payload carries the full SHA. Use it to make the SBOM of a commit that already runs in an
environment, for example when the pipeline had no SBOM step yet. The SBOM replaces the stored
package list of that environment when coda-secure allows it. Add --dry-run to only write the
file.
npx [email protected] sbom . --environment production --commit 3f2a9c1Policy in tc-scan.config.json:
{
"controls": {
"SEC_SBOM": {
"block_on": ["malicious", "kev", "critical_with_fix"],
"allow": [
{
"purl": "pkg:npm/lodash",
"vuln_id": "GHSA-35jh-r3h4-6jhm",
"reason": "The affected function is not used",
"expires": "2026-12-15"
}
],
"private_namespaces": ["@acme"]
}
}
}block_ondefaults to["malicious", "kev"].- An
allowentry needs a reason and expires at most 30 days ahead. An expired entry has no effect. - Packages in
private_namespacesare stored but never sent to OSV.
Options
| Option | Alias | Description | Default |
| --------------- | ----- | ----------------------------------------------------------- | ------- |
| --severity | -s | Minimum severity level: LOW, MEDIUM, HIGH, CRITICAL | HIGH |
| --output | -o | Save reports to file (creates .json, .txt, .html) | - |
| --webhook | -w | Send results to a webhook URL | - |
| --exit-code | - | Exit code when issues are found | 1 |
| --include-dev | - | Include dev dependencies (deps command only) | false |
Reports
Generate reports in multiple formats:
npx tc-scanner scan ./Dockerfile --output ./reports/scan-reportThis creates:
scan-report.json- Structured data for APIs and integrationsscan-report.txt- Plain text for email notificationsscan-report.html- Styled HTML report for attachments
Webhooks
Send scan results to any webhook endpoint:
# Generic webhook
npx tc-scanner scan ./Dockerfile --webhook https://your-api.com/security-alerts
# Slack incoming webhook
npx tc-scanner scan ./Dockerfile --webhook https://hooks.slack.com/services/xxx/yyy/zzzWebhook payload:
{
"scanner": "tc-scanner",
"scanType": "dockerfile",
"timestamp": "2024-01-15T10:30:00.000Z",
"target": "./Dockerfile",
"summary": {
"total": 3,
"critical": 0,
"high": 1,
"medium": 2,
"low": 0
},
"issues": [
{
"id": "DS-0002",
"severity": "HIGH",
"title": "Last USER command should not be 'root'",
"description": "Running containers with 'root' user can lead to container escape.",
"url": "https://avd.aquasec.com/misconfig/ds-0002"
}
]
}CI/CD Integration
Bitbucket Pipelines
image: node:24
definitions:
services:
docker:
memory: 2048
pipelines:
default:
- step:
name: Security Scan
services:
- docker
script:
- npx tc-scanner scan ./Dockerfile --severity HIGH
- npx tc-scanner deps . --severity HIGH
# Send results to Slack or custom webhook
- npx tc-scanner scan ./Dockerfile --webhook $SECURITY_WEBHOOK_URL --exit-code 0
pull-requests:
"**":
- step:
name: PR Security Check
services:
- docker
script:
- npx tc-scanner scan ./Dockerfile --severity CRITICAL
- npx tc-scanner secrets ./srcNote: Add
SECURITY_WEBHOOK_URLas a repository variable in Bitbucket settings for webhook notifications.
Bitbucket Pipelines — Java / Maven (Kotlin)
image: eclipse-temurin:17
definitions:
services:
docker:
memory: 2048
pipelines:
default:
- step:
name: TC-Secure Controls (Maven)
services:
- docker
caches:
- maven
script:
# Auto-detects maven stack from pom.xml and runs all 5 controls
- npx tc-scanner controls .
--base-url $TC_ADMIN_BASE_URL
--api-key $SERVICE_API_KEY
--client-name $CLIENT_NAME
pull-requests:
"**":
- step:
name: PR Security Check (Maven)
services:
- docker
caches:
- maven
script:
- npx tc-scanner controls . --controls 1,2,3 --dry-runJaCoCo coverage: to get real line-coverage numbers in control 7, add the JaCoCo Maven plugin to your
pom.xmland run./mvnw verifyinstead of./mvnw testso thattarget/site/jacoco/jacoco.xmlis generated before the scanner reads it.
GitHub Actions
name: Security Scan
on: [push, pull_request]
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Scan Dockerfile
run: npx tc-scanner scan ./Dockerfile --severity HIGH
- name: Scan Dependencies
run: npx tc-scanner deps . --severity HIGH
- name: Scan for Secrets
run: npx tc-scanner secrets ./srcGitLab CI
security-scan:
image: node:24
services:
- docker:dind
variables:
DOCKER_HOST: tcp://docker:2375
script:
- npx tc-scanner scan ./Dockerfile --severity HIGH
- npx tc-scanner deps . --severity HIGH
- npx tc-scanner secrets ./src
artifacts:
paths:
- reports/
when: alwaysControls Platform Integration (tc-admin)
For normalized control ingestion into tc-admin, use:
- emitter script:
./scripts/emit-check-run.mjs - pipeline template:
./examples/bitbucket-pipelines.controls.example.yml
Required CI variables:
TC_ADMIN_BASE_URL(example:https://tc-admin.internal)SERVICE_API_KEY(the team's ingest key,tcs_…; it posts only for repositories of its own team)CLIENT_NAME(team label; ignored with a team key, which always posts to its own team)
Quality-gate readiness check:
# Human-readable readiness output
npx tc-scanner quality-gate . --ci-provider bitbucket
# JSON output for automation
npx tc-scanner quality-gate . --ci-provider bitbucket --json
# Fail CI when gate is not enabled
npx tc-scanner quality-gate . --ci-provider bitbucket --strictThe check inspects:
- Presence of
bitbucket-pipelines.yml - Control pipeline signals (e.g.
tc-scan controls, emit script, scan/test commands) - Required ingestion env vars (
TC_ADMIN_BASE_URL,SERVICE_API_KEY,CLIENT_NAME)
The template posts these control codes:
SEC_DEP_PATCHSEC_CONTAINER_VULNSEC_SECRETSCODE_STATICQA_TESTS
Pull request feedback
tc-scan controls writes the result of the run back to the pull request, so
nobody has to open a build log to learn what failed.
GitHub Actions. On a pull_request event with GITHUB_TOKEN in the
environment, the scanner keeps ONE comment on the pull request (marker
<!-- coda-secure -->) and rewrites it on every re-run. The workflow needs
write permission on pull requests:
on: [pull_request]
permissions:
contents: read
pull-requests: write
jobs:
controls:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npx tc-scanner controls .
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TC_ADMIN_BASE_URL: ${{ vars.TC_ADMIN_BASE_URL }}
SERVICE_API_KEY: ${{ secrets.SERVICE_API_KEY }}
CLIENT_NAME: ${{ vars.CLIENT_NAME }}Bitbucket Pipelines. The scanner writes a Code Insights report plus inline
annotations on the commit, using the Pipelines auth proxy on
localhost:29418 — no token needed inside a build.
The sticky pull request comment needs two more things:
- a
pull-requests:pipeline, because Bitbucket setsBITBUCKET_PR_IDonly there — adefault:pipeline never sees a PR id; BITBUCKET_ACCESS_TOKENas a secured repository variable, holding a repository access token withpullrequest:write. The Pipelines proxy signs Code Insights calls only and answers 5xx for a comment, so the scanner falls back to this token; without it the report still lands and the comment is skipped.
Pass --no-feedback to run the controls without writing any comment or report.
--dry-run prints the comment it would have posted and posts nothing.
--sarif <file> also writes every finding of the run as SARIF 2.1.0, for GitHub
code scanning. Each result has a rule id per control and rule, a severity level,
the file and line (a dependency finding points at the lockfile), and a stable
partialFingerprints.codaSecure/v1:
- run: npx --yes [email protected] controls . --ci-provider github --sarif tc-scanner.sarif
- if: always() && hashFiles('tc-scanner.sarif') != ''
continue-on-error: true
uses: github/codeql-action/upload-sarif@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0
with:
sarif_file: tc-scanner.sarifThe comment reports:
- a one-line verdict (controls failed, new findings, findings resolved)
- a table of control / status / open findings
- new findings grouped worst-first, with
file:line, capped at ten rows; each title links to the finding's page in coda-secure - a link to the repository page in coda-secure
AI security review in CI
CI does not start AI security reviews. A user starts each one in coda-secure,
with coda reviews start <workspace/repo> or over MCP.
tc-scanner review is still there for pipelines that have the step. The
coda-secure API answers 403 (ai_scans_on_request) and no review starts. With
the default --fail-on none the step passes. Remove the step from the pipeline.
Speed in CI
Each Trivy scan runs once, in a container that shares one cache directory. On
Bitbucket it is .tc-scan-trivy-cache in the clone directory (Bitbucket's
Docker service only mounts paths inside it); elsewhere it is
tc-scan-trivy-cache in the system temp directory. TC_SCAN_TRIVY_CACHE
overrides both. Scans of the repository skip it. Keep it between pipeline runs
and Trivy stops downloading its vulnerability database and checks bundle on
every scan:
definitions:
caches:
trivy: .tc-scan-trivy-cache
pipelines:
pull-requests:
"**":
- step:
caches:
- trivy
services:
- docker
script:
- npx --yes [email protected] controls .Supported stacks (auto-detected from project files):
| Stack | Detected by | Control 1 | Control 4 | Control 7 with --run-tests |
| -------- | ------------------------------------ | -------------------------------------------------- | --------------------------- | ------------------------------------- |
| php | composer.json | composer audit --locked | composer run lint/phpstan | composer run test |
| node | package.json, lockfiles | npm/pnpm/yarn audit (yarn npm audit on Yarn 2+) | lint/typecheck scripts | test script + coverage-summary.json |
| python | requirements.txt, pyproject.toml | Trivy filesystem CVE scan | ruff/pyright/mypy | pytest |
| maven | pom.xml | Trivy filesystem CVE scan | ./mvnw test-compile | ./mvnw test + Surefire + JaCoCo |
Python and Maven dependencies are scanned with Trivy (native trivy, else Trivy in
Docker), which rates each vulnerability. For Python it reads requirements.txt with
pinned (==) versions, Pipfile.lock, poetry.lock and uv.lock; a project with none
of those is posted as "Not run".
When a directory has files of several stacks, the first row that matches is the
primary stack: a PHP app with a package.json for its frontend build is php.
Control 1 also audits every other ecosystem that has a lockfile next to it
(composer.lock, a JS lockfile, requirements.txt/Pipfile.lock/poetry.lock,
pom.xml) and reports the sum; if one of those audits fails, the control reports
a scan incomplete. Controls 4 and 7 use the primary stack.
A control that the scanner selects but cannot run (no test report, no Dockerfile, no lint script) is posted as "Not run" with its reason. It never counts as a pass or a fail, and it never changes findings.
Control 7 (QA_TESTS) reads test results; by default it runs no tests. It
looks for a test report that an earlier step wrote, and reads these formats:
| Format | Written by | Default paths |
| --- | --- | --- |
| JUnit XML | jest-junit, vitest --reporter=junit, pytest --junitxml, Maven Surefire | test-results/**/*.xml, junit.xml, reports/junit.xml, reports/**/junit*.xml; Maven: target/surefire-reports/TEST-*.xml |
| Jest or Vitest JSON | jest --json, vitest --reporter=json | test-report.json in the repository root, reports/, coverage/ or .tc-scan/ |
| pytest JSON | pytest-json-report | test-report.json, .pytest-report.json |
Several JUnit files under one path (for example the files of sharded runs) are added up.
The pass rate is passed tests divided by the tests that ran: a skipped test does not lower
it, and the skipped count is kept in the evidence. A test suite that could not run counts as
an error. Coverage comes from Istanbul coverage/coverage-summary.json, coverage.py
coverage.json, Cobertura coverage.xml or coverage/cobertura-coverage.xml, LCOV coverage/lcov.info
(node --test --experimental-test-coverage --test-reporter=lcov), or JaCoCo
target/site/jacoco/jacoco.xml. The scanner also records the test framework it detects
(jest, vitest, pytest, maven).
With no report, control 7 is posted as "Not run", with the paths it searched. A report in
which no test ran is also posted as "Not run". --run-tests (or
controls.tests.launcher_mode: "auto" in tc-scan.config.json (or .tc-scan.json)) runs
the commands in the last column when no report exists.
Settings in controls.tests of tc-scan.config.json:
| Setting | Meaning |
| --- | --- |
| report_paths.test | Report paths or globs, read before the default paths |
| report_paths.coverage | Coverage report paths or globs, read before the default paths |
| report_format | junit, jest-json or pytest-json: read the reports in this format only |
| framework | jest, vitest, pytest or maven: replaces the detected framework in the evidence |
Sharded tests. When tests run in several parallel steps, each step runs
tc-scanner controls --controls 7 --shard <index>/<total> after its tests. coda-secure
keeps each shard, shows the control as incomplete ("1 of 2 test shards reported") until
every shard of the build has posted, and then evaluates the sum.
Force a specific stack with --stack maven if auto-detection is ambiguous.
Maven / Java / Kotlin notes:
- Control 1 uses Trivy's filesystem scanner to match
pom.xmldependencies against the CVE database — no Maven execution needed. If nativetrivyis unavailable, the scanner automatically falls back to Docker-based Trivy. - Control 3 (Secrets) runs a repository scan first; for Maven projects with a
pom.xml, it also performs a focusedpom.xmlsecret scan when the repository-level result is empty. - Control 4 runs
./mvnw test-compile -B -q(falls back to systemmvnif no wrapper is present). Compile errors are reported aslint_errors. - You can override Control 4 for Maven in
tc-scan.config.json(or.tc-scan.json) withcontrols.static.lint_command(and optionalcontrols.static.cwd) to run project-specific quality goals. - With
--run-tests, control 7 runs./mvnw test -Band parsestarget/surefire-reports/TEST-*.xmlfor accurate pass/fail counts. Line coverage is read fromtarget/site/jacoco/jacoco.xmlwhen present (requires the JaCoCo Maven plugin); otherwisecoverage_pctfalls back topass_rate_pct. - The Maven wrapper (
mvnw) is preferred over a system-installedmvnwhen present in the project root.
Exit Codes
| Code | Meaning |
| ---- | --------------------------------------------- |
| 0 | No issues found (or below severity threshold) |
| 1 | Issues found at or above severity threshold |
| 2 | sbom only: --environment missing or invalid |
Use --exit-code 0 to always pass (useful for non-blocking scans):
npx tc-scanner scan ./Dockerfile --exit-code 0Severity Levels
| Level | Description |
| ---------- | --------------------------------------------------- |
| CRITICAL | Severe vulnerabilities requiring immediate action |
| HIGH | Important security issues that should be fixed soon |
| MEDIUM | Moderate issues to address in regular maintenance |
| LOW | Minor issues or best practice recommendations |
Examples
Fail CI only on critical issues:
npx tc-scanner scan ./Dockerfile --severity CRITICALFull security audit with reports:
npx tc-scanner scan ./Dockerfile --output ./reports/dockerfile --severity LOW
npx tc-scanner deps . --output ./reports/deps --severity LOW --include-dev
npx tc-scanner secrets ./src --output ./reports/secretsSend alerts to Slack on failures:
npx tc-scanner scan ./Dockerfile --webhook $SLACK_WEBHOOK_URLTroubleshooting
"Docker is required"
- Ensure Docker is installed and running
- In CI, enable the Docker service (see examples above)
"No lockfile found" (deps command)
- The scanner needs
package-lock.json,yarn.lock,pom.xml, or similar - Run
npm install(Node) or ensurepom.xmlis present (Maven) to enable scanning
Control 7 is "Not run"
- The scanner found no test report. The "Not run" reason lists the paths it searched. Write a JUnit XML or JSON report in an earlier step and pass it to the scanner step as an artifact, set
controls.tests.report_paths.test, or run with--run-tests.
Maven build fails during control 4 or 7
- Ensure JDK 17+ is available in the CI image (e.g.
eclipse-temurin:17) - The scanner prefers
./mvnwover a systemmvn; commit the Maven wrapper to your repo - For coverage data, add the JaCoCo plugin and run
./mvnw verifyto producetarget/site/jacoco/jacoco.xml
Slow first run
- First run downloads the Trivy Docker image (~50MB) and vulnerability database (~80MB)
- Subsequent runs are faster due to caching
