Skip to content

Lint several Dockerfiles per run and add a .docker-lint.yaml config - #8

Merged
devblac merged 2 commits into
mainfrom
feat/multi-file-config
Oct 24, 2026
Merged

devblac merged 2 commits into
mainfrom
feat/multi-file-config

Conversation

@devblac

@devblac devblac commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Stacked on #5 (base feat/sarif-action); retarget to main once #5 merges.

What

Several files per run. Every path argument can be:

  • a file, linted as given whatever its name;
  • a directory, searched recursively for Dockerfile, Containerfile, Dockerfile.* and *.Dockerfile (skipping .git and node_modules; Dockerfile.dockerignore is not a Dockerfile);
  • a glob with **, expanded by docker-lint so it works the same in every shell, including on Windows.

A directory or pattern that matches nothing exits 2, so a CI job can't go green without linting anything. A file that fails to parse is reported on stderr and the run exits 2, but the other files are still linted and reported.

Output. A single file (or stdin) keeps today's output exactly, including the JSON object. Several files produce a JSON array of those objects, and SARIF produces a single run covering every file, which is what code scanning expects.

.docker-lint.yaml. Looked up from the current directory to the repository root; --config/-c picks another file and --no-config disables it.

ignore: [DKL103]
severity:
  DKL303: error   # error | warning | info | off
  DKL404: off
strict: true
quiet: false
exclude: [vendor, "examples/**"]
  • Flags win over the file (--strict=false beats strict: true); --ignore adds to the file's list.
  • Unknown keys and invalid severities are fatal, so a typo can't silently disable the config.
  • Unknown or renamed rule IDs in the file get the same warnings as --ignore.
  • SARIF rule metadata reflects the severity overrides.

Action. dockerfile takes one path or pattern per line, and there is a new config input. The action workflow gains a multi-file case that runs on all three OSes.

Testing

  • New unit tests: matcher, **, excludes, discovery and its errors (internal/files); parsing, validation and lookup bounded by .git (internal/config); end-to-end CLI tests for directories, globs, the JSON array and object shapes, a single SARIF run, partial parse failure, config discovery, flag precedence and config errors.
  • Existing tests pass unchanged, which shows single-file behavior is preserved.
  • Ran the action's lint step locally under the runner's bash -e -o pipefail with multi-line input, a glob, a directory, empty input, partial failure and the new workflow case.
  • Checked the README config example against the real parser.

🤖 Generated with Claude Code

Paths may now be files, directories searched recursively for Dockerfiles,
or glob patterns with **, expanded by docker-lint so they behave the same
on Windows. A directory or pattern that matches nothing is fatal, so CI
cannot pass without linting anything; a file that fails to parse is
reported while the others are still linted.

A single file keeps its JSON object output; several files produce an
array, and SARIF a single run covering all of them.

.docker-lint.yaml, found up to the repository root, sets ignored rules,
per-rule severities (or off), strict, quiet and exclude patterns. Flags
win over the file, and unknown keys are errors so typos fail loudly.

The GitHub Action takes one path or pattern per line and a config input.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T05:39:48.687370Z 4374e59 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4374e595a2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/files/files.go
Comment on lines +57 to +58
if err != nil {
return nil, err

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Continue after an explicit input is missing

When several explicit files are supplied and one is missing, this immediate return discards every path already expanded, so docker-lint valid.Dockerfile missing.Dockerfile never analyzes the valid file. This contradicts the new multi-file behavior that other inputs continue to be linted after a file cannot be read; collect this error while preserving the remaining inputs so the run can emit their reports and still exit fatally.

Useful? React with 👍 / 👎.

Comment thread internal/files/files.go
Comment on lines +102 to +109
rel := filepath.ToSlash(p)
if d.IsDir() {
if p != dir && skipDir(d.Name()) {
return filepath.SkipDir
}
return nil
}
if IsDockerfile(d.Name()) && !Excluded(rel, exclude) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize scanned paths before applying exclusions

When a directory or glob is given as an absolute or parent-relative path, p retains that prefix, so an anchored relative exclusion such as examples/** does not match /repo/examples/Dockerfile or ../examples/Dockerfile. As a result, the same configured exclusion works for docker-lint . but is silently bypassed for equivalent absolute or parent-relative inputs; exclusion matching should use a consistently relative path.

Useful? React with 👍 / 👎.

@devblac
devblac changed the base branch from feat/sarif-action to main October 24, 2026 18:32
@devblac
devblac merged commit 348c238 into main Oct 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant