Skip to content

fix(analyzer): align file-size guard with character semantics (#284)#287

Open
rodboev wants to merge 1 commit into
NVIDIA:mainfrom
rodboev:pr/clarify-char-file-limit
Open

fix(analyzer): align file-size guard with character semantics (#284)#287
rodboev wants to merge 1 commit into
NVIDIA:mainfrom
rodboev:pr/clarify-char-file-limit

Conversation

@rodboev

@rodboev rodboev commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

The analyzer file-size guard already measures decoded Python characters, but the shared constant name and skip logs still describe that threshold as bytes. Multibyte UTF-8 content therefore follows the current compatibility policy while being reported with the wrong unit.

Closes #284

Root cause

src/skillspector/nodes/analyzers/static_runner.py owns the shared analyzer size guard, and every affected analyzer compares len(content) on decoded str content against that constant. The value and behavior were already character-based; only the constant name, skip logs, and one adjacent _agent_cli.py comment still claimed byte semantics.

Diff Notes

  • Renamed MAX_FILE_BYTES to MAX_FILE_CHARS in src/skillspector/nodes/analyzers/static_runner.py and updated static patterns, YARA, behavioral AST, and behavioral taint consumers to import the renamed authority.
  • Updated static-runner and YARA oversize skip logs to report character units instead of bytes.
  • Rewrote the _agent_cli.py cap comment so the analyzer character limit and the CLI's encoded-byte limit are described as separate guards.
  • Added focused boundary, over-boundary, multibyte-under-limit, later-component-continuation, and log-wording coverage in tests/nodes/analyzers/test_static_runner_filtering.py, tests/nodes/analyzers/test_static_yara.py, tests/nodes/analyzers/test_behavioral_ast.py, and tests/nodes/analyzers/test_behavioral_taint_tracking.py.

Scope

This keeps the existing one-million-character analyzer policy and per-file skip behavior. It does not switch analyzers to encoded-byte limits, change build_context size_bytes metadata, touch input acquisition or report schemas, or alter _agent_cli.py runtime behavior.

Verification

  • uv sync --all-extras passed; Resolved 156 packages in 0.88ms and Checked 151 packages in 3ms.
  • cmd.exe /d /s /c "set PYTHONPATH=src&& .\.venv\Scripts\python.exe -m pytest tests\nodes\analyzers\test_static_runner_filtering.py tests\nodes\analyzers\test_static_yara.py tests\nodes\analyzers\test_behavioral_ast.py tests\nodes\analyzers\test_behavioral_taint_tracking.py" passed; 206 passed in 44.64s.
  • uv run ruff check src/ tests/ passed.
  • uv run ruff format --check src/ tests/ passed.
  • git diff --check passed.

@koriyoshi2041 koriyoshi2041 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The character-based policy is applied consistently across the four analyzer paths, and the renamed constant/log wording now matches the actual len(str) guard. The boundary and multibyte cases also preserve the existing behavior explicitly.

I ran the four focused analyzer test modules on this head: 206 passed.

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.

Clarify MAX_FILE_BYTES character-based size limit

2 participants