RUScan

// CLI

apksonar

The apksonar npm package wraps the whole REST API. Zero dependencies, Node 18+, one behavioural binary: upload, wait, parse JSON.

Установка: npmjs.com/package/apksonar, исходники: github.com/matestani/apksonar-tools

npm i -g apksonar
curl -O https://apksonar.com/tools/apksonar.mjs && node apksonar.mjs scan app.apk

COMMANDS

The scan cycle

Four commands cover the full cycle:

apksonar scan app-release.apk --mode fast --wait
apksonar scan app-release.apk --mode deep --wait   # Ghidra native pass
apksonar status 42
apksonar report BCh8dT6Lg3VbLHqXz0ZT70DL

ENVIRONMENT

Variables

Three environment variables; the key comes from your account:

export APKSONAR_URL=https://apksonar.com
export APKSONAR_KEY_ID=apk_mcp_…
export APKSONAR_SECRET=…

EXIT CODES

For pipelines

Exit codes for CI: 0 clean or completed successfully, 1 request error, 2 scan finished with critical or high findings. That is what lets a pipeline fail the build on the code alone.

CI RECIPES

Ready pipelines

A GitHub Action on npx:

# .github/workflows/security.yml
name: apk-security
on: [push]
jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: ./gradlew assembleRelease
      - name: APKSonar scan
        env:
          APKSONAR_URL: https://apksonar.com
          APKSONAR_KEY_ID: ${{ secrets.APKSONAR_KEY_ID }}
          APKSONAR_SECRET: ${{ secrets.APKSONAR_SECRET }}
        run: |
          npx --yes apksonar scan app/build/outputs/apk/release/app-release.apk \
            --mode fast --wait --out apksonar.json
      - uses: actions/upload-artifact@v4
        if: always()
        with: { name: apksonar-report, path: apksonar.json }

GitLab CI

GitLab on raw curl (v1 key):

# .gitlab-ci.yml
apk_security:
  stage: test
  image: curlimages/curl:latest
  script:
    - ID=$(curl -s -X POST https://apksonar.com/api/v1/scans
        -H "Authorization: Bearer $APKSONAR_KEY"
        -F "[email protected]" | sed -n 's/.*"id":\([0-9]*\).*/\1/p')
    - until curl -s https://apksonar.com/api/v1/scans/$ID -H "Authorization: Bearer $APKSONAR_KEY" | tee r.json | grep -q '"status":"done\|failed"'; do sleep 10; done
    - grep -q '"critical":0' r.json && grep -q '"high":0' r.json

API response format →