Skip to content

fix(dockerfile): support custom-prefix Dockerfile names like AdtDockerfile#7557

Open
AlexanderSanin wants to merge 1 commit into
bridgecrewio:mainfrom
AlexanderSanin:fix/dockerfile-mask-custom-prefix
Open

fix(dockerfile): support custom-prefix Dockerfile names like AdtDockerfile#7557
AlexanderSanin wants to merge 1 commit into
bridgecrewio:mainfrom
AlexanderSanin:fix/dockerfile-mask-custom-prefix

Conversation

@AlexanderSanin

Copy link
Copy Markdown
Contributor

Summary

  • DOCKERFILE_MASK in checkov/common/util/dockerfile.py only matched Dockerfile/dockerfile at the start of the filename or after a dot separator (e.g. dev.Dockerfile).
  • Files with a CamelCase or word prefix without a dot separator — such as AdtDockerfile or MyServiceDockerfile — were silently skipped, leaving those images unscanned.
  • The regex is updated to add a second alternative that allows any non-dot prefix followed by an uppercase D, so AdtDockerfile and similar variants are now recognised.
  • Lowercase-only prefix variants (e.g. ddockerfile) remain invalid to avoid ambiguity, preserving all existing test expectations.

Closes #7541

Test plan

  • All previously-valid names still pass is_dockerfile(): Dockerfile, dockerfile, Dockerfile.prod, dev.Dockerfile, team1.product.dockerfile, etc.
  • All previously-invalid names still fail: .dockerfile, ddockerfile, docker-file, dockerfile1, Dockerfile.env.dockerignore, etc.
  • New valid names now pass: AdtDockerfile, MyServiceDockerfile, AdtDockerfile.prod
  • Run pytest tests/dockerfile/test_utils.py::test_is_dockerfile

…rfile

The DOCKERFILE_MASK regex only matched files where "Dockerfile" appeared
at the start or after a dot separator (e.g. Dockerfile, dev.Dockerfile).
Files that use a CamelCase or word prefix without a dot separator, such
as AdtDockerfile or MyServiceDockerfile, were silently skipped, leaving
those images unscanned.

The regex is updated to also match when a non-dot prefix precedes an
uppercase-D "Dockerfile". Lowercase-only prefixes (e.g. ddockerfile)
remain invalid to avoid ambiguity. All existing valid/invalid test cases
continue to pass.

Closes bridgecrewio#7541

Signed-off-by: Oleksandr Sanin <alexaaander.sanin@gmail.com>
@AlexanderSanin

Copy link
Copy Markdown
Contributor Author

Hey @yuvalmich @talazuri @omriyoffe-panw. Could you, please, have a look at this?

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.

Enhance Pattern DOCKERFILE_MASK in dockerfile.py

1 participant