Skip to content

Commit

Permalink
Adds support for waiting for a scan summary
Browse files Browse the repository at this point in the history
  • Loading branch information
ubiratansoares committed Sep 22, 2024
1 parent add3643 commit 0f5ac2a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 13 deletions.
2 changes: 1 addition & 1 deletion e2e/bitwarden-ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ curl -fsSL -o "$actual_dir/.tmp/$ipa" -C - "$ipa_download_url"
curl -fsSL -o "$actual_dir/.tmp/$dsyms_zip" -C - "$dsyms_download_url"
unzip -d "$actual_dir/.tmp/dsyms" "$actual_dir/.tmp/$dsyms_zip"

src/main.sh "$actual_dir/.tmp/$ipa" "$actual_dir/.tmp/dsyms"
src/main.sh --archive "$actual_dir/.tmp/$ipa" --extras "$actual_dir/.tmp/dsyms"
2 changes: 1 addition & 1 deletion e2e/cromite-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ rm -rf "$actual_dir/.tmp" && mkdir "$actual_dir/.tmp"
curl -fsSL -o "$actual_dir/.tmp/$apk" -C - "$apk_download_url"
curl -fsSL -o "$actual_dir/.tmp/$mappings" -C - "$mappings_download_url"

src/main.sh "$actual_dir/.tmp/$apk" "$actual_dir/.tmp/$mappings"
src/main.sh --archive "$actual_dir/.tmp/$apk" --extras "$actual_dir/.tmp/$mappings"
2 changes: 1 addition & 1 deletion e2e/pocketcasts-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ actual_dir=$(pwd)

rm -rf "$actual_dir/.tmp" && mkdir "$actual_dir/.tmp"
curl -fsSL -o "$actual_dir/.tmp/$package" -C - "$download_url"
src/main.sh "$actual_dir/.tmp/$package"
src/main.sh --archive "$actual_dir/.tmp/$package"
2 changes: 1 addition & 1 deletion e2e/pocketcasts-ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ actual_dir=$(pwd)

rm -rf "$actual_dir/.tmp" && mkdir "$actual_dir/.tmp"
curl -fsSL -o "$actual_dir/.tmp/$package" -C - "$download_url"
src/main.sh "$actual_dir/.tmp/$package"
src/main.sh --archive "$actual_dir/.tmp/$package" --sumary

Check warning on line 19 in e2e/pocketcasts-ios.sh

View workflow job for this annotation

GitHub Actions / quality-checks

"sumary" should be "summary".
52 changes: 43 additions & 9 deletions src/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ readonly install_location="$HOME/bin"
readonly guardsquare="$install_location/guardsquare"
readonly installer_url="https://platform.guardsquare.com/cli/install.sh"

readonly archive="$1"
readonly extras="$2"

require_archive() {
if [[ -z "$archive" ]]; then
echo "✗ ERROR : expecting an 'archive' input"
Expand Down Expand Up @@ -43,41 +40,78 @@ install_guardsquare_cli() {
}

execute_android_scan() {
local archive="$1"
local extras="$2"
scan_id

if [[ -z "$extras" ]]; then
echo "Scanning standalone archive : $archive"
install_guardsquare_cli
"$guardsquare" scan "$archive" --commit-hash "$GITHUB_SHA"
scan_id=$("$guardsquare" scan "$archive" --commit-hash "$GITHUB_SHA" --format "json")
else
require_r8_or_proguard_mappings
echo "Scanning archive : $archive"
echo "R8/Proguard mappings : $extras"
install_guardsquare_cli
"$guardsquare" scan "$archive" --mapping-file "$extras" --commit-hash "$GITHUB_SHA"
scan_id=$("$guardsquare" scan "$archive" --mapping-file "$extras" --commit-hash "$GITHUB_SHA" --format "json")
fi

echo "$scan_id" | jq
}

execute_ios_scan() {
local archive="$1"
local extras="$2"
scan_id

if [[ -z "$extras" ]]; then
echo "Scanning standalone archive : $archive"
install_guardsquare_cli
"$guardsquare" scan "$archive" --commit-hash "$GITHUB_SHA"
scan_id=$("$guardsquare" scan "$archive" --commit-hash "$GITHUB_SHA" --format "json")
else
require_dsyms_folder
echo "Scanning archive : $archive"
echo "dsyms location : $extras"
install_guardsquare_cli
"$guardsquare" scan "$archive" --dsym "$extras" --commit-hash "$GITHUB_SHA"
scan_id=$("$guardsquare" scan "$archive" --dsym "$extras" --commit-hash "$GITHUB_SHA" --format "json")
fi

echo "$scan_id" | jq
}

archive=
extras=
summary=

while [ "$#" -gt 0 ]; do
case "$1" in
--archive)
archive="$2"
shift 2
;;
--extras)
extras="$2"
shift 2
;;
--summary)
summary=1
shift 1
;;
*)
error "Unknown argument: $1"
exit 1
;;
esac
done

require_archive

case "$archive" in
*.apk | *.aab)
execute_android_scan
execute_android_scan "$archive" "$extras" "$summary"
;;
*.xcarchive | *.ipa)
execute_ios_scan
execute_ios_scan "$archive" "$extras" "$summary"
;;
*)
echo "Error: unsupported archive → $archive"
Expand Down

0 comments on commit 0f5ac2a

Please sign in to comment.