The CLI is a thin terminal entry point over the engine that powers the app. It reads a package without executing it, reports the manifest, the compiled Dart library, the assets and the signing material, and writes the result where a build can collect it. It does not need a phone, an emulator or an Android device.
In short. Build the launcher from source with JDK 17 or newer, run flutterguard scan INPUT.apk --json OUTPUT.json, and add --sarif or --fail-on confirmed when a pipeline needs them. Output parents must already exist, and output files must not already exist. Exit 0 is success, 1 is the confirmed gate, 2 is an error.
Build it from source
There is no published CLI download and no Maven or JitPack dependency to add. Build the launcher from the repository at the tag or commit you intend to run:
git clone https://github.com/anasfik/FlutterGuard.git
cd FlutterGuard
echo "sdk.dir=$ANDROID_HOME" > local.properties
./gradlew :cli:installDist
export PATH="$PWD/cli/build/install/flutterguard/bin:$PATH"
flutterguard --help
sample result: <your output here>
You need JDK 17 or newer, plus an Android SDK with a platform and build-tools installed and ANDROID_HOME pointing at it. The repository build also configures the Android app module, so without that SDK the build fails during configuration; the SDK setup is described in the project README (opens in a new tab). The resulting launcher runs the engine, org.json and kotlinx-coroutines-core from the distribution; the scanning machine does not need the Android SDK.
--help prints the usage line and exits 2. That is the argument-error convention, not a failed build.
Scan one APK
The contract is one input APK and explicit output paths:
flutterguard scan INPUT.apk --json OUTPUT.json [--sarif OUTPUT.sarif] [--fail-on confirmed]
sample result: <your output here>
A runnable example creates its output directory and uses fresh filenames. The parent directory must exist, and neither destination may already exist: the CLI refuses to overwrite a file and exits 2 instead.
mkdir -p ci-out
stamp="$(date -u +%Y%m%dT%H%M%SZ)"
flutterguard scan app-release.apk \
--json "ci-out/report-$stamp.json" \
--sarif "ci-out/report-$stamp.sarif" \
--fail-on confirmed
sample result: <your output here>
The timestamp keeps each run's names new. If you prefer fixed names, delete the previous files or write to a fresh directory first; the same paths cannot be reused in place. Output is staged as sibling temporary files, flushed, then published with atomic moves. A destination that appears during the scan is refused rather than replaced, and a failed publication rolls back what was already written.
What the reports contain
--json writes the engine's redacted report, schema flutterguard/report/2. Values detected as secrets are masked and are never written to disk by the CLI. The file uses the same report model as the app, so a saved Android report and a CLI report are the same shape.
--sarif writes one run of SARIF 2.1.0 in the GitHub code-scanning shape. There is one rule per distinct finding id, with a title, remediation text and severity level. Results carry a rule id, a level, a scrubbed message, a partial fingerprint and one location.
- Locations point at the APK as a
file:URI. They carry no region or line data: the artifact is a binary, and inventing source positions would be false precision. - Fingerprints identify a finding as
findingId|evidence.source. They contain no secret value, snippet or hash of one. - Levels follow confidence. Confirmed critical and high findings are errors; confirmed medium and low are warnings; confirmed informational findings and every suspected finding are notes. Inventory is omitted by default.
The SARIF document is parsed and structurally checked before it is written. Progress and errors go to stderr, so redirecting stdout loses no diagnostics; stdout itself stays empty.
Exit codes and the CI gate
| Exit | Meaning |
|---|---|
0 | Scan completed; the gate was not requested or was not hit. |
1 | Scan completed and --fail-on confirmed found at least one confirmed finding. |
2 | Invalid arguments, unreadable or unsupported input, scan failure, cancellation or output failure. |
The gate is evaluated only after both outputs are published, so exit 1 cannot hide a scan or write error. A confirmed finding means the artifact proves the configuration; it is not proof that the app is exploitable, and only confirmed findings affect the grade.
Use it in CI
The repository includes .github/workflows/apk-scan.yml. It sets up JDK 17, runs the CLI tests, builds the distribution, builds FlutterGuard's own debug APK as an owned fixture, scans it to JSON and SARIF, and keeps both as workflow artifacts for 14 days. A separate job uploads the SARIF to code scanning and is the only one granted security-events: write; fork pull requests skip that job.
The workflow does not use --fail-on on its own fixture. A debug build legitimately contains confirmed findings such as a debuggable manifest and a debug certificate, so the gate would reject the repository itself. Gate usage belongs to the project being scanned, where a confirmed policy failure should stop the build.
CI artifact retention, upload permissions and any code-scanning ingestion are properties of the workflow you run, not of the CLI. Local SARIF validation is not GitHub acceptance: alert display and fingerprint deduplication remain unverified until the workflow actually runs on GitHub with those permissions.
Limits and honest edges
- One APK per invocation. The CLI does not assemble split APK sets. Convert an AAB to APKs with
bundletoolfirst. - No comparison command. Comparing releases is an Android app feature, for compatible scans of the same package. The CLI has no diff mode.
- No decompilation. The compiled library is AOT machine code. Snapshot metadata describes how it was built; it is not decompiled Dart and does not definitively prove obfuscation.
- No standalone SDK. The engine lives at engine/ in the repository (opens in a new tab) and is not a separately published package.
- Static evidence only. The scan does not run the target, test a backend or observe traffic. Confirmed findings are artifact facts; a lead still needs verification against a system you own or are authorised to test.
- Build-time network is not scan-time network. The scan stays local. Building may fetch Gradle dependencies, and a CI job may upload artifacts according to its own policy.
Questions people ask
Can I download the FlutterGuard CLI?
No published CLI distribution is established. Build the launcher from the repository. The GitHub release provides the Android app, and there is no Maven or JitPack package for the engine.
Does the CLI need a device or Android Studio?
The launcher runs on a JVM with JDK 17 or newer and needs no Android device or emulator. The repository build also configures the Android app module, so use the Android SDK setup described in the project README.
Is a CLI scan offline?
The scan itself is local and the report is written where you point it. Building the project may download Gradle dependencies, and a CI job uploads artifacts only if its own workflow says so.
Can the CLI compare two releases?
No CLI comparison command exists. Release comparisons happen in the Android app, for compatible scans of the same package.
Does a SARIF file prove GitHub code scanning works?
No. The CLI validates the SARIF document before writing it, but GitHub security-tab ingestion, alert display and fingerprint deduplication are unverified until the workflow runs on GitHub with the required permissions.
Does a confirmed finding prove the app is exploitable?
No. Confirmed means the artifact proves the configuration. It is not an exploitability verdict, and only confirmed findings affect the grade.
Get the source and run the first scan.
FlutterGuard is MIT licensed. The repository contains the Android app, the shared engine and the CLI; no account or hosted service is involved.
FlutterGuard on GitHub (opens in a new tab) Android release (opens in a new tab) Inspect an APK on Android