-
Notifications
You must be signed in to change notification settings - Fork 5
feat: kotlin/android sdk to kmp #299
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -300,56 +300,150 @@ jobs: | |
| - name: Install cross (for Android targets, if not cached) | ||
| run: command -v cross || cargo install cross --git https://github.com/cross-rs/cross --locked | ||
|
|
||
| - name: Build Kotlin bindings (host + Android ABIs) | ||
| - name: Build Kotlin native libraries (host + Android ABIs) | ||
| run: ./scripts/build-kotlin.sh | ||
|
|
||
| - name: Setup Android SDK | ||
| uses: android-actions/setup-android@v4 | ||
| with: | ||
| packages: tools platform-tools platforms;android-35 build-tools;35.0.0 | ||
|
|
||
| # iOS targets are disabled on Linux (kotlin.native.ignoreDisabledTargets); | ||
| # this runs commonTest on the host JVM against the host libidkit_kmp. | ||
| - name: Run tests | ||
| working-directory: kotlin/ | ||
| run: gradle bindings:test | ||
| run: ./gradlew :idkit:testReleaseUnitTest | ||
|
|
||
| - name: Build Kotlin sample app | ||
| working-directory: kotlin/Examples/IDKitSampleApp | ||
| run: ./gradlew :app:assembleDebug | ||
|
|
||
| - name: Validate Kotlin Maven publication | ||
| - name: Build KMP sample app (Android) | ||
| working-directory: kotlin/Examples/IDKitKmpSampleApp | ||
| run: ./gradlew :androidApp:assembleDebug | ||
|
|
||
| # Validates the Android slice of the KMP publication. The iOS variants and | ||
| # complete root metadata can only be produced on macOS; the publish workflow | ||
| # runs there and the build fails remote publishing from non-Mac hosts. | ||
| - name: Validate Kotlin Maven publication (Android slice) | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| ./kotlin/Examples/IDKitSampleApp/gradlew -p kotlin :bindings:publishToMavenLocal | ||
| ./kotlin/Examples/IDKitSampleApp/gradlew -p kotlin \ | ||
| ./kotlin/gradlew -p kotlin :idkit:publishToMavenLocal | ||
| ./kotlin/gradlew -p kotlin \ | ||
| -Pidkit.publish.mavenCentral=true \ | ||
| :bindings:publishToMavenCentral --dry-run | ||
| :idkit:publishToMavenCentral --dry-run | ||
|
|
||
| VERSION="$(grep '^version=' kotlin/gradle.properties | cut -d= -f2- | tr -d '[:space:]')" | ||
| ARTIFACT_DIR="$HOME/.m2/repository/com/worldcoin/idkit/$VERSION" | ||
| ARTIFACT_BASE="$ARTIFACT_DIR/idkit-$VERSION" | ||
| REPO="$HOME/.m2/repository/com/worldcoin" | ||
| ROOT_BASE="$REPO/idkit/$VERSION/idkit-$VERSION" | ||
| ANDROID_BASE="$REPO/idkit-android/$VERSION/idkit-android-$VERSION" | ||
|
|
||
| for artifact in \ | ||
| "$ARTIFACT_BASE.aar" \ | ||
| "$ARTIFACT_BASE.pom" \ | ||
| "$ARTIFACT_BASE.module" \ | ||
| "$ARTIFACT_BASE-sources.jar" \ | ||
| "$ARTIFACT_BASE-javadoc.jar"; do | ||
| "$ROOT_BASE.pom" \ | ||
| "$ROOT_BASE.module" \ | ||
| "$ANDROID_BASE.aar" \ | ||
| "$ANDROID_BASE.pom" \ | ||
| "$ANDROID_BASE.module" \ | ||
| "$ANDROID_BASE-sources.jar"; do | ||
| if [ ! -s "$artifact" ]; then | ||
| echo "::error::Missing Maven publication artifact: $artifact" | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| grep -q '<groupId>com.worldcoin</groupId>' "$ARTIFACT_BASE.pom" | ||
| grep -q '<artifactId>idkit</artifactId>' "$ARTIFACT_BASE.pom" | ||
| grep -q '<packaging>aar</packaging>' "$ARTIFACT_BASE.pom" | ||
| grep -q '<groupId>com.worldcoin</groupId>' "$ROOT_BASE.pom" | ||
| grep -q '<artifactId>idkit</artifactId>' "$ROOT_BASE.pom" | ||
| grep -q '<packaging>aar</packaging>' "$ANDROID_BASE.pom" | ||
|
|
||
| AAR_CONTENTS="$(mktemp)" | ||
| jar tf "$ARTIFACT_BASE.aar" > "$AAR_CONTENTS" | ||
| jar tf "$ANDROID_BASE.aar" > "$AAR_CONTENTS" | ||
| for abi in arm64-v8a armeabi-v7a x86 x86_64; do | ||
| if ! grep -q "^jni/$abi/libidkit.so$" "$AAR_CONTENTS"; then | ||
| echo "::error::Missing native library in AAR: jni/$abi/libidkit.so" | ||
| if ! grep -q "^jni/$abi/libidkit_kmp.so$" "$AAR_CONTENTS"; then | ||
| echo "::error::Missing native library in AAR: jni/$abi/libidkit_kmp.so" | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| kotlin-ios: | ||
| name: Kotlin SDK - iOS targets (macOS) | ||
| runs-on: macos-latest | ||
| needs: rust-core | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Read rust-toolchain | ||
| id: rust-version | ||
| run: echo "toolchain=$(yq '.toolchain.channel' rust-toolchain.toml)" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Install Rust | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| toolchain: ${{ steps.rust-version.outputs.toolchain }} | ||
|
|
||
| - name: Setup Java | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: temurin | ||
| java-version: "17" | ||
|
|
||
| - name: Setup Android SDK | ||
| uses: android-actions/setup-android@v4 | ||
|
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. Semgrep identified an issue in your code: GitHub Actions workflow uses a mutable version tag ( More details about thisThe Exploit scenario: An attacker could compromise the
Since this action runs early in your workflow ( To resolve this comment: ✨ Commit fix suggestion
Alternatively, if you need to avoid depending on a third-party action here, replace 💬 Ignore this findingReply with Semgrep commands to ignore this finding.
Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by third-party-action-not-pinned-to-commit-sha. You can view more details about this finding in the Semgrep AppSec Platform. |
||
| with: | ||
| packages: tools platform-tools platforms;android-35 build-tools;35.0.0 | ||
|
|
||
| - name: Cache Rust dependencies | ||
| uses: Swatinem/rust-cache@v2 | ||
|
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. Semgrep identified an issue in your code: GitHub Action More details about thisThe GitHub Action Here's how an attacker could exploit this:
By pinning to a full commit SHA (e.g., To resolve this comment: ✨ Commit fix suggestion
Alternatively, if you need to stay on the latest 💬 Ignore this findingReply with Semgrep commands to ignore this finding.
Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by third-party-action-not-pinned-to-commit-sha. You can view more details about this finding in the Semgrep AppSec Platform. |
||
| with: | ||
| key: kotlin-ios | ||
|
|
||
| - name: Build Kotlin native libraries (host + iOS) | ||
| run: SKIP_ANDROID=1 ./scripts/build-kotlin.sh | ||
|
|
||
| # commonTest on the iOS simulator: exercises the cinterop bridge and the | ||
| # statically linked Rust core on Kotlin/Native. | ||
| - name: Run iOS simulator tests | ||
| working-directory: kotlin/ | ||
| run: ./gradlew :idkit:iosSimulatorArm64Test | ||
|
|
||
| # Rehearse the full multi-target publication so release-day breakage in | ||
| # variant metadata or publication wiring is caught on PRs (the release | ||
| # itself is the first time the real publish tasks otherwise run). The | ||
| # rehearsal flag skips the Android .so check — mac runners cannot | ||
| # cross-build them — and remote publishing rejects that flag, so it | ||
| # cannot leak into a release. | ||
| - name: Rehearse full KMP publication (Maven Local) | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| ./kotlin/gradlew -p kotlin :idkit:publishToMavenLocal \ | ||
| -Pidkit.rehearsal.allowMissingAndroidNativeLibs=true | ||
|
|
||
| VERSION="$(grep '^version=' kotlin/gradle.properties | cut -d= -f2- | tr -d '[:space:]')" | ||
| REPO="$HOME/.m2/repository/com/worldcoin" | ||
|
|
||
| for module in idkit-iosarm64 idkit-iossimulatorarm64 idkit-iosx64; do | ||
| for ext in klib pom module; do | ||
| artifact="$REPO/$module/$VERSION/$module-$VERSION.$ext" | ||
| if [ ! -s "$artifact" ]; then | ||
| echo "::error::Missing Maven publication artifact: $artifact" | ||
| exit 1 | ||
| fi | ||
| done | ||
| done | ||
|
|
||
| # The root module metadata is what consumers resolve; every target | ||
| # variant must be present in it. | ||
| ROOT_MODULE="$REPO/idkit/$VERSION/idkit-$VERSION.module" | ||
| for variant in \ | ||
| releaseApiElements-published \ | ||
| iosArm64ApiElements-published \ | ||
| iosSimulatorArm64ApiElements-published \ | ||
| iosX64ApiElements-published; do | ||
| if ! grep -q "\"$variant\"" "$ROOT_MODULE"; then | ||
| echo "::error::Root Gradle module metadata is missing variant: $variant" | ||
| exit 1 | ||
| fi | ||
| done | ||
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.
Semgrep identified an issue in your code:
GitHub Action not pinned to commit SHA;
@stabletag can be updated with malicious code, compromising your workflow at runtime.More details about this
The GitHub Action
dtolnay/rust-toolchain@stableis pinned to thestabletag rather than a specific commit SHA. This means the action can change at any time when the tag is updated.Attack scenario:
dtolnay/rust-toolchainrepository or performs a man-in-the-middle attackstabletag—for example, injecting code that steals environment secrets or injects a backdoor into your build artifactsstableversion since the action is not pinned to a specific commitcontents: readaccess, allowing it to read your repository code and potentially exfiltrate sensitive dataBy pinning to a full commit SHA (e.g.,
dtolnay/rust-toolchain@a6e1e2f3c4b5d6e7f8a9b0c1d2e3f4a5b6c7d8e9), you ensure that only that exact version of the action runs, making it immutable and preventing this type of supply-chain attack.To resolve this comment:
✨ Commit fix suggestion
dtolnay/rust-toolchain@stablewith a full 40-character commit SHA for the exact action release you want to use, for exampledtolnay/rust-toolchain@<full-commit-sha>.uses: dtolnay/rust-toolchain@<full-commit-sha> # stableor# v1.x.y, so future updates are easier to manage.with:block unchanged so the workflow still installs the toolchain from${{ steps.rust-version.outputs.toolchain }}. Pinning the action version makes the workflow immutable, while thetoolchain:input can still select the Rust version to install.Alternatively, if you need the workflow to track a newer release of this action, update it to that release first, then pin that release's commit SHA instead of using a tag like
@stable.💬 Ignore this finding
Reply with Semgrep commands to ignore this finding.
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasonsAlternatively, triage in Semgrep AppSec Platform to ignore the finding created by third-party-action-not-pinned-to-commit-sha.
You can view more details about this finding in the Semgrep AppSec Platform.