fullcourtdefense-cli 1.35.2 → 1.35.3
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.
- package/dist/actionPolicyEngine.js +88 -8
- package/dist/approvalPrompt.d.ts +3 -0
- package/dist/approvalPrompt.js +20 -1
- package/dist/blockExplanation.js +17 -0
- package/dist/commandNarrative.d.ts +29 -0
- package/dist/commandNarrative.js +602 -0
- package/dist/commands/workloadProtect.d.ts +10 -0
- package/dist/commands/workloadProtect.js +27 -4
- package/dist/detectorBaseline.d.ts +2 -2
- package/dist/detectorBaseline.js +2 -2
- package/dist/devConfirm.js +7 -2
- package/dist/index.js +4 -0
- package/dist/version.json +1 -1
- package/package.json +1 -1
|
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.assertWorkloadSubstrate = assertWorkloadSubstrate;
|
|
37
|
+
exports.resolveEnrolledVia = resolveEnrolledVia;
|
|
37
38
|
exports.detectWorkloadContext = detectWorkloadContext;
|
|
38
39
|
exports.workloadProtectCommand = workloadProtectCommand;
|
|
39
40
|
const fs = __importStar(require("fs"));
|
|
@@ -64,6 +65,16 @@ function assertWorkloadSubstrate(kind, rt, options = {}) {
|
|
|
64
65
|
+ 'workload-protect is for containers, pods and functions. On a laptop or long-lived VM run `fullcourtdefense onboard` instead, '
|
|
65
66
|
+ 'or pass --force true if this really is a disposable workload host.');
|
|
66
67
|
}
|
|
68
|
+
/** Connections the console has a section for; anything else is the generic snippet. */
|
|
69
|
+
const ENROLLED_VIA_VALUES = new Set(['heroku', 'kubernetes', 'aws', 'gcp', 'snippet']);
|
|
70
|
+
function resolveEnrolledVia(explicit, env, detected) {
|
|
71
|
+
for (const candidate of [explicit, env.FCD_ENROLLED_VIA, detected]) {
|
|
72
|
+
const clean = (candidate || '').trim().toLowerCase();
|
|
73
|
+
if (clean && ENROLLED_VIA_VALUES.has(clean))
|
|
74
|
+
return clean;
|
|
75
|
+
}
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
67
78
|
/** Cloud coding agents that run as unattended workloads (env markers they set). */
|
|
68
79
|
const CLOUD_AGENT_MARKERS = [
|
|
69
80
|
['CURSOR_AGENT', 'cursor-cloud-agent'],
|
|
@@ -86,22 +97,32 @@ function detectWorkloadContext(env = process.env, fsProbe = fs) {
|
|
|
86
97
|
}
|
|
87
98
|
}
|
|
88
99
|
if (env.AWS_LAMBDA_FUNCTION_NAME) {
|
|
89
|
-
return { kind: 'serverless', name: explicitName || env.AWS_LAMBDA_FUNCTION_NAME, environment: environment || env.AWS_LAMBDA_FUNCTION_VERSION, instanceId: env.AWS_LAMBDA_LOG_STREAM_NAME, image };
|
|
100
|
+
return { kind: 'serverless', name: explicitName || env.AWS_LAMBDA_FUNCTION_NAME, environment: environment || env.AWS_LAMBDA_FUNCTION_VERSION, instanceId: env.AWS_LAMBDA_LOG_STREAM_NAME, image, enrolledVia: 'aws' };
|
|
90
101
|
}
|
|
91
102
|
if (env.K_SERVICE) {
|
|
92
103
|
// Cloud Run / Knative
|
|
93
|
-
return { kind: 'serverless', name: explicitName || env.K_SERVICE, environment, instanceId: env.K_REVISION, image };
|
|
104
|
+
return { kind: 'serverless', name: explicitName || env.K_SERVICE, environment, instanceId: env.K_REVISION, image, enrolledVia: 'gcp' };
|
|
94
105
|
}
|
|
95
106
|
if (env.FUNCTIONS_WORKER_RUNTIME && env.WEBSITE_SITE_NAME) {
|
|
96
107
|
// Azure Functions
|
|
97
108
|
return { kind: 'serverless', name: explicitName || env.WEBSITE_SITE_NAME, environment, instanceId: env.WEBSITE_INSTANCE_ID, image };
|
|
98
109
|
}
|
|
110
|
+
if (env.ECS_CONTAINER_METADATA_URI_V4 || env.ECS_CONTAINER_METADATA_URI) {
|
|
111
|
+
// ECS / Fargate task: the service name comes from the task definition env.
|
|
112
|
+
return { kind: 'container', name: explicitName || env.SERVICE_NAME || env.APP_NAME, environment, instanceId: env.HOSTNAME, image, enrolledVia: 'aws' };
|
|
113
|
+
}
|
|
99
114
|
if (env.KUBERNETES_SERVICE_HOST) {
|
|
100
115
|
// Pod names are "<deployment>-<replicaset-hash>-<pod-hash>"; the stable
|
|
101
116
|
// workload name comes from the Downward API when the chart exposes it.
|
|
102
117
|
const podName = env.HOSTNAME || env.POD_NAME || undefined;
|
|
103
118
|
const name = explicitName || env.WORKLOAD_NAME || env.APP_NAME || env.DEPLOYMENT_NAME || (podName ? podName.replace(/(-[a-z0-9]{8,10})?-[a-z0-9]{5}$/, '') : undefined);
|
|
104
|
-
return { kind: 'kubernetes', name, environment: environment || env.POD_NAMESPACE || env.NAMESPACE, instanceId: podName, image };
|
|
119
|
+
return { kind: 'kubernetes', name, environment: environment || env.POD_NAMESPACE || env.NAMESPACE, instanceId: podName, image, enrolledVia: 'kubernetes' };
|
|
120
|
+
}
|
|
121
|
+
if (env.DYNO) {
|
|
122
|
+
// Heroku dyno (buildpack or container stack). HEROKU_APP_NAME exists only
|
|
123
|
+
// with the runtime-dyno-metadata feature; the console snippet sets
|
|
124
|
+
// FCD_WORKLOAD_NAME so the row is named after the app either way.
|
|
125
|
+
return { kind: 'container', name: explicitName || env.HEROKU_APP_NAME, environment, instanceId: env.DYNO, image, enrolledVia: 'heroku' };
|
|
105
126
|
}
|
|
106
127
|
if (fsProbe.existsSync('/.dockerenv') || env.container || env.DOCKER_CONTAINER) {
|
|
107
128
|
return { kind: 'container', name: explicitName || env.SERVICE_NAME || env.APP_NAME, environment, instanceId: env.HOSTNAME, image };
|
|
@@ -137,8 +158,9 @@ async function workloadProtectCommand(args, config) {
|
|
|
137
158
|
// substrate, not to the `--kind` the caller claimed.
|
|
138
159
|
const hostRuntime = (0, hostRuntime_1.getHostRuntime)();
|
|
139
160
|
assertWorkloadSubstrate(kind, hostRuntime, { force: args.force === 'true' });
|
|
161
|
+
const enrolledVia = resolveEnrolledVia(args.enrolledVia, process.env, detected.enrolledVia);
|
|
140
162
|
console.log('\x1b[1m\x1b[36mFullCourtDefense — workload runtime protection\x1b[0m');
|
|
141
|
-
console.log(` Workload: ${kind}/${name}${environment ? `/${environment}` : ''}`);
|
|
163
|
+
console.log(` Workload: ${kind}/${name}${environment ? `/${environment}` : ''}${enrolledVia ? ` · via ${enrolledVia}` : ''}`);
|
|
142
164
|
if (instanceId)
|
|
143
165
|
console.log(` Instance: ${instanceId}`);
|
|
144
166
|
console.log(` Detected: ${(0, hostRuntime_1.describeHostRuntime)(hostRuntime)}`);
|
|
@@ -156,6 +178,7 @@ async function workloadProtectCommand(args, config) {
|
|
|
156
178
|
// `npm run`, never when the binary runs from a container entrypoint.
|
|
157
179
|
cliVersion: (0, cliVersion_1.cliVersion)(),
|
|
158
180
|
hostRuntime,
|
|
181
|
+
enrolledVia,
|
|
159
182
|
}),
|
|
160
183
|
});
|
|
161
184
|
const data = (await resp.json().catch(() => ({})));
|