Skip to content

Multi-tier framework for evaluating AI agent skills and plugins with quality gates, security scanning, harness compatibility checks, semantic overlap detection, synthetic evaluation dataset generation, and live agent evaluation that measures how skills affect agent behavior. Ships reusable CI templates that bring every check to any repository.

Report Semgrep file-level parse errors as a partial scan (#475)

Christopher Kevin957e8ff6b231
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7ad3f4f3..e2d95462 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -758,6 +758,14 @@ All notable changes to SkillEvaluator are documented in this file.
- The unknown-artifact CLI guidance links to the published content-types documentation route.
+- Code Risk Analysis reports Semgrep file-level parse errors as one partial-scan
+ error that names up to 20 unparsed files, relative to the skill and with the
+ line of the first error, instead of the first three truncated messages. The
+ check stays `incomplete` because Semgrep skips the code it cannot parse. The
+ JSON report lists the files in `semgrep_unparsed_files` (up to 1,000, with
+ `semgrep_unparsed_files_omitted` counting the rest); other Semgrep errors are
+ reported as before.
+
- Security checks preserve authored evaluation files and their findings while
excluding generated outputs. Fully inspected skills with only missing-path
reference caveats retain visible warnings instead of an incomplete-scan
diff --git a/docs/tier1-validation.mdx b/docs/tier1-validation.mdx
index 414cdc18..c014ebd9 100644
--- a/docs/tier1-validation.mdx
+++ b/docs/tier1-validation.mdx
@@ -366,7 +366,7 @@ For `validate`, the default set is `schema`, `version`, `security`, `pii`, `lice
Default Tier 1 does not import or execute target-controlled Python code. The `test_discovery` result is filename evidence only: it counts regular, in-tree, non-symlink `test_*.py` and `*_test.py` candidates without parsing or importing them. It reports `execution_performed=false` and `coverage_measured=false`; test success and code coverage must be established separately in a trusted project environment or an explicit sandbox.
- A missing, timed-out, crashed, or malformed Bandit, Semgrep, Gitleaks, or SkillSpector run is treated as `INCOMPLETE`: terminal and saved reports are non-green and `validate` exits non-zero. See [Scanner setup](#scanner-setup) for installation.
+ A missing, timed-out, crashed, or malformed Bandit, Semgrep, Gitleaks, or SkillSpector run is treated as `INCOMPLETE`: terminal and saved reports are non-green and `validate` exits non-zero. When Semgrep runs but cannot fully parse some files (for example a shell or JavaScript file with syntax Semgrep's parser rejects), the check stays `INCOMPLETE` because Semgrep skips the code it cannot parse, so findings there are missed. The report names up to 20 of those files, relative to the skill and with the line of the first error, keeps Semgrep's findings for the other files, and lists them in the `semgrep_unparsed_files` field of the JSON report, up to 1,000 files; `semgrep_unparsed_files_omitted` counts any beyond that. Fix the syntax error, or check whether it comes from Semgrep's parser or its rule configuration. See [Scanner setup](#scanner-setup) for installation.
</Accordion>
<Accordion title="unicode — smuggling detection">
diff --git a/src/skillevaluator/models/result.py b/src/skillevaluator/models/result.py
index e2deebc3..25f1f866 100644
--- a/src/skillevaluator/models/result.py
+++ b/src/skillevaluator/models/result.py
@@ -739,6 +739,21 @@ class ValidationResult:
self.metadata["gate_failures"] = gate_failures
if scanners := {**self.scanners, **other.scanners}:
self.metadata["scanners"] = scanners
+ # Keep each skill's unparsed files, prefixed like errors and findings so
+ # skills stay distinguishable when a folder holds several.
+ unparsed = other.metadata.get("semgrep_unparsed_files")
+ if isinstance(unparsed, list) and unparsed:
+ carried = self.metadata.get("semgrep_unparsed_files")
+ self.metadata["semgrep_unparsed_files"] = [
+ *(carried if isinstance(carried, list) else []),
+ *(f"[{prefix}] {path}" for path in unparsed if isinstance(path, str)),
+ ]
+ omitted = other.metadata.get("semgrep_unparsed_files_omitted")
+ if type(omitted) is int and omitted > 0:
+ carried_omitted = self.metadata.get("semgrep_unparsed_files_omitted")
+ self.metadata["semgrep_unparsed_files_omitted"] = omitted + (
+ carried_omitted if type(carried_omitted) is int else 0
+ )
# Merge summary
self.summary.errors += other.summary.errors
diff --git a/src/skillevaluator/reporting/json_reporter.py b/src/skillevaluator/reporting/json_reporter.py
index 12c47aaf..ea8f6f80 100644
--- a/src/skillevaluator/reporting/json_reporter.py
+++ b/src/skillevaluator/reporting/json_reporter.py
@@ -71,6 +71,9 @@ def _json_safe_benchmark_policy(value: object) -> dict[str, bool] | None:
return policy or None
+_MAX_SEMGREP_UNPARSED_FILES = 1000
+
+
def _tier1_scope_strings(value: object, field: str) -> list[str]:
"""Copy bounded scope evidence without narrowing its publication meaning.
@@ -430,6 +433,22 @@ class JSONReporter(ReporterBase):
if isinstance(coverage, list):
data["dependency_coverage"] = coverage
+ # Files Semgrep could not fully parse. The error message names at most 20;
+ # this keeps up to _MAX_SEMGREP_UNPARSED_FILES and counts the rest, so a
+ # report that was cut short says so instead of looking complete.
+ unparsed_files = result.metadata.get("semgrep_unparsed_files")
+ if isinstance(unparsed_files, list):
+ paths = [item for item in unparsed_files if isinstance(item, str) and 0 < len(item) <= 4096]
+ if paths:
+ data["semgrep_unparsed_files"] = paths[:_MAX_SEMGREP_UNPARSED_FILES]
+ # A report restored from JSON already carries the count of files it left out.
+ carried = result.metadata.get("semgrep_unparsed_files_omitted")
+ omitted = max(0, len(paths) - _MAX_SEMGREP_UNPARSED_FILES)
+ if type(carried) is int and carried > 0:
+ omitted += carried
+ if omitted:
+ data["semgrep_unparsed_files_omitted"] = omitted
+
# Tier 1 SkillSpector file-role scoping: retained and suppressed issue
# counts, and the raw versus applicable aggregate risk score.
skillspector_applicability = result.metadata.get("skillspector_applicability")
diff --git a/src/skillevaluator/reporting/retained.py b/src/skillevaluator/reporting/retained.py
index 6839bb4d..4d29ce35 100644
--- a/src/skillevaluator/reporting/retained.py
+++ b/src/skillevaluator/reporting/retained.py
@@ -271,9 +271,13 @@ def retained_results(
# Retain source identity under the exact carrier consumed by reporters.
if payload.get("evaluated_source") is not None:
metadata["evaluated_source"] = mapping(payload["evaluated_source"], "evaluated_source")
- for key in ("incomplete_scans", "gate_failures"):
+ for key in ("incomplete_scans", "gate_failures", "semgrep_unparsed_files"):
if key in row:
metadata[key] = _strings(row[key], key)
+ if "semgrep_unparsed_files_omitted" in row:
+ omitted = row["semgrep_unparsed_files_omitted"]
+ _require(type(omitted) is int and omitted >= 0, "Invalid semgrep_unparsed_files_omitted")
+ metadata["semgrep_unparsed_files_omitted"] = omitted
for key in (TIER1_REQUIRED_CHECKS_KEY, TIER1_UNSCANNED_PATHS_KEY):
if key in row:
try:
diff --git a/src/skillevaluator/validators/code_risk.py b/src/skillevaluator/validators/code_risk.py
index f6dea895..c02a7901 100644
--- a/src/skillevaluator/validators/code_risk.py
+++ b/src/skillevaluator/validators/code_risk.py
@@ -18,6 +18,51 @@ from skillevaluator.utils.path_security import matches_filesystem_name
from skillevaluator.utils.tool_runner import Severity, Tools, parse_json_output
from skillevaluator.validators.base import Finding, ValidationResult, ValidatorBase, iter_scannable_files
+_SEMGREP_PARSE_ERROR_TYPES = frozenset(
+ {"SyntaxError", "PartialParsing", "LexicalError", "ParseError", "OtherParseError", "AstBuilderError"}
+)
+_SEMGREP_PARSE_ERROR_PATH_LIMIT = 20
+
+
+def _semgrep_error_type(error: dict) -> str:
+ """Return the Semgrep error type name; JSON reports use a string or ``["Name", ...]``."""
+ error_type = error.get("type")
+ if isinstance(error_type, list) and error_type:
+ error_type = error_type[0]
+ return error_type if isinstance(error_type, str) else ""
+
+
+def _is_semgrep_parse_error(error: dict) -> bool:
+ """True for a file-level parse error: Semgrep ran but could not parse one input file."""
+ return bool(error.get("path")) and _semgrep_error_type(error) in _SEMGREP_PARSE_ERROR_TYPES
+
+
+def _semgrep_display_path(path: str, skill_root: Path | None) -> str:
+ """Return *path* relative to the scanned skill.
+
+ Semgrep reports absolute paths for the absolute target ``_run_semgrep`` passes, so a
+ raw path would put the user's home directory into every report. A path outside the
+ skill keeps only its file name.
+ """
+ candidate = Path(path)
+ if not candidate.is_absolute():
+ return candidate.as_posix()
+ if skill_root is not None:
+ try:
+ return candidate.relative_to(skill_root).as_posix()
+ except ValueError:
+ pass
+ return candidate.name
+
+
+def _semgrep_error_line(error: dict) -> int | None:
+ spans = error.get("spans")
+ if isinstance(spans, list) and spans and isinstance(spans[0], dict):
+ start = spans[0].get("start")
+ if isinstance(start, dict) and isinstance(start.get("line"), int):
+ return start["line"]
+ return None
+
def _semgrep_file_excludes(skill_path: Path) -> list[str]:
"""Return generated file patterns using the target filesystem's case semantics."""
@@ -305,7 +350,9 @@ class CodeRiskValidator(ValidatorBase):
elif tool_result.exit_code in (0, 1):
# Exit code 0 = clean, 1 = findings; both emit JSON on stdout
result.record_scanner("semgrep", Tools.semgrep.version)
- self._process_semgrep_output(tool_result.stdout, result, exit_code=tool_result.exit_code)
+ self._process_semgrep_output(
+ tool_result.stdout, result, exit_code=tool_result.exit_code, skill_path=skill_path.resolve()
+ )
else:
error_msg = tool_result.stderr or tool_result.stdout or "no diagnostic output"
result.add_error(f"Semgrep error (exit code {tool_result.exit_code}): {error_msg[:200]}")
@@ -319,8 +366,12 @@ class CodeRiskValidator(ValidatorBase):
result: ValidationResult,
*,
exit_code: int | None = None,
+ skill_path: Path | None = None,
) -> None:
- """Parse Semgrep JSON output and report findings."""
+ """Parse Semgrep JSON output and report findings.
+
+ *skill_path* is the resolved skill root; it lets parse-error paths be shown relative to it.
+ """
data = parse_json_output(output)
if data is None:
result.add_error("Semgrep did not return valid JSON; scan did not complete")
@@ -359,8 +410,15 @@ class CodeRiskValidator(ValidatorBase):
result.mark_scan_incomplete("semgrep")
return
- # Report scan errors (limit to avoid noise)
- for error in scan_errors[:3]:
+ # File-level parse errors mean Semgrep ran but skipped part of the input; every
+ # other error is reported one by one (limited to avoid noise).
+ parse_errors: list[dict] = []
+ other_errors: list[dict] = []
+ for error in scan_errors:
+ (parse_errors if _is_semgrep_parse_error(error) else other_errors).append(error)
+ if parse_errors:
+ self._report_semgrep_parse_errors(result, parse_errors, skill_path)
+ for error in other_errors[:3]:
message = str(error.get("message") or error.get("type") or "Unknown scan error")
result.add_error(f"Semgrep scan error: {message[:100]}")
if scan_errors:
@@ -386,6 +444,33 @@ class CodeRiskValidator(ValidatorBase):
for finding in findings:
self._report_semgrep_finding(result, finding)
+ def _report_semgrep_parse_errors(
+ self, result: ValidationResult, parse_errors: list[dict], skill_path: Path | None = None
+ ) -> None:
+ """Report files Semgrep could not fully parse as a partial scan.
+
+ The message names up to ``_SEMGREP_PARSE_ERROR_PATH_LIMIT`` files with the line of
+ their first error; ``semgrep_unparsed_files`` keeps every file path, relative to the skill.
+ """
+ first_line: dict[str, int | None] = {}
+ for error in parse_errors:
+ path = _semgrep_display_path(str(error.get("path") or "unknown"), skill_path)
+ line = _semgrep_error_line(error)
+ if first_line.get(path) is None:
+ first_line[path] = line
+ files = list(first_line)
+ locations = [f"{path}:{line}" if line else path for path, line in first_line.items()]
+ shown = locations[:_SEMGREP_PARSE_ERROR_PATH_LIMIT]
+ extra = len(locations) - len(shown)
+ listing = ", ".join(shown) + (f", and {extra} more" if extra > 0 else "")
+ result.metadata["semgrep_unparsed_files"] = files
+ result.add_error(
+ f"Semgrep partial scan: {len(files)} file(s) could not be fully parsed ({listing}). "
+ f"Semgrep skips the code it cannot parse, so findings there are missed. Findings for the "
+ f"other files are kept. Fix the syntax error, or check whether it comes from Semgrep's parser "
+ f"or the rule configuration for that language."
+ )
+
def _report_semgrep_finding(self, result: ValidationResult, finding: dict) -> None:
"""Report a single Semgrep finding."""
rule_id = finding.get("check_id", "unknown")
diff --git a/tests/reporting/test_incomplete_scans.py b/tests/reporting/test_incomplete_scans.py
index e19ebbbf..a0b6f24b 100644
--- a/tests/reporting/test_incomplete_scans.py
+++ b/tests/reporting/test_incomplete_scans.py
@@ -131,3 +131,70 @@ def test_status_handles_sanitized_finding_without_location():
result = ValidationResult(validator_name="Security Scan")
result.add_finding(Finding(category="X", severity=Severity.LOW, check_name="c", message="m", file_path=None))
assert result_status(result).value == "passed"
+
+
+def test_json_report_lists_every_unparsed_semgrep_file_and_round_trips() -> None:
+ """The error text names at most 20 files; the saved JSON keeps the full list."""
+ from skillevaluator.reporting.retained import retained_results
+
+ paths = [f"scripts/f{i}.sh" for i in range(25)]
+ result = ValidationResult(validator_name="Code Risk Analysis", validator_description="Static code analysis")
+ result.metadata["semgrep_unparsed_files"] = paths
+ result.mark_scan_incomplete("semgrep")
+ result.add_error("Semgrep partial scan: 25 file(s) could not be fully parsed")
+
+ payload = json.loads(JSONReporter(include_timestamp=False).render_all([result]))
+
+ assert payload["results"][0]["semgrep_unparsed_files"] == paths
+ (restored,) = retained_results(payload)
+ assert restored.metadata["semgrep_unparsed_files"] == paths
+
+
+def test_json_report_omits_malformed_unparsed_semgrep_files() -> None:
+ result = ValidationResult(validator_name="Code Risk Analysis", validator_description="Static code analysis")
+ result.metadata["semgrep_unparsed_files"] = ["scripts/a.sh", 3, "", None]
+
+ payload = json.loads(JSONReporter(include_timestamp=False).render_all([result]))
+
+ assert payload["results"][0]["semgrep_unparsed_files"] == ["scripts/a.sh"]
+ result.metadata["semgrep_unparsed_files"] = "scripts/a.sh"
+ rendered = json.loads(JSONReporter(include_timestamp=False).render_all([result]))
+ assert "semgrep_unparsed_files" not in rendered["results"][0]
+
+
+def test_json_report_counts_unparsed_semgrep_files_beyond_its_cap() -> None:
+ result = ValidationResult(validator_name="Code Risk Analysis", validator_description="Static code analysis")
+ result.metadata["semgrep_unparsed_files"] = [f"scripts/f{i}.sh" for i in range(1005)]
+
+ row = json.loads(JSONReporter(include_timestamp=False).render_all([result]))["results"][0]
+
+ assert len(row["semgrep_unparsed_files"]) == 1000
+ assert row["semgrep_unparsed_files_omitted"] == 5
+ result.metadata["semgrep_unparsed_files"] = result.metadata["semgrep_unparsed_files"][:1000]
+ row = json.loads(JSONReporter(include_timestamp=False).render_all([result]))["results"][0]
+ assert "semgrep_unparsed_files_omitted" not in row
+
+
+def test_omitted_unparsed_semgrep_count_survives_a_retained_round_trip() -> None:
+ from skillevaluator.reporting.retained import retained_results
+
+ result = ValidationResult(validator_name="Code Risk Analysis", validator_description="Static code analysis")
+ result.metadata["semgrep_unparsed_files"] = [f"scripts/f{i}.sh" for i in range(1005)]
+ payload = json.loads(JSONReporter(include_timestamp=False).render_all([result]))
+ assert payload["results"][0]["semgrep_unparsed_files_omitted"] == 5
+
+ (restored,) = retained_results(payload)
+ again = json.loads(JSONReporter(include_timestamp=False).render_all([restored]))
+
+ assert len(again["results"][0]["semgrep_unparsed_files"]) == 1000
+ assert again["results"][0]["semgrep_unparsed_files_omitted"] == 5
+
+
+def test_folder_merge_adds_up_omitted_unparsed_semgrep_counts() -> None:
+ merged = ValidationResult()
+ for prefix, count in (("a", 3), ("b", 4)):
+ part = ValidationResult()
+ part.metadata["semgrep_unparsed_files_omitted"] = count
+ merged.merge_with_prefix(part, prefix)
+
+ assert merged.metadata["semgrep_unparsed_files_omitted"] == 7
diff --git a/tests/validators/test_security_validators.py b/tests/validators/test_security_validators.py
index 81971555..cdbb94e0 100644
--- a/tests/validators/test_security_validators.py
+++ b/tests/validators/test_security_validators.py
@@ -714,6 +714,164 @@ class TestCodeRiskValidator:
finding.check_name == "python.lang.security.audit.dangerous-system-call" for finding in result.findings
)
+ def test_semgrep_parse_errors_report_every_path_and_stay_incomplete(self) -> None:
+ result = ValidationResult()
+ errors = [
+ {
+ "code": 3,
+ "level": "warn",
+ "type": "SyntaxError",
+ "path": f"scripts/file{i}.sh",
+ "message": "Syntax error",
+ "spans": [{"start": {"line": i + 1, "col": 1}}],
+ }
+ for i in range(5)
+ ]
+ errors.append({"type": ["PartialParsing", []], "path": "scripts/copy.mjs", "message": "Partial parsing"})
+ output = json.dumps({"results": [], "errors": errors})
+
+ CodeRiskValidator()._process_semgrep_output(output, result)
+
+ assert not result.passed
+ assert result.metadata["incomplete_scans"] == ["semgrep"]
+ assert result.metadata["semgrep_unparsed_files"][0] == "scripts/file0.sh"
+ assert len(result.metadata["semgrep_unparsed_files"]) == 6
+ summary = [e for e in result.errors if "Semgrep partial scan" in e]
+ assert len(summary) == 1
+ assert "6 file(s) could not be fully parsed" in summary[0]
+ assert all(f"scripts/file{i}.sh:{i + 1}" in summary[0] for i in range(5))
+ assert "scripts/copy.mjs" in summary[0]
+ assert "were not scanned" not in summary[0]
+ assert not any("Semgrep scan error" in e for e in result.errors)
+
+ def test_semgrep_parse_error_listing_is_capped(self) -> None:
+ result = ValidationResult()
+ errors = [{"type": "SyntaxError", "path": f"s/f{i}.sh", "message": "Syntax error"} for i in range(25)]
+
+ CodeRiskValidator()._process_semgrep_output(json.dumps({"results": [], "errors": errors}), result)
+
+ assert len(result.metadata["semgrep_unparsed_files"]) == 25
+ assert any("and 5 more" in e for e in result.errors)
+
+ def test_semgrep_parse_errors_count_files_not_locations(self) -> None:
+ result = ValidationResult()
+ errors = [
+ {"type": "SyntaxError", "path": "scripts/a.sh", "spans": [{"start": {"line": 3}}]},
+ {"type": "SyntaxError", "path": "scripts/a.sh", "spans": [{"start": {"line": 9}}]},
+ {"type": "SyntaxError", "path": "scripts/b.sh"},
+ ]
+
+ CodeRiskValidator()._process_semgrep_output(json.dumps({"results": [], "errors": errors}), result)
+
+ assert result.metadata["semgrep_unparsed_files"] == ["scripts/a.sh", "scripts/b.sh"]
+ (summary,) = [e for e in result.errors if "Semgrep partial scan" in e]
+ assert "2 file(s)" in summary
+ assert "scripts/a.sh:3" in summary
+ assert "scripts/a.sh:9" not in summary
+
+ def test_semgrep_parse_errors_use_paths_relative_to_the_skill(self, tmp_path: Path) -> None:
+ skill = tmp_path / "my-skill"
+ (skill / "scripts").mkdir(parents=True)
+ elsewhere = tmp_path / "private-home" / "other.sh"
+ errors = [
+ {"type": "SyntaxError", "path": str(skill / "scripts" / "a.sh"), "spans": [{"start": {"line": 3}}]},
+ {"type": "SyntaxError", "path": str(elsewhere)},
+ ]
+ result = ValidationResult()
+
+ CodeRiskValidator()._process_semgrep_output(
+ json.dumps({"results": [], "errors": errors}), result, skill_path=skill.resolve()
+ )
+
+ assert result.metadata["semgrep_unparsed_files"] == ["scripts/a.sh", "other.sh"]
+ (summary,) = [e for e in result.errors if "Semgrep partial scan" in e]
+ assert "scripts/a.sh:3" in summary
+ assert str(tmp_path) not in summary
+ assert not any(str(tmp_path) in path for path in result.metadata["semgrep_unparsed_files"])
+
+ def test_semgrep_partial_parsing_error_in_semgrep_json_shape(self) -> None:
+ """Semgrep 1.x reports a partially parsed file as ``["PartialParsing", [span, ...]]`` with ``spans``."""
+ result = ValidationResult()
+ error = {
+ "code": 3,
+ "level": "warn",
+ "type": ["PartialParsing", [{"path": "scripts/bad.sh", "start": {"line": 2, "col": 1, "offset": 0}}]],
+ "path": "scripts/bad.sh",
+ "spans": [{"start": {"line": 2, "col": 1, "offset": 0}, "end": {"line": 3, "col": 10, "offset": 23}}],
+ }
+
+ CodeRiskValidator()._process_semgrep_output(json.dumps({"results": [], "errors": [error]}), result)
+
+ assert result.metadata["incomplete_scans"] == ["semgrep"]
+ (summary,) = [e for e in result.errors if "Semgrep partial scan" in e]
+ assert "scripts/bad.sh:2" in summary
+ assert "skips the code it cannot parse" in summary
+
+ def test_run_semgrep_reports_parse_errors_with_relative_paths(
+ self, tmp_path: Path, mock_tool_available
+ ) -> None:
+ skill = tmp_path / "my-skill"
+ (skill / "scripts").mkdir(parents=True)
+ absolute = str(skill.resolve() / "scripts" / "bad.sh")
+ semgrep_result = MagicMock()
+ semgrep_result.exit_code = 0
+ semgrep_result.error_message = None
+ semgrep_result.stdout = json.dumps(
+ {"results": [], "errors": [{"type": "SyntaxError", "path": absolute, "spans": [{"start": {"line": 2}}]}]}
+ )
+
+ with (
+ mock_tool_available("semgrep", "/usr/bin/semgrep"),
+ patch.object(Tools.semgrep, "run", return_value=semgrep_result),
+ ):
+ result = CodeRiskValidator()._run_semgrep(skill)
+
+ assert result.metadata["incomplete_scans"] == ["semgrep"]
+ assert result.metadata["semgrep_unparsed_files"] == ["scripts/bad.sh"]
+ assert not any(str(tmp_path) in error for error in result.errors)
+
+ def test_folder_scan_merge_keeps_unparsed_files_per_skill(self) -> None:
+ first = ValidationResult()
+ first.metadata["semgrep_unparsed_files"] = ["scripts/a.sh"]
+ second = ValidationResult()
+ second.metadata["semgrep_unparsed_files"] = ["scripts/b.sh", "scripts/c.sh"]
+ merged = ValidationResult()
+
+ merged.merge_with_prefix(first, "skill-a")
+ merged.merge_with_prefix(second, "skill-b")
+
+ assert merged.metadata["semgrep_unparsed_files"] == [
+ "[skill-a] scripts/a.sh",
+ "[skill-b] scripts/b.sh",
+ "[skill-b] scripts/c.sh",
+ ]
+
+ def test_semgrep_parse_errors_keep_findings_and_other_errors(self) -> None:
+ result = ValidationResult()
+ output = json.dumps(
+ {
+ "results": [
+ {
+ "check_id": "rule.id",
+ "path": "a.py",
+ "start": {"line": 1},
+ "extra": {"severity": "ERROR", "message": "bad", "metadata": {}},
+ }
+ ],
+ "errors": [
+ {"type": "SyntaxError", "path": "run.sh", "message": "Syntax error"},
+ {"message": "invalid security-audit configuration"},
+ ],
+ }
+ )
+
+ CodeRiskValidator()._process_semgrep_output(output, result)
+
+ assert any("Semgrep partial scan" in e and "run.sh" in e for e in result.errors)
+ assert any("invalid security-audit configuration" in e for e in result.errors)
+ assert any(f.check_name == "rule.id" for f in result.findings)
+ assert result.metadata["incomplete_scans"] == ["semgrep"]
+
def test_semgrep_accepts_valid_clean_report(self) -> None:
result = ValidationResult()