-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
buildah-sast: use the JSON output of gcc
- Loading branch information
Showing
3 changed files
with
32 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM quay.io/konflux-ci/oras:latest AS oras | ||
FROM quay.io/konflux-ci/buildah-task | ||
|
||
RUN microdnf install --enable-repo=updates-testing -y cs{diff{,-static},gcca,wrap} | ||
|
||
RUN ln -fsv "../../bin/cswrap" "$(cswrap --print-path-to-wrap)/gcc-wrapper" | ||
COPY gcc-wrapper.sh /usr/bin/gcc-wrapper | ||
|
||
COPY --from=oras /usr/bin/oras /usr/bin/yq /usr/bin/ | ||
COPY --from=oras /usr/local/bin/select-oci-auth /usr/local/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
# assign file name for the diagnostics output | ||
sast_dir="/shared/sast-results" | ||
fn="$(flock "${sast_dir}" mktemp "${sast_dir}/$$-XXXX.json.raw")" | ||
|
||
# cleanup handler | ||
trap "rm -f '${fn}'" EXIT TERM | ||
|
||
# run gcc and record its exit code | ||
/usr/bin/gcc "$@" -fdiagnostics-format=json 2>"${fn}" | ||
EC=$? | ||
|
||
# embed source code context | ||
/usr/libexec/csgrep-static --mode=json --event=^warning --embed-context=3 --quiet "${fn}" >"${fn%.raw}" | ||
|
||
# preserve the exit code from gcc | ||
exit $EC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters