Review planner sends Swift health, permission and on-device storage code to full review (GST-3052) (#4472)

/ship's review planner now sends Swift code that asks for a privacy
permission, reads HealthKit or calendar data, or writes, deletes or
protects users' files on the device to the full review panel.

Why: since #4469, iOS changes that asked for microphone permission,
wrote and deleted meeting transcript files, or read calendars got the
light, one-reader review. Reported from the GHome iOS app's PR review.

Nothing to do: plain SwiftUI views, UserDefaults settings and file reads
still plan light.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1/red-team#1 reader=red-team
Review-Finding: p1/red-team#2 reader=red-team
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-18 03:55:13 +00:00
1 parent 0a6bb42e74
commit 9222485040
8 files changed
+116 -6

No files matched your search

@@ -0,0 +1 @@
- **/ship's review plan now sends Swift code that touches private user data to the full review panel (GST-3052).** Once `.swift` stopped failing closed, an iOS change that asked for microphone or speech permission, read HealthKit or calendar data, or wrote and deleted users' files on the device planned the light review. Swift lines that request a privacy permission (speech, microphone, HealthKit, calendars, location, camera, photos, tracking) now count as security, and lines that read HealthKit, EventKit or contacts, write, delete or protect files on the device, use an app group container, exclude files from backup, or declare how long data is kept count as user data. Plain SwiftUI views, UserDefaults settings and file reads stay light. Reported from the GHome iOS app's PR review.
+8 -1
View File
@@ -429,7 +429,14 @@ rules are coarse on purpose and parse no import clause or call arguments;
200,000-character hostile lines, its anchor followed by a long run of the
characters it repeats included. `test/review-risk-redos.test.ts` (GST-898) holds every risk pattern, R51's `rm` and `rmSync` rules included, under 100 ms on 100,000-character hostile lines. An `rmSync(` or `rm(` call (`fs.rm`, `fs.promises.rm` or an imported `rm`) counts as security when `recursive: true` follows within 500 characters, whatever the arguments hold (a `path.join(...)` first argument or a `)` in a comment included) and also when a formatter split a new call across lines, which is read over the file's changed lines joined (GST-942; an edit to one line of an existing split call is read on its own); a call with more than 500 characters before the first `)` after it counts on its own. **data** is user data: a path naming pii, gdpr, ccpa, privacy,
personal, account, customer, cookie, persistence, storage or database, or a line
that drops a table or column, deletes rows or bulk-deletes records. Auth scope,
that drops a table or column, deletes rows or bulk-deletes records. On `.swift`
paths outside XCTest targets (a `Tests/` or `*Tests/` directory, or a
`*Tests.swift` file), a privacy permission request (speech, microphone,
HealthKit, calendars, location, camera, photos) is security, and a HealthKit,
EventKit or Contacts read, an on-device file write or delete, a file protection
class, an app group container, backup exclusion or a declared retention period is
data; UserDefaults settings, SwiftUI views and file reads are neither, and a call
split across lines is read over the file's changed lines joined (GST-3052). Auth scope,
migrations and deleted code paths were already gate class. `RISK_RULES` hashes
the patterns and `DEPTH_RULES` includes it.
+31 -1
View File
@@ -124,6 +124,31 @@ export const DATA_LINE = [
/\.(?:deleteMany|destroyAll|bulkDelete)\s*\(/, /\b(?:destroy_all|delete_all)\b/,
];
/**
* Swift code that reaches private user data (GST-3052: ghome#10, #14 and #31 planned light once .swift stopped failing closed).
* Read on .swift paths only, so this module and TypeScript never match. A privacy permission request is security, as a consent
* path is; HealthKit and EventKit reads, on-device file writes, deletes, protection classes, app group containers, backup
* exclusion and a declared retention period are data. UserDefaults, SwiftUI, file reads and EventKit type names are not.
* A call split across lines (`removeItem(` then `at: url)`) is read over the file's changed lines joined, as SECURITY_JOINED is.
* XCTest files (a Tests/ or *Tests/ target directory, a *Tests.swift file) read as code to the classifier but are skipped here:
* their temp-file setup and cleanup is not user data (GSTA-604 replay: ghome#17 gained data from test cleanup alone).
*/
export const SWIFT_PATH = /\.swift$/i;
export const SWIFT_TEST_PATH = /(^|\/)\w{0,80}Tests\/|Tests\.swift$/;
export const SWIFT_SECURITY_LINE = [
/\brequest\w{0,40}Authorization\b/, /\brequest(?:Full|WriteOnly)?Access(?:To(?:Events|Reminders))?\b/, /\brequestRecordPermission\b/,
];
export const SWIFT_DATA_LINE = [
/^\s{0,40}import\s{1,20}(?:HealthKit|EventKit|Contacts)\b/, /\b(?:HKHealthStore|EKEventStore|CNContactStore)\b/, /\bHK[A-Z]\w{0,40}Query\b/,
/\.(?:events|calendars|calendarItems)\s{0,20}\(\s{0,20}(?:matching|for)\s{0,20}:/, /\bpredicateFor(?:Events|Reminders|IncompleteReminders|CompletedReminders)\w{0,40}\s{0,20}\(/, /\.fetchReminders\s{0,20}\(/,
/\.write\s{0,20}\(\s{0,20}(?:to(?:File)?\s{0,20}:\s{0,20}(?![\s&])|contentsOf\s{0,20}:)/, /\.(?:removeItem|trashItem)\s{0,20}\(\s{0,20}at(?:Path)?\s{0,20}:/, /\.createFile\s{0,20}\(\s{0,20}atPath\s{0,20}:/, /\.replaceItem(?:At)?\s{0,20}\(/,
/\bFileHandle\s{0,20}\(\s{0,20}for(?:WritingTo|WritingAtPath|Updating|UpdatingAtPath)\s{0,20}:/, /\bOutputStream\s{0,20}\(\s{0,20}(?:url|toFileAtPath)\s{0,20}:/,
/\bNSFileProtection\w{0,60}|\bFileProtectionType\b|\.(?:complete|no)FileProtection\w{0,60}|\.protectionKey\b/,
/\bforSecurityApplicationGroupIdentifier\b|\bUserDefaults\s{0,20}\(\s{0,20}suiteName\s{0,20}:\s{0,20}"group\./, /\bisExcludedFromBackup\w{0,20}/,
/\b(?:let|var)\s{1,20}(?:\w{0,60}(?:Retention|RetainFor|RetainDays|RetainUntil|Purge|MaxAge|KeepFor|KeepDays|KeepUntil|DeleteAfter|TTL|Ttl)|(?:retention|retain(?:For|Days|Until)|purge|maxAge|keep(?:For|Days|Until)|deleteAfter|ttl))\w{0,60}\b/,
/\b(?:olderThan|purgeBefore|deleteBefore|deleteAfter)\s{0,20}:/,
];
/**
* Data and config files (HARN-1, harness-evals#231): judged by their path only, so a lease_usd value in a VM record never names money.
* A key in a config file still names a secret.
@@ -155,7 +180,7 @@ export const RISK_RULES = createHash('sha256').update(JSON.stringify({
RISK_CLASSES, MONEY_PATH_TOKENS, AUTH_PATH_TOKENS, AUTH_PATH_PREFIXES, KEY_NAME, SECURITY_PATH_TOKENS, DATA_PATH_TOKENS, EVAL_PATH_TOKENS,
MONEY_LINE_TOKENS, MONEY_PAIRS, SPEND_PAIRS, REPORTED_COST_WORDS, MONEY_USD_WORDS,
SECRET_SCAN,
patterns: Object.entries({ PROSE_PATH: [PROSE_PATH], DOC_SECRET_LINE, CONFIG_DATA_PATH: [CONFIG_DATA_PATH], STATS_SCRIPT: [STATS_SCRIPT], MONEY_LINE, PAID_MONEY_LINE, USD_COMPARE, RESULTS_TREE: [RESULTS_TREE], PRICE_USD_KEY: [PRICE_USD_KEY], PRICE_KEY_EXEMPT: [PRICE_KEY_EXEMPT], SECRET_LINE, SECRET_PATH: [SECRET_PATH], TOKEN_PATH: [TOKEN_PATH], TOKEN_SOURCE: [TOKEN_SOURCE], SECURITY_LINE, SECURITY_JOINED, DATA_LINE, SVG_PATH: [SVG_PATH], SVG_ACTIVE }).map(([k, v]) => [k, v.map(r => '/' + r.source + '/' + r.flags)]),
patterns: Object.entries({ PROSE_PATH: [PROSE_PATH], DOC_SECRET_LINE, CONFIG_DATA_PATH: [CONFIG_DATA_PATH], STATS_SCRIPT: [STATS_SCRIPT], MONEY_LINE, PAID_MONEY_LINE, USD_COMPARE, RESULTS_TREE: [RESULTS_TREE], PRICE_USD_KEY: [PRICE_USD_KEY], PRICE_KEY_EXEMPT: [PRICE_KEY_EXEMPT], SECRET_LINE, SECRET_PATH: [SECRET_PATH], TOKEN_PATH: [TOKEN_PATH], TOKEN_SOURCE: [TOKEN_SOURCE], SECURITY_LINE, SECURITY_JOINED, DATA_LINE, SVG_PATH: [SVG_PATH], SVG_ACTIVE, SWIFT_PATH: [SWIFT_PATH], SWIFT_TEST_PATH: [SWIFT_TEST_PATH], SWIFT_SECURITY_LINE, SWIFT_DATA_LINE }).map(([k, v]) => [k, v.map(r => '/' + r.source + '/' + r.flags)]),
})).digest('hex').slice(0, 16);
export const tokens = (p: string) => p.replace(/([a-z0-9])([A-Z])/g, '$1 $2').toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
@@ -187,6 +212,7 @@ export function matchRisk(i: RiskInput): Map<RiskClass, string> {
const config = !exe && CONFIG_DATA_PATH.test(p);
const pathOnly = config || stats;
const prose = PROSE_PATH.test(p);
const swift = SWIFT_PATH.test(p) && !SWIFT_TEST_PATH.test(p);
if (i.scopeAuth && t.some(x => AUTH_PATH_TOKENS.includes(x) || AUTH_PATH_PREFIXES.some(a => x.startsWith(a)))) hit('auth', 'auth path: ' + p);
if (secretPath(p, [...(i.added?.[p] ?? []), ...(i.removed?.[p] ?? [])])) hit('secret', 'secret path: ' + p);
const money = !(i.dataPaths?.includes(p) && RESULTS_TREE.test(p));
@@ -202,8 +228,12 @@ export function matchRisk(i: RiskInput): Map<RiskClass, string> {
if (!why.has('money') && (PAID_MONEY_LINE.some(r => r.test(line)) || (money && (usdMoney(line) || namesMoney(tokens(line), MONEY_LINE_TOKENS) || (!prose && pairs(tokens(line), SPEND_PAIRS)))))) hit('money', 'money line: ' + p);
if (!why.has('security') && SECURITY_LINE.some(r => r.test(line))) hit('security', 'security line: ' + p);
if (!why.has('data') && DATA_LINE.some(r => r.test(line))) hit('data', 'data line: ' + p);
if (swift && !why.has('security') && SWIFT_SECURITY_LINE.some(r => r.test(line))) hit('security', 'Swift permission request: ' + p);
if (swift && !why.has('data') && SWIFT_DATA_LINE.some(r => r.test(line))) hit('data', 'Swift user-data line: ' + p);
}
if (!why.has('security') && [i.added?.[p], i.removed?.[p]].some(l => l && SECURITY_JOINED.some(r => r.test(l.join('\n'))))) hit('security', 'security lines: ' + p);
if (swift && !why.has('security') && [i.added?.[p], i.removed?.[p]].some(l => l && SWIFT_SECURITY_LINE.some(r => r.test(l.join('\n'))))) hit('security', 'Swift permission request lines: ' + p);
if (swift && !why.has('data') && [i.added?.[p], i.removed?.[p]].some(l => l && SWIFT_DATA_LINE.some(r => r.test(l.join('\n'))))) hit('data', 'Swift user-data lines: ' + p);
}
return new Map(RISK_CLASSES.filter(c => why.has(c)).map(c => [c, why.get(c)!]));
}
+1 -1
View File
@@ -1 +1 @@
{"sha":"2dbe134d502279da7a5f27e5370bb45a9658f01322030b1e27180d0e9e11285d","replay":"GST-3041"}
{"sha":"1bf74fcb384978ba30b36f02959a8e30c1f8feb9bbb549a99fbd9ff70496c80d","replay":"GST-3052"}
+1
View File
@@ -0,0 +1 @@
{"replay":"GST-3052","justification":"GST-3052 no-loss replay (GSTA-604, preregistered as reports/GSTA-604-prereg.md sha256 95d75d44): review-risk.ts adds Swift-only line rules (SWIFT_SECURITY_LINE for privacy permission requests, SWIFT_DATA_LINE for HealthKit, EventKit and contacts access, on-device file writes, deletes, protection, app groups, backup exclusion and retention), read per line and over a file's changed lines joined, and skipped on XCTest paths; they only add security and data hits. Planner depth from 29e95022 (old) and 39009fa5 (new): the last 200 first-parent main commits (64862e41..29e95022) are 200 identical (129 full, 71 light); the 34 merged Apple-platform PRs (garrytan/ghome 33, garrytan/imsg-reader 1) have 0 lowered, 3 raised light to full (ghome#10 data, #14 security, #31 data) and 31 unchanged, no risk class lost. A read-only gpt-6.2-sol reader labeled all 3 raises true positives and 35 of 49 matched lines true (PR level 11 of 12). Reviewer text is unchanged."}
+14
View File
@@ -77,6 +77,20 @@ describe('gstack-review-plan', () => {
const client = run(repo({ ...ui, 'App/Client.swift': 'final class Client {\n func load(_ r: URLRequest) async throws -> Data { try await URLSession.shared.data(for: r).0 }\n}\n' }), []);
expect(client.stdout).toMatch(/^REVIEW_DEPTH: full .*risk:security/m);
});
// Value: protects=an iOS PR that writes or deletes users' files on the device, or reads their calendars, plans full even when it
// also touches Markdown and tests, while a SwiftUI view that reads a UserDefaults setting stays light; fails_when=the Swift
// user-data rules stop reaching gstack-review-plan; why_new=GST-3052: ghome#10 (spill files written and deleted) and ghome#31
// (calendar choices, read through EventKit) planned light (GSTA-601); seam=gstack-review-plan on a real repo; no_claim=what the readers find
test('a Swift diff that writes and deletes spill files, or reads calendars, plans full; a SwiftUI settings view stays light (GST-3052)', () => {
const view = 'import SwiftUI\nstruct SettingsView: View {\n @AppStorage("speaksAnswers") private var speaksAnswers = true\n var body: some View { Toggle("Speak answers", isOn: $speaksAnswers) }\n}\n';
const shared = { 'DESIGN.md': '# Design\n', 'App/Home/SettingsView.swift': view, 'Tests/AppTests/SettingsTests.swift': 'import XCTest\n' };
const control = run(repo({ ...shared, 'App/Home/PickerModel.swift': 'final class PickerModel {\n let defaults: UserDefaults\n init(defaults: UserDefaults = .standard) { self.defaults = defaults }\n var chosen: Data? { defaults.data(forKey: "picker.chosen") }\n func save(_ blob: Data) { defaults.set(blob, forKey: "picker.chosen") }\n}\n' }), []);
expect(control.stdout).toMatch(/^REVIEW_DEPTH: light /m);
const spill = 'import Foundation\npublic struct DraftSpill {\n public let file: URL\n public func reserve(_ size: Int) throws {\n guard FileManager.default.createFile(atPath: file.path, contents: Data(count: size)) else { throw CocoaError(.fileWriteUnknown) }\n }\n public func discard() { try? FileManager.default.removeItem(at: file) }\n}\n';
expect(run(repo({ ...shared, 'Packages/Core/Sources/Core/Capture/DraftSpill.swift': spill }), []).stdout).toMatch(/^REVIEW_DEPTH: full .*risk:data/m);
const agenda = 'import EventKit\nfinal class AgendaSource {\n private let events = EKEventStore()\n func calendarNames() -> [String] { events.calendars(for: .event).map(\\.title) }\n}\n';
expect(run(repo({ ...shared, 'App/Meeting/AgendaSource.swift': agenda }), []).stdout).toMatch(/^REVIEW_DEPTH: full .*risk:data/m);
});
test('a docs diff that publishes numbers keeps the outside voice', () => {
const r = run(repo({ 'docs/bench.md': 'Median latency fell 42% to 180 ms.\n' }), []);
expect(r.stdout).toContain('DISPATCH: outside-voice outside-voice effort=host');
+4 -3
View File
@@ -5,7 +5,7 @@
*/
import { describe, expect, test } from 'bun:test';
import { SVG_REFUSED, svgDrawing } from '../lib/review-depth';
import { DATA_LINE, MONEY_LINE, SECRET_LINE, SECRET_PATH, SECURITY_JOINED, SECURITY_LINE, USD_COMPARE, matchRisk, usdMoney } from '../lib/review-risk';
import { DATA_LINE, MONEY_LINE, SECRET_LINE, SECRET_PATH, SECURITY_JOINED, SECURITY_LINE, SWIFT_DATA_LINE, SWIFT_SECURITY_LINE, USD_COMPARE, matchRisk, usdMoney } from '../lib/review-risk';
const L = 100_000;
const ms = (f: () => unknown) => { const t = performance.now(); f(); return performance.now() - t; };
@@ -15,7 +15,7 @@ const security = (line: string) => matchRisk({ codePaths: ['x.sh'], added: { 'x.
describe('linear time on hostile input', () => {
// Value: protects=gstack-review-plan, the targeted pass and the queue depth check never stall on one added line;
// fails_when=any risk pattern backtracks quadratically on its anchor followed by a long run of the class it repeats,
// or on a line of repeated anchors; seam=every pattern in SECURITY_LINE, DATA_LINE, SECRET_LINE, MONEY_LINE and SECRET_PATH
// or on a line of repeated anchors; seam=every pattern in SECURITY_LINE, DATA_LINE, SECRET_LINE, MONEY_LINE, SECRET_PATH, SWIFT_SECURITY_LINE and SWIFT_DATA_LINE
const hostile = [
run('rm -', 'r'), run('rm -', 'f'), run('rm -r', 'r'), run('rm -f', 'a'), run('rm\t-', 'r'), run('rm ', ' '), run('rm -', 'r', '1'), run('rm -', 'rf', '_'), run('', 'rm -r '),
run('', 'rmSync('), run('rmSync(', ' '), run('rmSync(', 'recursive '), run('rmSync(', 'recursive: '), run('', '.rm('), run('.rm(', ' '), run('.rm(', 'recursive: '), run('', 'rm('), run('rm(', ' '), run('rmSync(', ' \n'),
@@ -26,8 +26,9 @@ describe('linear time on hostile input', () => {
run('DELETE', ' '), run('drop', ' '), run('truncate', ' '), run('delete from', ' '), run('delete from ', 'a.'), run('', 'delete from a '), run('.deleteMany', ' '),
run('', 'a_'), run('', 'aU'), run('a', 'A'), run('spend', '_'), run('new Anthropic', ' '), run('.messages.create', ' '),
run('$', 'A_'), run('${', 'A_'), run('', '$A_'), run('process.env.', 'A_'), run('process.env[', ' '), run('os.environ[', ' '), run('os.getenv(', ' '), run('ENV[', ' '),
run('request', 'a'), run('', 'requestA'), run('HK', 'A'), run('', 'HKAQuery '), run('.write(', ' '), run('.write(to:', ' '), run('let ', 'a'), run('let ', 'Purge'), run('', 'let x'), run('import', ' '), run('NSFileProtection', 'a'),
];
test.each(Object.entries({ SECURITY_LINE, SECURITY_JOINED, DATA_LINE, SECRET_LINE, MONEY_LINE, USD_COMPARE, SECRET_PATH: [SECRET_PATH] }))('every %s pattern finishes under 100 ms on each 100k-character hostile line', (_n, patterns) => {
test.each(Object.entries({ SECURITY_LINE, SECURITY_JOINED, DATA_LINE, SECRET_LINE, MONEY_LINE, USD_COMPARE, SECRET_PATH: [SECRET_PATH], SWIFT_SECURITY_LINE, SWIFT_DATA_LINE }))('every %s pattern finishes under 100 ms on each 100k-character hostile line', (_n, patterns) => {
const slow = patterns.flatMap(r => hostile.map(([label, s]) => [r.source.slice(0, 50), label, Math.round(ms(() => r.test(s)))] as const)).filter(([, , t]) => t >= 100);
expect(slow).toEqual([]);
}, 120_000);
+56
View File
@@ -292,6 +292,62 @@ describe('GST-3041: Swift networking is security, SwiftUI is not', () => {
});
});
describe('GST-3052: Swift user-data access, permission requests and on-device storage plan full; plain SwiftUI does not', () => {
// Value: protects=an iOS diff that reads health or calendar data, asks for a privacy permission, or writes, deletes, protects
// or sets how long user files live on the device reaches the full panel now that .swift no longer fails closed;
// fails_when=any line below reads light, an ordinary SwiftUI or UserDefaults line raises a class, or a non-Swift path
// naming these APIs (this module's own patterns) raises one; why_new=GST-3052: ghome#10, #14 and #31 planned light;
// seam=matchRisk; no_claim=what the full panel finds
test.each([
'SFSpeechRecognizer.requestAuthorization { status in done(status == .authorized) }',
'let granted = await AVAudioApplication.requestRecordPermission()',
'AVAudioSession.sharedInstance().requestRecordPermission { ok in done(ok) }',
'try await health.requestAuthorization(toShare: [], read: readTypes)',
'let ok = try await events.requestFullAccessToEvents()',
'events.requestAccess(to: .event) { ok, _ in done(ok) }',
'locations.requestWhenInUseAuthorization()',
'AVCaptureDevice.requestAccess(for: .audio) { _ in }',
'PHPhotoLibrary.requestAuthorization(for: .readWrite) { _ in }',
])('%s is security', line => {
expect(risk(['App/Talk/Dictation.swift'], { 'App/Talk/Dictation.swift': [line] })).toEqual(['security']);
});
test.each([
'import HealthKit', 'private let health = HKHealthStore()',
'let query = HKSampleQuery(sampleType: sleep, predicate: nil, limit: 50, sortDescriptors: nil) { _, _, _ in }',
'let stats = HKStatisticsCollectionQuery(quantityType: steps, quantitySamplePredicate: nil, options: .cumulativeSum, anchorDate: start, intervalComponents: day)',
'import EventKit', 'private let events = EKEventStore()', 'return events.calendars(for: .event).map(Self.summary)',
'let found = events.events(matching: events.predicateForEvents(withStart: from, end: to, calendars: nil))',
'try blob.write(to: notesURL, options: [.atomic, .completeFileProtection])', 'try text.write(to: fileURL, atomically: true, encoding: .utf8)',
'try? FileManager.default.removeItem(at: draftFile)', 'try files.removeItem(atPath: path)', 'try FileManager.default.trashItem(at: old, resultingItemURL: nil)',
'guard FileManager.default.createFile(atPath: spill.path, contents: Data(count: size)) else { throw SpillError.create }',
'let handle = try FileHandle(forWritingTo: spill)', 'let handle = try FileHandle(forUpdating: spill)', 'try handle.write(contentsOf: page)',
'try files.setAttributes([.protectionKey: FileProtectionType.complete], ofItemAtPath: path)', 'let mode = NSFileProtectionCompleteUntilFirstUserAuthentication',
'let shared = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.example.app")',
'values.isExcludedFromBackup = true',
'static let recordingRetentionDays = 7', 'let keepDays: Int = 30', 'try archive.prune(olderThan: cutoff)',
])('%s is data', line => {
expect(risk(['Packages/Core/Sources/Core/Notes/Store.swift'], { 'Packages/Core/Sources/Core/Notes/Store.swift': [line] })).toEqual(['data']);
});
test('ordinary SwiftUI, UserDefaults, reads and type mentions raise no class', () => {
for (const line of [
'import SwiftUI', 'struct HealthCard: View {', ' var body: some View { Text(event.title) }', '@AppStorage("speaksAnswers") private var speaksAnswers = true',
'let on = UserDefaults.standard.bool(forKey: "speaksAnswers")', 'defaults.set(encoded, forKey: Self.key)', 'didSet { defaults?.set(speaksAnswers, forKey: Self.speaksKey) }',
'switch SFSpeechRecognizer.authorizationStatus() {', 'func tint(of calendar: EKCalendar) -> Color { Color(cgColor: calendar.cgColor) }',
'let bytes = try Data(contentsOf: url)', 'let scratch = FileManager.default.temporaryDirectory', 'print(line, to: &log)', 'stream.write(to: &output)',
'let expiresAt = token.expiresAt', 'let settled = true', 'let subtitle = "Today"', 'func requestAccessToken() async throws -> String',
]) expect(risk(['App/Home/HealthCard.swift'], { 'App/Home/HealthCard.swift': [line] })).toEqual([]);
});
test('a product file named *Test.swift is still read, and a call split across lines still matches', () => {
expect(risk(['App/Hearing/HearingTest.swift'], { 'App/Hearing/HearingTest.swift': ['guard await AVAudioApplication.requestRecordPermission() else { return }'] })).toEqual(['security']);
for (const lines of [['try FileManager.default.removeItem(', ' at: draftFile', ')'], ['try blob.write(', ' to: notesURL,', ' options: .atomic', ')'], ['let handle = try FileHandle(', ' forWritingTo: spill', ')']])
expect(risk(['App/Notes/Store.swift'], { 'App/Notes/Store.swift': lines })).toEqual(['data']);
});
test('the Swift rules read only .swift paths outside XCTest targets', () => {
for (const p of ['lib/review-risk.ts', 'docs/ios.md', 'Sources/Bridge.m', 'Tests/AppTests/StoreTests.swift', 'Packages/Core/Tests/CoreTests/Support.swift', 'App/StoreTests.swift'])
expect(risk([p], { [p]: ['const r = /\\bHKHealthStore\\b/;', 'SFSpeechRecognizer.requestAuthorization { _ in }', 'try FileManager.default.removeItem(at: url)'] })).toEqual([]);
});
});
describe('GST-850: money reaches metering, charge and credit code', () => {
// Value: protects=a billing-client or metering diff gets the money reader; fails_when=gbrain-evals #289 reads required=none again,
// or costume, a CLI usage line or a proxy with no billing names money; seam=matchRisk and targetedClasses