runcloud 0.2.237 → 0.2.239

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -117,6 +117,8 @@ const SKIP_DIRS = new Set([
117
117
  '.expo',
118
118
  '.git',
119
119
  '.next',
120
+ '.newly',
121
+ 'legacy-attachments',
120
122
  'build',
121
123
  'dist',
122
124
  'node_modules',
@@ -160,7 +162,7 @@ export function evaluateCompliance(manifest, projectDir, options = {}) {
160
162
  items.push(makeItem(item, 'info', `Not targeting ${platformNames(item.platform)}.`, 'app.json target platform detection'));
161
163
  continue;
162
164
  }
163
- const evaluated = evaluateLocalItem(root, appJson, item);
165
+ const evaluated = evaluateLocalItem(root, appJson, item, dynamicConfig);
164
166
  if (evaluated && dynamicConfig && READS_APP_CONFIG.has(item.id) && (evaluated.status === 'fail' || evaluated.status === 'warning')) {
165
167
  items.push(makeItem(item, 'info', uncheckedUnder(dynamicConfig, evaluated.message ?? `${item.label} is not set.`), evaluated.evidence));
166
168
  continue;
@@ -209,7 +211,7 @@ export function renderEvaluation(result) {
209
211
  function activeItems(manifest, rollouts = []) {
210
212
  return manifest.items.filter((item) => !item.deferred && item.resolvedBy !== 'card' && (!item.rollout || rollouts.includes(item.rollout)));
211
213
  }
212
- function evaluateLocalItem(root, appJson, item) {
214
+ function evaluateLocalItem(root, appJson, item, dynamicConfig) {
213
215
  if (item.id === 'scheme')
214
216
  return evaluateScheme(root, appJson, item);
215
217
  const rule = CONFIG_RULES[item.id];
@@ -217,11 +219,11 @@ function evaluateLocalItem(root, appJson, item) {
217
219
  return evaluateConfigItem(appJson, item, rule);
218
220
  switch (item.id) {
219
221
  case 'hardcoded_secrets':
220
- return patternItem(root, item, /sk-[A-Za-z0-9]{20,}|AIza[0-9A-Za-z_-]{30,}|-----BEGIN.*PRIVATE KEY|api[_-]?key\s*[:=]\s*['"][A-Za-z0-9]{16,}/i, 'fail', 'Hardcoded secret-like value found.', 'No secret-like values found.', {
221
- filter: (match) => !isFirebaseClientKey(root, match),
222
- });
222
+ return evaluateSecrets(root, item);
223
223
  case 'http_endpoints':
224
- return patternItem(root, item, /http:\/\/(?!localhost|127\.0\.0\.1)/i, 'warning', 'Non-local HTTP endpoint found.', 'No non-local HTTP endpoints found.');
224
+ return evaluateHttpEndpoints(root, appJson, item);
225
+ case 'app_icon':
226
+ return evaluateIosIconFiles(root, appJson, item, dynamicConfig);
225
227
  case 'placeholder_content':
226
228
  return patternItem(root, item, PLACEHOLDER_COPY, 'warning', 'Placeholder text found.', 'No placeholder text found.', {
227
229
  filter: (match) => PLACEHOLDER_COPY.test(withoutInputPlaceholders(match.text)),
@@ -305,14 +307,100 @@ function evaluateEncryption(appJson, item) {
305
307
  return makeItem(item, 'pass', `${item.label} is set.`, evidence);
306
308
  return makeItem(item, 'info', `${item.label} is declared exempt (no non-exempt encryption) when you publish.`, evidence);
307
309
  }
310
+ const IAP_PACKAGES = ['react-native-purchases', 'react-native-iap', 'expo-iap', 'expo-in-app-purchases'];
308
311
  function evaluateRestorePurchases(root, item) {
309
- const iap = scan(root, /react-native-purchases|expo-in-app-purchases|StoreKit/i);
310
- if (!iap.length)
312
+ const deps = objectValue(getPath(readJson(path.join(root, 'package.json')), ['dependencies']));
313
+ const installed = IAP_PACKAGES.filter((name) => Object.hasOwn(deps, name));
314
+ const iap = scan(root, /['"](?:react-native-purchases|react-native-iap|expo-iap|expo-in-app-purchases)['"]|StoreKit/i, { projectWide: true });
315
+ if (!installed.length && !iap.length)
311
316
  return makeItem(item, 'pass', 'No in-app purchase APIs found.', 'scan: no IAP APIs found');
312
- const restore = scan(root, /restorePurchases|restoreTransactions/i);
317
+ const restore = scan(root, /\b(?:restorePurchases|restoreTransactions|getAvailablePurchases)\s*\(/i, { projectWide: true });
313
318
  if (restore.length)
314
319
  return makeItem(item, 'pass', 'Restore purchases flow appears in source.', evidence(restore));
315
- return makeItem(item, 'fail', 'IAP APIs found but no restore purchases flow was found.', evidence(iap));
320
+ return makeItem(item, 'fail', 'IAP APIs found but no restore purchases flow was found.', installed.length ? `package.json dependencies: ${installed.join(', ')}` : evidence(iap));
321
+ }
322
+ function evaluateSecrets(root, item) {
323
+ const pattern = /sk-[A-Za-z0-9_-]{20,}|sk_live_[A-Za-z0-9]{20,}|AIza[0-9A-Za-z_-]{30,}|['"]AAAA[A-Za-z0-9:_-]{100,}['"]|-----BEGIN.*PRIVATE KEY|(?:api[_-]?key|service[_-]?role[_-]?key|secret)\s*[:=]\s*['"][A-Za-z0-9_.-]{16,}/i;
324
+ const hits = scan(root, pattern, { projectWide: true, filter: (match) => !isFirebaseClientKey(root, match) });
325
+ if (!hits.length)
326
+ return makeItem(item, 'pass', 'No secret-like values found.', 'scan: no secret-like values found');
327
+ const locations = hits.slice(0, 5).map(({ file, line }) => `${file}:${line}`).join('\n');
328
+ return makeItem(item, 'fail', 'Hardcoded secret-like value found.', locations);
329
+ }
330
+ function nonLocalHttpHosts(line) {
331
+ if (line.trimStart().startsWith('//'))
332
+ return [];
333
+ return [...line.matchAll(/['"`]http:\/\/([^'"`\s]+)['"`]/gi)].flatMap((endpoint) => {
334
+ if (/^www\.apple\.com\/DTDs\//i.test(endpoint[1] ?? ''))
335
+ return [];
336
+ const host = endpoint[1]?.split(/[/:]/, 1)[0]?.toLowerCase();
337
+ return !host || /^(?:localhost$|127\.|0\.0\.0\.0$|10\.|192\.168\.|172\.(?:1[6-9]|2\d|3[01])\.|www\.w3\.org$|schemas\.android\.com$)/.test(host) ? [] : [host];
338
+ });
339
+ }
340
+ function evaluateHttpEndpoints(root, appJson, item) {
341
+ const hits = scan(root, /http:\/\//i, { projectWide: true, filter: (match) => nonLocalHttpHosts(match.text).length > 0 });
342
+ if (!hits.length)
343
+ return makeItem(item, 'pass', 'No non-local HTTP endpoints found.', 'scan: no non-local HTTP endpoints found');
344
+ const hosts = new Set(hits.flatMap((hit) => nonLocalHttpHosts(hit.text)));
345
+ const ats = objectValue(getPath(appJson, ['expo', 'ios', 'infoPlist', 'NSAppTransportSecurity']));
346
+ const exceptions = objectValue(ats.NSExceptionDomains);
347
+ const uncovered = [...hosts].filter((host) => !Object.entries(exceptions).some(([domain, config]) => {
348
+ const rule = objectValue(config);
349
+ return (host === domain || (rule.NSIncludesSubdomains === true && host.endsWith(`.${domain}`))) &&
350
+ (rule.NSExceptionAllowsInsecureHTTPLoads === true || rule.NSTemporaryExceptionAllowsInsecureHTTPLoads === true);
351
+ }));
352
+ const allowed = ats.NSAllowsArbitraryLoads === true || !uncovered.length;
353
+ const message = allowed
354
+ ? 'Non-local HTTP endpoint found. App Transport Security allows it, but HTTPS is recommended.'
355
+ : 'Non-local HTTP endpoint found without a matching App Transport Security exception. Use HTTPS.';
356
+ return makeItem(item, 'warning', message, hits.slice(0, 5).map(({ file, line }) => `${file}:${line}`).join('\n'));
357
+ }
358
+ function evaluateIosIconFiles(root, appJson, item, dynamicConfig) {
359
+ if (safeReadDir(path.join(root, 'ios')).some(({ name }) => /\.(xcodeproj|xcworkspace)$/.test(name))) {
360
+ return makeItem(item, 'info', 'Xcode supplies the app icon for this native project.', 'ios/');
361
+ }
362
+ if (dynamicConfig) {
363
+ return makeItem(item, 'info', `Expo resolves the iOS icon from ${dynamicConfig} at build time.`, dynamicConfig);
364
+ }
365
+ const staticConfigPath = path.join(root, 'app.config.json');
366
+ const configFile = existsSync(staticConfigPath) ? 'app.config.json' : 'app.json';
367
+ const config = configFile === 'app.config.json' ? readJson(staticConfigPath) : appJson;
368
+ if (!config)
369
+ return makeItem(item, 'info', `The iOS icon configuration could not be read from ${configFile}.`, configFile);
370
+ const expo = objectValue(getPath(config, ['expo']) ?? config);
371
+ const iosIcon = getPath(expo, ['ios', 'icon']);
372
+ const variants = objectValue(iosIcon);
373
+ const configured = typeof iosIcon === 'string' && iosIcon
374
+ ? [iosIcon]
375
+ : [variants.light, variants.dark, variants.tinted].filter(Boolean);
376
+ const icons = configured.length ? configured : [expo.icon].filter(Boolean);
377
+ if (!icons.length)
378
+ return makeItem(item, 'pass', 'Expo supplies a default iOS icon.', configFile);
379
+ const missing = [];
380
+ let unchecked = false;
381
+ for (const icon of icons) {
382
+ if (typeof icon !== 'string' || path.isAbsolute(icon) || /^[a-z][a-z\d+.-]*:/i.test(icon)) {
383
+ unchecked = true;
384
+ continue;
385
+ }
386
+ const file = path.resolve(root, icon);
387
+ const relative = path.relative(root, file);
388
+ if (relative === '..' || relative.startsWith(`..${path.sep}`)) {
389
+ unchecked = true;
390
+ continue;
391
+ }
392
+ if (path.extname(icon) === '.icon') {
393
+ unchecked ||= !existsSync(file);
394
+ }
395
+ else if (!safeStat(file)?.isFile()) {
396
+ missing.push(icon);
397
+ }
398
+ }
399
+ if (missing.length)
400
+ return makeItem(item, 'fail', 'Expo cannot build the iOS icon because a configured image file is missing.', `${configFile} → ${missing.join(', ')}`);
401
+ if (unchecked)
402
+ return makeItem(item, 'info', 'Some configured iOS icon paths could not be verified from the project files.', configFile);
403
+ return makeItem(item, 'pass', 'Configured iOS icon paths exist in the project.', configFile);
316
404
  }
317
405
  const NON_RELEASE_BACKEND = /[a-z0-9]+-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}-dev\.api\.newlyapp\.com|\.api-dev\.newlyapp\.com|\b[a-z0-9-]+\.(?:ngrok(?:-free)?\.(?:app|dev|io)|loca\.lt|trycloudflare\.com)\b|\b10\.0\.2\.2\b/i;
318
406
  const RELEASE_ENV_FILES = ['.env', '.env.production', '.env.production.local', '.env.local'];
@@ -624,7 +712,7 @@ function makeItem(manifestItem, status, message, evidenceText) {
624
712
  };
625
713
  }
626
714
  function scan(root, regex, options = {}) {
627
- const files = collectScanFiles(root, options.dirs);
715
+ const files = options.projectWide ? walkFiles(root).filter((file) => !file.endsWith('.md') && (safeStat(file)?.size ?? Infinity) <= 1_000_000) : collectScanFiles(root, options.dirs);
628
716
  const matches = [];
629
717
  for (const file of files) {
630
718
  const content = readText(file);
@@ -636,7 +724,7 @@ function scan(root, regex, options = {}) {
636
724
  regex.lastIndex = 0;
637
725
  if (!regex.test(line))
638
726
  return;
639
- const match = { file: rel, line: index + 1, text: compact(line) };
727
+ const match = { file: rel, line: index + 1, text: line };
640
728
  if (options.filter && !options.filter(match))
641
729
  return;
642
730
  matches.push(match);
@@ -700,7 +788,7 @@ function routeKeys(appDir, file) {
700
788
  return keys;
701
789
  }
702
790
  function evidence(matches) {
703
- return matches.slice(0, 5).map((match) => `${match.file}:${match.line}: ${match.text}`).join('\n');
791
+ return matches.slice(0, 5).map((match) => `${match.file}:${match.line}: ${compact(match.text)}`).join('\n');
704
792
  }
705
793
  function asReleased(appJson, iosBundleId) {
706
794
  const expo = getPath(appJson, ['expo']);
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = '0.2.237';
1
+ export const CLI_VERSION = '0.2.239';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runcloud",
3
- "version": "0.2.237",
3
+ "version": "0.2.239",
4
4
  "description": "Create and control run.cloud remote mobile simulators and cloud sandboxes",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
Binary file
Binary file