scan: accounts mean User ID, never email without evidence; accounts.signUp (username -> PSL_ACM_USER_ID_OTHER_AUTH); built bundles are low-trust evidence; privacy-manifest and scan find plugins in monorepo node_modules, workspaces and local SwiftPM packages
This commit is contained in:
parent
179e4d3815
commit
582ea909ca
45 changed files with 625 additions and 38 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -15,3 +15,6 @@ apps/desktop/src-tauri/binaries/
|
||||||
apps/desktop/src-tauri/gen/
|
apps/desktop/src-tauri/gen/
|
||||||
apps/desktop/.screens/
|
apps/desktop/.screens/
|
||||||
.scratch/
|
.scratch/
|
||||||
|
|
||||||
|
# scan fixtures: a monorepo whose Capacitor plugins live in apps/native/node_modules
|
||||||
|
!tests/fixtures/scan/monorepo/apps/native/node_modules/
|
||||||
|
|
|
||||||
13
CHANGELOG.md
13
CHANGELOG.md
|
|
@ -2,6 +2,19 @@
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
- Fixes from a live monorepo game (username accounts, Capacitor in `apps/native`):
|
||||||
|
- `scan` no longer turns accounts into "Email Address" / `PSL_EMAIL`: accounts mean User ID; email is "detected"
|
||||||
|
only with real evidence (an email field or keyboard, an `email` property in a body / schema / type, an email
|
||||||
|
validation or endpoint, an email sign-in call, an SDK that collects it, or `accounts.signUp`), otherwise a question.
|
||||||
|
- New `accounts.signUp` (`username`, `username-password`, `email-password`, `email-link`, `phone`, `oauth`, `other`):
|
||||||
|
`scan` proposes the account data and `dataSafety.accountCreation` from it (`scan --write` writes it); a username
|
||||||
|
with no password is Play's "Username and other authentication" (`PSL_ACM_USER_ID_OTHER_AUTH`).
|
||||||
|
- Built output (bundles, dist / build, the Capacitor webDir, minified files) is low-trust evidence: `scan` prefers
|
||||||
|
the own sources and `*.test.*` / `*.spec.*` files are no longer app sources.
|
||||||
|
- `privacy-manifest --ios` finds Capacitor / Cordova / React Native plugins without `--sdk-dirs`: node_modules next to
|
||||||
|
the app's package.json and above it, workspace packages, local SwiftPM packages (CapApp-SPM), nested Pods.
|
||||||
|
- `scan` reads the native dependencies behind each npm plugin (its podspec, Package.swift, android/build.gradle), so an
|
||||||
|
ad SDK wrapped in a Capacitor plugin (Unity LevelPlay) is detected; LevelPlay's Swift package is matched too.
|
||||||
- `storebound flow list | validate | run <name>`: repo-local workflows in `store/workflows/*.yml` (or
|
- `storebound flow list | validate | run <name>`: repo-local workflows in `store/workflows/*.yml` (or
|
||||||
`storebound.workflows.yml|json|ts`): named steps run in order with progress, `${VAR}` params and captures, `if:`
|
`storebound.workflows.yml|json|ts`): named steps run in order with progress, `${VAR}` params and captures, `if:`
|
||||||
conditions, sub-flows, before / after / onError hooks. Writes run as dry runs unless `--apply`; owner steps (submit,
|
conditions, sub-flows, before / after / onError hooks. Writes run as dry runs unless `--apply`; owner steps (submit,
|
||||||
|
|
|
||||||
|
|
@ -300,8 +300,19 @@ export interface AccountsConfig {
|
||||||
deletionUrl?: string;
|
deletionUrl?: string;
|
||||||
/** Where deletion starts inside the app, e.g. "Settings > Account > Delete account" (goes into the review notes). */
|
/** Where deletion starts inside the app, e.g. "Settings > Account > Delete account" (goes into the review notes). */
|
||||||
inApp?: string;
|
inApp?: string;
|
||||||
|
/**
|
||||||
|
* How people sign up. Decides which account data `storebound scan` proposes and the Play Data safety "Account
|
||||||
|
* creation" answer it suggests for dataSafety.accountCreation (ACCOUNT_SIGN_UP in declarations.ts):
|
||||||
|
* 'username' = a username or player name picked in the app with no password and no email (the server keeps a token on
|
||||||
|
* the device), 'username-password', 'email-password', 'email-link' (magic link / one-time code by email), 'phone'
|
||||||
|
* (SMS code), 'oauth' (Sign in with Apple / Google / Facebook ...), 'other'. Only 'email-*' means an email address.
|
||||||
|
*/
|
||||||
|
signUp?: AccountSignUp[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type AccountSignUp = 'username' | 'username-password' | 'email-password' | 'email-link' | 'phone' | 'oauth' | 'other';
|
||||||
|
export const ACCOUNT_SIGN_UPS: readonly AccountSignUp[] = ['username', 'username-password', 'email-password', 'email-link', 'phone', 'oauth', 'other'];
|
||||||
|
|
||||||
/** How a reviewer gets past a sign-in (App Review demo account, Play App content > App access). The credentials
|
/** How a reviewer gets past a sign-in (App Review demo account, Play App content > App access). The credentials
|
||||||
* themselves are never in the config: "reviewDemoAccount" in .storebound/credentials.json or REVIEW_DEMO_USER /
|
* themselves are never in the config: "reviewDemoAccount" in .storebound/credentials.json or REVIEW_DEMO_USER /
|
||||||
* REVIEW_DEMO_PASSWORD. See the review-access skill. */
|
* REVIEW_DEMO_PASSWORD. See the review-access skill. */
|
||||||
|
|
@ -712,6 +723,8 @@ export function validateConfig(c: unknown): string[] {
|
||||||
if (cfg.accounts) {
|
if (cfg.accounts) {
|
||||||
if (typeof cfg.accounts.enabled !== 'boolean') e.push('accounts.enabled: true | false');
|
if (typeof cfg.accounts.enabled !== 'boolean') e.push('accounts.enabled: true | false');
|
||||||
if (cfg.accounts.deletionUrl !== undefined && !URL_RE.test(cfg.accounts.deletionUrl)) e.push('accounts.deletionUrl: must be an https URL');
|
if (cfg.accounts.deletionUrl !== undefined && !URL_RE.test(cfg.accounts.deletionUrl)) e.push('accounts.deletionUrl: must be an https URL');
|
||||||
|
if (cfg.accounts.signUp !== undefined && (!Array.isArray(cfg.accounts.signUp) || cfg.accounts.signUp.some(x => !ACCOUNT_SIGN_UPS.includes(x))))
|
||||||
|
e.push(`accounts.signUp: a list of ${ACCOUNT_SIGN_UPS.map(x => `'${x}'`).join(' | ')}`);
|
||||||
}
|
}
|
||||||
if (cfg.reviewAccess && typeof cfg.reviewAccess.signInRequired !== 'boolean') e.push('reviewAccess.signInRequired: true | false');
|
if (cfg.reviewAccess && typeof cfg.reviewAccess.signInRequired !== 'boolean') e.push('reviewAccess.signInRequired: true | false');
|
||||||
const langs = cfg.languages;
|
const langs = cfg.languages;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
// content rights), the export compliance answer and the App Review details (presence only, masked). Every answer the
|
// content rights), the export compliance answer and the App Review details (presence only, masked). Every answer the
|
||||||
// config does not prove is an "ask the owner" item, never a guess (AGENTS.md rule 5). Pure.
|
// config does not prove is an "ask the owner" item, never a guess (AGENTS.md rule 5). Pure.
|
||||||
import { parseCsv } from './csv';
|
import { parseCsv } from './csv';
|
||||||
import { type DataSafety, type PlayPurpose, profileOf, type ShipConfig } from './config';
|
import { type AccountSignUp, type DataSafety, type PlayPurpose, profileOf, type ShipConfig } from './config';
|
||||||
import { CATEGORIES, dataSafetyCsv } from './data-safety';
|
import { CATEGORIES, dataSafetyCsv } from './data-safety';
|
||||||
import type { DeclarationsResult, DeclAsk } from './desktop-protocol';
|
import type { DeclarationsResult, DeclAsk } from './desktop-protocol';
|
||||||
import { NOTES_MAX_BYTES, reviewNotes } from './review-details';
|
import { NOTES_MAX_BYTES, reviewNotes } from './review-details';
|
||||||
|
|
@ -13,6 +13,42 @@ import { NOTES_MAX_BYTES, reviewNotes } from './review-details';
|
||||||
/** Where `storebound play data-safety` keeps the CSV it uploaded last (gitignored). */
|
/** Where `storebound play data-safety` keeps the CSV it uploaded last (gitignored). */
|
||||||
export const DATA_SAFETY_UPLOADED = '.storebound/data-safety.uploaded.csv';
|
export const DATA_SAFETY_UPLOADED = '.storebound/data-safety.uploaded.csv';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Play Data safety "Account creation" (question PSL_SUPPORTED_ACCOUNT_CREATION_METHODS): the options Play Console
|
||||||
|
* shows (Data safety > Data collection and security > Account creation) and the response ids storebound writes.
|
||||||
|
* Google publishes no list of these ids (README "Not verified"): compare with a Console export (App content > Data
|
||||||
|
* safety > Export to CSV) when an import is refused.
|
||||||
|
*/
|
||||||
|
export const ACCOUNT_CREATION: Record<string, string> = {
|
||||||
|
PSL_ACM_USER_ID_PASSWORD: 'Username and password',
|
||||||
|
PSL_ACM_USER_ID_OTHER_AUTH: 'Username and other authentication',
|
||||||
|
PSL_ACM_USER_ID_PASSWORD_OTHER_AUTH: 'Username, password and other authentication',
|
||||||
|
PSL_ACM_OAUTH: 'OAuth',
|
||||||
|
PSL_ACM_OTHER: 'Other',
|
||||||
|
PSL_ACM_NONE: 'My app does not allow users to create an account',
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* accounts.signUp -> the closest Play "Account creation" option and the account data it means (Play type ids).
|
||||||
|
* A username with no password and a server token kept on the device is "Username and other authentication" (the
|
||||||
|
* token is the other authentication; there is no "username only" option): User ID, and no email.
|
||||||
|
*/
|
||||||
|
export const ACCOUNT_SIGN_UP: Record<AccountSignUp, { acm: string; data: string[] }> = {
|
||||||
|
username: { acm: 'PSL_ACM_USER_ID_OTHER_AUTH', data: ['PSL_USER_ACCOUNT'] },
|
||||||
|
'username-password': { acm: 'PSL_ACM_USER_ID_PASSWORD', data: ['PSL_USER_ACCOUNT'] },
|
||||||
|
'email-password': { acm: 'PSL_ACM_USER_ID_PASSWORD', data: ['PSL_EMAIL', 'PSL_USER_ACCOUNT'] },
|
||||||
|
'email-link': { acm: 'PSL_ACM_USER_ID_OTHER_AUTH', data: ['PSL_EMAIL', 'PSL_USER_ACCOUNT'] },
|
||||||
|
phone: { acm: 'PSL_ACM_USER_ID_OTHER_AUTH', data: ['PSL_PHONE', 'PSL_USER_ACCOUNT'] },
|
||||||
|
oauth: { acm: 'PSL_ACM_OAUTH', data: ['PSL_USER_ACCOUNT'] },
|
||||||
|
other: { acm: 'PSL_ACM_OTHER', data: ['PSL_USER_ACCOUNT'] },
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The accountCreation answer accounts.signUp implies (null when signUp is not set). */
|
||||||
|
export function accountCreationOf(signUp: readonly AccountSignUp[] | undefined): string[] | null {
|
||||||
|
if (!signUp?.length) return null;
|
||||||
|
return [...new Set(signUp.map(s => ACCOUNT_SIGN_UP[s]?.acm).filter((x): x is string => !!x))];
|
||||||
|
}
|
||||||
|
|
||||||
/** Play data type -> the App Store App Privacy data type it usually is (Apple's own names). */
|
/** Play data type -> the App Store App Privacy data type it usually is (Apple's own names). */
|
||||||
export const APPLE_PRIVACY: Record<string, [string, string]> = {
|
export const APPLE_PRIVACY: Record<string, [string, string]> = {
|
||||||
PSL_NAME: ['Contact Info', 'Name'], PSL_EMAIL: ['Contact Info', 'Email Address'], PSL_PHONE: ['Contact Info', 'Phone Number'],
|
PSL_NAME: ['Contact Info', 'Name'], PSL_EMAIL: ['Contact Info', 'Email Address'], PSL_PHONE: ['Contact Info', 'Phone Number'],
|
||||||
|
|
@ -88,7 +124,7 @@ export function declarations(config: ShipConfig, inp: DeclarationInputs): Declar
|
||||||
if (ds.collectsData && !types.length) ask.push({ area: 'dataSafety', id: 'ds-no-types', text: 'collectsData is true but no data type is listed.', fix: 'List each data type the app or its SDKs collect in dataSafety.data, or set collectsData: false if nothing is.' });
|
if (ds.collectsData && !types.length) ask.push({ area: 'dataSafety', id: 'ds-no-types', text: 'collectsData is true but no data type is listed.', fix: 'List each data type the app or its SDKs collect in dataSafety.data, or set collectsData: false if nothing is.' });
|
||||||
if (!ds.collectsData && types.length) ask.push({ area: 'dataSafety', id: 'ds-contradiction', text: 'collectsData is false but data types are listed.', fix: 'Decide which is true; Play rejects a form that says both.' });
|
if (!ds.collectsData && types.length) ask.push({ area: 'dataSafety', id: 'ds-contradiction', text: 'collectsData is false but data types are listed.', fix: 'Decide which is true; Play rejects a form that says both.' });
|
||||||
if (profile === 'game' && !ds.data.PSL_DEVICE_ID) ask.push({ area: 'dataSafety', id: 'ds-ads-id', text: 'A game profile usually ships an ads or analytics SDK that reads the advertising id, but PSL_DEVICE_ID is not declared.', fix: 'Check every SDK\'s data disclosure; declare PSL_DEVICE_ID (advertising, analytics) if any reads it.' });
|
if (profile === 'game' && !ds.data.PSL_DEVICE_ID) ask.push({ area: 'dataSafety', id: 'ds-ads-id', text: 'A game profile usually ships an ads or analytics SDK that reads the advertising id, but PSL_DEVICE_ID is not declared.', fix: 'Check every SDK\'s data disclosure; declare PSL_DEVICE_ID (advertising, analytics) if any reads it.' });
|
||||||
if (config.accounts?.enabled && (ds.accountCreation ?? ['PSL_ACM_NONE']).includes('PSL_ACM_NONE')) ask.push({ area: 'dataSafety', id: 'ds-accounts', text: 'The app has accounts, but the form says no account creation.', fix: 'Set dataSafety.accountCreation to the methods the app offers, and the delete-account URL in dataSafety.extra.' });
|
if (config.accounts?.enabled && (ds.accountCreation ?? ['PSL_ACM_NONE']).includes('PSL_ACM_NONE')) ask.push({ area: 'dataSafety', id: 'ds-accounts', text: 'The app has accounts, but the form says no account creation.', fix: `Set dataSafety.accountCreation to the methods the app offers${accountCreationOf(config.accounts.signUp) ? ` (accounts.signUp means ${JSON.stringify(accountCreationOf(config.accounts.signUp))})` : ' (or set accounts.signUp and run storebound scan)'}, and the delete-account URL in dataSafety.extra.` });
|
||||||
if (!ds.deletionRequest && config.accounts?.enabled) ask.push({ area: 'dataSafety', id: 'ds-deletion', text: 'Users can create accounts but deletionRequest is false.', fix: 'Both stores want account deletion (account-deletion skill); then set deletionRequest: true.' });
|
if (!ds.deletionRequest && config.accounts?.enabled) ask.push({ area: 'dataSafety', id: 'ds-deletion', text: 'Users can create accounts but deletionRequest is false.', fix: 'Both stores want account deletion (account-deletion skill); then set deletionRequest: true.' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
132
cli/lib/node-packages.ts
Normal file
132
cli/lib/node-packages.ts
Normal file
|
|
@ -0,0 +1,132 @@
|
||||||
|
// Where a JS project's native plugins (Capacitor, Cordova, React Native) live, also in monorepos: Node's own lookup
|
||||||
|
// (node_modules next to the app's package.json and in every folder above it, up to the repo root), workspace package
|
||||||
|
// folders (package.json "workspaces", npm / yarn / pnpm-style array or { packages }, as Bun reads them) and local
|
||||||
|
// SwiftPM packages (`.package(path:)` in a Package.swift, e.g. Capacitor 8's CapApp-SPM). Used by `privacy-manifest`
|
||||||
|
// and `scan`. Read-only; never throws.
|
||||||
|
import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs';
|
||||||
|
import { dirname, join, resolve } from 'node:path';
|
||||||
|
|
||||||
|
interface PkgJson { name?: string; dependencies?: Record<string, string>; workspaces?: string[] | { packages?: string[] } }
|
||||||
|
const readJson = (p: string): PkgJson | null => { try { return JSON.parse(readFileSync(p, 'utf8')) as PkgJson; } catch { return null; } };
|
||||||
|
const isDir = (p: string): boolean => { try { return statSync(p).isDirectory(); } catch { return false; } };
|
||||||
|
const real = (p: string): string => { try { return realpathSync(p); } catch { return resolve(p); } };
|
||||||
|
|
||||||
|
/** The repo root at or above `dir`: the nearest folder with .git, else the top-most package.json with workspaces,
|
||||||
|
* else `dir` itself. */
|
||||||
|
export function repoRoot(dir: string): string {
|
||||||
|
let ws: string | null = null;
|
||||||
|
for (let d = resolve(dir); ; d = dirname(d)) {
|
||||||
|
if (existsSync(join(d, '.git'))) return d;
|
||||||
|
if (readJson(join(d, 'package.json'))?.workspaces) ws = d;
|
||||||
|
if (dirname(d) === d) return ws ?? resolve(dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Workspace package folders of a repo root ("apps/*", "packages/**" one level deep, or literal folders). */
|
||||||
|
export function workspaceDirs(root: string): string[] {
|
||||||
|
const w = readJson(join(root, 'package.json'))?.workspaces;
|
||||||
|
const pats = Array.isArray(w) ? w : Array.isArray(w?.packages) ? w.packages : [];
|
||||||
|
const out: string[] = [];
|
||||||
|
for (const p of pats) {
|
||||||
|
if (typeof p !== 'string' || p.startsWith('!')) continue;
|
||||||
|
const m = /^(.*?)\/\*\*?$/.exec(p);
|
||||||
|
if (m) {
|
||||||
|
const base = join(root, m[1]!);
|
||||||
|
let names: string[] = [];
|
||||||
|
try { names = readdirSync(base).sort(); } catch { /* missing */ }
|
||||||
|
for (const n of names) if (existsSync(join(base, n, 'package.json'))) out.push(join(base, n));
|
||||||
|
} else if (!p.includes('*') && existsSync(join(root, p, 'package.json'))) out.push(join(root, p));
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Folder of package `name` as Node resolves it from `fromDir` (node_modules there and in every parent up to `root`),
|
||||||
|
* else the workspace package of that name. */
|
||||||
|
export function resolvePackage(name: string, fromDir: string, root: string): string | null {
|
||||||
|
const top = resolve(root);
|
||||||
|
for (let d = resolve(fromDir); ; d = dirname(d)) {
|
||||||
|
const p = join(d, 'node_modules', name);
|
||||||
|
if (existsSync(join(p, 'package.json'))) return p;
|
||||||
|
if (d === top || dirname(d) === d) break;
|
||||||
|
}
|
||||||
|
for (const w of workspaceDirs(top)) if (readJson(join(w, 'package.json'))?.name === name) return w;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The package has native iOS code: a podspec or Package.swift at its root, or an ios/ folder. */
|
||||||
|
export function hasNativeIos(dir: string): boolean {
|
||||||
|
let names: string[] = [];
|
||||||
|
try { names = readdirSync(dir); } catch { return false; }
|
||||||
|
return names.some(n => n.endsWith('.podspec') || n === 'Package.swift') || isDir(join(dir, 'ios'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Local SwiftPM packages (`.package(path: "...")` / `.package(name: "X", path: "...")`) of every Package.swift under
|
||||||
|
* `dir` (a few levels, skipping build output and checkouts). */
|
||||||
|
export function localSwiftPackages(dir: string): string[] {
|
||||||
|
const out: string[] = [];
|
||||||
|
const skip = new Set(['Pods', 'build', 'DerivedData', 'node_modules', '.build', 'SourcePackages', '.git', 'xcuserdata']);
|
||||||
|
const walk = (d: string, depth: number) => {
|
||||||
|
if (depth > 4) return;
|
||||||
|
let names: string[] = [];
|
||||||
|
try { names = readdirSync(d); } catch { return; }
|
||||||
|
for (const n of names) {
|
||||||
|
if (skip.has(n)) continue;
|
||||||
|
const p = join(d, n);
|
||||||
|
if (n === 'Package.swift') {
|
||||||
|
let t = '';
|
||||||
|
try { t = readFileSync(p, 'utf8'); } catch { continue; }
|
||||||
|
for (const m of t.matchAll(/\.package\(\s*(?:name:\s*"[^"]*"\s*,\s*)?path:\s*"([^"]+)"/g)) {
|
||||||
|
const target = resolve(d, m[1]!);
|
||||||
|
if (isDir(target)) out.push(target);
|
||||||
|
}
|
||||||
|
} else if (isDir(p) && !/\.(xc)?framework$|\.xcassets$/.test(n)) walk(p, depth + 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
walk(dir, 0);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NativePlugin { name: string; dir: string }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The native plugin packages an iOS project at `iosDir` builds: the dependencies of the app's package.json (the
|
||||||
|
* nearest one at or above `iosDir`, i.e. next to capacitor.config) resolved through node_modules and workspaces,
|
||||||
|
* plus the local SwiftPM packages its Package.swift files reference. Without a package.json: every package with
|
||||||
|
* native iOS code in the node_modules folders from `iosDir` up to the repo root. Deduplicated by real path.
|
||||||
|
*/
|
||||||
|
export function nativeIosPlugins(iosDir: string): NativePlugin[] {
|
||||||
|
const start = resolve(iosDir);
|
||||||
|
const root = repoRoot(start);
|
||||||
|
const out: NativePlugin[] = [];
|
||||||
|
const seen = new Set<string>();
|
||||||
|
const add = (dir: string, name?: string) => {
|
||||||
|
const r = real(dir);
|
||||||
|
if (seen.has(r) || !hasNativeIos(dir)) return;
|
||||||
|
seen.add(r);
|
||||||
|
out.push({ name: name ?? readJson(join(dir, 'package.json'))?.name ?? dir.split(/[\\/]/).pop()!, dir });
|
||||||
|
};
|
||||||
|
let appDir: string | null = null;
|
||||||
|
for (let d = start; ; d = dirname(d)) {
|
||||||
|
if (existsSync(join(d, 'package.json'))) { appDir = d; break; }
|
||||||
|
if (d === root || dirname(d) === d) break;
|
||||||
|
}
|
||||||
|
if (appDir) {
|
||||||
|
for (const name of Object.keys(readJson(join(appDir, 'package.json'))?.dependencies ?? {})) {
|
||||||
|
const p = resolvePackage(name, appDir, root);
|
||||||
|
if (p) add(p, name);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (let d = start; ; d = dirname(d)) {
|
||||||
|
const nm = join(d, 'node_modules');
|
||||||
|
let names: string[] = [];
|
||||||
|
try { names = readdirSync(nm).filter(n => !n.startsWith('.')).sort(); } catch { /* none */ }
|
||||||
|
for (const n of names) {
|
||||||
|
if (n.startsWith('@')) { try { for (const k of readdirSync(join(nm, n)).sort()) add(join(nm, n, k), `${n}/${k}`); } catch { /* unreadable */ } }
|
||||||
|
else add(join(nm, n), n);
|
||||||
|
}
|
||||||
|
if (d === root || dirname(d) === d) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const p of localSwiftPackages(start)) add(p);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
// must have in the config before any store sees it. Pure. The online counterparts (URLs answer, the demo account is
|
// must have in the config before any store sees it. Pure. The online counterparts (URLs answer, the demo account is
|
||||||
// on App Review, subscription states) are in validate-rules.ts (profileRules, appleSubscriptionRules).
|
// on App Review, subscription states) are in validate-rules.ts (profileRules, appleSubscriptionRules).
|
||||||
import { profileOf, type ShipConfig } from './config';
|
import { profileOf, type ShipConfig } from './config';
|
||||||
|
import { accountCreationOf } from './declarations';
|
||||||
import { allSubscriptions } from './subscriptions';
|
import { allSubscriptions } from './subscriptions';
|
||||||
|
|
||||||
export interface ProfileIssue { level: 'error' | 'warn'; msg: string }
|
export interface ProfileIssue { level: 'error' | 'warn'; msg: string }
|
||||||
|
|
@ -18,7 +19,10 @@ export function profileIssues(config: ShipConfig, o: { demoAccount: boolean }):
|
||||||
if (config.play && !config.accounts!.deletionUrl) err('accounts.enabled: set accounts.deletionUrl (Play asks for a web page to request account deletion; account-deletion skill)');
|
if (config.play && !config.accounts!.deletionUrl) err('accounts.enabled: set accounts.deletionUrl (Play asks for a web page to request account deletion; account-deletion skill)');
|
||||||
if (config.apple && !config.accounts!.inApp) warn('accounts.enabled: set accounts.inApp to where deletion starts in the app (Apple 5.1.1(v); it goes into the review notes)');
|
if (config.apple && !config.accounts!.inApp) warn('accounts.enabled: set accounts.inApp to where deletion starts in the app (Apple 5.1.1(v); it goes into the review notes)');
|
||||||
if (config.dataSafety) {
|
if (config.dataSafety) {
|
||||||
if (acm.includes('PSL_ACM_NONE')) err('accounts.enabled but dataSafety.accountCreation says PSL_ACM_NONE: list the sign-up methods you offer');
|
if (acm.includes('PSL_ACM_NONE')) {
|
||||||
|
const s = accountCreationOf(config.accounts!.signUp);
|
||||||
|
err(`accounts.enabled but dataSafety.accountCreation says PSL_ACM_NONE: list the sign-up methods you offer${s ? ` (accounts.signUp means accountCreation: ${JSON.stringify(s)})` : ' (accounts.signUp, e.g. [\'username\'] for a username with no password, tells storebound scan which)'}`);
|
||||||
|
}
|
||||||
if (!config.dataSafety.deletionRequest) err('accounts.enabled but dataSafety.deletionRequest is false: people must be able to delete their account and data');
|
if (!config.dataSafety.deletionRequest) err('accounts.enabled but dataSafety.deletionRequest is false: people must be able to delete their account and data');
|
||||||
}
|
}
|
||||||
} else if (config.dataSafety && !acm.includes('PSL_ACM_NONE')) warn('dataSafety.accountCreation lists sign-up methods but accounts.enabled is not set: add accounts { enabled: true, deletionUrl, inApp }');
|
} else if (config.dataSafety && !acm.includes('PSL_ACM_NONE')) warn('dataSafety.accountCreation lists sign-up methods but accounts.enabled is not set: add accounts { enabled: true, deletionUrl, inApp }');
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
// marked "detected (file:line)" or "ask owner", and a diff against the config's dataSafety / appPrivacy blocks.
|
// marked "detected (file:line)" or "ask owner", and a diff against the config's dataSafety / appPrivacy blocks.
|
||||||
// Only detected items are ever written (`scan --write`); "ask owner" items stay questions (AGENTS.md rule 5). Pure.
|
// Only detected items are ever written (`scan --write`); "ask owner" items stay questions (AGENTS.md rule 5). Pure.
|
||||||
import type { AppPrivacyConfig, DataSafety, DataUsage, PlayPurpose, ShipConfig } from '../config';
|
import type { AppPrivacyConfig, DataSafety, DataUsage, PlayPurpose, ShipConfig } from '../config';
|
||||||
import { APPLE_PRIVACY, applePurpose } from '../declarations';
|
import { ACCOUNT_CREATION, ACCOUNT_SIGN_UP, accountCreationOf, APPLE_PRIVACY, applePurpose } from '../declarations';
|
||||||
import { REQUIRED_REASON_APIS } from '../privacy-manifest';
|
import { REQUIRED_REASON_APIS } from '../privacy-manifest';
|
||||||
import { IOS_PERMISSIONS } from './permissions';
|
import { IOS_PERMISSIONS } from './permissions';
|
||||||
import { grep, type Hit, lineOf, type ProjectFacts } from './project';
|
import { grep, grepOwn, type Hit, lineOf, type ProjectFacts } from './project';
|
||||||
import { SIGNALS } from './rules';
|
import { SIGNALS } from './rules';
|
||||||
|
|
||||||
export type DeclArea = 'dataSafety' | 'appPrivacy' | 'att' | 'privacyManifest';
|
export type DeclArea = 'dataSafety' | 'appPrivacy' | 'att' | 'privacyManifest';
|
||||||
|
|
@ -27,6 +27,8 @@ export interface Proposal {
|
||||||
dataSafety: Partial<DataSafety> & { data: Record<string, DataUsage> } | null;
|
dataSafety: Partial<DataSafety> & { data: Record<string, DataUsage> } | null;
|
||||||
appPrivacy: AppPrivacyConfig | null;
|
appPrivacy: AppPrivacyConfig | null;
|
||||||
appPrivacyChange: { from: boolean | null; to: boolean } | null;
|
appPrivacyChange: { from: boolean | null; to: boolean } | null;
|
||||||
|
/** dataSafety.accountCreation --write would set (from accounts.signUp, while the config says PSL_ACM_NONE or nothing). */
|
||||||
|
accountCreationChange: { from: string[] | null; to: string[] } | null;
|
||||||
/** Types an SDK collects that the config's dataSafety does not declare (the privacy-labels rule). */
|
/** Types an SDK collects that the config's dataSafety does not declare (the privacy-labels rule). */
|
||||||
labelGaps: { type: string; apple: string; evidence: Hit[] }[];
|
labelGaps: { type: string; apple: string; evidence: Hit[] }[];
|
||||||
/** --write would change the config. */
|
/** --write would change the config. */
|
||||||
|
|
@ -61,14 +63,27 @@ export function proposeDeclarations(p: ProjectFacts, c: ShipConfig | null, confi
|
||||||
detected.set(d.type, e);
|
detected.set(d.type, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// accounts proven by the config or sign-up code
|
// accounts proven by the config or sign-up code: a user id. Email (or phone) only with real evidence: an email field,
|
||||||
const signUp = grep(p.sources, SIGNALS.signUp, 1);
|
// property, validation, endpoint or sign-in call in the own sources, or accounts.signUp saying so. Built output
|
||||||
if (c?.accounts?.enabled || signUp.length) {
|
// (bundles, the Capacitor webDir) is low trust: alone it only makes a question.
|
||||||
const ev: Hit[] = signUp.length ? signUp : [{ file: configFile?.path ?? 'storebound.config.ts', line: configFile ? lineOf(configFile.text, /accounts\s*:/) : 1, text: 'accounts.enabled' }];
|
const su = grepOwn(p, SIGNALS.signUp, 1);
|
||||||
for (const t of ['PSL_EMAIL', 'PSL_USER_ACCOUNT']) {
|
const signUp = su.built ? [] : su.hits;
|
||||||
const e = detected.get(t) ?? { collect: new Set<PlayPurpose>(), share: new Set<PlayPurpose>(), evidence: [], from: [] };
|
const cfgAt = (re: RegExp, text: string): Hit => ({ file: configFile?.path ?? 'storebound.config.ts', line: configFile ? lineOf(configFile.text, re) : 1, text });
|
||||||
e.collect.add('account'); e.collect.add('functionality'); e.evidence.push(...ev); e.from.push('accounts');
|
const accounts = !!c?.accounts?.enabled || signUp.length > 0;
|
||||||
detected.set(t, e);
|
const signUpCfg = c?.accounts?.signUp ?? [];
|
||||||
|
const markAccount = (t: string, ev: Hit[], from: string) => {
|
||||||
|
const e = detected.get(t) ?? { collect: new Set<PlayPurpose>(), share: new Set<PlayPurpose>(), evidence: [], from: [] };
|
||||||
|
e.collect.add('account'); e.collect.add('functionality'); e.evidence.push(...ev); if (!e.from.includes(from)) e.from.push(from);
|
||||||
|
detected.set(t, e);
|
||||||
|
};
|
||||||
|
if (accounts) {
|
||||||
|
markAccount('PSL_USER_ACCOUNT', signUp.length ? signUp : [cfgAt(/accounts\s*:/, 'accounts.enabled')], 'accounts');
|
||||||
|
for (const s of signUpCfg) for (const t of ACCOUNT_SIGN_UP[s]?.data ?? []) if (t !== 'PSL_USER_ACCOUNT') markAccount(t, [cfgAt(/signUp\s*:/, `accounts.signUp: ${s}`)], `accounts.signUp ${s}`);
|
||||||
|
const em = grepOwn(p, SIGNALS.email, 2);
|
||||||
|
if (em.hits.length && !em.built) markAccount('PSL_EMAIL', em.hits, 'email in the sources');
|
||||||
|
else if (!detected.has('PSL_EMAIL')) {
|
||||||
|
if (em.hits.length) items.push({ area: 'dataSafety', what: 'PSL_EMAIL', value: 'collected? an email field shows up only in built output', status: 'ask', evidence: em.hits.slice(0, 1), note: 'check the source; not written' });
|
||||||
|
else if (!signUpCfg.length) items.push({ area: 'dataSafety', what: 'PSL_EMAIL', value: 'collected? only if sign-up, sign-in or support asks for an email address (none found in the sources)', status: 'ask', evidence: [], note: 'set accounts.signUp to say how people sign up; not written' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const have = c?.dataSafety?.data ?? {};
|
const have = c?.dataSafety?.data ?? {};
|
||||||
|
|
@ -107,8 +122,15 @@ export function proposeDeclarations(p: ProjectFacts, c: ShipConfig | null, confi
|
||||||
if (anyData) items.push({ area: 'dataSafety', what: 'collectsData', value: 'true', status: 'detected', evidence: diff.flatMap(d => d.evidence).slice(0, 1) });
|
if (anyData) items.push({ area: 'dataSafety', what: 'collectsData', value: 'true', status: 'detected', evidence: diff.flatMap(d => d.evidence).slice(0, 1) });
|
||||||
for (const k of ['encryptedInTransit', 'deletionRequest'] as const)
|
for (const k of ['encryptedInTransit', 'deletionRequest'] as const)
|
||||||
items.push({ area: 'dataSafety', what: k, value: c?.dataSafety ? String(c.dataSafety[k]) : '?', status: 'ask', evidence: [], note: k === 'encryptedInTransit' ? 'all traffic over HTTPS / TLS? (ATS and the SDKs\' own endpoints)' : 'can users ask for their data to be deleted?' });
|
items.push({ area: 'dataSafety', what: k, value: c?.dataSafety ? String(c.dataSafety[k]) : '?', status: 'ask', evidence: [], note: k === 'encryptedInTransit' ? 'all traffic over HTTPS / TLS? (ATS and the SDKs\' own endpoints)' : 'can users ask for their data to be deleted?' });
|
||||||
if ((c?.accounts?.enabled || signUp.length) && (c?.dataSafety?.accountCreation ?? ['PSL_ACM_NONE']).includes('PSL_ACM_NONE'))
|
const acmFromCfg = accountCreationOf(signUpCfg);
|
||||||
items.push({ area: 'dataSafety', what: 'accountCreation', value: 'which sign-up methods (PSL_ACM_USER_ID_PASSWORD, PSL_ACM_OAUTH, ...)?', status: 'ask', evidence: signUp.slice(0, 1) });
|
const acmNone = (c?.dataSafety?.accountCreation ?? ['PSL_ACM_NONE']).includes('PSL_ACM_NONE');
|
||||||
|
let accountCreation: string[] | null = null;
|
||||||
|
if (accounts && acmNone) {
|
||||||
|
if (acmFromCfg) {
|
||||||
|
accountCreation = acmFromCfg;
|
||||||
|
items.push({ area: 'dataSafety', what: 'accountCreation', value: `${JSON.stringify(acmFromCfg)} (${acmFromCfg.map(x => ACCOUNT_CREATION[x] ?? x).join('; ')})`, status: 'detected', evidence: [cfgAt(/signUp\s*:/, 'accounts.signUp')], note: 'from accounts.signUp' });
|
||||||
|
} else items.push({ area: 'dataSafety', what: 'accountCreation', value: 'which sign-up methods? set accounts.signUp (\'username\' = username, no password: PSL_ACM_USER_ID_OTHER_AUTH; \'email-password\': PSL_ACM_USER_ID_PASSWORD; \'oauth\': PSL_ACM_OAUTH ...)', status: 'ask', evidence: signUp.slice(0, 1) });
|
||||||
|
}
|
||||||
|
|
||||||
// App Privacy per type (linked / tracking are owner answers)
|
// App Privacy per type (linked / tracking are owner answers)
|
||||||
for (const d of diff) {
|
for (const d of diff) {
|
||||||
|
|
@ -146,10 +168,11 @@ export function proposeDeclarations(p: ProjectFacts, c: ShipConfig | null, confi
|
||||||
if (diff.length) items.push({ area: 'privacyManifest', what: 'NSPrivacyCollectedDataTypes', value: uniq(diff.map(d => d.apple.split(' / ')[1]!)).join(', '), status: 'detected', evidence: diff.flatMap(d => d.evidence).slice(0, 1), note: 'the app\'s own collection; SDKs declare theirs in their manifests' });
|
if (diff.length) items.push({ area: 'privacyManifest', what: 'NSPrivacyCollectedDataTypes', value: uniq(diff.map(d => d.apple.split(' / ')[1]!)).join(', '), status: 'detected', evidence: diff.flatMap(d => d.evidence).slice(0, 1), note: 'the app\'s own collection; SDKs declare theirs in their manifests' });
|
||||||
}
|
}
|
||||||
|
|
||||||
const dsChanged = diff.some(d => d.change === 'add' || d.change === 'merge') || (anyData && c?.dataSafety?.collectsData === false);
|
const dsChanged = diff.some(d => d.change === 'add' || d.change === 'merge') || (anyData && c?.dataSafety?.collectsData === false) || !!accountCreation;
|
||||||
const dataSafety = anyData || c?.dataSafety ? { ...(c?.dataSafety ?? {}), collectsData: anyData || !!c?.dataSafety?.collectsData, data: out } : null;
|
const dataSafety = anyData || c?.dataSafety ? { ...(c?.dataSafety ?? {}), collectsData: anyData || !!c?.dataSafety?.collectsData, ...(accountCreation ? { accountCreation } : {}), data: out } : null;
|
||||||
const from = c?.appPrivacy?.tracking ?? null;
|
const from = c?.appPrivacy?.tracking ?? null;
|
||||||
const appPrivacyChange = tracking !== null && from !== tracking ? { from, to: tracking } : null;
|
const appPrivacyChange = tracking !== null && from !== tracking ? { from, to: tracking } : null;
|
||||||
const appPrivacy = appPrivacyChange ? { ...(c?.appPrivacy ?? {}), tracking: appPrivacyChange.to } : c?.appPrivacy ?? null;
|
const appPrivacy = appPrivacyChange ? { ...(c?.appPrivacy ?? {}), tracking: appPrivacyChange.to } : c?.appPrivacy ?? null;
|
||||||
return { items, diff, dataSafety, appPrivacy, appPrivacyChange, labelGaps, changed: dsChanged || !!appPrivacyChange };
|
const accountCreationChange = accountCreation ? { from: c?.dataSafety?.accountCreation ?? null, to: accountCreation } : null;
|
||||||
|
return { items, diff, dataSafety, appPrivacy, appPrivacyChange, accountCreationChange, labelGaps, changed: dsChanged || !!appPrivacyChange };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,12 +116,13 @@ export function formatScan(r: ScanReport, o: { declarations?: boolean } = {}): s
|
||||||
for (const x of items) L.push(` ${x.status === 'detected' ? 'detected ' : 'ask owner'} ${x.what}: ${x.value}${x.evidence[0] ? ` (${x.evidence[0].file}:${x.evidence[0].line})` : ''}${x.note ? ` · ${x.note}` : ''}`);
|
for (const x of items) L.push(` ${x.status === 'detected' ? 'detected ' : 'ask owner'} ${x.what}: ${x.value}${x.evidence[0] ? ` (${x.evidence[0].file}:${x.evidence[0].line})` : ''}${x.note ? ` · ${x.note}` : ''}`);
|
||||||
}
|
}
|
||||||
const changes = d.diff.filter(x => x.change === 'add' || x.change === 'merge');
|
const changes = d.diff.filter(x => x.change === 'add' || x.change === 'merge');
|
||||||
if (changes.length || d.appPrivacyChange) {
|
if (changes.length || d.appPrivacyChange || d.accountCreationChange) {
|
||||||
L.push('', ` Diff against ${r.config ?? 'the config'} (written only with --write):`);
|
L.push('', ` Diff against ${r.config ?? 'the config'} (written only with --write):`);
|
||||||
for (const x of changes) {
|
for (const x of changes) {
|
||||||
if (x.change === 'add') L.push(` + dataSafety.data.${x.type}: { shared: ${x.after.shared}, collect: [${x.after.collect.join(', ')}]${x.after.share?.length ? `, share: [${x.after.share.join(', ')}]` : ''} }`);
|
if (x.change === 'add') L.push(` + dataSafety.data.${x.type}: { shared: ${x.after.shared}, collect: [${x.after.collect.join(', ')}]${x.after.share?.length ? `, share: [${x.after.share.join(', ')}]` : ''} }`);
|
||||||
else L.push(` ~ dataSafety.data.${x.type}: collect [${x.before!.collect.join(', ')}] -> [${x.after.collect.join(', ')}]${x.after.shared !== x.before!.shared ? `, shared ${x.before!.shared} -> ${x.after.shared}` : ''}${(x.after.share ?? []).join() !== (x.before!.share ?? []).join() ? `, share [${(x.before!.share ?? []).join(', ')}] -> [${(x.after.share ?? []).join(', ')}]` : ''}`);
|
else L.push(` ~ dataSafety.data.${x.type}: collect [${x.before!.collect.join(', ')}] -> [${x.after.collect.join(', ')}]${x.after.shared !== x.before!.shared ? `, shared ${x.before!.shared} -> ${x.after.shared}` : ''}${(x.after.share ?? []).join() !== (x.before!.share ?? []).join() ? `, share [${(x.before!.share ?? []).join(', ')}] -> [${(x.after.share ?? []).join(', ')}]` : ''}`);
|
||||||
}
|
}
|
||||||
|
if (d.accountCreationChange) L.push(` ~ dataSafety.accountCreation: ${d.accountCreationChange.from ? JSON.stringify(d.accountCreationChange.from) : 'unset'} -> ${JSON.stringify(d.accountCreationChange.to)}`);
|
||||||
if (d.appPrivacyChange) L.push(` ~ appPrivacy.tracking: ${d.appPrivacyChange.from ?? 'unset'} -> ${d.appPrivacyChange.to}`);
|
if (d.appPrivacyChange) L.push(` ~ appPrivacy.tracking: ${d.appPrivacyChange.from ?? 'unset'} -> ${d.appPrivacyChange.to}`);
|
||||||
} else if (r.config) L.push('', ` No changes to ${r.config}: the dataSafety / appPrivacy blocks already cover what was detected.`);
|
} else if (r.config) L.push('', ` No changes to ${r.config}: the dataSafety / appPrivacy blocks already cover what was detected.`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@
|
||||||
// privacy manifests, the Android manifest (permissions, services, target SDK) and the app's own source files.
|
// privacy manifests, the Android manifest (permissions, services, target SDK) and the app's own source files.
|
||||||
// Tolerant on purpose: an unreadable or odd file is skipped, never an exception.
|
// Tolerant on purpose: an unreadable or odd file is skipped, never an exception.
|
||||||
import { readdirSync, readFileSync, statSync } from 'node:fs';
|
import { readdirSync, readFileSync, statSync } from 'node:fs';
|
||||||
import { basename, extname, join, relative, sep } from 'node:path';
|
import { basename, dirname, extname, join, relative, sep } from 'node:path';
|
||||||
|
import { resolvePackage } from '../node-packages';
|
||||||
import { type Manifest, parseManifest } from '../privacy-manifest';
|
import { type Manifest, parseManifest } from '../privacy-manifest';
|
||||||
import { type DepRef, type Eco, matchesSdk, SDKS, type SdkDef } from './sdks';
|
import { type DepRef, type Eco, matchesSdk, SDKS, type SdkDef } from './sdks';
|
||||||
|
|
||||||
|
|
@ -85,6 +86,8 @@ export interface ProjectFacts {
|
||||||
remoteStart: { url: string; at: Loc } | null;
|
remoteStart: { url: string; at: Loc } | null;
|
||||||
/** App source files (Swift, Objective-C, Kotlin, Java, Dart, JS / TS, C#, GDScript, HTML). */
|
/** App source files (Swift, Objective-C, Kotlin, Java, Dart, JS / TS, C#, GDScript, HTML). */
|
||||||
sources: { path: string; text: string }[];
|
sources: { path: string; text: string }[];
|
||||||
|
/** Folders of built web output inside the project (Capacitor webDir): low-trust evidence, see isBuilt. */
|
||||||
|
builtDirs: string[];
|
||||||
/** Files looked at, relative to root (for the report). */
|
/** Files looked at, relative to root (for the report). */
|
||||||
scanned: number;
|
scanned: number;
|
||||||
}
|
}
|
||||||
|
|
@ -257,6 +260,46 @@ function packageJson(file: string, text: string): DepRef[] {
|
||||||
return Object.entries(j.dependencies ?? {}).map(([n, v]) => ({ eco: 'npm' as const, name: n, version: v, file, line: lineOf(text, `"${n}"`) }));
|
return Object.entries(j.dependencies ?? {}).map(([n, v]) => ({ eco: 'npm' as const, name: n, version: v, file, line: lineOf(text, `"${n}"`) }));
|
||||||
} catch { return []; }
|
} catch { return []; }
|
||||||
}
|
}
|
||||||
|
/** `s.dependency 'IronSourceSDK', '~> 9.6'` lines of a podspec (a native plugin's own CocoaPods dependencies). */
|
||||||
|
function podspec(file: string, text: string): DepRef[] {
|
||||||
|
return [...text.matchAll(/^\s*\w+\.dependency\s+['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?/gm)].map(m => ({ eco: 'cocoapods' as const, name: m[1]!, version: m[2] ?? null, file, line: lineAt(text, m.index!) }));
|
||||||
|
}
|
||||||
|
/** `.package(url: "...", from: "1.0")` lines of a Package.swift. */
|
||||||
|
function packageSwift(file: string, text: string): DepRef[] {
|
||||||
|
return [...text.matchAll(/\.package\(\s*(?:name:\s*"[^"]*"\s*,\s*)?url:\s*"([^"]+)"\s*,?\s*(?:(?:from|exact):\s*)?(?:"([^"]+)")?/g)]
|
||||||
|
.map(m => ({ eco: 'spm' as const, name: m[1]!, version: m[2] ?? null, file, line: lineAt(text, m.index!) }));
|
||||||
|
}
|
||||||
|
/** The native dependencies an npm plugin package brings (its podspec, Package.swift and android/build.gradle), with
|
||||||
|
* paths relative to the scanned root. Capacitor / Cordova / React Native plugins wrap the real SDK this way. */
|
||||||
|
function pluginNativeDeps(root: string, dir: string): DepRef[] {
|
||||||
|
const out: DepRef[] = [];
|
||||||
|
const rd = (p: string): string => { try { return readFileSync(p, 'utf8'); } catch { return ''; } };
|
||||||
|
const rel = (p: string) => relative(root, p).split(sep).join('/');
|
||||||
|
let names: string[] = [];
|
||||||
|
try { names = readdirSync(dir); } catch { return out; }
|
||||||
|
for (const n of names) {
|
||||||
|
if (n.endsWith('.podspec')) out.push(...podspec(rel(join(dir, n)), rd(join(dir, n))));
|
||||||
|
else if (n === 'Package.swift') out.push(...packageSwift(rel(join(dir, n)), rd(join(dir, n))));
|
||||||
|
}
|
||||||
|
for (const g of ['android/build.gradle', 'android/build.gradle.kts']) { const t = rd(join(dir, g)); if (t) out.push(...gradle(rel(join(dir, g)), t)); }
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Built output (bundles, dist / build folders, minified files, the Capacitor webDir): low-trust evidence for what the
|
||||||
|
* app collects; the own sources are preferred and these are only a fallback. */
|
||||||
|
export function isBuilt(path: string, builtDirs: readonly string[] = []): boolean {
|
||||||
|
return /(^|\/)(bundles?|dist|build|out|www|\.output|\.vite)\//.test(path) || /\.min\.(js|css)$|\.map$|\.(bundle|chunk)\.js$/.test(path)
|
||||||
|
|| builtDirs.some(d => path.startsWith(`${d}/`));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** grep the own sources first; built output (isBuilt) only when they have no match. `built` marks that fallback. */
|
||||||
|
export function grepOwn(p: Pick<ProjectFacts, 'sources' | 'builtDirs'>, re: RegExp, max = 5): { hits: Hit[]; built: boolean } {
|
||||||
|
const own = grep(p.sources, re, max, f => !isBuilt(f, p.builtDirs));
|
||||||
|
if (own.length) return { hits: own, built: false };
|
||||||
|
const b = grep(p.sources, re, max, f => isBuilt(f, p.builtDirs));
|
||||||
|
return { hits: b, built: b.length > 0 };
|
||||||
|
}
|
||||||
|
|
||||||
function pubspec(file: string, text: string): DepRef[] {
|
function pubspec(file: string, text: string): DepRef[] {
|
||||||
const sec = /^dependencies:\n([\s\S]*?)(?=^\S|$(?![\s\S]))/m.exec(text);
|
const sec = /^dependencies:\n([\s\S]*?)(?=^\S|$(?![\s\S]))/m.exec(text);
|
||||||
if (!sec) return [];
|
if (!sec) return [];
|
||||||
|
|
@ -315,6 +358,7 @@ export function detectProject(root: string): ProjectFacts {
|
||||||
let remoteStart: ProjectFacts['remoteStart'] = null;
|
let remoteStart: ProjectFacts['remoteStart'] = null;
|
||||||
const sources: { path: string; text: string }[] = [];
|
const sources: { path: string; text: string }[] = [];
|
||||||
const stacks = new Set<Stack>();
|
const stacks = new Set<Stack>();
|
||||||
|
const builtDirs: string[] = [];
|
||||||
let pubLock = new Map<string, string>();
|
let pubLock = new Map<string, string>();
|
||||||
|
|
||||||
for (const f of files) {
|
for (const f of files) {
|
||||||
|
|
@ -376,6 +420,12 @@ export function detectProject(root: string): ProjectFacts {
|
||||||
const t = read(f);
|
const t = read(f);
|
||||||
const d = packageJson(f, t);
|
const d = packageJson(f, t);
|
||||||
deps.push(...d);
|
deps.push(...d);
|
||||||
|
// the native SDKs behind each plugin, resolved like Node does (node_modules next to this package.json, then up
|
||||||
|
// to the root, then workspace packages): apps/native/node_modules in a monorepo too
|
||||||
|
for (const x of d) {
|
||||||
|
const dir = resolvePackage(x.name, join(root, dirname(f)), root);
|
||||||
|
if (dir) deps.push(...pluginNativeDeps(root, dir));
|
||||||
|
}
|
||||||
const names = new Set(d.map(x => x.name));
|
const names = new Set(d.map(x => x.name));
|
||||||
if (names.has('react-native')) stacks.add('react-native');
|
if (names.has('react-native')) stacks.add('react-native');
|
||||||
if (names.has('expo')) stacks.add('expo');
|
if (names.has('expo')) stacks.add('expo');
|
||||||
|
|
@ -403,6 +453,8 @@ export function detectProject(root: string): ProjectFacts {
|
||||||
} else if (/^capacitor\.config\.(json|ts|js)$/.test(n)) {
|
} else if (/^capacitor\.config\.(json|ts|js)$/.test(n)) {
|
||||||
stacks.add('capacitor');
|
stacks.add('capacitor');
|
||||||
const t = read(f);
|
const t = read(f);
|
||||||
|
const wd = /webDir\s*["']?\s*:\s*["']([^"']+)["']/.exec(t)?.[1];
|
||||||
|
if (wd) builtDirs.push(join(dirname(f), wd).split(sep).join('/').replace(/^\.\//, '').replace(/\/$/, ''));
|
||||||
const m = /server\s*["']?\s*:\s*\{[\s\S]*?\burl["']?\s*:\s*["'](https?:\/\/[^"']+)["']/.exec(t);
|
const m = /server\s*["']?\s*:\s*\{[\s\S]*?\burl["']?\s*:\s*["'](https?:\/\/[^"']+)["']/.exec(t);
|
||||||
if (m && !/^https?:\/\/(localhost|127\.0\.0\.1|10\.0\.2\.2|192\.168\.)/.test(m[1]!)) remoteStart = { url: m[1]!, at: { file: f, line: lineAt(t, m.index! + m[0].indexOf(m[1]!)) } };
|
if (m && !/^https?:\/\/(localhost|127\.0\.0\.1|10\.0\.2\.2|192\.168\.)/.test(m[1]!)) remoteStart = { url: m[1]!, at: { file: f, line: lineAt(t, m.index! + m[0].indexOf(m[1]!)) } };
|
||||||
} else if (n === 'config.xml' && /<widget\b/.test(read(f))) {
|
} else if (n === 'config.xml' && /<widget\b/.test(read(f))) {
|
||||||
|
|
@ -441,7 +493,7 @@ export function detectProject(root: string): ProjectFacts {
|
||||||
for (const m of t.matchAll(/^permissions\/([a-z_]+)=true/gm)) android.permissions.push({ name: `android.permission.${m[1]!.toUpperCase()}`, at: { file: f, line: lineAt(t, m.index!) } });
|
for (const m of t.matchAll(/^permissions\/([a-z_]+)=true/gm)) android.permissions.push({ name: `android.permission.${m[1]!.toUpperCase()}`, at: { file: f, line: lineAt(t, m.index!) } });
|
||||||
}
|
}
|
||||||
// app sources
|
// app sources
|
||||||
if (SRC_EXT.has(extname(n)) && !testy && !/\.min\.js$|\.d\.ts$|(^|\/)(Plugins|ThirdParty|third_party|Packages|addons)\//.test(f) && !/\.config\.(ts|js)$/.test(n)) {
|
if (SRC_EXT.has(extname(n)) && !testy && !/\.(test|spec)\.[cm]?[jt]sx?$/.test(n) && !/\.min\.js$|\.d\.ts$|(^|\/)(Plugins|ThirdParty|third_party|Packages|addons)\//.test(f) && !/\.config\.(ts|js)$/.test(n)) {
|
||||||
const t = read(f);
|
const t = read(f);
|
||||||
if (t && !t.includes('\u0000')) sources.push({ path: f, text: t });
|
if (t && !t.includes('\u0000')) sources.push({ path: f, text: t });
|
||||||
}
|
}
|
||||||
|
|
@ -490,7 +542,7 @@ export function detectProject(root: string): ProjectFacts {
|
||||||
for (const x of extra.services) if (!svc.has(key('service', x.name))) android.services.push(x);
|
for (const x of extra.services) if (!svc.has(key('service', x.name))) android.services.push(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { root, stacks: [...stacks], ios, android: isAndroid, deps, sdks, plist, plistSources, entitlements, privacyManifests, androidInfo: android, native, remoteStart, sources, scanned: files.length };
|
return { root, stacks: [...stacks], ios, android: isAndroid, deps, sdks, plist, plistSources, entitlements, privacyManifests, androidInfo: android, native, remoteStart, sources, builtDirs, scanned: files.length };
|
||||||
}
|
}
|
||||||
|
|
||||||
/** NDK r27 flag and the linker flag of older NDKs that make native libraries 16 KB aligned. */
|
/** NDK r27 flag and the linker flag of older NDKs that make native libraries 16 KB aligned. */
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ import { allSubscriptions } from '../subscriptions';
|
||||||
import { LISTED_SDKS, REQUIRED_REASON_APIS } from '../privacy-manifest';
|
import { LISTED_SDKS, REQUIRED_REASON_APIS } from '../privacy-manifest';
|
||||||
import { IOS_PERMISSIONS, vaguePurpose } from './permissions';
|
import { IOS_PERMISSIONS, vaguePurpose } from './permissions';
|
||||||
import { playRules } from './play-rules';
|
import { playRules } from './play-rules';
|
||||||
import { grep, type Hit, lineOf, type ProjectFacts } from './project';
|
import { grep, grepOwn, type Hit, lineOf, type ProjectFacts } from './project';
|
||||||
import { versionAtLeast } from './sdks';
|
import { versionAtLeast } from './sdks';
|
||||||
|
|
||||||
export type Severity = 'blocker' | 'high' | 'medium' | 'low';
|
export type Severity = 'blocker' | 'high' | 'medium' | 'low';
|
||||||
|
|
@ -89,6 +89,10 @@ export const SIGNALS = {
|
||||||
thirdPartyLogin: /GIDSignIn|GoogleSignin\.signIn|GoogleSignIn\(|GoogleAuthProvider|signInWithGoogle|FacebookAuthProvider|LoginManager\(\)\.logIn|LoginManager\.logInWithPermissions|signInWithFacebook|FacebookLogin|TwitterAuthProvider|GithubAuthProvider|OAuthProvider\(\s*['"](microsoft\.com|yahoo\.com|twitter\.com|github\.com)/,
|
thirdPartyLogin: /GIDSignIn|GoogleSignin\.signIn|GoogleSignIn\(|GoogleAuthProvider|signInWithGoogle|FacebookAuthProvider|LoginManager\(\)\.logIn|LoginManager\.logInWithPermissions|signInWithFacebook|FacebookLogin|TwitterAuthProvider|GithubAuthProvider|OAuthProvider\(\s*['"](microsoft\.com|yahoo\.com|twitter\.com|github\.com)/,
|
||||||
signIn: /signInWithEmailAndPassword|signInWithPassword|signInWithCredential|createUserWithEmailAndPassword|\bsupabase\.auth\.sign|Amplify\.Auth\.signIn|\bAuth0\b|\bloginWithPassword\b|\.signIn\(\s*\{|\/(api\/)?(auth\/)?(login|signin|sign-in)\b['"`]/,
|
signIn: /signInWithEmailAndPassword|signInWithPassword|signInWithCredential|createUserWithEmailAndPassword|\bsupabase\.auth\.sign|Amplify\.Auth\.signIn|\bAuth0\b|\bloginWithPassword\b|\.signIn\(\s*\{|\/(api\/)?(auth\/)?(login|signin|sign-in)\b['"`]/,
|
||||||
signUp: /createUserWithEmailAndPassword|\bsignUp\s*\(|\bsupabase\.auth\.signUp|Amplify\.Auth\.signUp|\/(api\/)?(auth\/)?(register|signup|sign-up)\b['"`]|["'>](Create (an )?account|Sign up)["'<]/,
|
signUp: /createUserWithEmailAndPassword|\bsignUp\s*\(|\bsupabase\.auth\.signUp|Amplify\.Auth\.signUp|\/(api\/)?(auth\/)?(register|signup|sign-up)\b['"`]|["'>](Create (an )?account|Sign up)["'<]/,
|
||||||
|
// real evidence that the app collects an email address: an email input or keyboard, an `email` property in a request
|
||||||
|
// body / schema / type (not a quoted constant or label), an email validation, an email endpoint or an email sign-in
|
||||||
|
// call. Accounts alone never mean email (a username with a device token has none).
|
||||||
|
email: /type\s*[:=]\s*["'{]*email["'}]|inputMode=["']email["']|keyboardType=["']?email-address|autoComplete=["']email|textContentType=["']?(emailAddress|\.emailAddress)|UITextContentType\.emailAddress|\.keyboardType\(\.emailAddress\)|keyboardType\s*=\s*\.emailAddress|TextInputType\.emailAddress|TYPE_TEXT_VARIATION_EMAIL_ADDRESS|KeyboardType\.Email\b|(?<![\w.$-])["']?email["']?\s*\??:\s*(?![\s"'`]|$)|z\.string\(\)(\.\w+\([^)]*\))*\.email\(|\bisEmail\(|\[\^\\s@\]\+@|\[a-zA-Z0-9._%+-\]\+@|\/(api\/)?(auth\/)?(email|verify-email|forgot-password|reset-password|magic-link)\b['"`]|signInWithEmailAndPassword|createUserWithEmailAndPassword|sendSignInLinkToEmail|createUser\(withEmail:|signIn\(withEmail:|sendSignInLink\(toEmail:|signInWithOtp\(\s*\{\s*email|ASAuthorization\.Scope\.email|requestedScopes[^\n]{0,40}\.email\b/,
|
||||||
deleteAccount: /deleteUser\b|\buser\.delete\(|currentUser\??\.delete\(|\bdeleteAccount\b|delete_account|DeleteAccount|delete-account|["'>]Delete (my |your )?account|\brevokeToken\b|auth\.admin\.deleteUser|Hesab(ı|ımı) sil/i,
|
deleteAccount: /deleteUser\b|\buser\.delete\(|currentUser\??\.delete\(|\bdeleteAccount\b|delete_account|DeleteAccount|delete-account|["'>]Delete (my |your )?account|\brevokeToken\b|auth\.admin\.deleteUser|Hesab(ı|ımı) sil/i,
|
||||||
restore: /restoreCompletedTransactions|AppStore\.sync\(|restorePurchases|restoreTransactions|RestoreTransactions|getAvailablePurchases|\brestorePurchase\b|\.restore\(\)|Restore Purchases|syncPurchases|Purchases\.shared\.restore|store\.restore\b|queryPurchasesAsync/i,
|
restore: /restoreCompletedTransactions|AppStore\.sync\(|restorePurchases|restoreTransactions|RestoreTransactions|getAvailablePurchases|\brestorePurchase\b|\.restore\(\)|Restore Purchases|syncPurchases|Purchases\.shared\.restore|store\.restore\b|queryPurchasesAsync/i,
|
||||||
subscriptionCode: /subscriptionPeriod|Product\.SubscriptionInfo|\.autoRenewable\b|entitlements\.active|SubscriptionStoreView|ProductType\.Subscription|ProductType\.SUBS|BillingClient\.ProductType\.SUBS/,
|
subscriptionCode: /subscriptionPeriod|Product\.SubscriptionInfo|\.autoRenewable\b|entitlements\.active|SubscriptionStoreView|ProductType\.Subscription|ProductType\.SUBS|BillingClient\.ProductType\.SUBS/,
|
||||||
|
|
@ -149,7 +153,8 @@ export function scanRules(inp: ScanInput): ScanFinding[] {
|
||||||
};
|
};
|
||||||
const dep = (id: string): Hit[] => p.sdks.filter(s => s.sdk.id === id).flatMap(s => s.deps.slice(0, 2).map(d => ({ file: d.file, line: d.line, text: `${d.name}${d.version ? ` ${d.version}` : ''}` })));
|
const dep = (id: string): Hit[] => p.sdks.filter(s => s.sdk.id === id).flatMap(s => s.deps.slice(0, 2).map(d => ({ file: d.file, line: d.line, text: `${d.name}${d.version ? ` ${d.version}` : ''}` })));
|
||||||
const sdkHits = (pred: (s: ProjectFacts['sdks'][number]) => boolean): Hit[] => p.sdks.filter(pred).flatMap(s => s.deps.slice(0, 1).map(d => ({ file: d.file, line: d.line, text: `${s.sdk.name}: ${d.name}${d.version ? ` ${d.version}` : ''}` })));
|
const sdkHits = (pred: (s: ProjectFacts['sdks'][number]) => boolean): Hit[] => p.sdks.filter(pred).flatMap(s => s.deps.slice(0, 1).map(d => ({ file: d.file, line: d.line, text: `${s.sdk.name}: ${d.name}${d.version ? ` ${d.version}` : ''}` })));
|
||||||
const src = (re: RegExp, max = 3) => grep(p.sources, re, max);
|
// the own sources first; built output (bundles, dist, the Capacitor webDir, minified files) only as a fallback
|
||||||
|
const src = (re: RegExp, max = 3) => grepOwn(p, re, max).hits;
|
||||||
const native = (path: string) => /\.(swift|m|mm|h)$/.test(path);
|
const native = (path: string) => /\.(swift|m|mm|h)$/.test(path);
|
||||||
const apple = c ? !!c.apple : p.ios;
|
const apple = c ? !!c.apple : p.ios;
|
||||||
const play = c ? !!c.play : p.android;
|
const play = c ? !!c.play : p.android;
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ export const SDKS: SdkDef[] = [
|
||||||
{ id: 'levelplay', name: 'Unity LevelPlay (ironSource)', category: 'ads', tracking: true, data: ADS_DATA,
|
{ id: 'levelplay', name: 'Unity LevelPlay (ironSource)', category: 'ads', tracking: true, data: ADS_DATA,
|
||||||
families: { certified: true, since: '7.2.1', note: 'listed as ironSource; every mediated network must be on the list too' },
|
families: { certified: true, since: '7.2.1', note: 'listed as ironSource; every mediated network must be on the list too' },
|
||||||
docs: 'https://developers.is.com/ironsource-mobile/general/ironsource-mobile-sdk-data-disclosure/',
|
docs: 'https://developers.is.com/ironsource-mobile/general/ironsource-mobile-sdk-data-disclosure/',
|
||||||
match: { cocoapods: ['IronSourceSDK', 'IronSourcePod'], gradle: ['com.unity3d.ads-mediation:mediation-sdk', 'com.ironsource.sdk:mediationsdk'],
|
match: { cocoapods: ['IronSourceSDK', 'IronSourcePod'], spm: ['LevelPlay-Swift-Package'], gradle: ['com.unity3d.ads-mediation:mediation-sdk', 'com.ironsource.sdk:mediationsdk'],
|
||||||
npm: ['ironsource-mediation', 'react-native-ironsource-mediation'], pub: ['unity_levelplay_mediation', 'ironsource_mediation'],
|
npm: ['ironsource-mediation', 'react-native-ironsource-mediation'], pub: ['unity_levelplay_mediation', 'ironsource_mediation'],
|
||||||
unity: ['com.unity.services.levelplay', 'IronSource', 'LevelPlay'] } },
|
unity: ['com.unity.services.levelplay', 'IronSource', 'LevelPlay'] } },
|
||||||
{ id: 'unity-ads', name: 'Unity Ads', category: 'ads', tracking: true, data: ADS_DATA,
|
{ id: 'unity-ads', name: 'Unity Ads', category: 'ads', tracking: true, data: ADS_DATA,
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ export const TOOLS: ToolDef[] = [
|
||||||
args: i => [...opt('lang', i.lang), ...flag('variants', i.variants)] },
|
args: i => [...opt('lang', i.lang), ...flag('variants', i.variants)] },
|
||||||
{ name: 'privacy_manifest', title: 'iOS privacy manifest scan', command: ['privacy-manifest'], write: false, network: false,
|
{ name: 'privacy_manifest', title: 'iOS privacy manifest scan', command: ['privacy-manifest'], write: false, network: false,
|
||||||
description: 'Local scan of an iOS project: PrivacyInfo.xcprivacy present, required-reason APIs declared, SDKs without manifests.',
|
description: 'Local scan of an iOS project: PrivacyInfo.xcprivacy present, required-reason APIs declared, SDKs without manifests.',
|
||||||
props: { ios: { type: 'string', description: 'Path of the iOS project folder, e.g. ios/App' }, sdk_dirs: { type: 'string', description: 'Extra plugin / SDK folders, comma-separated' } },
|
props: { ios: { type: 'string', description: 'Path of the iOS project folder, e.g. ios/App' }, sdk_dirs: { type: 'string', description: 'Extra plugin / SDK folders, comma-separated (node_modules plugins next to the app, workspaces, local SwiftPM packages and Pods are found without it)' } },
|
||||||
required: ['ios'], args: i => [...opt('ios', i.ios), ...opt('sdk-dirs', i.sdk_dirs)] },
|
required: ['ios'], args: i => [...opt('ios', i.ios), ...opt('sdk-dirs', i.sdk_dirs)] },
|
||||||
|
|
||||||
{ name: 'whats_new', title: 'Draft release notes', command: ['whats-new'], write: true, network: false, idempotent: true,
|
{ name: 'whats_new', title: 'Draft release notes', command: ['whats-new'], write: true, network: false, idempotent: true,
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,15 @@
|
||||||
// Local scan of an iOS project for Apple's privacy manifest rules (no network, no credentials, no config needed).
|
// Local scan of an iOS project for Apple's privacy manifest rules (no network, no credentials, no config needed).
|
||||||
// storebound privacy-manifest --ios ios/App [--sdk-dirs node_modules/@capacitor,node_modules/some-plugin] [--json]
|
// storebound privacy-manifest --ios ios/App [--sdk-dirs node_modules/@capacitor,node_modules/some-plugin] [--json]
|
||||||
// Reports: the app's PrivacyInfo.xcprivacy, required-reason API categories used in app sources vs declared, tracking
|
// Reports: the app's PrivacyInfo.xcprivacy, required-reason API categories used in app sources vs declared, tracking
|
||||||
// flag vs the ATT usage string, and every SDK (CocoaPods, .xcframework / .framework, SwiftPM checkouts, --sdk-dirs)
|
// flag vs the ATT usage string, and every SDK (CocoaPods, .xcframework / .framework, SwiftPM checkouts, local SwiftPM
|
||||||
|
// packages, the native plugins of a Capacitor / Cordova / React Native app found through node_modules and workspaces
|
||||||
|
// the way Node resolves them, so a monorepo's apps/native/node_modules works without flags, and --sdk-dirs)
|
||||||
// without its own manifest. Heuristic text scan: it can miss uses inside binaries and flag harmless matches.
|
// without its own manifest. Heuristic text scan: it can miss uses inside binaries and flag harmless matches.
|
||||||
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs';
|
||||||
import { basename, join, relative, resolve } from 'node:path';
|
import { basename, join, relative, resolve } from 'node:path';
|
||||||
import type { Args } from './lib/args';
|
import type { Args } from './lib/args';
|
||||||
import { log } from './lib/log';
|
import { log } from './lib/log';
|
||||||
|
import { nativeIosPlugins } from './lib/node-packages';
|
||||||
import { evaluatePrivacyManifest, type Manifest, parseManifest, scanSources, type SdkInfo } from './lib/privacy-manifest';
|
import { evaluatePrivacyManifest, type Manifest, parseManifest, scanSources, type SdkInfo } from './lib/privacy-manifest';
|
||||||
|
|
||||||
const SKIP = new Set(['.git', 'build', 'DerivedData', 'node_modules', '.build', 'xcuserdata']);
|
const SKIP = new Set(['.git', 'build', 'DerivedData', 'node_modules', '.build', 'xcuserdata']);
|
||||||
|
|
@ -40,10 +43,21 @@ export async function run(args: Args): Promise<void> {
|
||||||
if (!existsSync(root)) throw new Error(`${root} does not exist`);
|
if (!existsSync(root)) throw new Error(`${root} does not exist`);
|
||||||
const sdks: SdkInfo[] = [];
|
const sdks: SdkInfo[] = [];
|
||||||
const sdkRoots = new Set<string>();
|
const sdkRoots = new Set<string>();
|
||||||
const addSdk = (p: string) => { if (sdkRoots.has(p)) return; sdkRoots.add(p); sdks.push({ name: basename(p).replace(/\.(xc)?framework$/, ''), path: relative(process.cwd(), p), hasManifest: hasManifest(p) }); };
|
const seen = new Set<string>();
|
||||||
|
const addSdk = (p: string, name?: string) => {
|
||||||
|
let key = p;
|
||||||
|
try { key = realpathSync(p); } catch { /* keep p */ }
|
||||||
|
if (seen.has(key)) return;
|
||||||
|
seen.add(key); sdkRoots.add(p);
|
||||||
|
sdks.push({ name: name ?? basename(p).replace(/\.(xc)?framework$/, ''), path: relative(process.cwd(), p), hasManifest: hasManifest(p) });
|
||||||
|
};
|
||||||
|
const addPods = (dir: string) => { for (const n of readdirSync(dir)) if (!POD_META.has(n) && statSync(join(dir, n)).isDirectory()) addSdk(join(dir, n)); };
|
||||||
|
|
||||||
const pods = join(root, 'Pods');
|
const pods = join(root, 'Pods');
|
||||||
if (existsSync(pods)) for (const n of readdirSync(pods)) if (!POD_META.has(n) && statSync(join(pods, n)).isDirectory()) addSdk(join(pods, n));
|
if (existsSync(pods)) addPods(pods);
|
||||||
|
// Capacitor / Cordova / React Native plugins: node_modules next to the app's package.json and above it, workspace
|
||||||
|
// packages, local SwiftPM packages (CapApp-SPM)
|
||||||
|
for (const pl of nativeIosPlugins(root)) addSdk(pl.dir, pl.name);
|
||||||
for (const extra of args.list('sdk-dirs')) {
|
for (const extra of args.list('sdk-dirs')) {
|
||||||
const d = resolve(extra);
|
const d = resolve(extra);
|
||||||
if (!existsSync(d)) continue;
|
if (!existsSync(d)) continue;
|
||||||
|
|
@ -57,6 +71,7 @@ export async function run(args: Args): Promise<void> {
|
||||||
if ([...sdkRoots].some(s => p.startsWith(s + '/') || p === s)) return false;
|
if ([...sdkRoots].some(s => p.startsWith(s + '/') || p === s)) return false;
|
||||||
if (isDir) {
|
if (isDir) {
|
||||||
if (/\.(xc)?framework$/.test(p)) { addSdk(p); return false; }
|
if (/\.(xc)?framework$/.test(p)) { addSdk(p); return false; }
|
||||||
|
if (basename(p) === 'Pods') { addPods(p); return false; }
|
||||||
if (basename(p) === 'checkouts' && p.includes('SourcePackages')) { for (const n of readdirSync(p)) addSdk(join(p, n)); return false; }
|
if (basename(p) === 'checkouts' && p.includes('SourcePackages')) { for (const n of readdirSync(p)) addSdk(join(p, n)); return false; }
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,12 +55,12 @@ export async function run(args: Args): Promise<void> {
|
||||||
const d = report.declarations;
|
const d = report.declarations;
|
||||||
if (!configPath) warn('scan', '--write: no storebound.config.ts in this project (storebound init creates one)');
|
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 (!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 if (args.has('dry')) log('scan', `--dry: would write ${[(d.diff.some(x => x.change !== 'kept' && x.change !== 'same') || d.accountCreationChange) && 'dataSafety', d.appPrivacyChange && 'appPrivacy'].filter(Boolean).join(' + ')} into ${report.config}`);
|
||||||
else {
|
else {
|
||||||
let text = readFileSync(configPath, 'utf8');
|
let text = readFileSync(configPath, 'utf8');
|
||||||
const ds = d.dataSafety!;
|
const ds = d.dataSafety!;
|
||||||
const missing = (['encryptedInTransit', 'deletionRequest'] as const).filter(k => typeof ds[k] !== 'boolean');
|
const missing = (['encryptedInTransit', 'deletionRequest'] as const).filter(k => typeof ds[k] !== 'boolean');
|
||||||
if (d.diff.some(x => x.change === 'add' || x.change === 'merge'))
|
if (d.diff.some(x => x.change === 'add' || x.change === 'merge') || d.accountCreationChange)
|
||||||
text = upsertBlock(text, configPath, 'dataSafety', ds, missing.length ? `storebound scan: answer ${missing.join(' and ')} (ask the owner; store-declarations skill)` : undefined);
|
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);
|
if (d.appPrivacyChange) text = upsertBlock(text, configPath, 'appPrivacy', d.appPrivacy);
|
||||||
writeFileSync(configPath, text);
|
writeFileSync(configPath, text);
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,12 @@ deletion requirements" (https://support.google.com/googleplay/android-developer/
|
||||||
takes. No login wall to read it. `storebound validate --play` checks that it answers.
|
takes. No login wall to read it. `storebound validate --play` checks that it answers.
|
||||||
3. In the app: a clear entry, a confirmation step, then the deletion (or the web page). Sign people out afterwards.
|
3. In the app: a clear entry, a confirmation step, then the deletion (or the web page). Sign people out afterwards.
|
||||||
4. Play Data safety: `dataSafety.deletionRequest: true`, `accountCreation` set to the sign-up methods you offer (not
|
4. Play Data safety: `dataSafety.deletionRequest: true`, `accountCreation` set to the sign-up methods you offer (not
|
||||||
`PSL_ACM_NONE`). Google does not publish the question ids for the delete-account URL: export the form once
|
`PSL_ACM_NONE`). Say how people sign up in `accounts.signUp` and `storebound scan` proposes it: `username` (a name
|
||||||
|
picked in the app, no password, no email; a server token on the device) is Play's "Username and other
|
||||||
|
authentication" (`PSL_ACM_USER_ID_OTHER_AUTH`) with User ID as the only account data; `username-password` and
|
||||||
|
`email-password` are "Username and password" (`PSL_ACM_USER_ID_PASSWORD`); `email-link` and `phone` are
|
||||||
|
`PSL_ACM_USER_ID_OTHER_AUTH`; `oauth` is `PSL_ACM_OAUTH`; `other` is `PSL_ACM_OTHER`. An account alone never means
|
||||||
|
an email address: declare Email only when the app asks for one. Google does not publish the question ids for the delete-account URL: export the form once
|
||||||
(Play Console > App content > Data safety > Export to CSV), copy the id, and add it as
|
(Play Console > App content > Data safety > Export to CSV), copy the id, and add it as
|
||||||
`dataSafety.extra: [{ question: '<id>', value: '<deletionUrl>' }]`; otherwise enter the URL in the Console after
|
`dataSafety.extra: [{ question: '<id>', value: '<deletionUrl>' }]`; otherwise enter the URL in the Console after
|
||||||
`storebound play data-safety`.
|
`storebound play data-safety`.
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,12 @@ description: Add and check Apple privacy manifests (PrivacyInfo.xcprivacy) for a
|
||||||
|
|
||||||
`storebound scan` runs the same checks as part of its report (no manifest, undeclared required-reason APIs, SDKs older than their first manifest version) and proposes NSPrivacyTracking and the collected data types from the detected SDKs.
|
`storebound scan` runs the same checks as part of its report (no manifest, undeclared required-reason APIs, SDKs older than their first manifest version) and proposes NSPrivacyTracking and the collected data types from the detected SDKs.
|
||||||
|
|
||||||
Scan: `storebound privacy-manifest --ios ios/App` (local, no credentials). Capacitor / Cordova plugins live outside
|
Scan: `storebound privacy-manifest --ios ios/App` (local, no credentials). Capacitor / Cordova / React Native plugins
|
||||||
the iOS folder: add `--sdk-dirs node_modules/@capacitor,node_modules/<plugin>`. Exit 1 when something blocks upload.
|
live outside the iOS folder; they are found the way Node resolves them: the dependencies of the app's package.json
|
||||||
|
(next to capacitor.config) in the node_modules there and in every folder above it up to the repo root (so a monorepo's
|
||||||
|
`apps/native/node_modules` works), workspace packages (package.json `workspaces`, Bun / npm / yarn), local SwiftPM
|
||||||
|
packages (Capacitor 8's CapApp-SPM `Package.swift`), Pods and SwiftPM checkouts. `--sdk-dirs a,b` adds folders it
|
||||||
|
cannot find. Exit 1 when something blocks upload.
|
||||||
|
|
||||||
## What Apple checks at upload
|
## What Apple checks at upload
|
||||||
- **ITMS-91053 Missing API declaration**: the binary uses a required-reason API and no manifest in the app or in the
|
- **ITMS-91053 Missing API declaration**: the binary uses a required-reason API and no manifest in the app or in the
|
||||||
|
|
|
||||||
|
|
@ -57,5 +57,11 @@ CLI: `storebound` (or `bunx storebound` in a project that has it, or `bun <toolc
|
||||||
with accounts, what you store under the account is linked.
|
with accounts, what you store under the account is linked.
|
||||||
- Accounts: Play asks for a delete-account URL in Data safety and Apple wants deletion inside the app
|
- Accounts: Play asks for a delete-account URL in Data safety and Apple wants deletion inside the app
|
||||||
(`account-deletion` skill).
|
(`account-deletion` skill).
|
||||||
|
- Accounts are not email. A guest / username account (a name picked on the device, a server token, no password, no
|
||||||
|
email) is User ID only (Play `PSL_USER_ACCOUNT`, Apple Identifiers > User ID) and account creation "Username and other
|
||||||
|
authentication" (`PSL_ACM_USER_ID_OTHER_AUTH`): set `accounts.signUp: ['username']`. `storebound scan` marks Email
|
||||||
|
"detected" only for an email field, an `email` property in a request or schema, an email validation or endpoint, an
|
||||||
|
email sign-in call, an SDK that collects it (Google / Apple / Firebase sign-in) or `signUp: ['email-…']`; built
|
||||||
|
bundles (dist, build, the Capacitor webDir, minified files) only make it a question.
|
||||||
- App Privacy saved but not published = not submitted.
|
- App Privacy saved but not published = not submitted.
|
||||||
- Keep store answers, the privacy policy and the in-app privacy settings consistent; reviewers compare them.
|
- Keep store answers, the privacy policy and the in-app privacy settings consistent; reviewers compare them.
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,10 @@ const config: ShipConfig = {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
deletionUrl: 'https://example.com/delete-account', // public page, no login needed to request deletion
|
deletionUrl: 'https://example.com/delete-account', // public page, no login needed to request deletion
|
||||||
inApp: 'Settings > Account > Delete account', // goes into the App Review notes
|
inApp: 'Settings > Account > Delete account', // goes into the App Review notes
|
||||||
|
// How people sign up: 'username' (a name picked in the app, no password, no email), 'username-password',
|
||||||
|
// 'email-password', 'email-link', 'phone', 'oauth', 'other'. `storebound scan` proposes the account data and
|
||||||
|
// dataSafety.accountCreation from it; only the 'email-*' methods mean an email address.
|
||||||
|
signUp: ['email-password'],
|
||||||
},
|
},
|
||||||
|
|
||||||
// Sign-in for store reviewers (review-access skill). The demo account itself lives ONLY in
|
// Sign-in for store reviewers (review-access skill). The demo account itself lives ONLY in
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,10 @@ const config: ShipConfig = {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
deletionUrl: 'https://example.com/delete-account', // public page, no login needed to request deletion
|
deletionUrl: 'https://example.com/delete-account', // public page, no login needed to request deletion
|
||||||
inApp: 'Settings > Account > Delete account', // goes into the App Review notes
|
inApp: 'Settings > Account > Delete account', // goes into the App Review notes
|
||||||
|
// How people sign up: 'username' (a name picked in the app, no password, no email), 'username-password',
|
||||||
|
// 'email-password', 'email-link', 'phone', 'oauth', 'other'. `storebound scan` proposes the account data and
|
||||||
|
// dataSafety.accountCreation from it; only the 'email-*' methods mean an email address.
|
||||||
|
signUp: ['email-password'],
|
||||||
},
|
},
|
||||||
|
|
||||||
// Sign-in for store reviewers (review-access skill). The demo account itself lives ONLY in
|
// Sign-in for store reviewers (review-access skill). The demo account itself lives ONLY in
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,9 @@ const config: ShipConfig = {
|
||||||
collectsData: true,
|
collectsData: true,
|
||||||
encryptedInTransit: true,
|
encryptedInTransit: true,
|
||||||
deletionRequest: true, // e.g. "email us"; no accounts, so no account deletion URL needed
|
deletionRequest: true, // e.g. "email us"; no accounts, so no account deletion URL needed
|
||||||
|
// No accounts: PSL_ACM_NONE. A guest account with a name picked on the device and a server token (no password, no
|
||||||
|
// email): accounts { enabled: true, signUp: ['username'], ... } and ['PSL_ACM_USER_ID_OTHER_AUTH'] here (Play's
|
||||||
|
// "Username and other authentication"; `storebound scan` proposes it).
|
||||||
accountCreation: ['PSL_ACM_NONE'],
|
accountCreation: ['PSL_ACM_NONE'],
|
||||||
data: {
|
data: {
|
||||||
PSL_APPROX_LOCATION: { shared: true, collect: ['analytics', 'advertising', 'fraud'], share: ['analytics', 'advertising', 'fraud'] },
|
PSL_APPROX_LOCATION: { shared: true, collect: ['analytics', 'advertising', 'fraud'], share: ['analytics', 'advertising', 'fraud'] },
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ export default {
|
||||||
website: 'https://example.com',
|
website: 'https://example.com',
|
||||||
contactEmail: 'support@example.com',
|
contactEmail: 'support@example.com',
|
||||||
},
|
},
|
||||||
accounts: { enabled: true, inApp: 'Settings > Account > Delete account' },
|
accounts: { enabled: true, inApp: 'Settings > Account > Delete account', signUp: ['email-password'] },
|
||||||
reviewAccess: { signInRequired: false },
|
reviewAccess: { signInRequired: false },
|
||||||
languages: [{ id: 'en', play: 'en-US' }],
|
languages: [{ id: 'en', play: 'en-US' }],
|
||||||
play: { packageName: 'com.example.budget' },
|
play: { packageName: 'com.example.budget' },
|
||||||
|
|
|
||||||
8
tests/fixtures/scan/monorepo/README.md
vendored
Normal file
8
tests/fixtures/scan/monorepo/README.md
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# monorepo fixture
|
||||||
|
|
||||||
|
A made-up Bun monorepo game (the layout `storebound scan` and `privacy-manifest` met live): the Capacitor shell lives in
|
||||||
|
apps/native with its plugins in apps/native/node_modules (not the root node_modules), the web build is copied into
|
||||||
|
apps/native/web (the Capacitor webDir, a minified bundle with route constants), and accounts are a username picked on
|
||||||
|
the device plus a server token: no password, no email anywhere. Expected: User ID detected, no email finding, the ad
|
||||||
|
SDK found behind its plugin (podspec, Package.swift, android/build.gradle), the plugins found without --sdk-dirs.
|
||||||
|
Not a buildable project.
|
||||||
7
tests/fixtures/scan/monorepo/apps/game/package.json
vendored
Normal file
7
tests/fixtures/scan/monorepo/apps/game/package.json
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"name": "@rush/game",
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@rush/shared": "workspace:*"
|
||||||
|
}
|
||||||
|
}
|
||||||
9
tests/fixtures/scan/monorepo/apps/game/src/account.ts
vendored
Normal file
9
tests/fixtures/scan/monorepo/apps/game/src/account.ts
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { API_PREFIX, ROUTES } from '@rush/shared/src/routes';
|
||||||
|
|
||||||
|
/** First launch: the player picks a name; the server answers with a token kept on the device. */
|
||||||
|
export async function register(username: string): Promise<string> {
|
||||||
|
const res = await fetch(API_PREFIX + ROUTES.register, { method: 'POST', body: JSON.stringify({ username }) });
|
||||||
|
const { token } = (await res.json()) as { token: string };
|
||||||
|
localStorage.setItem('token', token);
|
||||||
|
return token;
|
||||||
|
}
|
||||||
8
tests/fixtures/scan/monorepo/apps/native/capacitor.config.ts
vendored
Normal file
8
tests/fixtures/scan/monorepo/apps/native/capacitor.config.ts
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
const config = {
|
||||||
|
appId: 'org.example.rush',
|
||||||
|
appName: 'Rush Example',
|
||||||
|
webDir: 'web',
|
||||||
|
server: { androidScheme: 'https' },
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
7
tests/fixtures/scan/monorepo/apps/native/ios/App/App.xcodeproj/project.pbxproj
vendored
Normal file
7
tests/fixtures/scan/monorepo/apps/native/ios/App/App.xcodeproj/project.pbxproj
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
objectVersion = 77;
|
||||||
|
objects = {
|
||||||
|
};
|
||||||
|
}
|
||||||
7
tests/fixtures/scan/monorepo/apps/native/ios/App/App/AppDelegate.swift
vendored
Normal file
7
tests/fixtures/scan/monorepo/apps/native/ios/App/App/AppDelegate.swift
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
import Capacitor
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
@UIApplicationMain
|
||||||
|
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||||
|
var window: UIWindow?
|
||||||
|
}
|
||||||
10
tests/fixtures/scan/monorepo/apps/native/ios/App/App/Info.plist
vendored
Normal file
10
tests/fixtures/scan/monorepo/apps/native/ios/App/App/Info.plist
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>Rush Example</string>
|
||||||
|
<key>ITSAppUsesNonExemptEncryption</key>
|
||||||
|
<false/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
12
tests/fixtures/scan/monorepo/apps/native/ios/App/CapApp-SPM/Package.swift
vendored
Normal file
12
tests/fixtures/scan/monorepo/apps/native/ios/App/CapApp-SPM/Package.swift
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
// swift-tools-version: 5.9
|
||||||
|
import PackageDescription
|
||||||
|
|
||||||
|
let package = Package(
|
||||||
|
name: "CapApp-SPM",
|
||||||
|
products: [.library(name: "CapApp-SPM", targets: ["CapApp-SPM"])],
|
||||||
|
dependencies: [
|
||||||
|
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", exact: "8.0.0"),
|
||||||
|
.package(name: "ExampleAdsPlugin", path: "../../../node_modules/example-ads-plugin")
|
||||||
|
],
|
||||||
|
targets: [.target(name: "CapApp-SPM", dependencies: [.product(name: "ExampleAdsPlugin", package: "ExampleAdsPlugin")])]
|
||||||
|
)
|
||||||
7
tests/fixtures/scan/monorepo/apps/native/node_modules/@example/capacitor-haptics/ExampleHaptics.podspec
generated
vendored
Normal file
7
tests/fixtures/scan/monorepo/apps/native/node_modules/@example/capacitor-haptics/ExampleHaptics.podspec
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
Pod::Spec.new do |s|
|
||||||
|
s.name = 'ExampleHaptics'
|
||||||
|
s.version = '1.0.0'
|
||||||
|
s.source_files = 'ios/Sources/**/*.swift'
|
||||||
|
s.resource_bundles = { 'ExampleHapticsPrivacy' => ['ios/Sources/PrivacyInfo.xcprivacy'] }
|
||||||
|
s.dependency 'Capacitor'
|
||||||
|
end
|
||||||
10
tests/fixtures/scan/monorepo/apps/native/node_modules/@example/capacitor-haptics/ios/Sources/PrivacyInfo.xcprivacy
generated
vendored
Normal file
10
tests/fixtures/scan/monorepo/apps/native/node_modules/@example/capacitor-haptics/ios/Sources/PrivacyInfo.xcprivacy
generated
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>NSPrivacyTracking</key>
|
||||||
|
<false/>
|
||||||
|
<key>NSPrivacyAccessedAPITypes</key>
|
||||||
|
<array/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
4
tests/fixtures/scan/monorepo/apps/native/node_modules/@example/capacitor-haptics/package.json
generated
vendored
Normal file
4
tests/fixtures/scan/monorepo/apps/native/node_modules/@example/capacitor-haptics/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"name": "@example/capacitor-haptics",
|
||||||
|
"version": "1.0.0"
|
||||||
|
}
|
||||||
7
tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/ExampleAdsPlugin.podspec
generated
vendored
Normal file
7
tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/ExampleAdsPlugin.podspec
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
Pod::Spec.new do |s|
|
||||||
|
s.name = 'ExampleAdsPlugin'
|
||||||
|
s.version = '0.3.0'
|
||||||
|
s.source_files = 'ios/Sources/**/*.swift'
|
||||||
|
s.dependency 'Capacitor'
|
||||||
|
s.dependency 'IronSourceSDK', '~> 9.6.1'
|
||||||
|
end
|
||||||
11
tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/Package.swift
generated
vendored
Normal file
11
tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/Package.swift
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
// swift-tools-version: 5.9
|
||||||
|
import PackageDescription
|
||||||
|
|
||||||
|
let package = Package(
|
||||||
|
name: "ExampleAdsPlugin",
|
||||||
|
products: [.library(name: "ExampleAdsPlugin", targets: ["ExampleAdsPlugin"])],
|
||||||
|
dependencies: [
|
||||||
|
.package(url: "https://github.com/ironsource-mobile/LevelPlay-Swift-Package.git", from: "9.6.1")
|
||||||
|
],
|
||||||
|
targets: [.target(name: "ExampleAdsPlugin", path: "ios/Sources/ExampleAdsPlugin")]
|
||||||
|
)
|
||||||
3
tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/android/build.gradle
generated
vendored
Normal file
3
tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/android/build.gradle
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
dependencies {
|
||||||
|
implementation "com.unity3d.ads-mediation:mediation-sdk:9.0.0"
|
||||||
|
}
|
||||||
4
tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/ios/Sources/ExampleAdsPlugin/Plugin.swift
generated
vendored
Normal file
4
tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/ios/Sources/ExampleAdsPlugin/Plugin.swift
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
import Capacitor
|
||||||
|
|
||||||
|
@objc(ExampleAdsPlugin)
|
||||||
|
public class ExampleAdsPlugin: CAPPlugin {}
|
||||||
4
tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/package.json
generated
vendored
Normal file
4
tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"name": "example-ads-plugin",
|
||||||
|
"version": "0.3.0"
|
||||||
|
}
|
||||||
10
tests/fixtures/scan/monorepo/apps/native/package.json
vendored
Normal file
10
tests/fixtures/scan/monorepo/apps/native/package.json
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"name": "@rush/native",
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@capacitor/core": "8.0.0",
|
||||||
|
"@capacitor/ios": "8.0.0",
|
||||||
|
"@example/capacitor-haptics": "1.0.0",
|
||||||
|
"example-ads-plugin": "0.3.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
1
tests/fixtures/scan/monorepo/apps/native/web/bundle/routes-AbC12345.js
vendored
Normal file
1
tests/fixtures/scan/monorepo/apps/native/web/bundle/routes-AbC12345.js
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
var e=`/api/v1`,t=`/api/health`,r={session:`/session`,usernameCheck:`/username/check`,register:`/register`,state:`/state`};export{e as A,r as R,t as H};
|
||||||
1
tests/fixtures/scan/monorepo/apps/native/web/bundle/vendor-XyZ98765.js
vendored
Normal file
1
tests/fixtures/scan/monorepo/apps/native/web/bundle/vendor-XyZ98765.js
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
function f(n){return n.createElement("input",{type:"email",name:"email"})}export{f as V};
|
||||||
8
tests/fixtures/scan/monorepo/package.json
vendored
Normal file
8
tests/fixtures/scan/monorepo/package.json
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"name": "monorepo-game",
|
||||||
|
"private": true,
|
||||||
|
"workspaces": [
|
||||||
|
"apps/*",
|
||||||
|
"packages/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
4
tests/fixtures/scan/monorepo/packages/shared/package.json
vendored
Normal file
4
tests/fixtures/scan/monorepo/packages/shared/package.json
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"name": "@rush/shared",
|
||||||
|
"private": true
|
||||||
|
}
|
||||||
8
tests/fixtures/scan/monorepo/packages/shared/src/routes.ts
vendored
Normal file
8
tests/fixtures/scan/monorepo/packages/shared/src/routes.ts
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
// API routes shared by the game client and the server.
|
||||||
|
export const API_PREFIX = '/api/v1';
|
||||||
|
export const ROUTES = {
|
||||||
|
session: '/session',
|
||||||
|
usernameCheck: '/username/check',
|
||||||
|
register: '/register',
|
||||||
|
state: '/state',
|
||||||
|
} as const;
|
||||||
30
tests/fixtures/scan/monorepo/storebound.config.ts
vendored
Normal file
30
tests/fixtures/scan/monorepo/storebound.config.ts
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
// Fixture config (made up, example.com placeholders only).
|
||||||
|
export default {
|
||||||
|
app: {
|
||||||
|
name: 'Rush Example',
|
||||||
|
profile: 'game',
|
||||||
|
privacyPolicyUrl: 'https://example.com/privacy',
|
||||||
|
supportUrl: 'https://example.com/support',
|
||||||
|
website: 'https://example.com',
|
||||||
|
contactEmail: 'support@example.com',
|
||||||
|
},
|
||||||
|
// A guest account is created on first launch with the name the player picks (no password, no email).
|
||||||
|
accounts: {
|
||||||
|
enabled: true,
|
||||||
|
deletionUrl: 'https://example.com/delete-account',
|
||||||
|
inApp: 'Settings > Delete account',
|
||||||
|
},
|
||||||
|
reviewAccess: { signInRequired: false },
|
||||||
|
languages: [{ id: 'en', play: 'en-US', apple: 'en-US' }],
|
||||||
|
play: { packageName: 'org.example.rush', accountType: 'organization' },
|
||||||
|
apple: { bundleId: 'org.example.rush', usesNonExemptEncryption: false },
|
||||||
|
dataSafety: {
|
||||||
|
collectsData: true,
|
||||||
|
encryptedInTransit: true,
|
||||||
|
deletionRequest: true,
|
||||||
|
accountCreation: ['PSL_ACM_NONE'],
|
||||||
|
data: {
|
||||||
|
PSL_USER_ACCOUNT: { shared: false, collect: ['account', 'functionality'] },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
@ -12,7 +12,9 @@ import { validateConfig } from '../cli/lib/config';
|
||||||
import { runScan } from '../cli/lib/scan';
|
import { runScan } from '../cli/lib/scan';
|
||||||
import { PLAY_REFS } from '../cli/lib/scan/play-rules';
|
import { PLAY_REFS } from '../cli/lib/scan/play-rules';
|
||||||
import { vaguePurpose } from '../cli/lib/scan/permissions';
|
import { vaguePurpose } from '../cli/lib/scan/permissions';
|
||||||
import { detectProject, parsePlist } from '../cli/lib/scan/project';
|
import { detectProject, isBuilt, parsePlist } from '../cli/lib/scan/project';
|
||||||
|
import { SIGNALS } from '../cli/lib/scan/rules';
|
||||||
|
import { localSwiftPackages, nativeIosPlugins, workspaceDirs } from '../cli/lib/node-packages';
|
||||||
import type { ScanFinding } from '../cli/lib/scan/rules';
|
import type { ScanFinding } from '../cli/lib/scan/rules';
|
||||||
import { matchesSdk, SDKS, versionAtLeast } from '../cli/lib/scan/sdks';
|
import { matchesSdk, SDKS, versionAtLeast } from '../cli/lib/scan/sdks';
|
||||||
|
|
||||||
|
|
@ -331,6 +333,87 @@ describe('config writing', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('monorepo: username accounts without email, plugins in apps/native/node_modules', () => {
|
||||||
|
test('accounts mean a user id, never an email; route constants in the built bundle are not evidence', async () => {
|
||||||
|
const r = await scan('monorepo');
|
||||||
|
const d = r.declarations;
|
||||||
|
expect(d.diff.find(x => x.type === 'PSL_EMAIL')).toBeUndefined();
|
||||||
|
expect(d.dataSafety!.data.PSL_EMAIL).toBeUndefined();
|
||||||
|
expect(r.findings.filter(f => /Email|PSL_EMAIL/.test(f.title))).toEqual([]);
|
||||||
|
const uid = d.items.find(x => x.what === 'PSL_USER_ACCOUNT')!;
|
||||||
|
expect(uid.status).toBe('detected');
|
||||||
|
expect(uid.evidence[0]!.file).toBe('packages/shared/src/routes.ts');
|
||||||
|
for (const x of d.items) for (const e of x.evidence) if (x.status === 'detected') expect(e.file).not.toContain('/web/bundle/');
|
||||||
|
// the email input in the vendor chunk is built output: a question, never written
|
||||||
|
expect(d.items.find(x => x.what === 'PSL_EMAIL')).toMatchObject({ status: 'ask', evidence: [{ file: 'apps/native/web/bundle/vendor-XyZ98765.js' }] });
|
||||||
|
expect(d.items.find(x => x.area === 'appPrivacy' && x.what === 'Identifiers / User ID')!.status).toBe('detected');
|
||||||
|
expect(d.items.some(x => x.area === 'appPrivacy' && x.what === 'Contact Info / Email Address')).toBe(false);
|
||||||
|
expect(d.items.find(x => x.what === 'accountCreation')!.status).toBe('ask');
|
||||||
|
});
|
||||||
|
test('accounts.signUp: username -> Username and other authentication, still no email; email-password -> email', async () => {
|
||||||
|
const dir = mkdtempSync(join(tmpdir(), 'sb-mono-'));
|
||||||
|
try {
|
||||||
|
cpSync(join(FX, 'monorepo'), dir, { recursive: true });
|
||||||
|
const cfgPath = join(dir, 'storebound.config.ts');
|
||||||
|
const base = readFileSync(cfgPath, 'utf8');
|
||||||
|
writeFileSync(cfgPath, base.replace("inApp: 'Settings > Delete account',", "inApp: 'Settings > Delete account',\n signUp: ['username'],"));
|
||||||
|
const d = (await runScan(dir)).report.declarations;
|
||||||
|
expect(d.accountCreationChange).toEqual({ from: ['PSL_ACM_NONE'], to: ['PSL_ACM_USER_ID_OTHER_AUTH'] });
|
||||||
|
expect(d.items.find(x => x.what === 'accountCreation')).toMatchObject({ status: 'detected', value: expect.stringContaining('Username and other authentication') });
|
||||||
|
expect(d.dataSafety!.data.PSL_EMAIL).toBeUndefined();
|
||||||
|
expect(d.dataSafety!.accountCreation).toEqual(['PSL_ACM_USER_ID_OTHER_AUTH']);
|
||||||
|
Bun.spawnSync(['bun', CLI, 'scan', '--dir', dir, '--write']);
|
||||||
|
const after = readFileSync(cfgPath, 'utf8');
|
||||||
|
expect(after).toContain("accountCreation: ['PSL_ACM_USER_ID_OTHER_AUTH']");
|
||||||
|
expect(after).not.toContain('PSL_EMAIL');
|
||||||
|
expect((await runScan(dir)).report.configError).toBeNull();
|
||||||
|
// a fresh folder: the config module of the first one stays cached in this process
|
||||||
|
const dir2 = join(dir, 'email');
|
||||||
|
cpSync(join(FX, 'monorepo'), dir2, { recursive: true });
|
||||||
|
writeFileSync(join(dir2, 'storebound.config.ts'), base.replace("inApp: 'Settings > Delete account',", "inApp: 'Settings > Delete account',\n signUp: ['email-password'],"));
|
||||||
|
const e = (await runScan(dir2)).report.declarations;
|
||||||
|
expect(e.items.find(x => x.what === 'PSL_EMAIL')!.status).toBe('detected');
|
||||||
|
expect(e.accountCreationChange!.to).toEqual(['PSL_ACM_USER_ID_PASSWORD']);
|
||||||
|
} finally { rmSync(dir, { recursive: true, force: true }); }
|
||||||
|
});
|
||||||
|
test('email evidence: fields, properties, validation, endpoints and SDK calls count; labels and constants do not', () => {
|
||||||
|
const yes = ['<input type="email" />', 'n.createElement("input",{type:"email"})', 'body: JSON.stringify({ email: form.email })', 'email?: string;', 'z.string().email()',
|
||||||
|
'const RE = /^[^\\s@]+@[^\\s@]+$/', "fetch('/api/auth/forgot-password')", 'auth.createUserWithEmailAndPassword(a, b)', 'Auth.auth().createUser(withEmail: e, password: p)',
|
||||||
|
'keyboardType="email-address"', 'request.requestedScopes = [.fullName, .email]'];
|
||||||
|
const no = ["const ROUTES = { register: '/register', usernameCheck: '/username/check' }", "contactEmail: 'support@example.com'", "email: 'privacy@example.com'",
|
||||||
|
"labels = { email: 'E-mail' }", 'register(username)', "fetch('/api/v1/session')"];
|
||||||
|
for (const s of yes) expect({ s, hit: SIGNALS.email.test(s) }).toEqual({ s, hit: true });
|
||||||
|
for (const s of no) expect({ s, hit: SIGNALS.email.test(s) }).toEqual({ s, hit: false });
|
||||||
|
});
|
||||||
|
test('built output is low trust', () => {
|
||||||
|
expect(isBuilt('apps/native/web/bundle/routes-AbC12345.js')).toBe(true);
|
||||||
|
expect(isBuilt('dist/index.min.js')).toBe(true);
|
||||||
|
expect(isBuilt('apps/native/web/index.js', ['apps/native/web'])).toBe(true);
|
||||||
|
expect(isBuilt('packages/shared/src/routes.ts')).toBe(false);
|
||||||
|
});
|
||||||
|
test('scan finds the SDK behind a plugin in apps/native/node_modules (podspec, Package.swift, android/build.gradle)', () => {
|
||||||
|
const p = detectProject(join(FX, 'monorepo'));
|
||||||
|
expect(p.stacks).toContain('capacitor');
|
||||||
|
expect(p.builtDirs).toEqual(['apps/native/web']);
|
||||||
|
const lp = p.sdks.find(s => s.sdk.id === 'levelplay')!;
|
||||||
|
expect(lp.deps.map(d => `${d.eco} ${d.file}`).sort()).toEqual([
|
||||||
|
'cocoapods apps/native/node_modules/example-ads-plugin/ExampleAdsPlugin.podspec',
|
||||||
|
'gradle apps/native/node_modules/example-ads-plugin/android/build.gradle',
|
||||||
|
'spm apps/native/node_modules/example-ads-plugin/Package.swift',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
test('privacy-manifest finds the plugins without --sdk-dirs (node_modules next to the app, local SwiftPM packages)', () => {
|
||||||
|
const ios = join(FX, 'monorepo/apps/native/ios/App');
|
||||||
|
expect(nativeIosPlugins(ios).map(x => x.name).sort()).toEqual(['@example/capacitor-haptics', 'example-ads-plugin']);
|
||||||
|
expect(localSwiftPackages(ios).map(x => x.split('/').pop())).toEqual(['example-ads-plugin']);
|
||||||
|
expect(workspaceDirs(join(FX, 'monorepo')).map(x => x.split('/').slice(-2).join('/'))).toEqual(['apps/game', 'apps/native', 'packages/shared']);
|
||||||
|
const r = Bun.spawnSync(['bun', CLI, 'privacy-manifest', '--ios', ios, '--json']);
|
||||||
|
const out = r.stdout.toString();
|
||||||
|
const j = JSON.parse(out.slice(out.indexOf('{'))) as { sdks: { name: string; hasManifest: boolean }[] };
|
||||||
|
expect(j.sdks.map(s => [s.name, s.hasManifest]).sort()).toEqual([['@example/capacitor-haptics', true], ['example-ads-plugin', false]]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('integration', () => {
|
describe('integration', () => {
|
||||||
test('2.2: beta / demo / test wording in the app name or the App Store text (not "demo account")', async () => {
|
test('2.2: beta / demo / test wording in the app name or the App Store text (not "demo account")', async () => {
|
||||||
const dir = mkdtempSync(join(tmpdir(), 'storebound-scan-beta-'));
|
const dir = mkdtempSync(join(tmpdir(), 'storebound-scan-beta-'));
|
||||||
|
|
@ -354,7 +437,8 @@ describe('integration', () => {
|
||||||
test('JSON output, --store filter, exit code', () => {
|
test('JSON output, --store filter, exit code', () => {
|
||||||
const r = Bun.spawnSync(['bun', CLI, 'scan', '--dir', join(FX, 'teaser'), '--json', '--store', 'apple'], { env: { ...process.env, REVIEW_DEMO_USER: '', REVIEW_DEMO_PASSWORD: '' } });
|
const r = Bun.spawnSync(['bun', CLI, 'scan', '--dir', join(FX, 'teaser'), '--json', '--store', 'apple'], { env: { ...process.env, REVIEW_DEMO_USER: '', REVIEW_DEMO_PASSWORD: '' } });
|
||||||
expect(r.exitCode).toBe(1);
|
expect(r.exitCode).toBe(1);
|
||||||
const j = JSON.parse(r.stdout.toString()) as { counts: { blocker: number }; findings: ScanFinding[] };
|
const out = r.stdout.toString();
|
||||||
|
const j = JSON.parse(out.slice(out.indexOf('{'))) as { counts: { blocker: number }; findings: ScanFinding[] };
|
||||||
expect(j.counts.blocker).toBe(2);
|
expect(j.counts.blocker).toBe(2);
|
||||||
expect(j.findings.every(f => f.store === 'apple')).toBe(true);
|
expect(j.findings.every(f => f.store === 'apple')).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue