docker-security

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2026 License: MIT

README

docker-security (dsecrat)

Go Scanner deps Platforms

A from-scratch, unified container-security tool in Go — one engine, many frontends (CLI, HTTP API, web dashboard, connectors). It covers the whole container lifecycle: SBOM, vulnerability scanning, secret detection, static image and Dockerfile analysis, license and malware gates, signing/attestation verification, registry posture, CIS/NIST/PCI compliance, RBAC and cloud-IAM risk, network-egress policy, container hardening, admission control, a Docker daemon authorization plugin, continuous monitoring, and eBPF-backed runtime detection.

Standard-library scanner — the dsecrat scanner is built entirely on the Go standard library and ships as a single static binary. The optional eBPF runtime sensor (dsecrat-runtime, Linux) is the sole exception: it uses one dependency, github.com/cilium/ebpf, isolated behind a //go:build linux tag so it never enters the scanner binary.

Naming: the project is docker-security; its CLI binary and Go package are dsecrat (go install github.com/Ratnadeepdeyroy/docker-security/cmd/dsecrat@latest). The runtime daemon is dsecrat-runtime. Rule IDs are prefixed DS-RAT-….

☕ If this project is useful to you, you can buy me a coffee.

Highlights

  • 18 capability modules in one engine — run all with dsecrat scan, or list them with dsecrat modules.
  • Offline & deterministic — no network required for a scan; the vulnerability DB and malware/compliance packs ship embedded and are refreshable.
  • CI-ready--fail-on, SARIF/JSON/OSCAL output, a policy-as-code gate, and connectors (webhook, Slack, SIEM, MCP).
  • Runtime & enforcement — Kubernetes admission webhook, Docker daemon authorization plugin, continuous watch mode, and an eBPF sensor (Linux).

Quickstart

make build        # → bin/dsecrat and bin/dsecrat-runtime
make test         # full test suite
make demo         # end-to-end: crafts a fixture image, drives every capability
make serve        # API + web dashboard + MCP on :8080 (with an inventory store)
make help         # list all targets

Or install straight from source with the Go toolchain:

go install github.com/Ratnadeepdeyroy/docker-security/cmd/dsecrat@latest
go install github.com/Ratnadeepdeyroy/docker-security/cmd/dsecrat-runtime@latest

No Docker is required to build or test.

CLI

dsecrat modules                        # list capability modules
dsecrat scan <target>                  # scan a Dockerfile / path / image tar (all modules)
dsecrat scan --format json  <target>   # json | table | sarif
dsecrat scan --fail-on high <target>   # exit non-zero on a HIGH+ finding (CI gate)
dsecrat watch --interval 5m <target>   # continuous re-scan; emit only new findings
dsecrat sbom  --format spdx <target>   # SBOM: spdx | cyclonedx
dsecrat vuln  info                     # advisory DB status (age / count / staleness)
dsecrat vuln update --ecosystems Debian,Alpine,PyPI,npm --epss --kev   # refresh advisories + EPSS + CISA KEV
dsecrat vuln update --nvd --since 30d                                  # pull/refresh from the NVD CVE API (opt-in)
dsecrat vuln cron install                                             # self-updating: install a daily refresh job
dsecrat scan --vuln-db ~/.dsecrat/vulndb.json <target>    # scan against a refreshed/custom advisory DB
dsecrat compliance report --format oscal <target>   # auditor export: json|csv|oscal|md
dsecrat verify cosign --root fulcio.pem --cert leaf.pem \
     --payload payload.json --signature sig.bin \
     --certificate-identity ... --certificate-oidc-issuer ...   # keyless verify
dsecrat admission serve                # Kubernetes admission webhook
dsecrat authz serve                    # Docker daemon authorization plugin
dsecrat serve --addr :8080             # HTTP API + web dashboard

Example:

dsecrat scan examples/Dockerfile.bad
docker save alpine:3.19 -o alpine.tar
dsecrat sbom --format cyclonedx alpine.tar > alpine.cdx.json

Capabilities

Domain Module(s) What it does
SBOM sbom OS (apk/dpkg/rpm — sqlite, ndb, Berkeley DB) + language packages → SPDX / CycloneDX
Vulnerabilities vuln SBOM → CVE matching with per-ecosystem version compare, EPSS, KEV, VEX; embedded DB + db update
Static analysis dockerfile, imageaudit Dockerfile lint + built-image CIS audit (root, ports, secrets, setuid, provenance)
License policy license Allow/deny SPDX licenses & copyleft classes over the SBOM
Malware malware Static layer scan for miners, web/reverse shells, persistence, known-bad hashes (incl. deleted layers)
Secrets secrets Credentials in image layers (incl. deleted), filesystems, Dockerfiles; opt-in live verification
Supply chain verify Keyed and cosign/Fulcio keyless signature + attestation + Rekor-inclusion verification
Registry registry Trusted-registry allowlist, digest pinning, insecure-HTTP, typosquat detection
Compliance dockerbench, kubebench + packs CIS Docker/Kubernetes; crosswalk to NIST 800-190/800-53, PCI, SOC 2; OSCAL export
Policy / admission policy, admission webhook, authz plugin Policy-as-code gate, K8s admission, Docker daemon AuthZ
K8s manifests k8smanifest Offline posture lint of YAML/Helm/kustomize output (dependency-free YAML reader)
Identity / RBAC rbac Over-privilege, token exposure, escalation paths, and cloud-IAM (IRSA/GKE/AKS) trust-chain risk
Network netpolicy Egress analysis + least-privilege policy generation from observed flows
Hardening harden Container/pod/OCI posture verification + seccomp/AppArmor profile generation
Runtime runtime (dsecrat-runtime) ATT&CK-mapped detection & forensics; eBPF sensor on Linux, replay everywhere

Continuous monitoring

dsecrat watch turns a one-shot scan into monitoring: it re-scans on an interval, diffs each run against the previous, and dispatches only newly-appeared findings through the configured connectors — so a stable target stays quiet and a regression (clean yesterday, vulnerable today) is surfaced immediately.

dsecrat watch --interval 5m --slack https://hooks.slack.com/... <target>

Platform support

Pure Go, CGO_ENABLED=0 → single static binaries. make release cross-builds every target into ./dist:

OS Arch Notes
Linux amd64, arm64 full support incl. the live eBPF runtime sensor
macOS amd64, arm64 full (runtime sensor runs in replay mode)
Windows amd64, arm64 full (runtime sensor runs in replay mode)

Every scanning capability is identical across platforms. The only OS-specific piece is live eBPF capture in dsecrat-runtime, gated behind //go:build linux; the binary builds and runs everywhere and live kernel capture activates only on Linux.

HTTP API & web dashboard

dsecrat serve --addr 127.0.0.1:8080     # then open http://localhost:8080/

curl localhost:8080/healthz
curl localhost:8080/v1/modules
curl -X POST localhost:8080/v1/scan -H 'Content-Type: application/json' -d '{
  "type": "dockerfile",
  "content": "FROM node:latest\nENV TOKEN=abc\n",
  "format": "json"
}'

The dashboard is embedded in the binary (no external assets, works offline).

Documentation

Contributing

Issues and pull requests are welcome. The project keeps two hard rules: the scanner stays standard-library-only (the lone dependency, cilium/ebpf, is confined to the Linux eBPF runtime sensor) and every capability is tested (go test ./... must stay green on all platforms).

License & attribution

MIT © Ratnadeep Dey Roy — https://github.com/Ratnadeepdeyroy/docker-security

dsecrat is free to use, fork, embed, and sell under the MIT License. The license requires that the copyright notice (which names this project and its repository) be retained in all copies and substantial portions.

Please credit the project wherever you use it. If you build on dsecrat, ship it, or reference it, keep the NOTICE file and link back:

Powered by dsecrathttps://github.com/Ratnadeepdeyroy/docker-security

  • Third-party code: the scanner is pure Go standard library. The optional eBPF runtime sensor depends on github.com/cilium/ebpf (Apache-2.0) — the one third-party license to track, and only when building dsecrat-runtime for Linux.
  • Bundled & fetched data (advisories, EPSS, KEV, compliance packs, malware signatures) has its own provenance and attribution terms — see DATA_SOURCES.md.

Support

If dsecrat saves you time, please consider starring the repo ⭐ and buying me a coffee.

Star history

A ⭐ helps others discover dsecrat — see the star history.

Directories

Path Synopsis
cmd
dsecrat command
Command dsecrat is the docker-security CLI entrypoint.
Command dsecrat is the docker-security CLI entrypoint.
dsecrat-runtime command
Command dsecrat-runtime is the runtime threat-detection daemon for the docker-security project.
Command dsecrat-runtime is the runtime threat-detection daemon for the docker-security project.
internal
admission
Package admission is the Kubernetes ValidatingWebhook half of Phase 4.
Package admission is the Kubernetes ValidatingWebhook half of Phase 4.
attacksim
Package attacksim is a SAFE, offline adversary-emulation harness.
Package attacksim is a SAFE, offline adversary-emulation harness.
attest
Package attest builds and verifies in-toto attestations wrapped in DSSE envelopes, re-implemented on internal/sig (no in-toto or sigstore libraries).
Package attest builds and verifies in-toto attestations wrapped in DSSE envelopes, re-implemented on internal/sig (no in-toto or sigstore libraries).
authz
Package authz implements a Docker daemon authorization plugin (CAPABILITY_SPEC domain 8 / 15).
Package authz implements a Docker daemon authorization plugin (CAPABILITY_SPEC domain 8 / 15).
cli
Package cli is the command-line frontend.
Package cli is the command-line frontend.
compliance
Package compliance is the shared machinery for hardening-benchmark auditing (CAPABILITY_SPEC domain 10).
Package compliance is the shared machinery for hardening-benchmark auditing (CAPABILITY_SPEC domain 10).
connector
Package connector delivers a finished Report to an external destination (webhook, chat, CI artifact, …).
Package connector delivers a finished Report to an external destination (webhook, chat, CI artifact, …).
dockercli
Package dockercli is a thin, guarded wrapper around the local `docker` CLI.
Package dockercli is a thin, guarded wrapper around the local `docker` CLI.
engine
Package engine is the core of docker-security: it defines the analysis Target, the Finding/Report model, the Module plugin interface, and the Engine that runs registered modules against a Target.
Package engine is the core of docker-security: it defines the analysis Target, the Finding/Report model, the Module plugin interface, and the Engine that runs registered modules against a Target.
harden
Package harden is the deterministic core for runtime confinement: it turns observed (or declared) workload behaviour into least-privilege seccomp and AppArmor profiles, and verifies a container/pod/OCI runtime spec against a hardening baseline (non-root, dropped caps, no-new-privileges, read-only rootfs, no host namespaces, no docker.sock, cgroup limits, GPU isolation, …).
Package harden is the deterministic core for runtime confinement: it turns observed (or declared) workload behaviour into least-privilege seccomp and AppArmor profiles, and verifies a container/pod/OCI runtime spec against a hardening baseline (non-root, dropped caps, no-new-privileges, read-only rootfs, no host namespaces, no docker.sock, cgroup limits, GPU isolation, …).
k8syaml
Package k8syaml is a minimal, dependency-free YAML reader scoped to the subset Kubernetes manifests actually use: indentation-based mappings and sequences, block scalars are not needed, and values are strings/bools/ints/null.
Package k8syaml is a minimal, dependency-free YAML reader scoped to the subset Kubernetes manifests actually use: indentation-based mappings and sequences, block scalars are not needed, and values are strings/bools/ints/null.
license
Package license implements license-policy evaluation over an SBOM: it turns the licenses the SBOM already detects (internal/sbom captures them per component) into a gate.
Package license implements license-policy evaluation over an SBOM: it turns the licenses the SBOM already detects (internal/sbom captures them per component) into a gate.
malware
Package malware is a deterministic, fully-offline static scanner for known-bad content in image layers: cryptominer binaries, web/reverse shells, persistence droppers, and known-bad file hashes.
Package malware is a deterministic, fully-offline static scanner for known-bad content in image layers: cryptominer binaries, web/reverse shells, persistence droppers, and known-bad file hashes.
mcp
Package mcp implements a Model Context Protocol server that exposes the docker-security engine to AI agents.
Package mcp implements a Model Context Protocol server that exposes the docker-security engine to AI agents.
modules
Package modules wires the available capability modules into a registry.
Package modules wires the available capability modules into a registry.
modules/attacksim
Package attacksim is the engine module wrapper around internal/attacksim.
Package attacksim is the engine module wrapper around internal/attacksim.
modules/dockerbench
Package dockerbench assesses a Docker host and daemon against the CIS Docker Benchmark (CAPABILITY_SPEC domain 10).
Package dockerbench assesses a Docker host and daemon against the CIS Docker Benchmark (CAPABILITY_SPEC domain 10).
modules/dockerfile
Package dockerfile implements static analysis and linting of Dockerfiles.
Package dockerfile implements static analysis and linting of Dockerfiles.
modules/harden
Package harden is the capability module that surfaces runtime-confinement findings through the engine.
Package harden is the capability module that surfaces runtime-confinement findings through the engine.
modules/imageaudit
Package imageaudit inspects a *built* container image — its configuration and its layer history — and reports hardening violations mapped to the CIS Docker Benchmark image controls (CIS-DI-*).
Package imageaudit inspects a *built* container image — its configuration and its layer history — and reports hardening violations mapped to the CIS Docker Benchmark image controls (CIS-DI-*).
modules/k8smanifest
Package k8smanifest is the offline Kubernetes-manifest linter (CAPABILITY_SPEC domains 8/10).
Package k8smanifest is the offline Kubernetes-manifest linter (CAPABILITY_SPEC domains 8/10).
modules/kubebench
Package kubebench assesses a Kubernetes cluster against a subset of the CIS Kubernetes Benchmark (CAPABILITY_SPEC domain 10).
Package kubebench assesses a Kubernetes cluster against a subset of the CIS Kubernetes Benchmark (CAPABILITY_SPEC domain 10).
modules/license
Package license is the engine module that gates an image's component licenses against an allow/deny policy (CAPABILITY_SPEC domain 1 — license-policy gating).
Package license is the engine module that gates an image's component licenses against an allow/deny policy (CAPABILITY_SPEC domain 1 — license-policy gating).
modules/malware
Package malware is the engine module for static malware/cryptominer scanning of image layers (CAPABILITY_SPEC domains 3/11, static side).
Package malware is the engine module for static malware/cryptominer scanning of image layers (CAPABILITY_SPEC domains 3/11, static side).
modules/netpolicy
Package netpolicy is the engine module for Phase 6 (CAPABILITY_SPEC domain 6): network egress analysis and least-privilege policy generation.
Package netpolicy is the engine module for Phase 6 (CAPABILITY_SPEC domain 6): network egress analysis and least-privilege policy generation.
modules/policy
Package policy is the engine module and command surface for policy-as-code.
Package policy is the engine module and command surface for policy-as-code.
modules/rbac
Package rbac is the engine module wrapper around internal/rbac.
Package rbac is the engine module wrapper around internal/rbac.
modules/registry
Package registry implements the registry-security & artifact-management capability (CAPABILITY_SPEC domain 13).
Package registry implements the registry-security & artifact-management capability (CAPABILITY_SPEC domain 13).
modules/runtime
Package runtime is the engine-module face of the runtime sensor.
Package runtime is the engine-module face of the runtime sensor.
modules/sbom
Package sbom is the engine module wrapper around internal/sbom.
Package sbom is the engine module wrapper around internal/sbom.
modules/secrets
Package secrets is the engine module wrapper around internal/secrets.
Package secrets is the engine module wrapper around internal/secrets.
modules/verify
Package verify is the engine module and command surface for supply-chain verification.
Package verify is the engine module and command surface for supply-chain verification.
modules/vuln
Package vuln is the engine module for vulnerability scanning (CAPABILITY_SPEC domain 2).
Package vuln is the engine module for vulnerability scanning (CAPABILITY_SPEC domain 2).
netmon
Package netmon is the offline core of Phase 6: network flow observability and egress analysis.
Package netmon is the offline core of Phase 6: network flow observability and egress analysis.
oci
Package oci loads container images into flat file trees that catalogers can walk.
Package oci loads container images into flat file trees that catalogers can walk.
plugin
Package plugin runs third-party analyzers out of process, so the community (and other AI tools) can extend detection without forking or being linked into the binary.
Package plugin runs third-party analyzers out of process, so the community (and other AI tools) can extend detection without forking or being linked into the binary.
policy
Package policy is a deterministic, dependency-free policy-as-code engine for docker-security.
Package policy is a deterministic, dependency-free policy-as-code engine for docker-security.
rbac
Package rbac analyzes Kubernetes and Docker identity configuration for over-privilege and privilege-escalation paths.
Package rbac analyzes Kubernetes and Docker identity configuration for over-privilege and privilege-escalation paths.
registry
Package registry is a from-scratch OCI distribution (registry v2) client plus a small in-memory registry for offline tests and demos.
Package registry is a from-scratch OCI distribution (registry v2) client plus a small in-memory registry for offline tests and demos.
report
Package report renders an engine.Report into human- and machine-readable formats.
Package report renders an engine.Report into human- and machine-readable formats.
runtime
Package runtime is the offline core of the runtime threat-detection sensor (dsecrat-runtime).
Package runtime is the offline core of the runtime threat-detection sensor (dsecrat-runtime).
sbom
Package sbom builds a Software Bill of Materials from a container image or a filesystem: it loads the image (via internal/oci), walks the flattened file tree with a set of catalogers (OS package DBs and language manifests), and serializes the result to SPDX 2.3 and CycloneDX 1.5.
Package sbom builds a Software Bill of Materials from a container image or a filesystem: it loads the image (via internal/oci), walks the flattened file tree with a set of catalogers (OS package DBs and language manifests), and serializes the result to SPDX 2.3 and CycloneDX 1.5.
secrets
internal/secrets/confidence.go
internal/secrets/confidence.go
server
Package server is the HTTP/web frontend.
Package server is the HTTP/web frontend.
sig
Package sig re-implements the core of a Sigstore/Cosign-style signing stack on top of the Go standard library — no cosign, no sigstore, no external crypto.
Package sig re-implements the core of a Sigstore/Cosign-style signing stack on top of the Go standard library — no cosign, no sigstore, no external crypto.
store
Package store persists scan results and SBOM inventory so the platform can answer questions that a single stateless scan cannot: "which of the images we have ever scanned contain component X at version Y?" (the blast-radius query a team runs the morning a zero-day drops), "is our critical count trending up?", and "who owns the image with the most findings?".
Package store persists scan results and SBOM inventory so the platform can answer questions that a single stateless scan cannot: "which of the images we have ever scanned contain component X at version Y?" (the blast-radius query a team runs the morning a zero-day drops), "is our critical count trending up?", and "who owns the image with the most findings?".
vulndb
Package vulndb is the offline, normalized advisory store behind the vuln module.
Package vulndb is the offline, normalized advisory store behind the vuln module.
watch
Package watch turns dsecrat's one-shot analysis into continuous monitoring.
Package watch turns dsecrat's one-shot analysis into continuous monitoring.
web
Package web serves the embedded single-page dashboard.
Package web serves the embedded single-page dashboard.
Package web serves the Phase 9 dashboard: a self-contained, offline single-page app over the same HTTP API the CLI and connectors use.
Package web serves the Phase 9 dashboard: a self-contained, offline single-page app over the same HTTP API the CLI and connectors use.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL