Skip to content

Clear error when injections references an unknown inline YARA rule - #2238

Draft
kilanassah wants to merge 1 commit into
NVIDIA-NeMo:developfrom
kilanassah:fix/2170-injection-rule-name-validation
Draft

Clear error when injections references an unknown inline YARA rule#2238
kilanassah wants to merge 1 commit into
NVIDIA-NeMo:developfrom
kilanassah:fix/2170-injection-rule-name-validation

Conversation

@kilanassah

@kilanassah kilanassah commented Jul 30, 2026

Copy link
Copy Markdown

Fixes #2170.

Raise a descriptive ValueError when an inline YARA rule referenced by injections isn't present in yara_rules.

Previously the missing rule surfaced as a bare KeyError, which made the misconfiguration hard to diagnose.

Adds a regression test for the missing-rule case.

…n inline rule

`_load_rules` filtered `yara_rules` by intersection with the requested
`rule_names` but then re-indexed the dict with *every* requested name, so a
name present in `injections` but absent from the inline `yara_rules` raised a
bare `KeyError` with no context.

Validate the requested names against the available inline rules up front and
raise a descriptive `ValueError` naming the missing rule(s) and listing the
available ones — matching the existing error convention in the `yara_path`
branch. Behaviour is unchanged when all names are present. Adds a CPU-only
regression test.

Fixes NVIDIA-NeMo#2170

Signed-off-by: operator <131236286+kilanassah@users.noreply.github.com>
@github-actions github-actions Bot added size: S status: needs triage New issues that have not yet been reviewed or categorized. labels Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: S status: needs triage New issues that have not yet been reviewed or categorized.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

injection_detection: opaque KeyError when inline yara_rules miss a requested injection name

1 participant