fix(detectors/azureappconfigconnectionstring): allow hyphen and colon in Id#4959
Open
ChrisJr404 wants to merge 1 commit into
Open
Conversation
… in Id Real Azure-issued App Configuration connection strings have an Id of the form <prefix>:<base64>, where the prefix can contain letters, digits, and hyphens. The existing character class [a-zA-Z0-9+/=] only covered the base64 alphabet, so the colon separator and any hyphen caused legitimate connection strings to be skipped by the detector. Expand the Id character class to also accept ':' and '-'. The Endpoint and Secret groups are unchanged. A regression test using a prefixed hyphen+colon Id is added. Closes trufflesecurity#4955 Signed-off-by: ChrisJr404 <chris@hacknow.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.
Summary
The
AzureAppConfigConnectionStringdetector misses real Azure-issued connection strings because theIdcapture group only allows the base64 alphabet. Azure's documented connection-string format iswhere
<prefix>is a short identifier that can contain letters, digits, and hyphens, joined to the base64 portion with a colon. See Microsoft's docs on the connection-string shape and on rotating access keys, both of which show theprefix:base64form forId:The current regex is
The colon separator alone is enough to break the match, and any hyphen inside the prefix breaks it too. Both happen on every store created in the portal or via
az appconfig credential list.Fix
Add
:and-to theIdcharacter class. TheEndpointhost class already permits hyphens, theSecretis unchanged, and no other detector calls were affected.Test plan
valid pattern - id with prefix and hyphentoazureappconfigconnectionstring_test.gothat feeds a real-shapeId=abcd-l0:u+DeEXamPleIdValue==connection string.go test ./pkg/detectors/azureappconfigconnectionstring/...passes all four subtests.Closes #4955
Note
Low Risk
Low risk: a small regex broadening plus a new unit test; behavior change is limited to matching more valid Azure App Config connection strings.
Overview
Improves
AzureAppConfigConnectionStringdetection by widening theIdcapture group inconnectionStringPatto accept-and:(matching Azure’sprefix:base64Idformat).Adds a new pattern test case covering an
Idwith a hyphenated prefix and colon separator to prevent regressions.Reviewed by Cursor Bugbot for commit b7793ac. Bugbot is set up for automated code reviews on this repo. Configure here.