Skip to content

fix(tier1): keep file scans inside the skill directory - #837

Merged
chrisknvidia merged 8 commits into
mainfrom
fix/tier1-symlink-scan-boundary
Nov 20, 2026
Merged

chrisknvidia merged 8 commits into
mainfrom
fix/tier1-symlink-scan-boundary

Conversation

@chrisknvidia

Copy link
Copy Markdown
Collaborator

Summary

Tier 1 file walkers returned symlinked files wherever they pointed, and readers such as the PII scan opened them with Path.read_text, which follows the link. A skill holding references/notes.md -> /some/host/file made a default Tier 1 run copy matching lines (emails, IPs, phone numbers, home paths) from that host file into the JSON, HTML and SARIF reports as line_content.

Changes

  • iter_scannable_files skips a symlinked file whose target resolves outside the skill root or does not exist. Links that resolve inside the skill are returned as before; symlinked directories are still not descended. Only symlinks pay the resolve() cost.
  • New path_resolves_inside helper holds the boundary check; _scan_file_for_pii applies it directly so a caller that hands it a path without going through the walker gets the same protection.
  • New iter_outside_symlinks helper; Code Integrity & Hygiene records a low-severity symlink_outside_skill finding for each skipped link, named by its path inside the skill and never by its target, so authors know the content was not scanned.
  • CHANGELOG entry.

Audit of other readers: unicode, license header, dead-link and PII/secrets scans all take files from iter_scannable_files, so they are covered. Bandit and Semgrep walk the directory themselves and would still follow a symlinked .py; that is a smaller, separate path worth its own follow-up.

Verification

Repro from the issue (with a non-placeholder address, since example.com is exempt from the email pattern): before, the JSON report quoted the host file's line; after, it does not, the PII scan counts one file, and the report names references/notes.md as skipped.

Tests cover the walker (outside link skipped, inside link kept, dangling link skipped, symlinked directory not descended), the PII scan, the hygiene finding, and an end-to-end check that JSON/Markdown/HTML reports contain none of the host file's content. tests/validators/: 5408 passed, 2 skipped locally.

Refs #833

Tier 1 file walkers returned symlinked files wherever they pointed, and
readers such as the PII scan opened them with Path.read_text, which
follows the link. A skill holding references/notes.md -> /some/host/file
made a default Tier 1 run copy matching lines from that host file into
the JSON, HTML and SARIF reports as line_content.

iter_scannable_files now drops a symlinked file whose target resolves
outside the skill root or does not exist; links that resolve inside the
skill are returned as before, and symlinked directories are still not
descended. The boundary check lives in a small path_resolves_inside
helper, and _scan_file_for_pii applies it directly so callers that hand
it a path bypassing the walker get the same protection. A new
iter_outside_symlinks helper lets Code Integrity & Hygiene record a
low-severity symlink_outside_skill finding for each skipped link, named
by its path inside the skill and never by its target.

Refs #833

Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
@chrisknvidia
chrisknvidia marked this pull request as ready for review November 20, 2026 18:15
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
devin-ai-integration[bot]

This comment was marked as resolved.

The skipped-symlink finding stored the escaped and truncated display text in file_path. SARIF reads file_path as a real path, so a non-ASCII or long link name pointed at a file that does not exist. Store the exact relative path in file_path and apply the display helper to the message only.

Signed-off-by: Christopher Kevin <christopherk@nvidia.com>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I reproduced two ways an outside link can still affect a Tier 1 report.

Comment thread src/skillevaluator/validators/base.py Resolved

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I also reproduced a license-policy result based on a file outside the skill.

Comment thread CHANGELOG.md Resolved
The dependency audit built requirements.txt and requirements-dev.txt
paths directly and read them with read_text, so a symlink at either
name pointed the audit at a file outside the skill, and every unpinned
line was quoted verbatim in a warning. The same run also reported that
link as skipped, so the two checks contradicted each other.

The audit now skips a requirements file that is a symlink resolving
outside the skill, leaving the symlink_outside_skill finding as the only
record of it, and the unpinned-dependency warning quotes only the parsed
package name instead of the whole line.

Refs #833

Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
@chrisknvidia

Copy link
Copy Markdown
Collaborator Author

Follow-up pushed: the hygiene dependency audit opened requirements.txt / requirements-dev.txt directly (not via the walker), so a symlink at either name was still read and each unpinned line quoted verbatim in a warning, while the same run reported the link as skipped. The audit now applies the same inside-the-skill check and the unpinned warning quotes only the package name. Tests added for outside link (not read), inside link (still audited), and the message shape.

os.walk only withholds symlinked directories, so it entered a junction
as a plain directory and the scanners read files behind it. Drop
junctions before the walk descends and report the ones whose target is
outside the skill with the same symlink_outside_skill finding.

Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
The license check read root LICENSE and COPYING files directly, so a
symlink to an outside Apache-2.0 file made a skill with no declared
license report Apache-2.0 as allowed. Skip links that leave the skill
without reading them; symlink_outside_skill still reports them.
Update the changelog entry to cover junctions and these root files.

Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
@chrisknvidia
chrisknvidia merged commit f3f3c09 into main Nov 20, 2026
24 checks passed
@chrisknvidia
chrisknvidia deleted the fix/tier1-symlink-scan-boundary branch November 20, 2026 19:03
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.

2 participants