Skip to content

fix(skill-scanner): Report symlink loops instead of crashing - #190

Open
axchadxs wants to merge 1 commit into
getsentry:mainfrom
axchadxs:fix/skill-scanner-symlink-loop
Open

axchadxs wants to merge 1 commit into
getsentry:mainfrom
axchadxs:fix/skill-scanner-symlink-loop

Conversation

@axchadxs

@axchadxs axchadxs commented Nov 2, 2026

Copy link
Copy Markdown

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:

mkdir -p demo-skill/references
printf -- '---\nname: demo-skill\ndescription: Demo skill for scanner tests.\n---\n\n# Demo\n' > demo-skill/SKILL.md
ln -s self.md demo-skill/references/self.md
uv run skills/skill-scanner/scripts/scan_skill.py demo-skill

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

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
Copilot AI balanced review requested due to automatic review settings November 2, 2026 19:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.

skill-scanner: scan_skill.py crashes on a symlink loop

2 participants