Failure to upload the SARIF file on pull requests (#10725)

The changes proposed here will resolve the issues we have with
pull-request after the merge of #10606. It creates 3 different
workflows to conditionally execute the job based on changes submitted.

A detailed explanation about the issue can be found on #10717.

Resolves #10717
This commit is contained in:
Bruno Oliveira da Silva
2022-03-15 04:59:59 -03:00
committed by GitHub
parent 1b214aaed6
commit 6ebad26904
7 changed files with 137 additions and 143 deletions
-40
View File
@@ -1,40 +0,0 @@
#!/bin/sh
CODEQL_BINARY="./codeql/codeql"
# Check if the binary exists
if [ ! -f "$CODEQL_BINARY" ];
then
printf "CodeQL binary not found!"
exit 1
fi
upload_results () {
echo "Uploading $1"
$CODEQL_BINARY github upload-results --sarif="$1" --repository="$GITHUB_REPOSITORY" --ref="$GITHUB_REF"
}
# Create the database based on the specifics per language
if [ "$1" = "java" ];
then
printf "Analyzing CodeQL Java database"
$CODEQL_BINARY database analyze "$1-database" codeql/java-queries --format=sarifv2.1.0 --output="$1".sarif --download --max-paths=1 --sarif-add-query-help
< java.sarif jq 'del(.runs[].results[].codeFlows)' > processed-java.sarif
upload_results processed-java.sarif
elif [ "$1" = "javascript" ];
then
printf "Analyzing themes database"
$CODEQL_BINARY database analyze themes-database codeql/javascript-queries --format=sarifv2.1.0 --output=themes.sarif --download --max-paths=1 --sarif-add-query-help
< themes.sarif jq 'del(.runs[].results[].codeFlows)' > processed-themes.sarif
upload_results processed-themes.sarif
printf "Analyzing js-adapter database"
$CODEQL_BINARY database analyze js-adapter-database codeql/javascript-queries --format=sarifv2.1.0 --output=js-adapter.sarif --download --max-paths=1 --sarif-add-query-help
< js-adapter.sarif jq 'del(.runs[].results[].codeFlows)' > processed-js-adapter.sarif
upload_results processed-js-adapter.sarif
fi
@@ -1,25 +0,0 @@
#!/bin/sh
CODEQL_BINARY="./codeql/codeql"
# Check if the binary exists
if [ ! -f "$CODEQL_BINARY" ];
then
printf "CodeQL binary not found!"
exit 1
fi
# Create the database based on the specifics per language
if [ "$1" = "java" ];
then
printf "Creating CodeQL Java database"
$CODEQL_BINARY database create "$1-database" --no-run-unnecessary-builds --language="$1" --command='mvn clean install -Dmaven.test.skip -DskipQuarkus -DskipTestsuite -DskipExamples -DskipTests'
elif [ "$1" = "javascript" ];
then
printf "Creating themes database"
$CODEQL_BINARY database create themes-database --no-run-unnecessary-builds --language=javascript --source-root=themes/ --command='mvn install -Dmaven.test.skip -DskipQuarkus -DskipTestsuite -DskipExamples -DskipTests'
printf "Creating js-adapter database"
$CODEQL_BINARY database create js-adapter-database --no-run-unnecessary-builds --language=javascript --source-root=adapters/oidc/js/ --command='mvn install -Dmaven.test.skip -DskipQuarkus -DskipTestsuite -DskipExamples -DskipTests'
fi
-6
View File
@@ -1,6 +0,0 @@
#!/bin/sh
LATEST_RELEASE_URL=$(curl -s https://api.github.com/repos/github/codeql-cli-binaries/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep -i linux)
wget -q --show-progress "$LATEST_RELEASE_URL"
unzip codeql-linux64.zip