Skip to content

Conversation

@markercm
Copy link

@markercm markercm commented Jul 16, 2025

I've added the regex pattern that @Nuru suggested in #5775 (comment) and added tests for the function to ensure that it actually works.

Copilot created the tests.

Inspired by a comment in but doesn't actually address #5775

@markercm markercm force-pushed the fix-SecretsUsedInArgOrEnv-logic-to-match-comment-and-test branch from ccae356 to dcda7e3 Compare July 16, 2025 19:31
Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

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

I'm not sure what is the difference between matching PASSWORD_ROOT but not matching DB_PASSWORD_ROOT. If this is causing too many false positives (not sure if the case) then matching last component or full text could be more limited set. @colinhemmings

A more general fix would be to add the skip comments per-line, that are currently only supported per-file.

key string
isSecret bool
}{
// Positive matches
Copy link
Member

Choose a reason for hiding this comment

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

None of these tests seem to actually check for the change of behavior (handling secrets in the middle of string).

Copy link
Author

Choose a reason for hiding this comment

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

{name: "contains key but not fitst of last or full", key: "new_key_file_path", isSecret: false},

This matches on the old behavior even though key is neither the first nor last nor full match but doesn't with the new logic.

@markercm
Copy link
Author

A more general fix would be to add the skip comments per-line, that are currently only supported per-file.

I would agree with you and would love to see that get prioritized as it seems like the only real option.

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.

2 participants