dockerfile-sentinel

Sentinel · security scanner

dockerfile-sentinel

Security linter for Dockerfiles and Docker Compose files.

npm i -D @mrlouiswright/dockerfile-sentinel

Published to GitHub Packages: add @mrlouiswright:registry=https://npm.pkg.github.com to .npmrc first (installing needs a token with read:packages).

What it checks

  • hardcoded-secretHardcoded credential or private key
  • secret-in-envSecret-looking ENV value baked into the image
  • secret-in-argSecret passed as a build ARG (visible in image history)
  • copy-sensitive-fileCOPY/ADD of keys, .env, cloud credentials or .git
  • missing-dockerignoreBuild context copied without a .dockerignore (or it misses .git/.env)
  • run-as-rootFinal stage runs as root
  • sudo-usagesudo installed or used
  • base-image-latestBase image uses :latest or no tag

Quick usage

CLI

npx dockerfile-sentinel                      # scan the current directory
npx dockerfile-sentinel Dockerfile docker-compose.yml --fail-on medium
npx dockerfile-sentinel services/ --format sarif > docker.sarif

API

import { lint, exitCode } from 'dockerfile-sentinel';
const report = lint(['.'], { severity: { 'no-healthcheck': 'off' } });
process.exitCode = exitCode(report, 'high');

Every option is documented in the dockerfile-sentinel docs.

CI / GitHub Action

permissions:
  contents: read
  security-events: write   # only for the SARIF upload
steps:
  - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
    with: { persist-credentials: false }
  - uses: MrLouisWright/dockerfile-sentinel@v1
    with:
      targets: '.'
      fail-on: high
      sarif: dockerfile-sentinel.sarif
  - uses: github/codeql-action/upload-sarif@v3
    if: always()
    with: { sarif_file: dockerfile-sentinel.sarif }