Skip to content

fix: require full string match in is_uuid4#3395

Open
dasokkk wants to merge 1 commit into
apache:masterfrom
dasokkk:fix/is-uuid4-fullmatch
Open

fix: require full string match in is_uuid4#3395
dasokkk wants to merge 1 commit into
apache:masterfrom
dasokkk:fix/is-uuid4-fullmatch

Conversation

@dasokkk

@dasokkk dasokkk commented Jun 28, 2026

Copy link
Copy Markdown

Summary

BaseWorld.is_uuid4 used re.match, which only anchors the start of the
string, so any value that begins with a UUID was treated as valid (e.g.
"<uuid>-extra" returned True). The helper decides identifier handling
in a few input-sensitive spots: payload lookup from the agent file
header in file_svc, fact source classification in fact_api_manager,
and #{payload:...} resolution in c_agent.

This switches the check to re.fullmatch so the whole string must be a
UUID. Identifiers are generated with uuid.uuid4() and still validate;
only trailing or leading junk is rejected.

Test plan

  • is_uuid4 returns True for a valid uuid4 string
  • is_uuid4 returns False when extra characters follow a valid uuid
  • existing base_world unit tests pass

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.
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.

1 participant