fix: require full string match in is_uuid4#3395
Open
dasokkk wants to merge 1 commit into
Open
Conversation
is_uuid4 used re.match, which only checks the start of the string, so a
value that just begins with a uuid was accepted (for example
"<uuid>-extra" returned True).
is_uuid4 decides how identifiers are handled in a few input-sensitive
places: payload lookup from the agent "file" header in file_svc, fact
source classification in fact_api_manager, and #{payload:...} resolution
in c_agent.
Use re.fullmatch so the whole string has to be a uuid. Identifiers are
generated with uuid.uuid4() and still pass; only trailing or leading
junk is rejected. Adds tests for is_uuid4, which had none before.
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
BaseWorld.is_uuid4usedre.match, which only anchors the start of thestring, so any value that begins with a UUID was treated as valid (e.g.
"<uuid>-extra"returnedTrue). The helper decides identifier handlingin a few input-sensitive spots: payload lookup from the agent
fileheader in
file_svc, fact source classification infact_api_manager,and
#{payload:...}resolution inc_agent.This switches the check to
re.fullmatchso the whole string must be aUUID. Identifiers are generated with
uuid.uuid4()and still validate;only trailing or leading junk is rejected.
Test plan
is_uuid4returns True for a valid uuid4 stringis_uuid4returns False when extra characters follow a valid uuid