Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

SARIF output format #376

Merged
merged 58 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
63f8a50
created new branch of master to merge the changes
Oct 6, 2021
90b0a7c
fixed tags bug
Oct 7, 2021
2ba31da
fixed bug with multiLocations
Oct 7, 2021
e707acc
fixed new single loc bug
Oct 7, 2021
7804bcb
bugfix
Oct 7, 2021
4ec8312
corrected rule display and matching
Oct 7, 2021
f0620c2
minor changes
Oct 7, 2021
94766e2
minor changes
Oct 7, 2021
54bfaba
github action location trimming
Oct 7, 2021
e3de786
removed useless struct
Oct 7, 2021
6e78b1d
removed useless struct
Oct 7, 2021
28a3c8b
refactoring
Oct 7, 2021
b12907d
path changes
Oct 7, 2021
8c1794b
path testing
Oct 7, 2021
4a07649
last refactoring
Oct 7, 2021
5cb2181
added testScript and GithubAction
Oct 7, 2021
886e20a
Update goblintAnalysis.yml
AlexanderEichler Oct 7, 2021
819b29a
improved indentation
Oct 8, 2021
e095fd0
Merge branch 'integrationSarif' of https://github.com/AlexanderEichle…
Oct 8, 2021
71c5d00
removed unneeded flags, and some other minor refactoring
Oct 8, 2021
36019f8
usage of yojson for Sarif output
Oct 9, 2021
7fc4176
added locationObject for yojson
Oct 9, 2021
3f50280
bugfix location
Oct 10, 2021
38e5ce0
added invocationsObject
Oct 10, 2021
0200afd
removed obsolete code
Oct 10, 2021
2ff8c0b
added location object to toolComponent
Oct 10, 2021
538b0a1
code cleanup
Oct 10, 2021
ce8c08d
code cleanup
Oct 10, 2021
d8e0ced
formatting
Oct 10, 2021
dbdddbf
added messageCategory toString
Oct 11, 2021
aeebcf9
added optional parameter -R to Goblint. This option removes the leadi…
Oct 11, 2021
7d52394
minor change to path of uri in Sarif
Oct 11, 2021
4162e27
added endline and endColumn
Oct 11, 2021
aae6252
added cil path
Oct 14, 2021
1253203
added firstElements function
Oct 14, 2021
d09d8db
added maximum to locations of result object
Oct 14, 2021
9779187
bugfix
Oct 15, 2021
665ba0b
modified gitHubaction path
Oct 15, 2021
bbc4470
added more documentation
Oct 15, 2021
c3d9c45
deleted unneeded script
Oct 15, 2021
0cad65f
improved documentation
Oct 15, 2021
038c6b7
deleted test output
Oct 15, 2021
db7e044
removed debug messages
Oct 15, 2021
eefe41f
removed dead code and debug messages
Oct 15, 2021
24bfd57
Trim trailing whitespace in Sarif
sim642 Nov 3, 2021
bef4b47
Use BatList in Sarif
sim642 Nov 3, 2021
c1bbb7c
Update --sarif options
sim642 Nov 3, 2021
2cdf708
Add *.sarif to .gitignore
sim642 Nov 3, 2021
cb093d6
Remove slow Sarif GitHub workflow example
sim642 Nov 3, 2021
901dc4b
Move Sarif from framework to util
sim642 Nov 3, 2021
dfbcb7d
Move Sarif rules to SarifRules module
sim642 Nov 3, 2021
7d9040e
Move Sarif types to SarifType module
sim642 Nov 3, 2021
370ce69
Rename Sarif types to match standard
sim642 Nov 3, 2021
d356c39
Remove removePath hack for Sarif
sim642 Nov 3, 2021
2636adb
Merge branch 'master' into sarif
sim642 Nov 3, 2021
7f9aa31
Remove scripts/run
sim642 Nov 3, 2021
9a8d370
Clean up Sarif in Analyses
sim642 Nov 3, 2021
2c52bfd
Revert Sarif whitespace changes to unrelated files
sim642 Nov 3, 2021
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
67 changes: 67 additions & 0 deletions gitHubActionCreateSarif/goblintAnalysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: goblintAnalysis

on:
push:
pull_request:

jobs:
generate-Sarif:
env:
# ./analysisTarget/main.c needs to be replaced with ./analysisTarget/PATH_TO_MAIN
#the prefix ./analysisTarget/ is removed in Goblint, so the location shows correctly in Github
MAIN_NAME: './analysisTarget/main.c'
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
ocaml-compiler:
- 4.12.0 # matches opam lock file
# don't add any other because they won't be used

runs-on: ${{ matrix.os }}
permissions:
security-events: write
steps:
- name: Checkout Goblint repository
uses: actions/checkout@v2
with:
repository: AlexanderEichler/analyzer
#this path needs to be changed to the main branch
ref: integrationSarif
- name: PWD
run: pwd

- name: Set up OCaml ${{ matrix.ocaml-compiler }}
env:
# otherwise setup-ocaml pins non-locked dependencies
# https://github.com/ocaml/setup-ocaml/issues/166
OPAMLOCKED: locked
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
- name: PWD
run: pwd

- name: Install dependencies
run: |
pwd
opam install . --deps-only --locked
- name: Build
run: |
pwd
./make.sh nat
- name: Checkout code
uses: actions/checkout@v2
with:
path: analysisTarget
- name: Generate the Sarif output
run: |
pwd
ls
./goblint --sarif -o GitHubSarif.sarif ${{env.MAIN_NAME}}
- name: Upload the generated Sarif File
uses: github/codeql-action/upload-sarif@v1
with:
# Path to SARIF file relative to the root of the repository
sarif_file: GitHubSarif.sarif
16 changes: 16 additions & 0 deletions scripts/createSarifTestOutput.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
clear
echo "Generating output of test runs of tests/regression/*"
mkdir "/home/alex/Documents/git/analyzer/testResults"
dstpath=/home/alex/Documents/git/analyzer/testResults/
for folder in "/home/alex/Documents/git/analyzer/tests/regression"/*; do
foldername=$(basename "$folder")
echo "$foldername"
mkdir "/home/alex/Documents/git/analyzer/testResults"/$foldername
for entry in "/home/alex/Documents/git/analyzer/tests/regression"/$foldername/*; do

basename=$(basename "$entry")
dst="${dstpath}"$foldername"/"${basename::-2}".sarif"
../goblint --sarif -o "$dst" "$entry"
done
done
11 changes: 11 additions & 0 deletions src/framework/analyses.ml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,17 @@ struct
else
let f = BatIO.output_channel out in
write_file f (get_string "outfile")
| "sarif" ->
let open BatPrintf in


let write_file f fn =
printf "Writing sarif to temp. file: %s\n%!" fn;
Sarif.createSarifOutput f;

in
let f = BatIO.output_channel out in
write_file f (get_string "outfile")
| "json" ->
let open BatPrintf in
let module SH = BatHashtbl.Make (Basetype.RawStrings) in
Expand Down
2 changes: 1 addition & 1 deletion src/framework/control.ml
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ struct
let cnt = Cilfacade.countLoc fn in
uncalled_dead := !uncalled_dead + cnt;
if get_bool "dbg.uncalled" then
M.warn ~loc ~category:Deadcode "Function \"%a\" will never be called: %dLoC" CilType.Fundec.pretty fn cnt
M.warn ~loc ~category:Deadcode "Function \'%a\' will never be called: %dLoC" CilType.Fundec.pretty fn cnt
| _ -> ()
in
List.iter print_and_calculate_uncalled file.globals;
Expand Down
Loading