Use byte offsets for YARA line lookup - #364
Open
rng1995 wants to merge 2 commits into
Open
Conversation
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
rng1995
force-pushed
the
agent/yara-byte-offset-lines
branch
from
August 12, 2026 05:11
5429c13 to
3545a85
Compare
rng1995
commented
Aug 12, 2026
rng1995
marked this pull request as ready for review
August 12, 2026 08:28
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
rng1995
force-pushed
the
agent/yara-byte-offset-lines
branch
from
August 12, 2026 08:36
f5f9941 to
b2fc637
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira
Jira: SKILLSPECT-12
Deliverable #3: Use byte offsets for YARA line lookup
Summary
yara-pythonmatch offsets as byte offsets against the exact UTF-8 buffer scanned by YARA.Problem
static_yaraencodes skill content to UTF-8 before callingrules.match(data=...), so everyStringMatchInstance.offsetis a byte position. The analyzer previously passed those positions to helpers that sliced the original Pythonstras though they were character positions.For content containing multibyte Unicode before a match, this could:
ASCII-only content masked the mismatch because its byte and character positions are identical.
Implementation
bytesbuffer.start_linefrom the YARA byte offset.Security invariants
rm -rf /blocking remains unchanged.User impact
YARA findings now point to the correct line and context in files containing multibyte Unicode. The destructive/autonomy locality guard also remains accurate regardless of the characters preceding its evidence.
Validation
62 passedintests/nodes/analyzers/test_static_yara.py.git diff --checkpassed.Files changed
src/skillspector/nodes/analyzers/static_yara.pytests/nodes/analyzers/test_static_yara.py