replicas-cli 0.3.625 → 0.3.626

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.
Files changed (2) hide show
  1. package/dist/index.cjs +118 -86
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -21549,6 +21549,88 @@ var init_environment_setups = __esm({
21549
21549
  }
21550
21550
  });
21551
21551
 
21552
+ // ../shared/src/guard.ts
21553
+ var GUARD_NETWORK_MODES, GUARD_ECOSYSTEMS, GUARD_PROXY_MODES, GUARD_ALLOW_GROUP_KEYS, GUARD_ALLOW_GROUPS, JUDGE_SETUP_REGISTRY_HOSTS, guardHostSchema, guardInstallExceptionSchema, guardEnvironmentSettingsSchema, DEFAULT_GUARD_SETTINGS, updateGuardSettingsRequestSchema;
21554
+ var init_guard = __esm({
21555
+ "../shared/src/guard.ts"() {
21556
+ "use strict";
21557
+ init_zod();
21558
+ GUARD_NETWORK_MODES = ["off", "watch", "locked"];
21559
+ GUARD_ECOSYSTEMS = ["npm", "pypi", "crates.io", "go", "rubygems", "maven"];
21560
+ GUARD_PROXY_MODES = ["off", "watch", "enforce"];
21561
+ GUARD_ALLOW_GROUP_KEYS = ["package_registries", "git_hosts", "model_apis"];
21562
+ GUARD_ALLOW_GROUPS = {
21563
+ package_registries: {
21564
+ hosts: [
21565
+ "registry.npmjs.org",
21566
+ "registry.yarnpkg.com",
21567
+ "repo.yarnpkg.com",
21568
+ "pypi.org",
21569
+ "files.pythonhosted.org",
21570
+ "crates.io",
21571
+ "index.crates.io",
21572
+ "static.crates.io",
21573
+ "proxy.golang.org",
21574
+ "sum.golang.org",
21575
+ "rubygems.org",
21576
+ "index.rubygems.org",
21577
+ "repo.maven.apache.org",
21578
+ "repo1.maven.org",
21579
+ "registry-1.docker.io",
21580
+ "auth.docker.io",
21581
+ "production.cloudflare.docker.com",
21582
+ "deb.debian.org",
21583
+ "security.debian.org",
21584
+ "archive.ubuntu.com",
21585
+ "security.ubuntu.com",
21586
+ "ports.ubuntu.com"
21587
+ ]
21588
+ },
21589
+ git_hosts: {
21590
+ hosts: ["github.com", "api.github.com", "codeload.github.com", "objects.githubusercontent.com", "gitlab.com"]
21591
+ },
21592
+ model_apis: { hosts: [] }
21593
+ };
21594
+ JUDGE_SETUP_REGISTRY_HOSTS = [
21595
+ ...GUARD_ALLOW_GROUPS.package_registries.hosts,
21596
+ "api.nuget.org",
21597
+ "repo.packagist.org",
21598
+ "production.cloudfront.docker.com",
21599
+ "docker-images-prod.s3.dualstack.us-east-1.amazonaws.com"
21600
+ ];
21601
+ guardHostSchema = external_exports.string().trim().toLowerCase().regex(/^(\*\.)?([a-z0-9-]+\.)+[a-z0-9-]+$/, "Must be a hostname like example.com or *.example.com");
21602
+ guardInstallExceptionSchema = external_exports.object({
21603
+ package: external_exports.string().trim().min(1),
21604
+ version: external_exports.string().trim().min(1),
21605
+ ecosystem: external_exports.enum(GUARD_ECOSYSTEMS),
21606
+ expires_at: external_exports.iso.datetime(),
21607
+ granted_by: external_exports.string()
21608
+ });
21609
+ guardEnvironmentSettingsSchema = external_exports.object({
21610
+ network: external_exports.object({
21611
+ mode: external_exports.enum(GUARD_NETWORK_MODES).default("off"),
21612
+ allow_groups: external_exports.array(external_exports.enum(GUARD_ALLOW_GROUP_KEYS)).default([...GUARD_ALLOW_GROUP_KEYS]),
21613
+ extra_hosts: external_exports.array(guardHostSchema).max(200).default([]),
21614
+ keep_user_github_token: external_exports.boolean().default(false)
21615
+ }).prefault({}),
21616
+ installs: external_exports.object({
21617
+ enabled: external_exports.boolean().default(false),
21618
+ waiting_period_days: external_exports.number().int().min(0).max(30).default(3),
21619
+ own_scopes: external_exports.array(external_exports.string().trim().min(1)).max(100).default([]),
21620
+ exceptions: external_exports.array(guardInstallExceptionSchema).max(200).default([]),
21621
+ proxy_mode: external_exports.enum(GUARD_PROXY_MODES).default("off")
21622
+ }).prefault({}),
21623
+ trusted_agent_config: external_exports.boolean().default(false)
21624
+ });
21625
+ DEFAULT_GUARD_SETTINGS = guardEnvironmentSettingsSchema.parse({});
21626
+ updateGuardSettingsRequestSchema = guardEnvironmentSettingsSchema.extend({
21627
+ installs: guardEnvironmentSettingsSchema.shape.installs.unwrap().extend({
21628
+ exceptions: external_exports.array(guardInstallExceptionSchema.omit({ granted_by: true })).max(200).default([])
21629
+ }).prefault({})
21630
+ });
21631
+ }
21632
+ });
21633
+
21552
21634
  // ../shared/src/security/repository-path.ts
21553
21635
  var repositoryPathSchema;
21554
21636
  var init_repository_path = __esm({
@@ -22367,19 +22449,37 @@ var init_secrets = __esm({
22367
22449
  });
22368
22450
 
22369
22451
  // ../shared/src/routes/security-app-setup.ts
22452
+ function securityAppEgressHostRefusal(host2) {
22453
+ const name = securityAppHostName(host2);
22454
+ if (SECURITY_APP_DOCKER_HUB_HOSTS.some((hub) => hub === name)) return null;
22455
+ if (name.startsWith("*.")) return `${host2} is a wildcard. List each host by its exact name.`;
22456
+ if (!guardHostSchema.safeParse(name).success) return `${host2} is not a public host name like api.example.com.`;
22457
+ const last = name.slice(name.lastIndexOf(".") + 1);
22458
+ if (/^(\d+|0x[0-9a-f]*)$/.test(last)) return `${host2} is an IP address. List the host by its name.`;
22459
+ if (INTERNAL_SUFFIXES.includes(last)) return `${host2} is a private network name, which a sandbox may not reach.`;
22460
+ if (OBJECT_STORAGE.test(name)) return `${host2} is file storage anyone can rent, so it does not say who receives what is sent there. Fetch what the app needs from the project's own host or registry.`;
22461
+ return null;
22462
+ }
22370
22463
  function prepareSecurityAppRecipe(recipe) {
22371
- const prepared = { ...recipe, variables: recipe.variables.map((variable) => ({ ...variable, reason: maskSecrets(variable.reason) })) };
22464
+ const refusal = [...recipe.egress.install, ...recipe.egress.run].map(securityAppEgressHostRefusal).find(Boolean);
22465
+ if (refusal) return createErrorResult({ message: refusal, code: 422 });
22466
+ const prepared = {
22467
+ ...recipe,
22468
+ egress: { install: recipe.egress.install.map(securityAppHostName), run: recipe.egress.run.map(securityAppHostName) },
22469
+ variables: recipe.variables.map((variable) => ({ ...variable, reason: maskSecrets(variable.reason) }))
22470
+ };
22372
22471
  return stringsIn(prepared).some(containsLiveKey) ? createErrorResult({
22373
22472
  message: "The recipe holds a private key or a live Stripe, AWS, GitHub, Slack or other provider key in a command or value. Invent a stand-in value instead, or list the variable as confirmed_real so the person supplies the real one.",
22374
22473
  code: 422
22375
22474
  }) : createSuccessResult(prepared);
22376
22475
  }
22377
- var SECURITY_APP_SETUP_STATUSES, SECURITY_APP_SETUP_BLOCKERS, SECURITY_APP_SETUP_CHECK_MESSAGE_MAX, SECURITY_APP_SETUP_CHECK_STEP_MAX, SECURITY_APP_VARIABLE_CLASSES, NOT_NEEDED, LOCAL_SERVICE, STAND_IN, FAKE, CONFIRMED_REAL, SECURITY_APP_FAKE_FORMATS, SECURITY_APP_STAND_INS, SECURITY_APP_LOGIN_STRATEGIES, SECURITY_APP_RESET_KINDS, SECURITY_APP_DATABASE_ENGINES, SECURITY_APP_LIMITS, L, text2, key, SECURITY_ANONYMOUS_ACTOR, actorKey, variableName, port, host, step, readiness, processSchema2, variableSchema, databaseSchema, securityAppMeasuredTimesSchema, securityAppRecipeSchema, securityAppSetupSubmissionSchema, securityAppSetupSchema, confirmSecurityAppVariableSchema, commitShaSchema, SECURITY_APP_BOOT_PHASES, SECURITY_APP_SETUP_CHECK_PHASES, securityAppSetupCheckSchema;
22476
+ var SECURITY_APP_SETUP_STATUSES, SECURITY_APP_SETUP_BLOCKERS, SECURITY_APP_SETUP_CHECK_MESSAGE_MAX, SECURITY_APP_SETUP_CHECK_STEP_MAX, SECURITY_APP_VARIABLE_CLASSES, NOT_NEEDED, LOCAL_SERVICE, STAND_IN, FAKE, CONFIRMED_REAL, SECURITY_APP_FAKE_FORMATS, SECURITY_APP_STAND_INS, SECURITY_APP_LOGIN_STRATEGIES, SECURITY_APP_RESET_KINDS, SECURITY_APP_DATABASE_ENGINES, SECURITY_APP_LIMITS, L, text2, key, SECURITY_ANONYMOUS_ACTOR, actorKey, variableName, port, host, step, readiness, processSchema2, variableSchema, databaseSchema, securityAppMeasuredTimesSchema, SECURITY_APP_DOCKER_HUB_HOSTS, securityAppRecipeSchema, INTERNAL_SUFFIXES, OBJECT_STORAGE, securityAppHostName, securityAppSetupSubmissionSchema, securityAppSetupSchema, confirmSecurityAppVariableSchema, commitShaSchema, SECURITY_APP_BOOT_PHASES, SECURITY_APP_SETUP_CHECK_PHASES, securityAppSetupCheckSchema;
22378
22477
  var init_security_app_setup = __esm({
22379
22478
  "../shared/src/routes/security-app-setup.ts"() {
22380
22479
  "use strict";
22381
22480
  init_zod();
22382
22481
  init_environment_setups();
22482
+ init_guard();
22383
22483
  init_repository_path();
22384
22484
  init_secrets();
22385
22485
  init_result();
@@ -22446,6 +22546,13 @@ var init_security_app_setup = __esm({
22446
22546
  boot_s: external_exports.number().min(0),
22447
22547
  reset_s: external_exports.number().min(0).nullable().default(null)
22448
22548
  });
22549
+ SECURITY_APP_DOCKER_HUB_HOSTS = [
22550
+ "registry-1.docker.io",
22551
+ "auth.docker.io",
22552
+ "production.cloudflare.docker.com",
22553
+ "production.cloudfront.docker.com",
22554
+ "docker-images-prod.s3.dualstack.us-east-1.amazonaws.com"
22555
+ ];
22449
22556
  securityAppRecipeSchema = external_exports.object({
22450
22557
  base_commit: external_exports.string().regex(/^[a-f0-9]{40}$/),
22451
22558
  app_dir: repositoryPathSchema.nullable().default(null),
@@ -22483,6 +22590,9 @@ var init_security_app_setup = __esm({
22483
22590
  path: ["markers", "plant"],
22484
22591
  message: "markers.plant is a step when the recipe has identities, and null when identities is null"
22485
22592
  });
22593
+ INTERNAL_SUFFIXES = ["localhost", "local", "localdomain", "internal", "intranet", "private", "corp", "home", "lan", "arpa", "test", "invalid", "onion"];
22594
+ OBJECT_STORAGE = /(^|\.)(s3([.-][a-z0-9-]+)*\.amazonaws\.com(\.cn)?|storage\.googleapis\.com|storage\.cloud\.google\.com|(blob|dfs|web)\.core\.windows\.net|r2\.cloudflarestorage\.com|r2\.dev|digitaloceanspaces\.com|backblazeb2\.com|linodeobjects\.com|wasabisys\.com)$/;
22595
+ securityAppHostName = (host2) => host2.trim().toLowerCase().replace(/\.$/, "");
22486
22596
  securityAppSetupSubmissionSchema = external_exports.discriminatedUnion("outcome", [
22487
22597
  external_exports.object({ outcome: external_exports.literal("recipe"), recipe: securityAppRecipeSchema }),
22488
22598
  external_exports.object({ outcome: external_exports.enum(SECURITY_APP_SETUP_BLOCKERS), reason: text2(L.reasonChars), recipe: securityAppRecipeSchema.nullable().default(null) })
@@ -22500,6 +22610,8 @@ var init_security_app_setup = __esm({
22500
22610
  // Checked, never trimmed: a credential's spaces are part of it.
22501
22611
  value: external_exports.string().max(1e4).refine((value) => value.trim() !== "", "Enter a value"),
22502
22612
  run_id: external_exports.string().uuid().nullable(),
22613
+ // The recipe on screen: an agent can submit another one, under the same run, while the form is open.
22614
+ submitted_at: external_exports.string(),
22503
22615
  environment_id: external_exports.string().uuid()
22504
22616
  });
22505
22617
  commitShaSchema = external_exports.string().regex(/^[a-f0-9]{40}$/);
@@ -23935,7 +24047,9 @@ var init_workspaces = __esm({
23935
24047
  securityRunConfigSchema = external_exports.object({
23936
24048
  run_id: external_exports.string().min(1),
23937
24049
  type: external_exports.enum(SECURITY_RUN_TYPES),
23938
- role: external_exports.enum(SECURITY_SANDBOX_ROLES)
24050
+ role: external_exports.enum(SECURITY_SANDBOX_ROLES),
24051
+ /** The recipe a sandbox was started and locked for: it is handed no other, and a setup check's report counts only for it. */
24052
+ app_setup_submitted_at: external_exports.string().optional()
23939
24053
  });
23940
24054
  WORKSPACE_KINDS = ["standard", "manager", "mothership", "scout"];
23941
24055
  MANAGER_KINDS = ["manager", "mothership"];
@@ -42268,88 +42382,6 @@ var init_hook_failure = __esm({
42268
42382
  }
42269
42383
  });
42270
42384
 
42271
- // ../shared/src/guard.ts
42272
- var GUARD_NETWORK_MODES, GUARD_ECOSYSTEMS, GUARD_PROXY_MODES, GUARD_ALLOW_GROUP_KEYS, GUARD_ALLOW_GROUPS, JUDGE_SETUP_REGISTRY_HOSTS, hostSchema2, guardInstallExceptionSchema, guardEnvironmentSettingsSchema, DEFAULT_GUARD_SETTINGS, updateGuardSettingsRequestSchema;
42273
- var init_guard = __esm({
42274
- "../shared/src/guard.ts"() {
42275
- "use strict";
42276
- init_zod();
42277
- GUARD_NETWORK_MODES = ["off", "watch", "locked"];
42278
- GUARD_ECOSYSTEMS = ["npm", "pypi", "crates.io", "go", "rubygems", "maven"];
42279
- GUARD_PROXY_MODES = ["off", "watch", "enforce"];
42280
- GUARD_ALLOW_GROUP_KEYS = ["package_registries", "git_hosts", "model_apis"];
42281
- GUARD_ALLOW_GROUPS = {
42282
- package_registries: {
42283
- hosts: [
42284
- "registry.npmjs.org",
42285
- "registry.yarnpkg.com",
42286
- "repo.yarnpkg.com",
42287
- "pypi.org",
42288
- "files.pythonhosted.org",
42289
- "crates.io",
42290
- "index.crates.io",
42291
- "static.crates.io",
42292
- "proxy.golang.org",
42293
- "sum.golang.org",
42294
- "rubygems.org",
42295
- "index.rubygems.org",
42296
- "repo.maven.apache.org",
42297
- "repo1.maven.org",
42298
- "registry-1.docker.io",
42299
- "auth.docker.io",
42300
- "production.cloudflare.docker.com",
42301
- "deb.debian.org",
42302
- "security.debian.org",
42303
- "archive.ubuntu.com",
42304
- "security.ubuntu.com",
42305
- "ports.ubuntu.com"
42306
- ]
42307
- },
42308
- git_hosts: {
42309
- hosts: ["github.com", "api.github.com", "codeload.github.com", "objects.githubusercontent.com", "gitlab.com"]
42310
- },
42311
- model_apis: { hosts: [] }
42312
- };
42313
- JUDGE_SETUP_REGISTRY_HOSTS = [
42314
- ...GUARD_ALLOW_GROUPS.package_registries.hosts,
42315
- "api.nuget.org",
42316
- "repo.packagist.org",
42317
- "production.cloudfront.docker.com",
42318
- "docker-images-prod.s3.dualstack.us-east-1.amazonaws.com"
42319
- ];
42320
- hostSchema2 = external_exports.string().trim().toLowerCase().regex(/^(\*\.)?([a-z0-9-]+\.)+[a-z0-9-]+$/, "Must be a hostname like example.com or *.example.com");
42321
- guardInstallExceptionSchema = external_exports.object({
42322
- package: external_exports.string().trim().min(1),
42323
- version: external_exports.string().trim().min(1),
42324
- ecosystem: external_exports.enum(GUARD_ECOSYSTEMS),
42325
- expires_at: external_exports.iso.datetime(),
42326
- granted_by: external_exports.string()
42327
- });
42328
- guardEnvironmentSettingsSchema = external_exports.object({
42329
- network: external_exports.object({
42330
- mode: external_exports.enum(GUARD_NETWORK_MODES).default("off"),
42331
- allow_groups: external_exports.array(external_exports.enum(GUARD_ALLOW_GROUP_KEYS)).default([...GUARD_ALLOW_GROUP_KEYS]),
42332
- extra_hosts: external_exports.array(hostSchema2).max(200).default([]),
42333
- keep_user_github_token: external_exports.boolean().default(false)
42334
- }).prefault({}),
42335
- installs: external_exports.object({
42336
- enabled: external_exports.boolean().default(false),
42337
- waiting_period_days: external_exports.number().int().min(0).max(30).default(3),
42338
- own_scopes: external_exports.array(external_exports.string().trim().min(1)).max(100).default([]),
42339
- exceptions: external_exports.array(guardInstallExceptionSchema).max(200).default([]),
42340
- proxy_mode: external_exports.enum(GUARD_PROXY_MODES).default("off")
42341
- }).prefault({}),
42342
- trusted_agent_config: external_exports.boolean().default(false)
42343
- });
42344
- DEFAULT_GUARD_SETTINGS = guardEnvironmentSettingsSchema.parse({});
42345
- updateGuardSettingsRequestSchema = guardEnvironmentSettingsSchema.extend({
42346
- installs: guardEnvironmentSettingsSchema.shape.installs.unwrap().extend({
42347
- exceptions: external_exports.array(guardInstallExceptionSchema.omit({ granted_by: true })).max(200).default([])
42348
- }).prefault({})
42349
- });
42350
- }
42351
- });
42352
-
42353
42385
  // ../shared/src/start-hooks.ts
42354
42386
  var init_start_hooks = __esm({
42355
42387
  "../shared/src/start-hooks.ts"() {
@@ -43071,7 +43103,7 @@ var CLI_VERSION;
43071
43103
  var init_cli_version = __esm({
43072
43104
  "../shared/src/cli-version.ts"() {
43073
43105
  "use strict";
43074
- CLI_VERSION = "0.3.625";
43106
+ CLI_VERSION = "0.3.626";
43075
43107
  }
43076
43108
  });
43077
43109
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-cli",
3
- "version": "0.3.625",
3
+ "version": "0.3.626",
4
4
  "description": "CLI for managing Replicas workspaces - SSH into cloud dev environments with automatic port forwarding",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {