sandbox 2.2.0 → 2.3.0
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.
|
@@ -7292,7 +7292,7 @@ const scope = {
|
|
|
7292
7292
|
|
|
7293
7293
|
//#endregion
|
|
7294
7294
|
//#region package.json
|
|
7295
|
-
var version = "2.
|
|
7295
|
+
var version = "2.3.0";
|
|
7296
7296
|
|
|
7297
7297
|
//#endregion
|
|
7298
7298
|
//#region src/error.ts
|
|
@@ -11524,45 +11524,32 @@ init_source();
|
|
|
11524
11524
|
const networkPolicyMode = import_cjs$12.extendType(import_cjs$12.string, {
|
|
11525
11525
|
displayName: "MODE",
|
|
11526
11526
|
async from(value) {
|
|
11527
|
-
const validModes = [
|
|
11528
|
-
"internet-access",
|
|
11529
|
-
"no-access",
|
|
11530
|
-
"restricted"
|
|
11531
|
-
];
|
|
11527
|
+
const validModes = ["allow-all", "deny-all"];
|
|
11532
11528
|
if (!validModes.includes(value)) throw new Error([`Invalid network policy mode: ${value}.`, `${source_default.bold("hint:")} Valid modes are: ${validModes.join(", ")}`].join("\n"));
|
|
11533
11529
|
return value;
|
|
11534
11530
|
}
|
|
11535
11531
|
});
|
|
11536
11532
|
const networkPolicy = import_cjs$12.option({
|
|
11537
11533
|
long: "network-policy",
|
|
11538
|
-
description: `Network policy mode: "
|
|
11539
|
-
|
|
11540
|
-
|
|
11541
|
-
|
|
11542
|
-
restricted: sandbox can only access websites and domains explicitly allowed`,
|
|
11534
|
+
description: `Network policy mode: "allow-all" or "deny-all"
|
|
11535
|
+
- allow-all: sandbox can access any website/domain
|
|
11536
|
+
- deny-all: sandbox has no network access
|
|
11537
|
+
Omit this option and use --allowed-domain / --allowed-cidr / --denied-cidr for custom policies.`,
|
|
11543
11538
|
type: import_cjs$12.optional(networkPolicyMode)
|
|
11544
11539
|
});
|
|
11545
11540
|
const allowedDomains = import_cjs$12.multioption({
|
|
11546
11541
|
long: "allowed-domain",
|
|
11547
|
-
description: `Domain to allow traffic to (
|
|
11548
|
-
|
|
11549
|
-
Supports "*" for wildcards for a segment (e.g. '*.vercel.com', 'www.*.com')
|
|
11550
|
-
If used as the first segment, will match any subdomain.`,
|
|
11542
|
+
description: `Domain to allow traffic to (creates a custom network policy). Supports "*" for wildcards for a segment (e.g. '*.vercel.com', 'www.*.com'). If used as the first segment, will match any subdomain.`,
|
|
11551
11543
|
type: import_cjs$12.array(import_cjs$12.string)
|
|
11552
11544
|
});
|
|
11553
11545
|
const allowedCIDRs = import_cjs$12.multioption({
|
|
11554
11546
|
long: "allowed-cidr",
|
|
11555
|
-
description: `CIDR to allow traffic to (
|
|
11556
|
-
|
|
11557
|
-
Takes precedence over 'allowed-domain'.
|
|
11558
|
-
`,
|
|
11547
|
+
description: `CIDR to allow traffic to (creates a custom network policy). Takes precedence over 'allowed-domain'.`,
|
|
11559
11548
|
type: import_cjs$12.array(import_cjs$12.string)
|
|
11560
11549
|
});
|
|
11561
11550
|
const deniedCIDRs = import_cjs$12.multioption({
|
|
11562
11551
|
long: "denied-cidr",
|
|
11563
|
-
description: `CIDR to deny traffic to (
|
|
11564
|
-
|
|
11565
|
-
Takes precedence over allowed domains/CIDRs.`,
|
|
11552
|
+
description: `CIDR to deny traffic to (creates a custom network policy). Takes precedence over allowed domains/CIDRs.`,
|
|
11566
11553
|
type: import_cjs$12.array(import_cjs$12.string)
|
|
11567
11554
|
});
|
|
11568
11555
|
const networkPolicyArgs = {
|
|
@@ -11576,24 +11563,28 @@ const networkPolicyArgs = {
|
|
|
11576
11563
|
//#region src/util/network-policy.ts
|
|
11577
11564
|
init_source();
|
|
11578
11565
|
/**
|
|
11579
|
-
*
|
|
11566
|
+
* Resolves the network policy mode from --network-policy and --mode flags.
|
|
11567
|
+
* Errors if both are provided with conflicting values.
|
|
11568
|
+
*/
|
|
11569
|
+
function resolveMode(networkPolicy$1, mode) {
|
|
11570
|
+
if (networkPolicy$1 && mode && networkPolicy$1 !== mode) throw new Error([`Conflicting network policy modes: --network-policy=${networkPolicy$1} and --mode=${mode}.`, `${source_default.bold("hint:")} Use only one of --network-policy or --mode.`].join("\n"));
|
|
11571
|
+
return networkPolicy$1 ?? mode;
|
|
11572
|
+
}
|
|
11573
|
+
/**
|
|
11574
|
+
* Builds a NetworkPolicy from CLI arguments.
|
|
11580
11575
|
*/
|
|
11581
11576
|
function buildNetworkPolicy(args$4) {
|
|
11582
11577
|
const { networkPolicy: networkPolicy$1, allowedDomains: allowedDomains$1, allowedCIDRs: allowedCIDRs$1, deniedCIDRs: deniedCIDRs$1 } = args$4;
|
|
11583
|
-
|
|
11584
|
-
|
|
11585
|
-
|
|
11586
|
-
|
|
11587
|
-
|
|
11588
|
-
|
|
11589
|
-
|
|
11590
|
-
|
|
11591
|
-
|
|
11592
|
-
|
|
11593
|
-
allowedCIDRs: allowedCIDRs$1.length > 0 ? allowedCIDRs$1 : void 0,
|
|
11594
|
-
deniedCIDRs: deniedCIDRs$1.length > 0 ? deniedCIDRs$1 : void 0
|
|
11595
|
-
};
|
|
11596
|
-
}
|
|
11578
|
+
const hasListOptions = allowedDomains$1.length > 0 || allowedCIDRs$1.length > 0 || deniedCIDRs$1.length > 0;
|
|
11579
|
+
if (networkPolicy$1 && hasListOptions) throw new Error([`Cannot combine --network-policy=${networkPolicy$1} with --allowed-domain, --allowed-cidr, or --denied-cidr.`, `${source_default.bold("hint:")} Use --allowed-domain / --allowed-cidr / --denied-cidr without --network-policy for custom policies.`].join("\n"));
|
|
11580
|
+
if (hasListOptions) return {
|
|
11581
|
+
...allowedDomains$1.length > 0 && { allow: allowedDomains$1 },
|
|
11582
|
+
...(allowedCIDRs$1.length > 0 || deniedCIDRs$1.length > 0) && { subnets: {
|
|
11583
|
+
...allowedCIDRs$1.length > 0 && { allow: allowedCIDRs$1 },
|
|
11584
|
+
...deniedCIDRs$1.length > 0 && { deny: deniedCIDRs$1 }
|
|
11585
|
+
} }
|
|
11586
|
+
};
|
|
11587
|
+
return networkPolicy$1 ?? "allow-all";
|
|
11597
11588
|
}
|
|
11598
11589
|
|
|
11599
11590
|
//#endregion
|
|
@@ -11794,7 +11785,7 @@ const list = import_cjs$9.command({
|
|
|
11794
11785
|
ID: { value: (s$1) => s$1.id },
|
|
11795
11786
|
STATUS: {
|
|
11796
11787
|
value: (s$1) => s$1.status,
|
|
11797
|
-
color: (s$1) => SandboxStatusColor
|
|
11788
|
+
color: (s$1) => SandboxStatusColor[s$1.status] ?? source_default.reset
|
|
11798
11789
|
},
|
|
11799
11790
|
CREATED: { value: (s$1) => timeAgo(s$1.createdAt) },
|
|
11800
11791
|
MEMORY: { value: (s$1) => memoryFormatter.format(s$1.memory) },
|
|
@@ -11806,13 +11797,15 @@ const list = import_cjs$9.command({
|
|
|
11806
11797
|
}));
|
|
11807
11798
|
}
|
|
11808
11799
|
});
|
|
11809
|
-
const SandboxStatusColor =
|
|
11810
|
-
|
|
11811
|
-
|
|
11812
|
-
|
|
11813
|
-
|
|
11814
|
-
|
|
11815
|
-
|
|
11800
|
+
const SandboxStatusColor = {
|
|
11801
|
+
"running": source_default.cyan,
|
|
11802
|
+
"failed": source_default.red,
|
|
11803
|
+
"stopped": source_default.gray.dim,
|
|
11804
|
+
"stopping": source_default.gray,
|
|
11805
|
+
"pending": source_default.magenta,
|
|
11806
|
+
"snapshotting": source_default.blue,
|
|
11807
|
+
"aborted": source_default.gray.dim
|
|
11808
|
+
};
|
|
11816
11809
|
|
|
11817
11810
|
//#endregion
|
|
11818
11811
|
//#region src/commands/connect.ts
|
|
@@ -14443,16 +14436,21 @@ var import_cjs$1 = /* @__PURE__ */ __toESM(require_cjs());
|
|
|
14443
14436
|
init_source();
|
|
14444
14437
|
const networkPolicyCommand = import_cjs$1.command({
|
|
14445
14438
|
name: "network-policy",
|
|
14446
|
-
description: `Update the network policy of a sandbox
|
|
14447
|
-
|
|
14448
|
-
This is a full update, fully overriding the pre-existing configuration.`,
|
|
14439
|
+
description: `Update the network policy of a sandbox.
|
|
14440
|
+
This will fully override the previous configuration.`,
|
|
14449
14441
|
args: {
|
|
14450
14442
|
scope,
|
|
14451
14443
|
sandbox: import_cjs$1.positional({ type: sandboxId }),
|
|
14452
|
-
...networkPolicyArgs
|
|
14444
|
+
...networkPolicyArgs,
|
|
14445
|
+
mode: import_cjs$1.option({
|
|
14446
|
+
long: "mode",
|
|
14447
|
+
description: `Alias for --network-policy.`,
|
|
14448
|
+
type: import_cjs$1.optional(networkPolicyMode)
|
|
14449
|
+
})
|
|
14453
14450
|
},
|
|
14454
|
-
async handler({ scope: { token: token$1, team: team$1, project: project$1 }, sandbox: sandboxId$1, networkPolicy:
|
|
14455
|
-
|
|
14451
|
+
async handler({ scope: { token: token$1, team: team$1, project: project$1 }, sandbox: sandboxId$1, networkPolicy: networkPolicyFlag, mode: modeFlag, allowedDomains: allowedDomains$1, allowedCIDRs: allowedCIDRs$1, deniedCIDRs: deniedCIDRs$1 }) {
|
|
14452
|
+
const networkPolicyMode$1 = resolveMode(networkPolicyFlag, modeFlag);
|
|
14453
|
+
if (networkPolicyMode$1 === void 0 && allowedDomains$1.length === 0 && allowedCIDRs$1.length === 0 && deniedCIDRs$1.length === 0) throw new Error(`Network policy mode or custom rules must be set.`);
|
|
14456
14454
|
const networkPolicy$1 = buildNetworkPolicy({
|
|
14457
14455
|
networkPolicy: networkPolicyMode$1,
|
|
14458
14456
|
allowedDomains: allowedDomains$1,
|
|
@@ -14477,10 +14475,11 @@ This is a full update, fully overriding the pre-existing configuration.`,
|
|
|
14477
14475
|
}
|
|
14478
14476
|
const spinner = ora("Updating network policy...").start();
|
|
14479
14477
|
try {
|
|
14480
|
-
await sandbox.updateNetworkPolicy(networkPolicy$1);
|
|
14478
|
+
const response = await sandbox.updateNetworkPolicy(networkPolicy$1);
|
|
14481
14479
|
spinner.stop();
|
|
14482
14480
|
process.stderr.write("✅ Network policy updated for sandbox " + source_default.cyan(sandbox.sandboxId) + "\n");
|
|
14483
|
-
|
|
14481
|
+
const mode = typeof response === "string" ? response : "restricted";
|
|
14482
|
+
process.stderr.write(source_default.dim(" ╰ ") + "mode: " + source_default.cyan(mode) + "\n");
|
|
14484
14483
|
} catch (error) {
|
|
14485
14484
|
spinner.stop();
|
|
14486
14485
|
throw error;
|
|
@@ -14520,4 +14519,4 @@ const app = (opts) => (0, import_cjs.subcommands)({
|
|
|
14520
14519
|
|
|
14521
14520
|
//#endregion
|
|
14522
14521
|
export { StyledError as n, require_cjs as r, app as t };
|
|
14523
|
-
//# sourceMappingURL=app-
|
|
14522
|
+
//# sourceMappingURL=app-CTYU83uM.mjs.map
|