Custom YARA rules that fail to compile are dropped silently: static_yara still reports completed and SAFE
メンテナーはふだん 4 日以内に返信
評価
調査の方向性
src/skillspector/nodes/analyzers/static_yara.py の 356、383、425 行目から開始し、degraded ステータスを生成する既存のルールサイズ制限処理と比較してください。Issue にある不正なルールのコマンドを再現し、スキップされたファイルが検査台帳に到達するまでの流れを追跡してください。スキップされたファイルについて警告され、analyzer が部分的な完全性で degraded を報告し、--fail-on-incomplete が 1 で終了すれば完了です。報告されたコンパイル失敗とデコード失敗のテストを追加してください。
索引モデルが issue の本文から書いたものです。
説明
Summary
A rule file passed through --yara-rules-dir that YARA cannot compile, or that SkillSpector cannot decode as UTF-8, is dropped whole and nothing is printed at the default log level. The report still says static_yara: completed and analysis_completeness: complete, the recommendation stays SAFE, and --fail-on-incomplete exits 0. Anyone gating a pipeline on their own detections gets a green scan from rules that never ran.
Environment
- SkillSpector 2.11.2 built from source at
9749372(currentmain) - Windows 10 19045, CPython 3.12.4, yara-python 4.5.4, console code page cp950
- Same result on Ubuntu 24.04 (WSL2), CPython 3.12.3, yara-python 4.5.4, clean non-editable install of the same commit
Reproduction
mkdir -p demo-skill rules-ok rules-typo
printf -- '---\nname: demo-skill\ndescription: demo skill for a custom YARA rule\n---\nThis skill body contains ACME_CANARY_TOKEN_123.\n' > demo-skill/SKILL.md
cat > rules-ok/acme.yar <<'EOF'
rule acme_canary
{
meta:
category = "malware"
description = "custom canary"
strings:
$a = "ACME_CANARY_TOKEN_123"
condition:
$a
}
EOF
sed 's/^ \$a$/ $a and/' rules-ok/acme.yar > rules-typo/acme.yar # breaks line 9; YARA reports it at line 10, the closing brace
skillspector scan demo-skill --no-llm --fail-on-incomplete --yara-rules-dir rules-ok --format json -o ok.json; echo "ok exit=$?"
skillspector scan demo-skill --no-llm --fail-on-incomplete --yara-rules-dir rules-typo --format json -o typo.json; echo "typo exit=$?"
Output (identical on Windows and Linux; fields read back from the JSON reports):
ok exit=0
typo exit=0
ok CAUTION [('YR1', 'CRITICAL')] static_yara=completed completeness=complete
typo SAFE [] static_yara=completed completeness=complete
The only trace is below the default log level:
SKILLSPECTOR_LOG_LEVEL=DEBUG skillspector scan demo-skill --no-llm --yara-rules-dir rules-typo ...
DEBUG [skillspector.nodes.analyzers.static_yara] static_yara: skipping acme: line 10: syntax error, unexpected '}'
INFO [skillspector.nodes.analyzers.static_yara] static_yara: compiled 5 YARA rule file(s) (1 skipped)
Expected vs actual
Expected: a rule file that does not load is reported at the default log level, and the scan does not claim the YARA analyzer completed.
Actual: no output at all, static_yara: completed, complete, SAFE, exit 0.
Two more triggers with the same outcome:
- A UTF-8 BOM at the start of the rule file. YARA rejects it (
line 1: non-ascii character), andSet-Content -Encoding UTF8in Windows PowerShell 5.1 (5.1.19041.6456) writesef bb bf, so this is easy to hit when authoring rules on Windows. - A non-UTF-8 byte in a comment, for example cp1252
ü.yara.compile(filepath=...)accepts that file, SkillSpector discards it and logsskipping malformed encoded rule <path>: 'utf-8' codec can't decode byte 0xfc .... That message names encoded rules but also fires for a plain.yar.
For contrast, other rule-load problems are visible: a missing --yara-rules-dir warns at the default level, and a rule file over 1 MiB yields static_yara: degraded, completeness: partial, exit 1.
Where (at 9749372)
src/skillspector/nodes/analyzers/static_yara.py:383per-source compile failure goes tologger.debugsrc/skillspector/nodes/analyzers/static_yara.py:356decode failure goes tologger.debugsrc/skillspector/nodes/analyzers/static_yara.py:425the skipped count is only an INFO total and never reaches the ledger or the analyzer status
Proposed fix
Log each skipped rule file at WARNING with its path and reason, and record the skip in the inspection ledger with LedgerOutcome.PARTIAL so static_yara reports degraded and --fail-on-incomplete exits 1, matching what the rule size limit already does (that status follows from any PARTIAL/SKIPPED event regardless of reason code). Either reuse the existing LedgerReason.RULES_UNAVAILABLE, or add a more precise reason if its message ("rules were unavailable before execution") reads wrong for a single skipped file among several that loaded fine.
One design question: should any skipped rule file degrade the scan, or only files from --yara-rules-dir? Happy to open the PR with tests if you agree with the approach.
- 主要言語
- Python
- スター
- 23.2k
- フォーク
- 2k
- 平均マージ
- 6日 2時間
- マージ済み PR(30日)
- 132
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NVIDIA/SkillSpector のほかの issue
-
RP1 `npx` pattern matches across line breaks, so a line ending in "npx" plus the next word becomes a command対応中かも @agentsope が 38 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
NVIDIA/SkillSpector#639 · コメント 2 件 ·
メンテナーはふだん 4 日以内に返信
-
Quoted version metadata creates a false missing-file reference and changes score 0 from SAFE to CAUTION対応中かも @goodhee が 54 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
NVIDIA/SkillSpector#524 · コメント 2 件 ·
メンテナーはふだん 4 日以内に返信
-
compare_scan_accuracy: editable-dependency file:// URL resolves to "C:\C:\..." on Windows対応中かも @mohgupta-ship-it が 59 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
NVIDIA/SkillSpector#485 · コメント 4 件 ·
メンテナーはふだん 4 日以内に返信
-
E2 shell arm matches one `env | grep` spelling: a second grep flag, quotes, or egrep all evade "Env Variable Harvesting"対応中かも @MandoCodes1 が 60 日前に担当しました。 オープン
難易度 2/5 半日 初心者へのやさしさ 78/100
NVIDIA/SkillSpector#482 · コメント 2 件 ·
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
NVIDIA/SkillSpector#444 · コメント 2 件 ·
メンテナーはふだん 4 日以内に返信
NVIDIA/SkillSpector の issue をすべて見る
似ている issue
-
Server mode OAuth2: 'NoneType' object is not subscriptable on every request after re-submitting the OAuth2 login while already logged in対応中かも @Rarasinhoo が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
pgadmin-org/pgadmin4#10733 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
aws-samples/sample-per-model-bedrock#752 ·
メンテナーはふだん 1 日以内に返信
-
lesson-submission pending-review
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
Ikalus1988/MisakaNet#4452 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
OCHA-DAP/topo-tools#250 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信