Skip to content

Scope the locality guard to the namespace - #365

Merged
keshprad merged 2 commits into
mainfrom
agent/yara-locality-namespace
Aug 14, 2026
Merged

Scope the locality guard to the namespace#365
keshprad merged 2 commits into
mainfrom
agent/yara-locality-namespace

Conversation

@rng1995

@rng1995 rng1995 commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Restrict the destructive/autonomy locality post-filter to the packaged agent_skills namespace.
  • Keep the existing rule-name check as the second half of the rule identity.
  • Add regression coverage for a user-supplied rule that intentionally reuses the built-in rule name.

Problem

SkillSpector compiles built-in and user-supplied YARA files into separate namespaces, but the locality guard introduced for agent_skill_destructive_autonomous_actions previously checked only match.rule.

Because YARA rule names need only be unique within a namespace, a user rule can legally use the same name with unrelated string identifiers and semantics. The built-in post-filter would then inspect that custom match, find no built-in destructive/autonomy identifiers, and silently discard a valid user-defined finding.

Implementation

  • Define the packaged destructive-action namespace as agent_skills.
  • Apply the locality filter only when both namespace and rule name identify the built-in rule.
  • Leave all other namespaces on the normal finding path, including same-named user rules.

Security invariants

  • The built-in cross-context false-positive suppression remains unchanged.
  • Built-in local destructive/autonomy evidence still produces a HIGH finding.
  • Built-in rm -rf / detection remains unconditionally blocking.
  • User-supplied rules are no longer altered solely because their rule name collides with a built-in rule in another namespace.

User impact

Custom YARA rules retain their declared behavior even when their rule names collide with built-in rules in a different namespace. The packaged destructive-action guard continues to suppress only its intended cross-context false positives.

Validation

  • 61 passed in tests/nodes/analyzers/test_static_yara.py.
  • Added a regression proving built-in directory precedence is preserved even when a same-named user rule path sorts first.\n- The regression also proves the packaged distant-evidence match is locality-filtered while the user-namespaced match is reported.
  • Existing regressions for distant built-in evidence, local destructive/autonomy evidence, and root deletion all pass.
  • Ruff lint and format checks passed for both changed files.
  • git diff --check passed.

Files changed

  • src/skillspector/nodes/analyzers/static_yara.py
  • tests/nodes/analyzers/test_static_yara.py

@rng1995
rng1995 force-pushed the agent/yara-locality-namespace branch from f805215 to bba2aa8 Compare August 12, 2026 05:11
Comment thread src/skillspector/nodes/analyzers/static_yara.py
@rng1995
rng1995 marked this pull request as ready for review August 12, 2026 08:28
@rng1995
rng1995 force-pushed the agent/yara-locality-namespace branch from c5e93e4 to d7b45d1 Compare August 12, 2026 08:36
@rng1995
rng1995 requested a review from keshprad August 12, 2026 08:48
@keshprad
keshprad force-pushed the agent/yara-locality-namespace branch from 1c61923 to 550d358 Compare August 14, 2026 21:12
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
@keshprad
keshprad force-pushed the agent/yara-locality-namespace branch from 415115b to c3c437d Compare August 14, 2026 22:47

@keshprad keshprad left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the namespace-scoped locality guard, packaged namespace precedence, and the rebase resolution preserving byte-offset handling from #364. The focused YARA suite passes 64 tests, Ruff passes, all required CI checks are green, and the sole review thread is resolved. No blocking findings.

@keshprad
keshprad merged commit 5680c2c into main Aug 14, 2026
5 checks passed
@keshprad
keshprad deleted the agent/yara-locality-namespace branch August 14, 2026 23:10
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