* fix(analyzer): stabilize TM1 window identity
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
* fix(analyzer): track eager receiver side effects
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
* feat(python): refresh execution surfaces on current main
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix(analyzer): preserve lexical TM1 when dataflow abstains
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix(analyzer): require a retained companion owner
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix(analyzer): preserve execution scope in binding evidence
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix(analyzer): preserve lexical TM1 across conservative Python analysis
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* style(analyzer): simplify binding event deduplication
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix: preserve runtime and retained shell evidence
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix: preserve runtime and retained shell evidence
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix(analyzer): preserve called-slot identity and cached method evidence
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix(analyzer): preserve called-slot identity and cached method evidence
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix: preserve cached subprocess slot state across scoped imports
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
* fix: preserve cached subprocess slot state across scoped imports
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
* fix(analyzer): reconcile explicit cached-slot evidence across scopes
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix(analyzer): reconcile explicit cached-slot evidence across scopes
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix: abstain from cached slot proof after eager effects
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
* fix: abstain from cached slot proof after eager effects
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
* test: retain lexical findings after unknown cached-slot effects
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* test: retain lexical findings after unknown cached-slot effects
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix: bound direct called-slot evidence to known execution order
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix: bound direct called-slot evidence to known execution order
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix: limit direct slot proof to single assignment targets
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix: limit direct slot proof to single assignment targets
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix: invalidate slot evidence on protocols and unsafe releases
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
* fix: invalidate slot evidence on protocols and unsafe releases
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
* fix: keep legacy shadow proof isolated from later effects
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix: keep legacy shadow proof isolated from later effects
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix: abstain from cached replacement proof after unknown effects
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
* fix: abstain from cached replacement proof after unknown effects
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
* fix: retain native callable detection across cached slot stores
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
* fix: retain native callable detection across cached slot stores
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
* fix: retain shell findings for native receiver assignments
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix: retain shell findings for native receiver assignments
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix: preserve native Popen replacement warnings
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* fix: preserve native Popen replacement warnings
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
* test: retain occurrence metadata in prose shell reports
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
* fix(analyzer): require proven replacement before revoking lexical TM1
Address the three remaining review findings on lexical TM1 reconciliation,
where a bound shell=True call still ran natively but lost its HIGH finding:
- Untaken expression stores: a walrus in a short-circuited BoolOp operand,
an untaken conditional-expression arm, or a comprehension/generator body
is no longer recorded as replacement evidence. Only constant operands
and tests prove that the store executed.
- Identity-preserving stores: unpacked targets are paired with their RHS
elements. Self-stores are transparent, truthy constants keep the flag,
and native receiver aliases (saved = subprocess, import subprocess as
saved, Popen = subprocess.Popen) keep the native receiver.
- Deferred bodies: an outer store only proves replacement when every
invocation the owner scope can reach sees it. Any reference to the
function, method or class (compound statements, main guards, callbacks,
other bodies) can invoke it from that point on, and decorators or
lambdas can run once defined. This also covers a re-import before a
later invocation.
The release-trigger test for a called function now matches its
module-level twin: the companion abstains and the lexical HIGH remains.
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(analyzer): require proven replacement before revoking lexical TM1
Address the three remaining review findings on lexical TM1 reconciliation,
where a bound shell=True call still ran natively but lost its HIGH finding:
- Untaken expression stores: a walrus in a short-circuited BoolOp operand,
an untaken conditional-expression arm, or a comprehension/generator body
is no longer recorded as replacement evidence. Only constant operands
and tests prove that the store executed.
- Identity-preserving stores: unpacked targets are paired with their RHS
elements. Self-stores are transparent, truthy constants keep the flag,
and native receiver aliases (saved = subprocess, import subprocess as
saved, Popen = subprocess.Popen) keep the native receiver.
- Deferred bodies: an outer store only proves replacement when every
invocation the owner scope can reach sees it. Any reference to the
function, method or class (compound statements, main guards, callbacks,
other bodies) can invoke it from that point on, and decorators or
lambdas can run once defined. This also covers a re-import before a
later invocation.
The release-trigger test for a called function now matches its
module-level twin: the companion abstains and the lexical HIGH remains.
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test: account for TM1 Python parsing in marker ownership ledger
Main's #784 test expects the tool-misuse ledger event for an invalid
Python file to carry obfuscated_instruction_text. This PR makes tool
misuse parse Python for TM1 reconciliation, so the runner's
higher-precedence syntax_error now names that partial event. Keep the
fail-closed contract: assert the marker reading through the lexical-only
anti-refusal analyzer and keep tool misuse partial with syntax_error.
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test: account for TM1 Python parsing in marker ownership ledger
Main's #784 test expects the tool-misuse ledger event for an invalid
Python file to carry obfuscated_instruction_text. This PR makes tool
misuse parse Python for TM1 reconciliation, so the runner's
higher-precedence syntax_error now names that partial event. Keep the
fail-closed contract: assert the marker reading through the lexical-only
anti-refusal analyzer and keep tool misuse partial with syntax_error.
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(analyzer): keep one TM1 owner for true-prefixed names without AST proof
Port the six true-prefixed TM1 regression tests from #577. This branch
already carries test_true_direct_calls_on_one_line_keep_distinct_locations
unchanged, so only the other five are added. Two of them reported the
same call twice on this branch:
- A variable window for a name spelled `true` (in any case) duplicated
the case-insensitive direct `shell=True` owner at the same call. AST
reconciliation removes that window only when the dataflow companion
takes the call, so a file that does not parse, or a call after an
unknown receiver effect, kept both findings. coalesce_path_findings
now drops such a window when a direct lexical owner starts at the
same call. A window for a call whose direct candidate was folded into
an identical same-line call still reports that call.
- A call-anchored window for a longer true-prefixed name (`true_value`)
used its raw text as identity, so the raw and normalized security
views of one call did not collapse, and reconciliation then moved both
to the call. The window now takes its identity from the normalized
view text, as the direct owner already does.
Also cover both root causes with a test for a nested `true` call after
an unknown receiver effect and a normalized `true_value` call in a file
that does not parse.
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(analyzer): keep one TM1 owner for true-prefixed names without AST proof
Port the six true-prefixed TM1 regression tests from #577. This branch
already carries test_true_direct_calls_on_one_line_keep_distinct_locations
as test_true_direct_calls_around_safe_comprehension_keep_distinct_locations,
so only the other five are added. Two of them reported the same call twice
on this branch:
- A variable window for a name spelled `true` (in any case) duplicated
the case-insensitive direct `shell=True` owner at the same call. AST
reconciliation removes that window only when the dataflow companion
takes the call, so a file that does not parse, or a call after an
unknown receiver effect, kept both findings. coalesce_path_findings
now drops such a window when a direct lexical owner starts at the
same call. A window for a call whose direct candidate was folded into
an identical same-line call still reports that call.
- A call-anchored window for a longer true-prefixed name (`true_value`)
used its raw text as identity, so the raw and normalized security
views of one call did not collapse, and reconciliation then moved both
to the call. The window now takes its identity from the normalized
view text, as the direct owner already does.
Also cover both root causes with a test for a nested `true` call after
an unknown receiver effect and a normalized `true_value` call in a file
that does not parse.
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(analyzer): report each true-prefixed shell call that #577 reports
The `\b`-bounded direct pattern does not match `shell=true_value`, so on
this branch such a call was reported only through a variable window. That
window pairs an assignment with a single call, skips an assignment
inside an earlier window, and was dropped outside Python. Compared with
#577 this lost:
- calls in JavaScript and Markdown files, fenced or plain;
- a later call that the AST companion abstains on, for example after an
unknown receiver effect;
- all but the last same-line call in a file that does not parse, and the
second of two identical same-line `shell=true` calls outside Python,
which the direct candidate key folds into one;
- a call whose assignment sits inside the window of an earlier one.
_variable_shell_matches now pairs every assignment of a true-prefixed
name with each call its bounded window reaches, and the nearest
assignment owns each call. Candidate generation, analysis and AST
reconciliation share that list, and a window's candidate identity uses
its full text, so windows to different calls do not collapse on a shared
200-character preview. Outside Python, call-anchored windows for
true-prefixed names are kept, and coalescing still drops one when a
direct owner reports the same call. With an AST, each added window
passes the same visibility, counterevidence, cached replacement and
companion checks as before. Windows for other names are unchanged.
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(analyzer): report each true-prefixed shell call that #577 reports
The `\b`-bounded direct pattern does not match `shell=true_value`, so on
this branch such a call was reported only through a variable window. That
window pairs an assignment with a single call, skips an assignment
inside an earlier window, and was dropped outside Python. Compared with
#577 this lost:
- calls in JavaScript and Markdown files, fenced or plain;
- a later call that the AST companion abstains on, for example after an
unknown receiver effect;
- all but the last same-line call in a file that does not parse, and the
second of two identical same-line `shell=true` calls outside Python,
which the direct candidate key folds into one;
- a call whose assignment sits inside the window of an earlier one.
_variable_shell_matches now pairs every assignment of a true-prefixed
name with each call its bounded window reaches, and the nearest
assignment owns each call. Candidate generation, analysis and AST
reconciliation share that list, and a window's candidate identity uses
its full text, so windows to different calls do not collapse on a shared
200-character preview. Outside Python, call-anchored windows for
true-prefixed names are kept, and coalescing still drops one when a
direct owner reports the same call. With an AST, each added window
passes the same visibility, counterevidence, cached replacement and
companion checks as before. Windows for other names are unchanged.
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(supply-chain): opt into Python source-type propagation
SC2's literal-XOR decoding and SC3 branch on file_type, but the
supply-chain analyzer was not in the USES_PYTHON_SOURCE_TYPE set, so
Python executed through an extensionless shebang file or a shebang
Markdown file received its suffix type and silently lost the decoded
SC2 HIGH while completeness stayed true. Opt the module in and add
graph-level parity tests for .py, .pyw, extensionless and .md surfaces.
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(build-context): decode PEP 263 primary Python before UTF-8 rejection
A selected primary file (direct .py/.pyw or extensionless Python
shebang) declaring a supported PEP 263 encoding such as latin-1 was
rejected as unsupported_primary_content because the generic primary
check only accepts UTF-8. The later source-decoding pass then decoded
it correctly, but the artifact stayed FAILED with a fatal event and 0%
coverage. Waive the generic UTF-8 rejection when the bytes classify as
Python and decode under their declared encoding; an unknown codec or
bytes invalid for the declared codec remain fatal, and format checks
(BOMs, archives, NUL density) are unchanged. The waiver is evaluated
lazily and not after the shared deadline, so no post-cache Python work
starts once the budget is spent.
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
Signed-off-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-authored-by: Christopher Kevin <256191862+chrisknvidia@users.noreply.github.com>
Co-authored-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* feat(input): support GitHub tree subdirectories
Signed-off-by: Deepak Jain <deepujain@gmail.com>
* fix(input): reject encoded Git tree path escapes
Signed-off-by: Deepak Jain <deepujain@gmail.com>
* fix(input): clean failed GitHub tree selections
Signed-off-by: Deepak Jain <deepujain@gmail.com>
* fix(input): resolve longest valid ref for GitHub tree URLs
GitHub branch names may contain slashes, so the first /tree/ segment is
not necessarily the complete ref. Resolve the longest advertised
branch/tag name via git ls-remote before splitting ref from subdirectory,
and reject URLs that name no known ref. Adds slash-ref regressions.
Signed-off-by: Deepak Jain <deepujain@gmail.com>
---------
Signed-off-by: Deepak Jain <deepujain@gmail.com>
The input handler already routes a forge "/blob/" URL to the file
download path instead of a clone, but it downloaded the URL as given.
On github.com and gitlab.com that URL is the HTML file viewer, so the
scan analysed the forge's page markup as the skill: scanning a clean
SKILL.md through its GitHub /blob/ URL reported a 286 KB SKILL.md and
DO_NOT_INSTALL.
Rewrite those URLs to the raw file (raw.githubusercontent.com for
GitHub, /-/raw/ for GitLab) before downloading. Hosts stay inside the
existing download allowlist, and other URLs are unchanged.
Signed-off-by: kevin9327 <5299031+kevin9327@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Two cases prove the failed-secure-open contract by patching
skillspector.input_handler.os.open. _HAS_SECURE_DIR_FD is False on
Windows, so _open_regular_file_no_follow dispatches to
_open_regular_file_from_windows_handle and os.open is never called. The
failure is never injected there: the file is read normally, and both
cases fail while asserting the contract they exist to protect.
Deny both primitives so the failure reaches the dispatcher on either
platform. The Windows stub raises _FileOpenError, which is what the real
helper raises when CreateFileW fails.
Signed-off-by: kevin9327 <kevin9327@users.noreply.github.com>
Co-authored-by: kevin9327 <kevin9327@users.noreply.github.com>
The descriptor-relative open walks every component from the filesystem
root with O_RDONLY | O_DIRECTORY | O_NOFOLLOW. O_RDONLY demands read
access on each ancestor, including "/", but traversal only needs search
access. Sandboxes that grant access per path hierarchy -- Landlock,
systemd ProtectSystem, containers with restricted mounts -- do not grant
read on "/", so the very first open fails with EACCES and every scan
reports "Could not safely open file".
Use O_PATH for the intermediate directory descriptors where it exists.
It requires only search access, and the resulting descriptor is still
valid for the relative openat() calls this walk performs. Elsewhere
(macOS, Windows) getattr falls back to O_RDONLY, i.e. 0, leaving the
flags unchanged.
The symlink guarantees are unaffected: O_DIRECTORY still rejects a
symlinked intermediate component with ENOTDIR, and the final component
is still opened with O_RDONLY | O_NOFOLLOW, so a symlinked target still
fails with ELOOP. Both errnos already map to _UnsafeFileError.
Signed-off-by: Bevan Kay <email@bevankay.me>