Skip to content

Potential fix for code scanning alert no. 3: Polynomial regular expression used on uncontrolled data - #291

Open
Exohayvan wants to merge 1 commit into
mainfrom
alert-autofix-3
Open

Potential fix for code scanning alert no. 3: Polynomial regular expression used on uncontrolled data#291
Exohayvan wants to merge 1 commit into
mainfrom
alert-autofix-3

Conversation

@Exohayvan

Copy link
Copy Markdown
Contributor

Potential fix for https://github.com/AetherMesh-AI/aethermesh-core/security/code-scanning/3

The best fix is to replace the regular-expression scheme check with bounded, linear string parsing before accepting an artifact or log reference.

Concretely, in src/aethermesh_core/job_result_schema.py, _artifact_reference_list now delegates URI-scheme detection to _starts_with_uri_scheme. The helper splits once at the first colon and validates the same ASCII scheme grammar without regex backtracking. This preserves the existing rejection behavior for URI-like and Windows drive references while ensuring long user-controlled strings are handled in linear time.

A regression test validates a 100,000-character reference while making any fallback to re.match fail explicitly. No API or schema changes are required.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

@Exohayvan
Exohayvan marked this pull request as ready for review July 23, 2026 02:07
@Exohayvan Exohayvan added type:bug Type: bug or broken behavior. priority:P2 Priority P2: high-impact near-term work. system:validation System: validation, tests, or quality policy. area:result-validation Area: generated triage label for result validation. area:artifact-provenance Area: generated triage label for artifact provenance. risk:medium Risk: changes existing working behavior with moderate regression risk. needs:review Needs: generated triage label for review. labels Jul 23, 2026
@Exohayvan Exohayvan added status:ready Human-readable workflow status: ready for the next review or merge step. status:in-review Human-readable workflow status: under review. status:blocked Human-readable workflow status: blocked by a failing gate or dependency. and removed needs:review Needs: generated triage label for review. status:ready Human-readable workflow status: ready for the next review or merge step. status:in-review Human-readable workflow status: under review. labels Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:artifact-provenance Area: generated triage label for artifact provenance. area:result-validation Area: generated triage label for result validation. priority:P2 Priority P2: high-impact near-term work. risk:medium Risk: changes existing working behavior with moderate regression risk. status:blocked Human-readable workflow status: blocked by a failing gate or dependency. system:validation System: validation, tests, or quality policy. type:bug Type: bug or broken behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant