Skip to content

Commit 4efe6cc

Browse files
committed
writer-json: always write the results property in SARIF
The property is strictly required by GitHub. Fixes: #102 Closes: #104
1 parent eabcf45 commit 4efe6cc

File tree

5 files changed

+49
-3
lines changed

5 files changed

+49
-3
lines changed

src/lib/writer-json.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,8 @@ void SarifTreeEncoder::writeTo(std::ostream &str)
433433
PTree run0;
434434
run0.put_child("tool", tool);
435435

436-
if (!results_.empty())
437-
// results
438-
run0.put_child("results", results_);
436+
// results
437+
run0.put_child("results", results_);
439438

440439
// mandatory: runs
441440
PTree runs;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--mode=sarif
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "https://json.schemastore.org/sarif-2.1.0.json",
3+
"version": "2.1.0",
4+
"inlineExternalProperties": [
5+
{
6+
"externalizedProperties": {
7+
"tool": "vcs-diff-lint",
8+
"tool-url": "https://github.com/fedora-copr/vcs-diff-lint#readme"
9+
}
10+
}
11+
],
12+
"runs": [
13+
{
14+
"tool": {
15+
"driver": {
16+
"name": "vcs-diff-lint",
17+
"informationUri": "https://github.com/fedora-copr/vcs-diff-lint#readme"
18+
}
19+
}
20+
}
21+
]
22+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "https://json.schemastore.org/sarif-2.1.0.json",
3+
"version": "",
4+
"inlineExternalProperties": [
5+
{
6+
"externalizedProperties": {
7+
"tool": "vcs-diff-lint",
8+
"tool-url": "https://github.com/fedora-copr/vcs-diff-lint#readme"
9+
}
10+
}
11+
],
12+
"runs": [
13+
{
14+
"tool": {
15+
"driver": {
16+
"name": "vcs-diff-lint",
17+
"informationUri": "https://github.com/fedora-copr/vcs-diff-lint#readme"
18+
}
19+
},
20+
"results": ""
21+
}
22+
]
23+
}

tests/csgrep/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,4 @@ test_csgrep("0101-json-parser-empty" )
148148
test_csgrep("0102-xml-parser-empty" )
149149
test_csgrep("0106-snyk-prepend-path" )
150150
test_csgrep("0107-gcc-prepend-path" )
151+
test_csgrep("0108-sarif-empty-results" )

0 commit comments

Comments
 (0)