storebound scan: offline rejection-risk scan of the project itself

Detects the stack (native iOS / Android, React Native, Expo, Capacitor, Cordova,
Flutter, Unity, Godot) and the SDKs from a maintained table with versions,
file:line and each vendor's disclosure page, then reports App Store and Google
Play rejection risks with guideline, evidence, fix, severity and skill: 2.1(a)
demo account and placeholder text, 5.1.1(v) account deletion, 4.8 login
services, 3.1.1 restore and outside payments, 3.1.2 subscription info, 5.1.2(i)
ATT, purpose strings, privacy link, privacy manifest, 2.3.10, 2.3.7, 2.3.8, 4.2
web wrappers, 2.5.1, 2.5.5, ATS, export compliance, 1.3 kids ads, review
prompts, privacy labels vs SDKs; Play target SDK 36, delete-account URL, App
access, foreground services, exact alarms, QUERY_ALL_PACKAGES, SMS / call log,
com.example package name.

Proposes Data safety / App Privacy / ATT / privacy manifest answers (detected
file:line or ask owner) as a diff against the config; --write adds only the
detected ones. scan.ignore records owner-accepted findings. MCP tool scan
(read-only), validate includes open findings, desktop Checks tab shows them.
Fixtures for iOS, Android, Capacitor, Unity, Flutter, clean and teaser.
This commit is contained in:
CRTkafa 2026-10-11 15:20:55 +00:00
parent 02d90de77a
commit 00a38cd305
109 changed files with 3103 additions and 31 deletions

57
cli/scan.ts Normal file
View file

@ -0,0 +1,57 @@
// Offline, read-only scan of the project itself for App Store and Google Play rejection risks, before you submit.
// storebound scan [--dir <project>] [--config <file>] [--store apple|play] [--json] [--no-declarations]
// storebound scan --write also write the detected dataSafety / appPrivacy answers into the config
// Reads the project files (Xcode project, Info.plist, entitlements, privacy manifests, Podfile.lock, Package.resolved,
// Gradle files, AndroidManifest.xml, package.json, app.json, capacitor.config, pubspec, Unity and Godot settings), the
// config and the listing files; detects the stack and the SDKs; reports each risk with the guideline, the evidence
// (file:line), the fix, a severity and the skill; and proposes the Data safety / App Privacy / ATT / privacy manifest
// answers as a diff against the config. Nothing is written without --write (and --dry always wins). No network.
// Exit 1 while an open blocker is left.
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
import { dirname, join, resolve } from 'node:path';
import type { Args } from './lib/args';
import { CONFIG_NAMES } from './lib/config';
import { log, printJson, warn } from './lib/log';
import { upsertBlock } from './lib/scan/config-edit';
import { formatScan, runScan } from './lib/scan';
/** Project folder: --dir, else the folder of the nearest storebound.config.* above the working directory, else it. */
function projectDir(args: Args): string {
if (args.get('dir')) return resolve(args.get('dir')!);
for (let d = process.cwd(); ; d = dirname(d)) {
if (CONFIG_NAMES.some(n => existsSync(join(d, n)))) return d;
if (dirname(d) === d) return process.cwd();
}
}
export async function run(args: Args): Promise<void> {
const dir = projectDir(args);
if (!existsSync(dir)) throw new Error(`${dir} does not exist`);
const { report, configPath } = await runScan(dir, { config: args.get('config') });
const store = args.get('store');
if (store === 'apple' || store === 'play') {
report.findings = report.findings.filter(f => f.store === store);
report.counts = { blocker: 0, high: 0, medium: 0, low: 0, accepted: 0 };
for (const f of report.findings) { if (f.accepted) report.counts.accepted++; else report.counts[f.severity]++; }
} else if (store) throw new Error('--store apple | play');
if (args.has('json')) printJson(report);
else console.log(formatScan(report, { declarations: !args.has('no-declarations') }));
if (args.has('write')) {
const d = report.declarations;
if (!configPath) warn('scan', '--write: no storebound.config.ts in this project (storebound init creates one)');
else if (!d.changed) log('scan', `--write: nothing to change in ${report.config}`);
else if (args.has('dry')) log('scan', `--dry: would write ${[d.diff.some(x => x.change !== 'kept' && x.change !== 'same') && 'dataSafety', d.appPrivacyChange && 'appPrivacy'].filter(Boolean).join(' + ')} into ${report.config}`);
else {
let text = readFileSync(configPath, 'utf8');
const ds = d.dataSafety!;
const missing = (['encryptedInTransit', 'deletionRequest'] as const).filter(k => typeof ds[k] !== 'boolean');
if (d.diff.some(x => x.change === 'add' || x.change === 'merge'))
text = upsertBlock(text, configPath, 'dataSafety', ds, missing.length ? `storebound scan: answer ${missing.join(' and ')} (ask the owner; store-declarations skill)` : undefined);
if (d.appPrivacyChange) text = upsertBlock(text, configPath, 'appPrivacy', d.appPrivacy);
writeFileSync(configPath, text);
log('scan', `wrote the detected answers into ${report.config}${missing.length ? `; still to answer: dataSafety.${missing.join(', dataSafety.')}` : ''}. Review the diff (git diff) before pushing it to a store.`);
}
}
if (report.counts.blocker) process.exitCode = 1;
}