Fix rule bugs, expand rule set, add multi-file input - #4
Merged
Conversation
Follow-up to a review of dockopt. Three correctness fixes, an analyzer cleanup, a broader rule set, and batch (multi-file) analysis. Bug fixes (each with a regression test + CI fixture contract): - GO002 no longer false-errors when CGO_ENABLED=0 is set via a stage-level ENV/ARG (not just inline in the RUN). - Bash here-strings (<<<) are no longer misparsed as heredocs. - GEN001 now flags untagged base images (implicit :latest), while exempting scratch, digest-pinned images, and prior stage references. Analyzer cleanup (behavior-preserving): - Remove the dead Context struct threaded through every rule. - Collapse the single-implementation Rule interface and its defensive copy layers into a concrete rule registry. - Detect the stack once per run instead of twice. New rules: - GEN002/GEN003: apt-get install without --no-install-recommends / cache cleanup. - GEN004: ADD <url> anti-pattern. - GEN005: final stage running as root. - JAVA001 broadened to all JDK versions/repos (openjdk, eclipse-temurin, amazoncorretto) rather than the exact tag openjdk:17. Multi-file input: - Accept N Dockerfile paths (shell globbing supported). - JSON output becomes JSON Lines; single-file output is unchanged. - Human output gets per-file headers; exit code is the max across paths. README gains a rules reference and multi-file docs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to a review of
dockopt: three correctness fixes, an analyzer cleanup, a broader rule set, and batch (multi-file) analysis.Bug fixes
Each has a regression test and a binary-level CI fixture contract.
CGO_ENABLED=0is set via a stage-levelENV/ARG(previously only the inlineRUNform was recognized, so idiomatic Dockerfiles failed CI with anerror-grade finding).<<<) are no longer misparsed as heredocs (previouslyparse_error, exit 2).:latest) are now flagged, while exemptingscratch, digest-pinned images, and prior stage references.Analyzer cleanup (behavior-preserving)
Contextstruct threaded through every rule.Ruleinterface + defensive copy layers into a concrete rule registry.New rules
GEN002apt-get installwithout--no-install-recommendsGEN003apt-get installwithout clearing/var/lib/apt/listsin the sameRUNGEN004ADD <url>anti-patternGEN005rootJAVA001broadened to all JDK versions/repos (openjdk,eclipse-temurin,amazoncorretto) instead of the single exact tagopenjdk:17.Multi-file input
==> path <==headers; exit code is the most severe outcome across all paths (2>1>0).Docs & tests
gofmt/go vetclean,-raceclean, fuzz clean, CI fixture contract replayed locally.Known limitations (marked with
ponytail:comments in code + noted in README)apt-get -y install(flag before the subcommand) isn't detected.🤖 Generated with Claude Code