diff --git a/bin/codeql-upload b/bin/codeql-upload index 3beb9c2..eadd820 100755 --- a/bin/codeql-upload +++ b/bin/codeql-upload @@ -8,16 +8,7 @@ export CODEQL_DATABASE_PATHS=$(cat $CODEQL_DATABASE_PATHS_FILE) if [[ $CODEQL_DATABASE_PATHS != "" ]]; then debug "Database paths found :: $CODEQL_DATABASE_PATHS" - - # for each database path, find sarif file - FILES="" - for CODEQL_DATABASE_PATH in $CODEQL_DATABASE_PATHS; do - SARIF_FILE="$CODEQL_RESULTS/$(basename $CODEQL_DATABASE_PATH).sarif" - debug "Possible SARIF file :: $SARIF_FILE" - if [ -f $SARIF_FILE ]; then - FILES="$FILES $SARIF_FILE" - fi - done + FILES=$(get-sarif-files $CODEQL_DATABASE_PATHS_FILE) else info "Uploading all SARIF files found in :: $CODEQL_RESULTS" FILES=$(find $CODEQL_RESULTS -type f -name "*.sarif") diff --git a/bin/codeql-utils b/bin/codeql-utils index 396d6e5..db562e0 100755 --- a/bin/codeql-utils +++ b/bin/codeql-utils @@ -104,3 +104,15 @@ codeql-install() { info "CodeQL installed!" } + +get-sarif-files() { + # return a list of SARIF files based on database names + DATABASE_PATHS=$(cat $1) + for CODEQL_DATABASE_PATH in $DATABASE_PATHS; do + SARIF_FILE="$CODEQL_RESULTS/$(basename $CODEQL_DATABASE_PATH).sarif" + debug "Possible SARIF file :: $SARIF_FILE" + if [ -f $SARIF_FILE ]; then + echo "$SARIF_FILE" + fi + done +} diff --git a/gh-codeql-scan b/gh-codeql-scan index 551a0c0..d7e93cc 100755 --- a/gh-codeql-scan +++ b/gh-codeql-scan @@ -6,7 +6,7 @@ export EXTENSION_LOCATION="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)" source $EXTENSION_LOCATION/bin/codeql-utils # >> CodeQL Scan -export CODEQL_SCAN_VERSION="0.6.1" +export CODEQL_SCAN_VERSION="0.6.2" # enabled by default export CODEQL_SCAN_BANNER=1 @@ -109,6 +109,10 @@ for i in "$@"; do export WORKSPACE="${i#*=}" shift ;; + --view-in-vscode) + export CODEQL_VIEW_IN_VSCODE=1 + shift + ;; # -*|--*) # echo "Unknown option $i" # exit 1 @@ -200,4 +204,10 @@ elif [ $MODE = "scan" ]; then fi fi + +if [ "$CODEQL_VIEW_IN_VSCODE" = "1" ]; then + info "Opening results in VSCode..." + code -r $(get-sarif-files $CODEQL_DATABASE_PATHS_FILE) +fi + info "Completed CodeQL Scan!"