Repository navigation
Harden ARM64 APK signing password handling in Android build workflow #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,14 +57,21 @@ jobs: | |
| KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | ||
| KEY_PASSWORD: ${{ secrets.KEY_PASSWORD || secrets.KEYSTORE_PASSWORD }} | ||
| run: | | ||
| EFFECTIVE_KEY_PASSWORD="$KEY_PASSWORD" | ||
| if [ -z "$EFFECTIVE_KEY_PASSWORD" ] || [ ${#EFFECTIVE_KEY_PASSWORD} -lt 6 ]; then | ||
| echo "::error::Signing key password must be at least 6 characters. Check KEY_PASSWORD/KEYSTORE_PASSWORD secrets." | ||
| exit 1 | ||
| fi | ||
|
JWEB0689 marked this conversation as resolved.
Resolved
|
||
| echo "::add-mask::$EFFECTIVE_KEY_PASSWORD" | ||
| echo "EFFECTIVE_KEY_PASSWORD=$EFFECTIVE_KEY_PASSWORD" >> "$GITHUB_ENV" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. Multiline key passwords stop apk builds The keystore step writes EFFECTIVE_KEY_PASSWORD to $GITHUB_ENV using a single-line assignment, which cannot preserve a password containing a newline. If a valid signing secret contains a newline, the environment file is rejected or a truncated password reaches apksigner, while keytool created the key with the full password. Agent Prompt
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot Fix the code for this review comment. When a review comment includes a suggested change, apply the suggestion exactly. Do not make changes beyond what is described in the linked review comment. |
||
| keytool -genkey -v \ | ||
| -keystore keystore.jks \ | ||
| -alias "$KEY_ALIAS" \ | ||
| -keyalg RSA \ | ||
| -keysize 2048 \ | ||
| -validity 10000 \ | ||
| -storepass "$KEYSTORE_PASSWORD" \ | ||
| -keypass "$KEY_PASSWORD" \ | ||
| -keypass "$EFFECTIVE_KEY_PASSWORD" \ | ||
|
JWEB0689 marked this conversation as resolved.
Resolved
JWEB0689 marked this conversation as resolved.
Resolved
|
||
| -dname "CN=KernelCrafter, OU=App, O=KernelCrafter, L=Unknown, ST=Unknown, C=US" | ||
| - name: Make gradlew executable | ||
| working-directory: android | ||
|
|
@@ -76,13 +83,13 @@ jobs: | |
| env: | ||
| KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | ||
| KEY_ALIAS: ${{ secrets.KEY_ALIAS || 'kernelcrafter' }} | ||
| KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | ||
| KEY_PASSWORD: ${{ env.EFFECTIVE_KEY_PASSWORD }} | ||
|
|
||
| - name: Locate, Align, and Sign APK | ||
| env: | ||
| KEY_ALIAS: ${{ secrets.KEY_ALIAS || 'kernelcrafter' }} | ||
| KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | ||
| KEY_PASSWORD: ${{ secrets.KEY_PASSWORD || secrets.KEYSTORE_PASSWORD }} | ||
| KEY_PASSWORD: ${{ env.EFFECTIVE_KEY_PASSWORD }} | ||
| run: | | ||
| mkdir -p dist | ||
| APK_UNSIGNED=$(find android/app/build/outputs/apk/release -name "*.apk" | head -1) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 The Roast: This PR exists to "fall back to KEYSTORE_PASSWORD when KEY_PASSWORD is missing OR too short." The incremental diff just deleted the "too short" half. If KEY_PASSWORD is set to a short stub, GitHub's
secrets.KEY_PASSWORD || secrets.KEYSTORE_PASSWORDbinding still wins — it only falls back on empty/null, never on short-but-truthy — so the workflow now hard-fails with "must be at least 6 characters" instead of falling back to KEYSTORE_PASSWORD. You removed the exact safety net for the scenario you set out to fix.🩹 The Fix: Restore the fallback before the guard:
📏 Severity: warning
Reply with
@kilocode-bot fix itto have Kilo Code address this issue.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kilocode-bot fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix has been applied successfully. Here's a summary of what was done:
Applied Fix
The Cloud Agent session modified
.github/workflows/android-build.yml(lines 60-67) to restore theKEYSTORE_PASSWORDfallback logic that was previously removed. The keystore step now uses a two-check validation pattern as requested:Verification
KEY_PASSWORDis empty or short, the code falls back toKEYSTORE_PASSWORDbefore erroringEFFECTIVE_KEY_PASSWORDis masked with::add-mask::and exported via$GITHUB_ENVfor downstream reuseEFFECTIVE_KEY_PASSWORDis used in keystore generation (keytool -keypass), the Gradle release build step (${{ env.EFFECTIVE_KEY_PASSWORD }}), and the apksigner step (${{ env.EFFECTIVE_KEY_PASSWORD }})Per policy, no PR was created with this change — it was applied directly to the existing branch. You can verify the change in the PR thread.