Skip to content

Commit 3e282d6

Browse files
committed
Enhance workflow files
1 parent 73ed20b commit 3e282d6

4 files changed

Lines changed: 45 additions & 22 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ on:
1919
schedule:
2020
- cron: '43 7 * * 1'
2121

22+
permissions: read-all
23+
2224
jobs:
2325
analyze:
2426
name: Analyze (${{ matrix.language }})

.github/workflows/generate-apk-release.yml

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ on:
44
workflow_dispatch:
55

66
permissions:
7-
contents: write
8-
id-token: write # Required for SLSA provenance signing
9-
actions: read # Required for SLSA provenance
7+
contents: read # default; jobs that need more grant it at job level
108

119
jobs:
1210
build:
1311
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
1414
env:
1515
ANDROID_STORE_PASSWORD: ${{ secrets.ANDROID_STORE_PASSWORD }}
1616
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
@@ -79,6 +79,7 @@ jobs:
7979
virustotal:
8080
needs: build
8181
runs-on: ubuntu-latest
82+
permissions: {}
8283
outputs:
8384
default_report: ${{ steps.scan.outputs.default_report }}
8485
armv7_report: ${{ steps.scan.outputs.armv7_report }}
@@ -96,10 +97,11 @@ jobs:
9697
VT_API_KEY: ${{ secrets.VIRUSTOTAL_API_KEY }}
9798
VERSION: ${{ needs.build.outputs.version_name }}
9899
run: |
99-
RESULT_URL=""
100-
RESULT_STATUS=""
100+
# Scans both APKs in parallel; results written to temp files to avoid
101+
# race conditions between background subshells.
101102
upload_and_poll() {
102103
local file="$1"
104+
local outprefix="$2"
103105
local sha256
104106
sha256=$(sha256sum "$file" | awk '{print $1}')
105107
local size_bytes
@@ -111,8 +113,8 @@ jobs:
111113
--url https://www.virustotal.com/api/v3/files/upload_url \
112114
--header "x-apikey: $VT_API_KEY" | jq -r '.data')
113115
if [ -z "$upload_url" ] || [ "$upload_url" = "null" ]; then
114-
RESULT_URL="https://www.virustotal.com/gui/file/$sha256/detection"
115-
RESULT_STATUS="⬜ N/A"
116+
printf '%s' "https://www.virustotal.com/gui/file/$sha256/detection" > "${outprefix}.url"
117+
printf '%s' "⬜ N/A" > "${outprefix}.status"
116118
return
117119
fi
118120
fi
@@ -122,8 +124,8 @@ jobs:
122124
--header "x-apikey: $VT_API_KEY" \
123125
--form "file=@$file" | jq -r '.data.id')
124126
if [ -z "$analysis_id" ] || [ "$analysis_id" = "null" ]; then
125-
RESULT_URL="https://www.virustotal.com/gui/file/$sha256/detection"
126-
RESULT_STATUS="⬜ N/A"
127+
printf '%s' "https://www.virustotal.com/gui/file/$sha256/detection" > "${outprefix}.url"
128+
printf '%s' "⬜ N/A" > "${outprefix}.status"
127129
return
128130
fi
129131
local last_response=""
@@ -143,19 +145,27 @@ jobs:
143145
harmless=$(echo "$last_response" | jq -r '.data.attributes.stats.harmless // 0')
144146
total=$((malicious + suspicious + undetected + harmless))
145147
detected=$((malicious + suspicious))
148+
local result_status
146149
if [ "$detected" -eq 0 ]; then
147-
RESULT_STATUS="✅ ${detected}/${total} Clean"
150+
result_status="✅ ${detected}/${total} Clean"
148151
else
149-
RESULT_STATUS="⚠️ ${detected}/${total} Detected"
152+
result_status="⚠️ ${detected}/${total} Detected"
150153
fi
151-
RESULT_URL="https://www.virustotal.com/gui/file/$sha256/detection"
154+
printf '%s' "https://www.virustotal.com/gui/file/$sha256/detection" > "${outprefix}.url"
155+
printf '%s' "$result_status" > "${outprefix}.status"
152156
}
153-
upload_and_poll "PlainApp-${VERSION}-default.apk"
154-
DEFAULT_REPORT="$RESULT_URL"
155-
DEFAULT_STATUS="$RESULT_STATUS"
156-
upload_and_poll "PlainApp-${VERSION}-armeabi-v7a.apk"
157-
ARMV7_REPORT="$RESULT_URL"
158-
ARMV7_STATUS="$RESULT_STATUS"
157+
# Launch both scans in parallel
158+
upload_and_poll "PlainApp-${VERSION}-default.apk" /tmp/vt_default &
159+
PID_DEFAULT=$!
160+
upload_and_poll "PlainApp-${VERSION}-armeabi-v7a.apk" /tmp/vt_armv7 &
161+
PID_ARMV7=$!
162+
# Wait for both to finish
163+
wait $PID_DEFAULT
164+
wait $PID_ARMV7
165+
DEFAULT_REPORT=$(cat /tmp/vt_default.url)
166+
DEFAULT_STATUS=$(cat /tmp/vt_default.status)
167+
ARMV7_REPORT=$(cat /tmp/vt_armv7.url)
168+
ARMV7_STATUS=$(cat /tmp/vt_armv7.status)
159169
{
160170
echo "default_report=$DEFAULT_REPORT"
161171
echo "armv7_report=$ARMV7_REPORT"

.github/workflows/release-to-playstore.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: Release to Play Store
33
on:
44
workflow_dispatch:
55

6+
permissions:
7+
contents: read
8+
69
jobs:
710
build:
811
runs-on: ubuntu-latest

.github/workflows/releases-to-discord.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,27 @@ on:
55
types: [published]
66
workflow_dispatch: {}
77

8+
permissions: {}
9+
810
jobs:
911
notify-discord:
1012
runs-on: ubuntu-latest
1113
steps:
1214
- name: Determine Release Info
1315
id: release-info
16+
# Pass github.event values via env to prevent expression injection
17+
env:
18+
GH_RELEASE_NAME: ${{ github.event.release.name }}
19+
GH_RELEASE_URL: ${{ github.event.release.html_url }}
20+
GH_RELEASE_TIMESTAMP: ${{ github.event.release.published_at }}
21+
GH_RELEASE_BODY: ${{ github.event.release.body }}
1422
run: |
1523
if [ "${{ github.event.release.tag_name != '' }}" = "true" ]; then
1624
echo "Using release event payload"
17-
echo "RELEASE_NAME=${{ github.event.release.name }}" >> $GITHUB_ENV
18-
echo "RELEASE_URL=${{ github.event.release.html_url }}" >> $GITHUB_ENV
19-
echo "RELEASE_TIMESTAMP=${{ github.event.release.published_at }}" >> $GITHUB_ENV
20-
CLEAN_BODY=$(echo "${{ github.event.release.body }}" | tr -d '\r')
25+
echo "RELEASE_NAME=$GH_RELEASE_NAME" >> $GITHUB_ENV
26+
echo "RELEASE_URL=$GH_RELEASE_URL" >> $GITHUB_ENV
27+
echo "RELEASE_TIMESTAMP=$GH_RELEASE_TIMESTAMP" >> $GITHUB_ENV
28+
CLEAN_BODY=$(printf '%s' "$GH_RELEASE_BODY" | tr -d '\r')
2129
echo "RELEASE_BODY<<EOF" >> $GITHUB_ENV
2230
echo "$CLEAN_BODY" >> $GITHUB_ENV
2331
echo "EOF" >> $GITHUB_ENV

0 commit comments

Comments
 (0)