Skip to content

linter: do not attempt to check for copying ignored file when negated patterns exist#6534

Merged
tonistiigi merged 1 commit intomoby:masterfrom
jsternberg:copy-ignored-file-linter-negated-matches
Feb 24, 2026
Merged

linter: do not attempt to check for copying ignored file when negated patterns exist#6534
tonistiigi merged 1 commit intomoby:masterfrom
jsternberg:copy-ignored-file-linter-negated-matches

Conversation

@jsternberg
Copy link
Copy Markdown
Collaborator

@jsternberg jsternberg commented Feb 24, 2026

It becomes too difficult to statically check whether a source path is an
error or expected when negated patterns are involved. This is because a
pattern may point to a directory and may exclude the directory, but a
further pattern may exclude a specific pattern in that directory.

In order to determine whether this happened when copying a source
directory, we'd need to either have some knowledge of the actual files
copied (wouldn't be a static pattern) or we would need to go through
each exclusion and try to determine if there exists a certain text that
would match both the original pattern and the excluded pattern.

This is likely too difficult or too computationally intense for what's
meant to be a simple linter check so just disable this linter check when
exclusions exist.

Fixes #6512.

… patterns exist

It becomes too difficult to statically check whether a source path is an
error or expected when negated patterns are involved. This is because a
pattern may point to a directory and may exclude the directory, but a
further pattern may exclude a specific pattern in that directory.

In order to determine whether this happened when copying a source
directory, we'd need to either have some knowledge of the actual files
copied (wouldn't be a static pattern) or we would need to go through
each exclusion and try to determine if there exists a certain text that
would match both the original pattern and the excluded pattern.

This is likely too difficult or too computationally intense for what's
meant to be a simple linter check so just disable this linter check when
exclusions exist.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
@tonistiigi tonistiigi added this to the v0.28.0 milestone Feb 24, 2026
@tonistiigi tonistiigi merged commit 373d0ad into moby:master Feb 24, 2026
190 checks passed
@jsternberg jsternberg deleted the copy-ignored-file-linter-negated-matches branch February 24, 2026 22:26
tinovyatkin added a commit to wharflab/tally that referenced this pull request Mar 5, 2026
- Normalise buildkit version in SARIF snapshot so dependency bumps don't
  break tests
- Backport moby/buildkit#6534: skip CopyIgnoredFile when .dockerignore
  contains negated patterns (static analysis is unreliable with exclusions)
- Backport moby/buildkit#6501: allow _FILE and _VERSION suffixes in
  SecretsUsedInArgOrEnv to reduce false positives

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CopyIgnoredFile linter triggers with negated matches and "COPY . $target"

2 participants