Repository navigation
fix(validators): stop the version-label regex stalling the PII scan on long identifiers #684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
chrisknvidia
merged 3 commits into
main
from
fix/christopherk/shell-word-regex-backtracking
Nov 16, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8613,6 +8613,40 @@ def test_separate_explicit_version_labels_stay_non_pii(self, tmp_path: Path) -> | |
|
|
||
| assert not any(finding.check_name == "ip_addresses" for finding in result.findings) | ||
|
|
||
| def test_long_identifiers_before_ip_values_do_not_stall_the_scan(self, tmp_path: Path) -> None: | ||
| """Regression (CWE-1333): the version-label pattern could split a run of letters in exponentially many | ||
| ways, so a 30-letter identifier before an IPv4-shaped value stalled the PII scan for about a minute and | ||
| every further letter doubled that. Runs in a subprocess so that a slow scan fails the timeout instead of | ||
| hanging the suite; the limit is generous because the scan takes about a second.""" | ||
|
Comment on lines
+8616
to
+8620
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔍 Incomplete local contribution gates The PR records that Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| skill_dir = tmp_path / "long-identifier-skill" | ||
| skill_dir.mkdir() | ||
| not_labels = ["a" * 76, "A" * 76, "aB" * 38, "a1" * 38] | ||
| labels = ["a" * 69 + "Version", "version" + "A" * 69, "Tag" + "Ab1" * 24, "a" * 60 + "_version"] | ||
| (skill_dir / "SKILL.md").write_text( | ||
| "".join(f'{name} = "8.8.0.{index}"\n' for index, name in enumerate(not_labels, 1)) | ||
| + "".join(f'{name} = "4.4.0.{index}"\n' for index, name in enumerate(labels, 1)), | ||
| encoding="utf-8", | ||
| ) | ||
| # Keep the child on this checkout even if its interpreter has another editable install. | ||
| code = ( | ||
| "import json, sys\n" | ||
| f"sys.path.insert(0, {str(Path(__file__).resolve().parents[2] / 'src')!r})\n" | ||
| "from pathlib import Path\n" | ||
| "from skillevaluator.validators.security import SecurityValidator\n" | ||
| "result = SecurityValidator().validate_pii_only(Path(sys.argv[1]))\n" | ||
| "found = {f.metadata.get('matched_value') for f in result.findings if f.check_name == 'ip_addresses'}\n" | ||
| "print(json.dumps(sorted(found)))\n" | ||
| ) | ||
|
|
||
| completed = subprocess.run( | ||
| [sys.executable, "-c", code, str(skill_dir)], capture_output=True, text=True, timeout=60 | ||
| ) | ||
|
|
||
| assert completed.returncode == 0, completed.stderr | ||
| # The long plain identifiers are not version labels, so their values are still reported; | ||
| # the long labels still mark theirs as release versions. | ||
| assert json.loads(completed.stdout) == ["8.8.0.1", "8.8.0.2", "8.8.0.3", "8.8.0.4"] | ||
|
|
||
| @pytest.mark.parametrize( | ||
| "line", | ||
| [ | ||
|
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.