Skip to content

Commit

Permalink
Fix sarift-fmt checks for test/basic.sh
Browse files Browse the repository at this point in the history
Previously, they were passing non-sarif input to sarif-fmt, which
obviously resulted in errors.

/facepalm

Signed-off-by: Adam Cmiel <[email protected]>
  • Loading branch information
chmeliik committed Nov 6, 2024
1 parent 9ead5b0 commit 5b7ce9c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
Error: missing field `runs` at line 36 column 1
warning: Double quote to prevent globbing and word splitting.
┌─ test/resources/files-to-check/busybox-sh.yaml:4:8
4 │ echo $HELLO_THERE
│ ^^^^^^^^^^^^

warning: 1 warnings emitted
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
Error: missing field `runs` at line 15 column 1
warning: Remove surrounding $() to avoid executing output (or use eval if intentional).
┌─ test/resources/files-to-check/nested-scripts.yaml:9:3
9 │ $(bash script.sh)
│ ^^^^^^^^^^^^^^^^^

warning: 1 warnings emitted
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
Error: missing field `runs` at line 58 column 1
error: On most OS, shebangs can only specify a single parameter.
┌─ test/resources/files-to-check/tektontask.yaml:34:9
34 │ #!/bin/bash -e -u -o pipefail
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: Double quote to prevent globbing and word splitting.
┌─ test/resources/files-to-check/tektontask.yaml:29:14
29 │ eval $SCRIPT
│ ^^^^^^^

warning: watery_tart is referenced but not assigned.
┌─ test/resources/files-to-check/tektontask.yaml:27:86
27 │ echo "You can't expect to wield supreme executive power just 'cause some $watery_tart threw a sword at you!"
│ ^^^^^^^^^^^^

warning: 2 warnings emitted
error: 1 errors emitted
13 changes: 12 additions & 1 deletion test/test_helper/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ test_human_readable_files() {
run csgrep --embed 4 <<< "$csgrep_input"
assert_output_file "$output" "$expected_files_dir/csgrep.embed4.txt"

run sarif-fmt --color never <<< "$csgrep_input"
local input_is_sarif
input_is_sarif=$(
jq '.["$schema"] and (.["$schema"] | test("sarif-.*\\.json$"))' <<< "$csgrep_input"
)
local sarif
if [[ $input_is_sarif == true ]]; then
sarif=$csgrep_input
else
sarif=$(csgrep --mode=sarif <<< "$csgrep_input")
fi

run sarif-fmt --color never <<< "$sarif"
assert_output_file "$output" "$expected_files_dir/sarif-fmt.txt"
}

0 comments on commit 5b7ce9c

Please sign in to comment.