Repository navigation
Conversation
scan_skill.py called path.resolve() on every symlink, which raises RuntimeError on a symlink loop in Python 3.12 and earlier. The scan aborted with a traceback and produced no report. Catch the error and report the link as a Symlink Detected finding, matching what Python 3.13 already reports. Fixes getsentry#188
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.
scan_skill.py aborted with a RuntimeError traceback when a skill contained a symlink loop (for example a file that links to itself) on Python 3.12 and earlier, so no report was produced and the skill was not scanned at all. Python 3.13 no longer raises here, so the same input already scanned fine there.
check_structural_attacks now catches the loop and reports the link as a "Symlink Detected" finding with medium severity, which matches what 3.13 already reports for the same input. Output for ordinary, external, and dangling symlinks is unchanged.
To reproduce on Python 3.12:
Before: exit 1 with "RuntimeError: Symlink loop". After: exit 0 and one medium "Symlink Detected" finding. I also checked a two-file loop (a.md and b.md pointing at each other) and a directory loop on Python 3.9, 3.11, 3.12 and 3.13, and confirmed the JSON output for internal, external, and dangling symlinks is byte-identical to before.
I chose medium rather than critical because a loop never resolves to a file, so it can't reach anything outside the skill. Happy to change it if you would rather treat unresolvable links as critical.
Fixes #188