Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@ All notable changes to SkillEvaluator are documented in this file.
inspection rather than observed unsafe behavior. The Tier 3 guide lists the
forms that are not read. Both the host checker and the bundled Harbor
verifier apply the fix.
- Incomplete SkillSpector scans now quote the parser span, cause, and check from
`parser_diagnostic` on `static_parse_limit` rows that have no line of their own,
keep a bounded copy of that diagnostic in `skillspector_completeness`, and, when
every such row is `runtime_dependent`, explain that SkillSpector could not resolve
a command or code string known only at run time. The check stays `INCOMPLETE`.
An AE1 finding for that file now names the same lines in its suggestion, such
as `static_parse_limit (static_patterns_tool_misuse) at target lines 74-170`:
SkillSpector leaves `parser_diagnostic` out of the finding's `evidence.reasons`,
so the span comes from the one `analysis_completeness.ledger_exceptions` row
with the same path and `reason_code`, and none is shown when several rows
match. That reason in `skillspector_evidence.reasons` carries
`line_source: "parser_diagnostic"`. Because the suggestion text changes, the `finding_id` of each such AE1
finding changes once with this release.

## 1.0.1 - 2026-11-17

Expand Down
26 changes: 25 additions & 1 deletion docs/tier1-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,30 @@ Tier 1 checks always gate the exit code inside `validate`. Tier 2 gates when it
<Accordion title="SkillSpector reports incomplete analysis for a valid helper script">
SkillSpector releases before v2.13.1 can stop inspecting a valid Python or Perl helper early and record a `static_parse_limit`, `obfuscated_instruction_text`, or `runtime_limit` ledger exception. The security check is then `INCOMPLETE`, often with a High **Incomplete referenced artifact analysis (AE1)** finding at each line that names the helper. The finding's suggestion names the helper and the reason, such as `static_parse_limit (static_patterns_tool_misuse)`. Check the resolved release with `skillevaluator doctor --tier 1` and follow [scanner setup](/skills/skillevaluator/installation-options#system-tools) to update an older installation. If the exception remains after the upgrade, investigate it like any other incomplete scan.
</Accordion>
<Accordion title="SkillSpector reports incomplete analysis for a JavaScript helper">
SkillSpector 2.13.4 through 2.13.6 can stop inspecting a JavaScript helper
(`.js`, `.mjs`, `.cjs`) or another script when a command or code string is
only known at run time, for example `spawnSync(process.execPath, [helper,
...process.argv.slice(2)])`. It records a `static_parse_limit` ledger
exception whose `start_line` is empty and whose `parser_diagnostic` names
the span, `cause` (`runtime_dependent`), and `check`
(`command_string_runtime`). The security check stays `INCOMPLETE`. The
error now labels that row as `scripts/helper.mjs:74-170 [static;
static_parse_limit; runtime_dependent command_string_runtime;
analyzers=static_patterns_tool_misuse]` and adds a short hint to review
those lines and prefer fixed argument lists. An AE1 finding for a skill
line that names the helper quotes the same span in its suggestion
(`at target lines 74-170`), read from that ledger row; the reason in
its `skillspector_evidence` metadata has
`line_source: "parser_diagnostic"`. Updating SkillSpector does
not clear this limit today. If the helper is valid and the command is
safe, report a minimal reproducer to SkillSpector. JSON reports keep a
bounded `parser_diagnostic` on the matching
`skillspector_completeness` row (`cause`, `check`, `start_line`,
`end_line`, `unchecked_scope`, `full_input_checked`; never source text or
byte offsets). These diagnostics never turn an incomplete scan into a
pass.
</Accordion>
<Accordion title="SkillSpector could not fully model the hooks">
With SkillSpector v2.12.0 and later, a skill, folder or hooks-only plugin
with an ordinary command or HTTP hook fails the security check with the
Expand Down Expand Up @@ -976,7 +1000,7 @@ Tier 1 checks always gate the exit code inside `validate`. Tier 2 gates when it

SkillSpector v2.13.4 also reads a hook's `"timeout"` key as a command
wrapper it cannot resolve and records
`hooks/hooks.json [static; static_parse_limit; analyzers=static_patterns_tool_misuse]`.
`hooks/hooks.json:11 [static; static_parse_limit; boundary_unresolved command_word_boundary; analyzers=static_patterns_tool_misuse]`.
That row is an ordinary analysis gap, so with v2.13.4 the SkillSpector
scan of such a manifest is also recorded as incomplete (`incomplete_scans`
in the JSON report, and publication eligibility **Incomplete**), with an
Expand Down
27 changes: 27 additions & 0 deletions src/skillevaluator/skillspector_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,30 @@ def _count(value: object) -> int:
return value if type(value) is int and 0 <= value <= 1_000_000_000 else 0


def _line_number(value: object) -> int | None:
return value if type(value) is int and 0 < value <= 1_000_000_000 else None


def parser_diagnostic_record(value: object) -> dict | None:
"""Project ``parser_diagnostic`` without source text or byte offsets."""
if not isinstance(value, dict):
return None
item: dict = {}
for key in ("cause", "check", "unchecked_scope"):
raw = value.get(key)
if isinstance(raw, str) and raw.strip():
item[key] = _text(raw)
start = _line_number(value.get("start_line"))
end = _line_number(value.get("end_line"))
if start is not None and end is not None and end >= start:
item["start_line"] = start
item["end_line"] = end
checked = value.get("full_input_checked")
if type(checked) is bool:
item["full_input_checked"] = checked
return item or None


def completeness_record(completeness: dict, stage: str) -> dict:
"""Project only diagnostic fields; do not copy arbitrary scanner payloads."""
rows = completeness.get("ledger_exceptions")
Expand All @@ -45,6 +69,9 @@ def completeness_record(completeness: dict, stage: str) -> dict:
if isinstance(analyzers, list):
item["analyzers"] = [_text(value) for value in analyzers[:8]]
item["omitted_analyzers"] = max(0, len(analyzers) - 8) + _count(row.get("omitted_analyzers"))
diagnostic = parser_diagnostic_record(row.get("parser_diagnostic"))
if diagnostic is not None:
item["parser_diagnostic"] = diagnostic
exceptions.append(item)
return {
"stage": stage if isinstance(stage, str) and stage in {"skillspector", "skillspector-llm"} else "unknown",
Expand Down
95 changes: 88 additions & 7 deletions src/skillevaluator/skillspector_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
# must stay the same across runs, so it shows only the limits that the file and
# the configuration fix; the finding's metadata keeps every limit.
_RUN_DEPENDENT_LIMITS = frozenset(field for field, seconds in _LIMIT_FIELDS if seconds)
# A reason's ``line_source`` when its lines come from a ``parser_diagnostic``.
# Only such a span is quoted as a range: a row's own end_line stays in
# metadata and must not change grouping or finding IDs.
_PARSER_DIAGNOSTIC = "parser_diagnostic"


def diagnostic_text(value: object, *, max_length: int = 4096) -> str | None:
Expand Down Expand Up @@ -192,6 +196,15 @@ def _reasons(rows: object, text: Callable[..., str | None]) -> list[dict]:
for field in ("start_line", "end_line"):
if (line := _line(row.get(field))) is not None:
reason[field] = line
if "start_line" not in reason:
Comment thread
rng1995 marked this conversation as resolved.
Resolved
diagnostic = row.get("parser_diagnostic")
if isinstance(diagnostic, dict):
start = _line(diagnostic.get("start_line"))
end = _line(diagnostic.get("end_line"))
if start is not None and end is not None and end >= start:
reason["start_line"] = start
reason["end_line"] = end
reason["line_source"] = _PARSER_DIAGNOSTIC
metrics = row.get("limits")
if isinstance(metrics, dict):
limits = {}
Expand Down Expand Up @@ -284,6 +297,54 @@ def normalize_once(path: object) -> str | None:
return by_target


def _with_ledger_parser_spans(
rows: object,
target: str,
completeness: object,
normalize_path: Callable[[object], str | None],
text: Callable[..., str | None],
) -> object:
"""*rows* with a ledger ``parser_diagnostic`` on each structured reason that has no line.

SkillSpector builds an AE1 finding's ``evidence.reasons`` without the
``parser_diagnostic`` of the ledger row behind each reason, so the span is
read from ``analysis_completeness.ledger_exceptions``: the one row for the
same target and ``reason_code``. A reason with a line of its own, or with
no row or several rows to match, is left as it is.
"""
if not isinstance(rows, list) or not isinstance(completeness, dict):
return rows
ledger = completeness.get("ledger_exceptions")
if not isinstance(ledger, list):
return rows

def needs_span(row: object) -> bool:
return (
isinstance(row, dict)
and _line(row.get("start_line")) is None
and not isinstance(row.get("parser_diagnostic"), dict)
and text(row.get("reason_code"), max_length=128) is not None
)

if not any(needs_span(row) for row in rows[:_MAX_REASONS]):
return rows
matches: dict[str, list[dict]] = {}
for entry in ledger:
if not isinstance(entry, dict) or normalize_path(entry.get("path")) != target:
continue
if reason_code := text(entry.get("reason_code"), max_length=128):
matches.setdefault(reason_code, []).append(entry)
filled: list[object] = []
for row in rows:
if needs_span(row):
candidates = matches.get(text(row.get("reason_code"), max_length=128) or "", [])
diagnostic = candidates[0].get("parser_diagnostic") if len(candidates) == 1 else None
if isinstance(diagnostic, dict):
row = {**row, "parser_diagnostic": diagnostic}
filled.append(row)
return filled


def issue_diagnostics(
issue: Mapping[str, object],
*,
Expand All @@ -298,7 +359,10 @@ def issue_diagnostics(
and up to 16 ``reasons``, with ``reasons_truncated`` when SkillSpector or
this projection left some out. Before v2.12.0 the reasons come from the
target's ledger rows in *completeness* (or *legacy_reason_index*), and the
finding gets no evidence without them. ``skillspector_occurrences`` lists
finding gets no evidence without them. A structured reason without a line
takes the ``parser_diagnostic`` span of its one matching ledger row in
*completeness*; a reason whose lines come from a ``parser_diagnostic``
has ``line_source: "parser_diagnostic"``. ``skillspector_occurrences`` lists
up to 128 of the issue's ``occurrences``. Any other issue gets ``{}``.
Paths go through *normalize_path* and other text through *text*.
"""
Expand All @@ -311,7 +375,9 @@ def issue_diagnostics(
evidence = issue.get("evidence")
evidence = evidence if isinstance(evidence, dict) else {}
rows = evidence.get("reasons") if structured else None
if not rows:
if rows:
rows = _with_ledger_parser_spans(rows, target, completeness, normalize_path, text)
else:
if legacy_reason_index is None:
legacy_reason_index = index_legacy_reference_reasons(
[issue], completeness=completeness, normalize_path=normalize_path, text=text
Expand Down Expand Up @@ -348,22 +414,36 @@ def _reason_details(reasons: list[dict]) -> list[str]:

The run time and the time budget (``observed_seconds``, ``limit_seconds``)
are left out, so the text, and the ``finding_id`` that hashes it, is the
same in every run of one scan.
same in every run of one scan. A span whose ``line_source`` is
``parser_diagnostic`` is part of that text; an ``end_line`` that was
already on the row is not.
"""
grouped: dict[tuple, list[str]] = {}
for reason in reasons:
limits = sorted(
(key, value) for key, value in (reason.get("limits") or {}).items() if key not in _RUN_DEPENDENT_LIMITS
)
key = (reason["reason_code"], reason.get("start_line"), reason.get("message"), tuple(limits))
start_line = reason.get("start_line")
parser_end = reason.get("end_line") if reason.get("line_source") == _PARSER_DIAGNOSTIC else None
if parser_end == start_line:
parser_end = None
key = (
reason["reason_code"],
start_line,
parser_end,
reason.get("message"),
tuple(limits),
)
analyzers = grouped.setdefault(key, [])
analyzers.extend(name for name in reason.get("analyzers", []) if name not in analyzers)
details = []
for (reason_code, start_line, message, limits), analyzers in grouped.items():
for (reason_code, start_line, parser_end, message, limits), analyzers in grouped.items():
detail = reason_code
if analyzers:
detail += f" ({', '.join(analyzers)})"
if start_line:
if reason_code == "static_parse_limit" and start_line and parser_end:
detail += f" at target lines {start_line}-{parser_end}"
elif start_line:
detail += f" at target line {start_line}"
if message:
detail += f": {message.rstrip('.')}"
Expand All @@ -381,7 +461,8 @@ def reference_suggestion(
SkillSpector's own remediation is kept unless it is missing or the generic
text of releases before v2.12.0. A specific remedy is then chosen only from
a complete list of reasons, because the visible part of a truncated list
cannot show that one remedy covers every cause.
cannot show that one remedy covers every cause. *evidence* is not
changed, so every call returns the same text.
"""
reasons = evidence["reasons"]
truncated = evidence.get("reasons_truncated") is True
Expand Down
Loading
Loading