Skip to main content

hardencheck

Static hardening checks for the files people actually ship: Dockerfiles, compose files, Kubernetes manifests and sshd config. Zero dependencies, no network, SARIF output for CI.

hardencheck scanning a fixture corpus

CI license: MIT python

Repo name is infra-hardening-checks; the package and command are hardencheck, because pipx install hardencheck is what people should have to type.

Install

pipx install git+https://github.com/mgkvibez/infra-hardening-checks.git

Three ways to use it

# 1. A repo, before you push
hardencheck scan .

# 2. Only what blocks a release, as machine-readable output
hardencheck scan . --min-severity high --json

# 3. In CI, as SARIF that GitHub code scanning can ingest
hardencheck scan . --sarif > hardencheck.sarif

Exit codes are a contract: 0 nothing at or above the threshold, 3 findings, 2 a problem with the invocation. hardencheck rules lists the ruleset, hardencheck explain HCD002 says why a rule exists and how to fix it.

What it checks

21 rules across four kinds. High severity, the ones worth stopping a merge for:

Id Catches
HCD002 Container runs as root
HCD003 Secret-looking value in ENV/ARG
HCD005 Remote script piped into a shell
HCC001 privileged: true in compose
HCC002 Docker socket mounted into a container
HCK001 privileged: true in a pod spec
HCK003 hostPath volume
HCS001 PermitRootLogin yes
HCS003 PermitEmptyPasswords yes

Medium and low cover unpinned base images, missing USER, missing HEALTHCHECK, missing resource limits, network_mode: host, host namespaces, world-writable permissions and apt cache leftovers. Full list with severities: hardencheck rules.

What it is not

It is a lexical checker, not a YAML parser and not a scanner. It reads lines, so it will miss anything that depends on real structure: anchors, merge keys, and values built by templating (Helm, Kustomize) are invisible to it. It flags patterns that are risky by policy, which means a deliberate privileged: true in a cluster-admin DaemonSet gets flagged too. Silence from this tool is not evidence of safety, which is why the clean result says No issues found by ruleset v1 rather than "safe".

How it works

  • hardencheck/rules.py is the ruleset: each rule declares its id, severity, remediation and a function over lines. Adding a rule is one function and one entry.
  • hardencheck/scanner.py decides a file's kind from its name and, for YAML, from its content, then runs only the matching rules. Unknown files are reported as skipped with the reason, never silently ignored.
  • hardencheck/report.py renders text, JSON or SARIF 2.1.0.

Contributing

Issues and PRs welcome. A new rule needs: an id in the existing scheme, a severity you can defend, remediation text a tired engineer can act on at 2am, and a fixture that proves the rule fires on bad input and stays silent on good input. scripts/verify.sh is the gate CI runs.

License

MIT.

Metadata

Release files for hardencheck 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hardencheck 0.1.0
File Size Uploaded Provenance Actions
hardencheck-0.1.0.tar.gz 13.7 kB With provenance Details for hardencheck-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hardencheck 0.1.0
File Interpreter ABI Platform Actions
hardencheck-0.1.0-py3-none-any.whl Python 3 none any Details for hardencheck-0.1.0-py3-none-any.whl

Total release size: 26.2 kB

Release files / hardencheck-0.1.0.tar.gz

Download URL hardencheck-0.1.0.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
79fb6f38524c563f5ab17e226ec5a36277970d6c94a6719ae4f30973c09092a9
BLAKE2b-256 checksum
How to use checksums
67c2788a29aa6647eb0cb624361bca9c13478362d9ca13d7bbb122c042b76d4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / hardencheck-0.1.0-py3-none-any.whl

Download URL hardencheck-0.1.0-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb40ceeaa6d1f5541fc1eb633f541c41b9e6995e8147ab591605f5ba0b4f5e7a
BLAKE2b-256 checksum
How to use checksums
48187510e660a67c037c97f49f900d542e9a09261e1d4e28b979465aec94a553
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Security for hardencheck 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for hardencheck-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page