Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,29 @@ jobs:
# keystore-store-password: ${{ secrets.KEYSTORE_STORE_PASSWORD }}
# keystore-key-alias: 'your-key-alias'
# keystore-key-password: ${{ secrets.KEYSTORE_KEY_PASSWORD }}
# keystore-path: 'tools/buildtools/upload-key.keystore' # Optional: for custom keystore locations
```

## Inputs

| Input | Description | Required | Default |
| ------------------------- | ---------------------------------------- | -------- | ------- |
| `github-token` | GitHub Token | Yes | - |
| `working-directory` | Working directory for the build command | No | `.` |
| `validate-gradle-wrapper` | Whether to validate the Gradle wrapper | No | `true` |
| `setup-java` | Whether to run actions/setup-java action | No | `true` |
| `variant` | Build variant (debug/release) | No | `debug` |
| `sign` | Whether to sign the build with keystore | No | - |
| `re-sign` | Re-sign the APK with new JS bundle | No | `false` |
| `keystore-file` | Path to the keystore file | No | - |
| `keystore-base64` | Base64 encoded keystore file | No | - |
| `keystore-store-file` | Keystore store file name | No | - |
| `keystore-store-password` | Keystore store password | No | - |
| `keystore-key-alias` | Keystore key alias | No | - |
| `keystore-key-password` | Keystore key password | No | - |
| `rock-build-extra-params` | Extra parameters for rock build:android | No | - |
| `comment-bot` | Whether to comment PR with build link | No | `true` |
| Input | Description | Required | Default |
| ------------------------- | ---------------------------------------- | -------- | ------------------ |
| `github-token` | GitHub Token | Yes | - |
| `working-directory` | Working directory for the build command | No | `.` |
| `validate-gradle-wrapper` | Whether to validate the Gradle wrapper | No | `true` |
| `setup-java` | Whether to run actions/setup-java action | No | `true` |
| `variant` | Build variant (debug/release) | No | `debug` |
| `sign` | Whether to sign the build with keystore | No | - |
| `re-sign` | Re-sign the APK with new JS bundle | No | `false` |
| `keystore-file` | Path to the keystore file | No | - |
| `keystore-base64` | Base64 encoded keystore file | No | - |
| `keystore-store-file` | Keystore store file name | No | - |
| `keystore-store-password` | Keystore store password | No | - |
| `keystore-key-alias` | Keystore key alias | No | - |
| `keystore-key-password` | Keystore key password | No | - |
| `keystore-path` | where the keystore should be placed | No | `release.keystore` |
| `rock-build-extra-params` | Extra parameters for rock build:android | No | - |
| `comment-bot` | Whether to comment PR with build link | No | `true` |

## Outputs

Expand Down
15 changes: 12 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ inputs:
keystore-key-password:
description: 'Keystore key password'
required: false
keystore-path:
description: 'Path within the Android source directory where the keystore should be placed'
required: false
default: 'release.keystore'
comment-bot:
description: 'Whether to send a comment under PR with the link to the generated build'
required: false
Expand Down Expand Up @@ -200,10 +204,15 @@ runs:
- name: Decode and store keystore file
if: ${{ !env.ARTIFACT_URL && inputs.sign }}
run: |
KEYSTORE_TARGET_PATH="$ANDROID_SOURCE_DIR/$APP_NAME/${{ inputs.keystore-path }}"
mkdir -p "$(dirname "$KEYSTORE_TARGET_PATH")" || {
echo "Failed to create keystore directory: $(dirname "$KEYSTORE_TARGET_PATH")"
exit 1
}
if [ -n "${{ inputs.keystore-file }}" ]; then
cp "${{ inputs.keystore-file }}" $ANDROID_SOURCE_DIR/$APP_NAME/release.keystore
cp "${{ inputs.keystore-file }}" "$KEYSTORE_TARGET_PATH"
else
echo "${{ inputs.keystore-base64 }}" | base64 --decode > $ANDROID_SOURCE_DIR/$APP_NAME/release.keystore
echo "${{ inputs.keystore-base64 }}" | base64 --decode > "$KEYSTORE_TARGET_PATH"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Keystore Path Traversal Vulnerability

The keystore-path input is vulnerable to path traversal. It's used directly in file path construction without validation, allowing files to be written outside the intended directory. This could lead to overwriting system files.

Fix in Cursor Fix in Web

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's the same as in the previous PR (we decided it wouldn't be an issue):
https://github.com/callstackincubator/ios/pull/16/files#r2382447133

fi
shell: bash
working-directory: ${{ inputs.working-directory }}
Expand Down Expand Up @@ -303,7 +312,7 @@ runs:
if: ${{ !env.ARTIFACT_URL && inputs.sign }}
run: |
rm $HOME/.gradle/gradle.properties
rm $ANDROID_SOURCE_DIR/$APP_NAME/release.keystore
rm "$ANDROID_SOURCE_DIR/$APP_NAME/${{ inputs.keystore-path }}"
shell: bash
working-directory: ${{ inputs.working-directory }}

Expand Down