Skip to content

test(sarif): check the log root and runs[0] are objects before using them - #34

Merged
SizzleUnrlsd merged 1 commit into
mainfrom
fix/sarif-test-json-shape
Oct 23, 2026
Merged

SizzleUnrlsd merged 1 commit into
mainfrom
fix/sarif-test-json-shape

Conversation

@SizzleUnrlsd

Copy link
Copy Markdown
Contributor

Closes #33.

Change

unittests/sarif_test.cpp: the parsing of the Run helper moves to RunOf(text), which checks that the log root and runs[0] are objects and returns an empty run otherwise. Run(findings) calls it on the writer's output, so the existing checks are unchanged.

Test first

MalformedLogHasNoRun feeds RunOf a top-level array ([]) and a non-object run ({"runs": [1]}):

  • before the fix: sarif_unit (SEGFAULT);
  • after: sarif_test: all checks passed.

ctest --test-dir build: 17/17 passed; scripts/format-check.sh: clean.

…them

The Run helper dereferenced the parsed log and its first run without
checking they were objects, so a log of the wrong shape crashed
sarif_unit instead of failing a check. RunOf now returns an empty run
for such a log, and a test feeds it an array and a non-object run.

Closes #33
@SizzleUnrlsd
SizzleUnrlsd merged commit d3f16b6 into main Oct 23, 2026
4 checks passed
@SizzleUnrlsd
SizzleUnrlsd deleted the fix/sarif-test-json-shape branch October 23, 2026 03:12
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.

sarif_test: check the log root and runs[0] are objects before using them

1 participant