@vellumai/credential-executor 0.4.55
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/Dockerfile +55 -0
- package/bun.lock +37 -0
- package/package.json +32 -0
- package/src/__tests__/command-executor.test.ts +1333 -0
- package/src/__tests__/command-validator.test.ts +708 -0
- package/src/__tests__/command-workspace.test.ts +997 -0
- package/src/__tests__/grant-store.test.ts +467 -0
- package/src/__tests__/http-executor.test.ts +1251 -0
- package/src/__tests__/http-policy.test.ts +970 -0
- package/src/__tests__/local-materializers.test.ts +826 -0
- package/src/__tests__/managed-materializers.test.ts +961 -0
- package/src/__tests__/toolstore.test.ts +539 -0
- package/src/__tests__/transport.test.ts +388 -0
- package/src/audit/store.ts +188 -0
- package/src/commands/auth-adapters.ts +169 -0
- package/src/commands/executor.ts +840 -0
- package/src/commands/output-scan.ts +157 -0
- package/src/commands/profiles.ts +282 -0
- package/src/commands/validator.ts +438 -0
- package/src/commands/workspace.ts +512 -0
- package/src/grants/index.ts +17 -0
- package/src/grants/persistent-store.ts +247 -0
- package/src/grants/rpc-handlers.ts +269 -0
- package/src/grants/temporary-store.ts +219 -0
- package/src/http/audit.ts +84 -0
- package/src/http/executor.ts +540 -0
- package/src/http/path-template.ts +179 -0
- package/src/http/policy.ts +256 -0
- package/src/http/response-filter.ts +233 -0
- package/src/index.ts +106 -0
- package/src/main.ts +263 -0
- package/src/managed-main.ts +420 -0
- package/src/materializers/local.ts +300 -0
- package/src/materializers/managed-platform.ts +270 -0
- package/src/paths.ts +137 -0
- package/src/server.ts +636 -0
- package/src/subjects/local.ts +177 -0
- package/src/subjects/managed.ts +290 -0
- package/src/toolstore/integrity.ts +94 -0
- package/src/toolstore/manifest.ts +154 -0
- package/src/toolstore/publish.ts +342 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CES auth adapter definitions for secure command profiles.
|
|
3
|
+
*
|
|
4
|
+
* Auth adapters describe how credentials are materialised into a command's
|
|
5
|
+
* execution environment. Each adapter type has different security properties
|
|
6
|
+
* and cleanup requirements.
|
|
7
|
+
*
|
|
8
|
+
* v1 adapter set:
|
|
9
|
+
*
|
|
10
|
+
* - `env_var` — Inject credential as an environment variable.
|
|
11
|
+
* Lifetime: process scope. Cleaned up on exit.
|
|
12
|
+
* - `temp_file` — Write credential to a temporary file and pass
|
|
13
|
+
* the path via an env var. File is deleted after
|
|
14
|
+
* command exits.
|
|
15
|
+
* - `credential_process` — Spawn a helper process that prints the credential
|
|
16
|
+
* to stdout (AWS credential_process pattern). The
|
|
17
|
+
* helper runs inside CES and is never exposed to the
|
|
18
|
+
* subprocess directly.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// Auth adapter type discriminator
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
export const AuthAdapterType = {
|
|
26
|
+
/** Inject credential value as an environment variable. */
|
|
27
|
+
EnvVar: "env_var",
|
|
28
|
+
/** Write credential to a temp file and set a path env var. */
|
|
29
|
+
TempFile: "temp_file",
|
|
30
|
+
/**
|
|
31
|
+
* Spawn a credential helper process (AWS credential_process-style).
|
|
32
|
+
* The helper stdout is captured and injected as an env var.
|
|
33
|
+
*/
|
|
34
|
+
CredentialProcess: "credential_process",
|
|
35
|
+
} as const;
|
|
36
|
+
|
|
37
|
+
export type AuthAdapterType =
|
|
38
|
+
(typeof AuthAdapterType)[keyof typeof AuthAdapterType];
|
|
39
|
+
|
|
40
|
+
/** All valid auth adapter type strings. */
|
|
41
|
+
export const AUTH_ADAPTER_TYPES: readonly AuthAdapterType[] = Object.values(
|
|
42
|
+
AuthAdapterType,
|
|
43
|
+
) as AuthAdapterType[];
|
|
44
|
+
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
// Auth adapter config shapes
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Inject a credential directly as an environment variable.
|
|
51
|
+
*
|
|
52
|
+
* Example: `GH_TOKEN=<secret>` with `envVarName: "GH_TOKEN"`.
|
|
53
|
+
*/
|
|
54
|
+
export interface EnvVarAdapterConfig {
|
|
55
|
+
type: typeof AuthAdapterType.EnvVar;
|
|
56
|
+
/** Environment variable name where the credential value is injected. */
|
|
57
|
+
envVarName: string;
|
|
58
|
+
/**
|
|
59
|
+
* Optional prefix prepended to the raw credential value before injection
|
|
60
|
+
* (e.g. "Bearer " for OAuth tokens).
|
|
61
|
+
*/
|
|
62
|
+
valuePrefix?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Write the credential to a temporary file and set an env var to the path.
|
|
67
|
+
*
|
|
68
|
+
* Example: `GOOGLE_APPLICATION_CREDENTIALS=/tmp/ces-xxx/svc.json`.
|
|
69
|
+
* The temp file is created in a CES-managed ephemeral directory and deleted
|
|
70
|
+
* after the command exits.
|
|
71
|
+
*/
|
|
72
|
+
export interface TempFileAdapterConfig {
|
|
73
|
+
type: typeof AuthAdapterType.TempFile;
|
|
74
|
+
/** Environment variable name pointing to the temp file path. */
|
|
75
|
+
envVarName: string;
|
|
76
|
+
/** File extension for the temp file (e.g. ".json", ".pem"). */
|
|
77
|
+
fileExtension?: string;
|
|
78
|
+
/**
|
|
79
|
+
* File mode (octal) for the temp file. Defaults to 0o600 (owner-only
|
|
80
|
+
* read/write). Must be <= 0o600.
|
|
81
|
+
*/
|
|
82
|
+
fileMode?: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Spawn a credential helper process, capture its stdout, and inject the
|
|
87
|
+
* result as an env var.
|
|
88
|
+
*
|
|
89
|
+
* Example: AWS `credential_process` that emits JSON with temporary keys.
|
|
90
|
+
* The helper command runs inside the CES process and is never exposed to
|
|
91
|
+
* the child command.
|
|
92
|
+
*/
|
|
93
|
+
export interface CredentialProcessAdapterConfig {
|
|
94
|
+
type: typeof AuthAdapterType.CredentialProcess;
|
|
95
|
+
/** The helper command to run (e.g. "aws-vault exec <profile> --json"). */
|
|
96
|
+
helperCommand: string;
|
|
97
|
+
/** Environment variable name where the helper's stdout is injected. */
|
|
98
|
+
envVarName: string;
|
|
99
|
+
/** Timeout in milliseconds for the helper process. Defaults to 10000. */
|
|
100
|
+
timeoutMs?: number;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Discriminated union of all auth adapter configurations.
|
|
105
|
+
*/
|
|
106
|
+
export type AuthAdapterConfig =
|
|
107
|
+
| EnvVarAdapterConfig
|
|
108
|
+
| TempFileAdapterConfig
|
|
109
|
+
| CredentialProcessAdapterConfig;
|
|
110
|
+
|
|
111
|
+
// ---------------------------------------------------------------------------
|
|
112
|
+
// Validation helpers
|
|
113
|
+
// ---------------------------------------------------------------------------
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Returns true if the given string is a valid auth adapter type.
|
|
117
|
+
*/
|
|
118
|
+
export function isValidAuthAdapterType(value: string): value is AuthAdapterType {
|
|
119
|
+
return (AUTH_ADAPTER_TYPES as readonly string[]).includes(value);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Validate an auth adapter config shape. Returns a list of error messages
|
|
124
|
+
* (empty array = valid).
|
|
125
|
+
*/
|
|
126
|
+
export function validateAuthAdapterConfig(
|
|
127
|
+
config: AuthAdapterConfig,
|
|
128
|
+
): string[] {
|
|
129
|
+
const errors: string[] = [];
|
|
130
|
+
|
|
131
|
+
if (!isValidAuthAdapterType(config.type)) {
|
|
132
|
+
errors.push(
|
|
133
|
+
`Unknown auth adapter type "${config.type}". Valid types: ${AUTH_ADAPTER_TYPES.join(", ")}`,
|
|
134
|
+
);
|
|
135
|
+
return errors;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (!config.envVarName || config.envVarName.trim().length === 0) {
|
|
139
|
+
errors.push(`Auth adapter "${config.type}" requires a non-empty envVarName`);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
switch (config.type) {
|
|
143
|
+
case AuthAdapterType.TempFile:
|
|
144
|
+
if (
|
|
145
|
+
config.fileMode !== undefined &&
|
|
146
|
+
config.fileMode > 0o600
|
|
147
|
+
) {
|
|
148
|
+
errors.push(
|
|
149
|
+
`temp_file adapter fileMode must be <= 0600 (owner-only), got ${config.fileMode.toString(8)}`,
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
|
|
154
|
+
case AuthAdapterType.CredentialProcess:
|
|
155
|
+
if (!config.helperCommand || config.helperCommand.trim().length === 0) {
|
|
156
|
+
errors.push(
|
|
157
|
+
`credential_process adapter requires a non-empty helperCommand`,
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
if (config.timeoutMs !== undefined && config.timeoutMs <= 0) {
|
|
161
|
+
errors.push(
|
|
162
|
+
`credential_process adapter timeoutMs must be positive, got ${config.timeoutMs}`,
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return errors;
|
|
169
|
+
}
|