envilder 0.13.2 → 0.15.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.
- package/README.md +27 -5
- package/ROADMAP.md +1 -1
- package/docs/changelogs/cli.md +110 -0
- package/docs/changelogs/gha.md +47 -1
- package/docs/changelogs/sdk-dotnet.md +10 -0
- package/docs/changelogs/sdk-nodejs.md +10 -0
- package/docs/changelogs/sdk-python.md +10 -0
- package/docs/exec-command.md +313 -0
- package/lib/envilder/apps/cli/Startup.d.ts +9 -0
- package/lib/envilder/apps/cli/Startup.d.ts.map +1 -1
- package/lib/envilder/apps/cli/Startup.js +39 -0
- package/lib/envilder/apps/cli/Startup.js.map +1 -1
- package/lib/envilder/apps/cli/entry/Cli.d.ts.map +1 -1
- package/lib/envilder/apps/cli/entry/Cli.js +423 -27
- package/lib/envilder/apps/cli/entry/Cli.js.map +1 -1
- package/lib/envilder/apps/cli/errors/CliErrorPresenter.d.ts.map +1 -1
- package/lib/envilder/apps/cli/errors/CliErrorPresenter.js +4 -1
- package/lib/envilder/apps/cli/errors/CliErrorPresenter.js.map +1 -1
- package/lib/envilder/apps/cli/errors/ParseErrorRedactor.d.ts +33 -0
- package/lib/envilder/apps/cli/errors/ParseErrorRedactor.d.ts.map +1 -0
- package/lib/envilder/apps/cli/errors/ParseErrorRedactor.js +121 -0
- package/lib/envilder/apps/cli/errors/ParseErrorRedactor.js.map +1 -0
- package/lib/envilder/apps/cli/recovery/SsoLoginRecovery.d.ts +13 -0
- package/lib/envilder/apps/cli/recovery/SsoLoginRecovery.d.ts.map +1 -1
- package/lib/envilder/apps/cli/recovery/SsoLoginRecovery.js +29 -13
- package/lib/envilder/apps/cli/recovery/SsoLoginRecovery.js.map +1 -1
- package/lib/envilder/apps/shared/ContainerConfiguration.d.ts +2 -1
- package/lib/envilder/apps/shared/ContainerConfiguration.d.ts.map +1 -1
- package/lib/envilder/apps/shared/ContainerConfiguration.js +4 -2
- package/lib/envilder/apps/shared/ContainerConfiguration.js.map +1 -1
- package/lib/envilder/core/application/dispatch/DispatchActionCommand.d.ts +19 -2
- package/lib/envilder/core/application/dispatch/DispatchActionCommand.d.ts.map +1 -1
- package/lib/envilder/core/application/dispatch/DispatchActionCommand.js +17 -1
- package/lib/envilder/core/application/dispatch/DispatchActionCommand.js.map +1 -1
- package/lib/envilder/core/application/dispatch/DispatchActionCommandHandler.d.ts +9 -2
- package/lib/envilder/core/application/dispatch/DispatchActionCommandHandler.d.ts.map +1 -1
- package/lib/envilder/core/application/dispatch/DispatchActionCommandHandler.js +28 -3
- package/lib/envilder/core/application/dispatch/DispatchActionCommandHandler.js.map +1 -1
- package/lib/envilder/core/application/execWithSecrets/CommandLineFormatter.d.ts +13 -0
- package/lib/envilder/core/application/execWithSecrets/CommandLineFormatter.d.ts.map +1 -0
- package/lib/envilder/core/application/execWithSecrets/CommandLineFormatter.js +19 -0
- package/lib/envilder/core/application/execWithSecrets/CommandLineFormatter.js.map +1 -0
- package/lib/envilder/core/application/execWithSecrets/ExecWithSecretsCommand.d.ts +20 -0
- package/lib/envilder/core/application/execWithSecrets/ExecWithSecretsCommand.d.ts.map +1 -0
- package/lib/envilder/core/application/execWithSecrets/ExecWithSecretsCommand.js +19 -0
- package/lib/envilder/core/application/execWithSecrets/ExecWithSecretsCommand.js.map +1 -0
- package/lib/envilder/core/application/execWithSecrets/ExecWithSecretsCommandHandler.d.ts +61 -0
- package/lib/envilder/core/application/execWithSecrets/ExecWithSecretsCommandHandler.d.ts.map +1 -0
- package/lib/envilder/core/application/execWithSecrets/ExecWithSecretsCommandHandler.js +159 -0
- package/lib/envilder/core/application/execWithSecrets/ExecWithSecretsCommandHandler.js.map +1 -0
- package/lib/envilder/core/application/pullSecretsToEnv/PullSecretsToEnvCommandHandler.d.ts +1 -9
- package/lib/envilder/core/application/pullSecretsToEnv/PullSecretsToEnvCommandHandler.d.ts.map +1 -1
- package/lib/envilder/core/application/pullSecretsToEnv/PullSecretsToEnvCommandHandler.js +9 -79
- package/lib/envilder/core/application/pullSecretsToEnv/PullSecretsToEnvCommandHandler.js.map +1 -1
- package/lib/envilder/core/application/secretResolution/SecretResolver.d.ts +66 -0
- package/lib/envilder/core/application/secretResolution/SecretResolver.d.ts.map +1 -0
- package/lib/envilder/core/application/secretResolution/SecretResolver.js +132 -0
- package/lib/envilder/core/application/secretResolution/SecretResolver.js.map +1 -0
- package/lib/envilder/core/domain/ChildEnvironment.d.ts +22 -0
- package/lib/envilder/core/domain/ChildEnvironment.d.ts.map +1 -0
- package/lib/envilder/core/domain/ChildEnvironment.js +50 -0
- package/lib/envilder/core/domain/ChildEnvironment.js.map +1 -0
- package/lib/envilder/core/domain/EnvironmentVariable.d.ts.map +1 -1
- package/lib/envilder/core/domain/EnvironmentVariable.js +4 -2
- package/lib/envilder/core/domain/EnvironmentVariable.js.map +1 -1
- package/lib/envilder/core/domain/EnvironmentVariableName.d.ts +9 -0
- package/lib/envilder/core/domain/EnvironmentVariableName.d.ts.map +1 -0
- package/lib/envilder/core/domain/EnvironmentVariableName.js +70 -0
- package/lib/envilder/core/domain/EnvironmentVariableName.js.map +1 -0
- package/lib/envilder/core/domain/ExecExitCode.d.ts +14 -0
- package/lib/envilder/core/domain/ExecExitCode.d.ts.map +1 -0
- package/lib/envilder/core/domain/ExecExitCode.js +23 -0
- package/lib/envilder/core/domain/ExecExitCode.js.map +1 -0
- package/lib/envilder/core/domain/OperationMode.d.ts +2 -1
- package/lib/envilder/core/domain/OperationMode.d.ts.map +1 -1
- package/lib/envilder/core/domain/OperationMode.js +1 -0
- package/lib/envilder/core/domain/OperationMode.js.map +1 -1
- package/lib/envilder/core/domain/errors/DomainErrors.d.ts +44 -0
- package/lib/envilder/core/domain/errors/DomainErrors.d.ts.map +1 -1
- package/lib/envilder/core/domain/errors/DomainErrors.js +57 -0
- package/lib/envilder/core/domain/errors/DomainErrors.js.map +1 -1
- package/lib/envilder/core/domain/ports/IProcessContext.d.ts +14 -0
- package/lib/envilder/core/domain/ports/IProcessContext.d.ts.map +1 -0
- package/lib/envilder/core/domain/ports/IProcessContext.js +2 -0
- package/lib/envilder/core/domain/ports/IProcessContext.js.map +1 -0
- package/lib/envilder/core/domain/ports/IProcessRunner.d.ts +27 -0
- package/lib/envilder/core/domain/ports/IProcessRunner.d.ts.map +1 -0
- package/lib/envilder/core/domain/ports/IProcessRunner.js +2 -0
- package/lib/envilder/core/domain/ports/IProcessRunner.js.map +1 -0
- package/lib/envilder/core/domain/ports/ISecretMasker.d.ts +7 -0
- package/lib/envilder/core/domain/ports/ISecretMasker.d.ts.map +1 -1
- package/lib/envilder/core/infrastructure/aws/AwsSecretProviderFactory.d.ts +5 -1
- package/lib/envilder/core/infrastructure/aws/AwsSecretProviderFactory.d.ts.map +1 -1
- package/lib/envilder/core/infrastructure/aws/AwsSecretProviderFactory.js +3 -2
- package/lib/envilder/core/infrastructure/aws/AwsSecretProviderFactory.js.map +1 -1
- package/lib/envilder/core/infrastructure/aws/AwsSsmSecretProvider.d.ts +6 -1
- package/lib/envilder/core/infrastructure/aws/AwsSsmSecretProvider.d.ts.map +1 -1
- package/lib/envilder/core/infrastructure/aws/AwsSsmSecretProvider.js +10 -3
- package/lib/envilder/core/infrastructure/aws/AwsSsmSecretProvider.js.map +1 -1
- package/lib/envilder/core/infrastructure/github/GitHubActionsSecretMasker.d.ts +22 -0
- package/lib/envilder/core/infrastructure/github/GitHubActionsSecretMasker.d.ts.map +1 -1
- package/lib/envilder/core/infrastructure/github/GitHubActionsSecretMasker.js +38 -1
- package/lib/envilder/core/infrastructure/github/GitHubActionsSecretMasker.js.map +1 -1
- package/lib/envilder/core/infrastructure/github/NoOpSecretMasker.d.ts +1 -0
- package/lib/envilder/core/infrastructure/github/NoOpSecretMasker.d.ts.map +1 -1
- package/lib/envilder/core/infrastructure/github/NoOpSecretMasker.js +3 -0
- package/lib/envilder/core/infrastructure/github/NoOpSecretMasker.js.map +1 -1
- package/lib/envilder/core/infrastructure/logger/StderrConsoleLogger.d.ts +11 -0
- package/lib/envilder/core/infrastructure/logger/StderrConsoleLogger.d.ts.map +1 -0
- package/lib/envilder/core/infrastructure/logger/StderrConsoleLogger.js +27 -0
- package/lib/envilder/core/infrastructure/logger/StderrConsoleLogger.js.map +1 -0
- package/lib/envilder/core/infrastructure/process/CrossSpawnProcessRunner.d.ts +15 -0
- package/lib/envilder/core/infrastructure/process/CrossSpawnProcessRunner.d.ts.map +1 -0
- package/lib/envilder/core/infrastructure/process/CrossSpawnProcessRunner.js +145 -0
- package/lib/envilder/core/infrastructure/process/CrossSpawnProcessRunner.js.map +1 -0
- package/lib/envilder/core/infrastructure/process/NodeProcessContext.d.ts +11 -0
- package/lib/envilder/core/infrastructure/process/NodeProcessContext.d.ts.map +1 -0
- package/lib/envilder/core/infrastructure/process/NodeProcessContext.js +18 -0
- package/lib/envilder/core/infrastructure/process/NodeProcessContext.js.map +1 -0
- package/lib/envilder/core/infrastructure/variableStore/FileVariableStore.d.ts +69 -2
- package/lib/envilder/core/infrastructure/variableStore/FileVariableStore.d.ts.map +1 -1
- package/lib/envilder/core/infrastructure/variableStore/FileVariableStore.js +294 -55
- package/lib/envilder/core/infrastructure/variableStore/FileVariableStore.js.map +1 -1
- package/lib/envilder/core/types.d.ts +6 -0
- package/lib/envilder/core/types.d.ts.map +1 -1
- package/lib/envilder/core/types.js +3 -0
- package/lib/envilder/core/types.js.map +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { OperationMode } from '../../domain/OperationMode.js';
|
|
2
|
+
export class ExecWithSecretsCommand {
|
|
3
|
+
constructor(mapPath, command, args,
|
|
4
|
+
/**
|
|
5
|
+
* Short description of where secrets come from, shown in the summary
|
|
6
|
+
* line, for example `aws, profile=dev`. Never contains secret values.
|
|
7
|
+
*/
|
|
8
|
+
sourceLabel) {
|
|
9
|
+
this.mapPath = mapPath;
|
|
10
|
+
this.command = command;
|
|
11
|
+
this.args = args;
|
|
12
|
+
this.sourceLabel = sourceLabel;
|
|
13
|
+
this.mode = OperationMode.EXEC;
|
|
14
|
+
}
|
|
15
|
+
static create(mapPath, command, args, sourceLabel) {
|
|
16
|
+
return new ExecWithSecretsCommand(mapPath, command, [...args], sourceLabel);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ExecWithSecretsCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExecWithSecretsCommand.js","sourceRoot":"","sources":["../../../../../src/envilder/core/application/execWithSecrets/ExecWithSecretsCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE9D,MAAM,OAAO,sBAAsB;IAGjC,YACkB,OAAe,EACf,OAAe,EACf,IAAuB;IACvC;;;OAGG;IACa,WAAoB;QAPpB,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAQ;QACf,SAAI,GAAJ,IAAI,CAAmB;QAKvB,gBAAW,GAAX,WAAW,CAAS;QAV7B,SAAI,GAAG,aAAa,CAAC,IAAI,CAAC;IAWhC,CAAC;IAEJ,MAAM,CAAC,MAAM,CACX,OAAe,EACf,OAAe,EACf,IAAuB,EACvB,WAAoB;QAEpB,OAAO,IAAI,sBAAsB,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,WAAW,CAAC,CAAC;IAC9E,CAAC;CACF"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ILogger } from '../../domain/ports/ILogger.js';
|
|
2
|
+
import type { IProcessContext } from '../../domain/ports/IProcessContext.js';
|
|
3
|
+
import type { IProcessRunner } from '../../domain/ports/IProcessRunner.js';
|
|
4
|
+
import type { ISecretMasker } from '../../domain/ports/ISecretMasker.js';
|
|
5
|
+
import type { ISecretProvider } from '../../domain/ports/ISecretProvider.js';
|
|
6
|
+
import type { IVariableStore } from '../../domain/ports/IVariableStore.js';
|
|
7
|
+
import type { ExecWithSecretsCommand } from './ExecWithSecretsCommand.js';
|
|
8
|
+
/**
|
|
9
|
+
* Secrets resolved for an exec command, ready to start the child.
|
|
10
|
+
*/
|
|
11
|
+
export type PreparedExec = {
|
|
12
|
+
readonly command: ExecWithSecretsCommand;
|
|
13
|
+
readonly secrets: Readonly<Record<string, string>>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Runs a command with the secrets of a map file in its environment, without
|
|
17
|
+
* writing anything to disk.
|
|
18
|
+
*
|
|
19
|
+
* Exec mode is fail-closed: the child is never started when a secret is
|
|
20
|
+
* missing, empty or unreadable. `handle` is the entry point (reached through
|
|
21
|
+
* the dispatcher): `prepare` resolves every secret and `start` runs the child
|
|
22
|
+
* once. Only `prepare` raises retriable errors, such as an expired SSO
|
|
23
|
+
* session; `start` turns any SSO or credentials error into a non-retriable
|
|
24
|
+
* `ExecInterruptedError`, so retrying `handle` never starts the child twice.
|
|
25
|
+
*/
|
|
26
|
+
export declare class ExecWithSecretsCommandHandler {
|
|
27
|
+
private readonly variableStore;
|
|
28
|
+
private readonly logger;
|
|
29
|
+
private readonly secretMasker;
|
|
30
|
+
private readonly processRunner;
|
|
31
|
+
private readonly processContext;
|
|
32
|
+
private readonly secretResolver;
|
|
33
|
+
constructor(secretProvider: ISecretProvider, variableStore: IVariableStore, logger: ILogger, secretMasker: ISecretMasker, processRunner: IProcessRunner, processContext: IProcessContext);
|
|
34
|
+
/**
|
|
35
|
+
* Resolves the secrets and runs the child. Returns the exit code Envilder
|
|
36
|
+
* must exit with: the child's code, or `128 + n` when a signal killed it.
|
|
37
|
+
*/
|
|
38
|
+
handle(command: ExecWithSecretsCommand): Promise<number>;
|
|
39
|
+
/**
|
|
40
|
+
* Resolves every secret declared in the map file. Never reads or writes a
|
|
41
|
+
* `.env` file. Throws `SecretsFetchError` when any secret does not resolve.
|
|
42
|
+
*/
|
|
43
|
+
prepare(command: ExecWithSecretsCommand): Promise<PreparedExec>;
|
|
44
|
+
/**
|
|
45
|
+
* Starts the child once with the inherited environment plus the resolved
|
|
46
|
+
* secrets (the map file wins) and waits for it to exit.
|
|
47
|
+
*
|
|
48
|
+
* SSO and credentials errors are only retriable before this point. Raised
|
|
49
|
+
* from here on, they become a non-retriable `ExecInterruptedError` so a
|
|
50
|
+
* caller's recovery never runs the command again.
|
|
51
|
+
*/
|
|
52
|
+
start(prepared: PreparedExec): Promise<number>;
|
|
53
|
+
private supervise;
|
|
54
|
+
/**
|
|
55
|
+
* On Windows two mapped names that differ only by case are one variable,
|
|
56
|
+
* so one value would be silently dropped. Refuse before resolving.
|
|
57
|
+
*/
|
|
58
|
+
private assertNoCaseCollisions;
|
|
59
|
+
private static buildSummary;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=ExecWithSecretsCommandHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExecWithSecretsCommandHandler.d.ts","sourceRoot":"","sources":["../../../../../src/envilder/core/application/execWithSecrets/ExecWithSecretsCommandHandler.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAQ3E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACpD,CAAC;AAIF;;;;;;;;;;GAUG;AACH,qBACa,6BAA6B;IAOtC,OAAO,CAAC,QAAQ,CAAC,aAAa;IACP,OAAO,CAAC,QAAQ,CAAC,MAAM;IAE9C,OAAO,CAAC,QAAQ,CAAC,YAAY;IAE7B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAE9B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAbjC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAEhD,YAEE,cAAc,EAAE,eAAe,EAEd,aAAa,EAAE,cAAc,EACN,MAAM,EAAE,OAAO,EAEtC,YAAY,EAAE,aAAa,EAE3B,aAAa,EAAE,cAAc,EAE7B,cAAc,EAAE,eAAe,EAOjD;IAED;;;OAGG;IACG,MAAM,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,CAG7D;IAED;;;OAGG;IACG,OAAO,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,YAAY,CAAC,CA4BpE;IAED;;;;;;;OAOG;IACG,KAAK,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAYnD;YAEa,SAAS;IAkCvB;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAc9B,OAAO,CAAC,MAAM,CAAC,YAAY;CAS5B"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var ExecWithSecretsCommandHandler_1;
|
|
23
|
+
import { inject, injectable } from 'inversify';
|
|
24
|
+
import { buildChildEnvironment, findCaseCollisions, } from '../../domain/ChildEnvironment.js';
|
|
25
|
+
import { exitCodeForChild } from '../../domain/ExecExitCode.js';
|
|
26
|
+
import { ExecInterruptedError, ExpiredCredentialsError, InvalidArgumentError, SecretsFetchError, SsoSessionExpiredError, } from '../../domain/errors/DomainErrors.js';
|
|
27
|
+
import { TYPES } from '../../types.js';
|
|
28
|
+
import { SecretResolver, } from '../secretResolution/SecretResolver.js';
|
|
29
|
+
import { formatProgram } from './CommandLineFormatter.js';
|
|
30
|
+
const NUL = '\0';
|
|
31
|
+
/**
|
|
32
|
+
* Runs a command with the secrets of a map file in its environment, without
|
|
33
|
+
* writing anything to disk.
|
|
34
|
+
*
|
|
35
|
+
* Exec mode is fail-closed: the child is never started when a secret is
|
|
36
|
+
* missing, empty or unreadable. `handle` is the entry point (reached through
|
|
37
|
+
* the dispatcher): `prepare` resolves every secret and `start` runs the child
|
|
38
|
+
* once. Only `prepare` raises retriable errors, such as an expired SSO
|
|
39
|
+
* session; `start` turns any SSO or credentials error into a non-retriable
|
|
40
|
+
* `ExecInterruptedError`, so retrying `handle` never starts the child twice.
|
|
41
|
+
*/
|
|
42
|
+
let ExecWithSecretsCommandHandler = ExecWithSecretsCommandHandler_1 = class ExecWithSecretsCommandHandler {
|
|
43
|
+
constructor(secretProvider, variableStore, logger, secretMasker, processRunner, processContext) {
|
|
44
|
+
this.variableStore = variableStore;
|
|
45
|
+
this.logger = logger;
|
|
46
|
+
this.secretMasker = secretMasker;
|
|
47
|
+
this.processRunner = processRunner;
|
|
48
|
+
this.processContext = processContext;
|
|
49
|
+
this.secretResolver = new SecretResolver(secretProvider, logger, secretMasker);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Resolves the secrets and runs the child. Returns the exit code Envilder
|
|
53
|
+
* must exit with: the child's code, or `128 + n` when a signal killed it.
|
|
54
|
+
*/
|
|
55
|
+
handle(command) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const prepared = yield this.prepare(command);
|
|
58
|
+
return this.start(prepared);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Resolves every secret declared in the map file. Never reads or writes a
|
|
63
|
+
* `.env` file. Throws `SecretsFetchError` when any secret does not resolve.
|
|
64
|
+
*/
|
|
65
|
+
prepare(command) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const mappings = yield this.variableStore.getMapping(command.mapPath);
|
|
68
|
+
if (Object.keys(mappings).length === 0) {
|
|
69
|
+
this.logger.warn('Map file declares no variables.');
|
|
70
|
+
}
|
|
71
|
+
this.assertNoCaseCollisions(Object.keys(mappings));
|
|
72
|
+
const { outcomes, resolved } = yield this.secretResolver.resolve(mappings);
|
|
73
|
+
const failures = outcomes.filter((outcome) => outcome.status !== 'resolved');
|
|
74
|
+
if (failures.length > 0) {
|
|
75
|
+
this.secretResolver.logSecretsSection(resolved, []);
|
|
76
|
+
throw new SecretsFetchError(failures.map(SecretResolver.toFailure));
|
|
77
|
+
}
|
|
78
|
+
const secrets = {};
|
|
79
|
+
for (const { envVar, value } of resolved) {
|
|
80
|
+
if (value.includes(NUL)) {
|
|
81
|
+
throw new InvalidArgumentError(`Secret for ${envVar} contains a NUL byte and cannot be passed as an environment variable.`);
|
|
82
|
+
}
|
|
83
|
+
secrets[envVar] = value;
|
|
84
|
+
}
|
|
85
|
+
return { command, secrets };
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Starts the child once with the inherited environment plus the resolved
|
|
90
|
+
* secrets (the map file wins) and waits for it to exit.
|
|
91
|
+
*
|
|
92
|
+
* SSO and credentials errors are only retriable before this point. Raised
|
|
93
|
+
* from here on, they become a non-retriable `ExecInterruptedError` so a
|
|
94
|
+
* caller's recovery never runs the command again.
|
|
95
|
+
*/
|
|
96
|
+
start(prepared) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
try {
|
|
99
|
+
return yield this.supervise(prepared);
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
if (error instanceof SsoSessionExpiredError ||
|
|
103
|
+
error instanceof ExpiredCredentialsError) {
|
|
104
|
+
throw new ExecInterruptedError(error);
|
|
105
|
+
}
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
supervise(prepared) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
const { command, secrets } = prepared;
|
|
113
|
+
// The child shares stdout with the mask registrations: start it only
|
|
114
|
+
// once every registration has been written.
|
|
115
|
+
yield this.secretMasker.flush();
|
|
116
|
+
const { env, overridden } = buildChildEnvironment(this.processContext.environment(), secrets, this.processContext.platform());
|
|
117
|
+
if (overridden.length > 0) {
|
|
118
|
+
this.logger.warn(`Overriding inherited variables: ${overridden.join(', ')}`);
|
|
119
|
+
}
|
|
120
|
+
this.logger.info(ExecWithSecretsCommandHandler_1.buildSummary(Object.keys(secrets).length, command));
|
|
121
|
+
const exit = yield this.processRunner.run({
|
|
122
|
+
command: command.command,
|
|
123
|
+
args: [...command.args],
|
|
124
|
+
env,
|
|
125
|
+
});
|
|
126
|
+
return exitCodeForChild(exit, (signal) => this.processContext.signalNumber(signal));
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* On Windows two mapped names that differ only by case are one variable,
|
|
131
|
+
* so one value would be silently dropped. Refuse before resolving.
|
|
132
|
+
*/
|
|
133
|
+
assertNoCaseCollisions(names) {
|
|
134
|
+
const collisions = findCaseCollisions(names, this.processContext.platform());
|
|
135
|
+
if (collisions.length === 0) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const listed = collisions.map((group) => group.join(', ')).join('; ');
|
|
139
|
+
throw new InvalidArgumentError(`Map file declares variables that differ only by case (${listed}); Windows treats them as the same variable.`);
|
|
140
|
+
}
|
|
141
|
+
static buildSummary(count, command) {
|
|
142
|
+
const noun = count === 1 ? 'secret' : 'secrets';
|
|
143
|
+
const source = command.sourceLabel ? ` (${command.sourceLabel})` : '';
|
|
144
|
+
const commandLine = formatProgram(command.command, command.args);
|
|
145
|
+
return `envilder: ${count} ${noun} resolved${source} \u2192 ${commandLine}`;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
ExecWithSecretsCommandHandler = ExecWithSecretsCommandHandler_1 = __decorate([
|
|
149
|
+
injectable(),
|
|
150
|
+
__param(0, inject(TYPES.ISecretProvider)),
|
|
151
|
+
__param(1, inject(TYPES.IVariableStore)),
|
|
152
|
+
__param(2, inject(TYPES.ILogger)),
|
|
153
|
+
__param(3, inject(TYPES.ISecretMasker)),
|
|
154
|
+
__param(4, inject(TYPES.IProcessRunner)),
|
|
155
|
+
__param(5, inject(TYPES.IProcessContext)),
|
|
156
|
+
__metadata("design:paramtypes", [Object, Object, Object, Object, Object, Object])
|
|
157
|
+
], ExecWithSecretsCommandHandler);
|
|
158
|
+
export { ExecWithSecretsCommandHandler };
|
|
159
|
+
//# sourceMappingURL=ExecWithSecretsCommandHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExecWithSecretsCommandHandler.js","sourceRoot":"","sources":["../../../../../src/envilder/core/application/execWithSecrets/ExecWithSecretsCommandHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EACL,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,qCAAqC,CAAC;AAO7C,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAEL,cAAc,GAEf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAW1D,MAAM,GAAG,GAAG,IAAI,CAAC;AAEjB;;;;;;;;;;GAUG;AAEI,IAAM,6BAA6B,qCAAnC,MAAM,6BAA6B;IAGxC,YAEE,cAA+B,EAEd,aAA6B,EACN,MAAe,EAEtC,YAA2B,EAE3B,aAA6B,EAE7B,cAA+B;6BAP/B,aAAa;sBACU,MAAM;4BAE7B,YAAY;6BAEZ,aAAa;8BAEb,cAAc;QAE/B,IAAI,CAAC,cAAc,GAAG,IAAI,cAAc,CACtC,cAAc,EACd,MAAM,EACN,YAAY,CACb,CAAC;IACJ,CAAC;IAED;;;OAGG;IACG,MAAM,CAAC,OAA+B;;YAC1C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,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,CAAC,CAAA;IAE5B,WAAA,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACrB,WAAA,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;IAE3B,WAAA,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;IAE5B,WAAA,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAA;;GAbrB,6BAA6B,CAqJzC"}
|
|
@@ -4,12 +4,9 @@ import type { ISecretProvider } from '../../domain/ports/ISecretProvider.js';
|
|
|
4
4
|
import type { IVariableStore } from '../../domain/ports/IVariableStore.js';
|
|
5
5
|
import type { PullSecretsToEnvCommand } from './PullSecretsToEnvCommand.js';
|
|
6
6
|
export declare class PullSecretsToEnvCommandHandler {
|
|
7
|
-
private readonly secretProvider;
|
|
8
7
|
private readonly variableStore;
|
|
9
8
|
private readonly logger;
|
|
10
|
-
private readonly
|
|
11
|
-
private static readonly LABEL_WIDTH;
|
|
12
|
-
private static readonly RULE;
|
|
9
|
+
private readonly secretResolver;
|
|
13
10
|
constructor(secretProvider: ISecretProvider, variableStore: IVariableStore, logger: ILogger, secretMasker: ISecretMasker);
|
|
14
11
|
/**
|
|
15
12
|
* Handles the PullSecretsToEnvCommand which orchestrates the process of fetching
|
|
@@ -21,11 +18,6 @@ export declare class PullSecretsToEnvCommandHandler {
|
|
|
21
18
|
private loadVariables;
|
|
22
19
|
private saveEnvFile;
|
|
23
20
|
private envild;
|
|
24
|
-
private processSecret;
|
|
25
|
-
private static describeErrorReason;
|
|
26
|
-
private logSecretsSection;
|
|
27
|
-
private logWarnings;
|
|
28
|
-
private static pad;
|
|
29
21
|
private static buildSummary;
|
|
30
22
|
}
|
|
31
23
|
//# sourceMappingURL=PullSecretsToEnvCommandHandler.d.ts.map
|
package/lib/envilder/core/application/pullSecretsToEnv/PullSecretsToEnvCommandHandler.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PullSecretsToEnvCommandHandler.d.ts","sourceRoot":"","sources":["../../../../../src/envilder/core/application/pullSecretsToEnv/PullSecretsToEnvCommandHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PullSecretsToEnvCommandHandler.d.ts","sourceRoot":"","sources":["../../../../../src/envilder/core/application/pullSecretsToEnv/PullSecretsToEnvCommandHandler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAG3E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAE5E,qBACa,8BAA8B;IAOvC,OAAO,CAAC,QAAQ,CAAC,aAAa;IACP,OAAO,CAAC,QAAQ,CAAC,MAAM;IAPhD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAEhD,YAEE,cAAc,EAAE,eAAe,EAEd,aAAa,EAAE,cAAc,EACN,MAAM,EAAE,OAAO,EAEvD,YAAY,EAAE,aAAa,EAO5B;IAED;;;;;OAKG;IACG,MAAM,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB5D;YAEa,aAAa;YAcb,WAAW;YAOX,MAAM;IA4BpB,OAAO,CAAC,MAAM,CAAC,YAAY;CAS5B"}
|
|
@@ -22,16 +22,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
22
22
|
var PullSecretsToEnvCommandHandler_1;
|
|
23
23
|
import { inject, injectable } from 'inversify';
|
|
24
24
|
import pc from 'picocolors';
|
|
25
|
-
import {
|
|
26
|
-
import { ExpiredCredentialsError, SecretsFetchError, SsoSessionExpiredError, } from '../../domain/errors/DomainErrors.js';
|
|
27
|
-
import { describeError } from '../../infrastructure/describeError.js';
|
|
25
|
+
import { SecretsFetchError } from '../../domain/errors/DomainErrors.js';
|
|
28
26
|
import { TYPES } from '../../types.js';
|
|
27
|
+
import { SecretResolver } from '../secretResolution/SecretResolver.js';
|
|
29
28
|
let PullSecretsToEnvCommandHandler = PullSecretsToEnvCommandHandler_1 = class PullSecretsToEnvCommandHandler {
|
|
30
29
|
constructor(secretProvider, variableStore, logger, secretMasker) {
|
|
31
|
-
this.secretProvider = secretProvider;
|
|
32
30
|
this.variableStore = variableStore;
|
|
33
31
|
this.logger = logger;
|
|
34
|
-
this.
|
|
32
|
+
this.secretResolver = new SecretResolver(secretProvider, logger, secretMasker);
|
|
35
33
|
}
|
|
36
34
|
/**
|
|
37
35
|
* Handles the PullSecretsToEnvCommand which orchestrates the process of fetching
|
|
@@ -61,17 +59,13 @@ let PullSecretsToEnvCommandHandler = PullSecretsToEnvCommandHandler_1 = class Pu
|
|
|
61
59
|
}
|
|
62
60
|
envild(paramMap, existingEnvVariables) {
|
|
63
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
this.logSecretsSection(resolved, warnings);
|
|
62
|
+
const { resolved, warnings, errors } = yield this.secretResolver.resolve(paramMap);
|
|
63
|
+
for (const outcome of resolved) {
|
|
64
|
+
existingEnvVariables[outcome.envVar] = outcome.value;
|
|
65
|
+
}
|
|
66
|
+
this.secretResolver.logSecretsSection(resolved, warnings);
|
|
69
67
|
if (errors.length > 0) {
|
|
70
|
-
throw new SecretsFetchError(errors.map(
|
|
71
|
-
envVar: error.envVar,
|
|
72
|
-
path: error.path,
|
|
73
|
-
reason: error.reason,
|
|
74
|
-
})));
|
|
68
|
+
throw new SecretsFetchError(errors.map(SecretResolver.toFailure));
|
|
75
69
|
}
|
|
76
70
|
return {
|
|
77
71
|
variables: existingEnvVariables,
|
|
@@ -80,74 +74,10 @@ let PullSecretsToEnvCommandHandler = PullSecretsToEnvCommandHandler_1 = class Pu
|
|
|
80
74
|
};
|
|
81
75
|
});
|
|
82
76
|
}
|
|
83
|
-
processSecret(envVar, secretName, existingEnvVariables) {
|
|
84
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
try {
|
|
86
|
-
const value = yield this.secretProvider.getSecret(secretName);
|
|
87
|
-
if (value === undefined) {
|
|
88
|
-
return {
|
|
89
|
-
status: 'warning',
|
|
90
|
-
envVar,
|
|
91
|
-
path: secretName,
|
|
92
|
-
reason: 'not-found',
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
if (value === '') {
|
|
96
|
-
return { status: 'warning', envVar, path: secretName, reason: 'empty' };
|
|
97
|
-
}
|
|
98
|
-
this.secretMasker.mask(value);
|
|
99
|
-
existingEnvVariables[envVar] = value;
|
|
100
|
-
const masked = new EnvironmentVariable(envVar, value, true).maskedValue;
|
|
101
|
-
return { status: 'resolved', envVar, masked };
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
if (error instanceof ExpiredCredentialsError ||
|
|
105
|
-
error instanceof SsoSessionExpiredError) {
|
|
106
|
-
throw error;
|
|
107
|
-
}
|
|
108
|
-
const maskedPath = EnvironmentVariable.maskSecretPath(secretName);
|
|
109
|
-
const reason = PullSecretsToEnvCommandHandler_1.describeErrorReason(error, maskedPath);
|
|
110
|
-
return { status: 'error', envVar, path: maskedPath, reason };
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
static describeErrorReason(error, maskedPath) {
|
|
115
|
-
const message = describeError(error);
|
|
116
|
-
const duplicatedPrefix = `${maskedPath}: `;
|
|
117
|
-
return message.startsWith(duplicatedPrefix)
|
|
118
|
-
? message.slice(duplicatedPrefix.length)
|
|
119
|
-
: message;
|
|
120
|
-
}
|
|
121
|
-
logSecretsSection(resolved, warnings) {
|
|
122
|
-
if (resolved.length === 0 && warnings.length === 0) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
this.logger.info(`\n${pc.bold(pc.yellow('\u{1FA99} RESOLVING SECRETS'))}`);
|
|
126
|
-
this.logger.info(PullSecretsToEnvCommandHandler_1.RULE);
|
|
127
|
-
for (const outcome of resolved) {
|
|
128
|
-
this.logger.info(` ${pc.green('\u2713 ')}${pc.bold(PullSecretsToEnvCommandHandler_1.pad(outcome.envVar))}${pc.dim('\u2192 ')}${pc.dim(outcome.masked)}`);
|
|
129
|
-
}
|
|
130
|
-
this.logWarnings(warnings);
|
|
131
|
-
}
|
|
132
|
-
logWarnings(warnings) {
|
|
133
|
-
for (const outcome of warnings) {
|
|
134
|
-
const maskedPath = EnvironmentVariable.maskSecretPath(outcome.path);
|
|
135
|
-
if (outcome.reason === 'not-found') {
|
|
136
|
-
this.logger.warn(` ${pc.red('\u2717 ')}${pc.bold(pc.red(PullSecretsToEnvCommandHandler_1.pad(outcome.envVar)))} ${pc.red(`secret not found (path: ${maskedPath}) \u2014 skipped`)}`);
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
this.logger.warn(` ${pc.yellow('\u26A0 ')}${pc.bold(PullSecretsToEnvCommandHandler_1.pad(outcome.envVar))} ${pc.dim(`no value found (path: ${maskedPath}) \u2014 skipped`)}`);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
static pad(name) {
|
|
143
|
-
return name.padEnd(PullSecretsToEnvCommandHandler_1.LABEL_WIDTH);
|
|
144
|
-
}
|
|
145
77
|
static buildSummary(resolvedCount, totalCount, envFilePath) {
|
|
146
78
|
return `\n${pc.bold(pc.green('\u2B50 LEVEL CLEARED'))}${pc.dim(` \u2014 ${resolvedCount}/${totalCount} secrets loaded \u00B7 `)}${pc.bold(envFilePath)}${pc.dim(' written')}\n`;
|
|
147
79
|
}
|
|
148
80
|
};
|
|
149
|
-
PullSecretsToEnvCommandHandler.LABEL_WIDTH = 20;
|
|
150
|
-
PullSecretsToEnvCommandHandler.RULE = pc.yellow('\u2501'.repeat(60));
|
|
151
81
|
PullSecretsToEnvCommandHandler = PullSecretsToEnvCommandHandler_1 = __decorate([
|
|
152
82
|
injectable(),
|
|
153
83
|
__param(0, inject(TYPES.ISecretProvider)),
|
package/lib/envilder/core/application/pullSecretsToEnv/PullSecretsToEnvCommandHandler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PullSecretsToEnvCommandHandler.js","sourceRoot":"","sources":["../../../../../src/envilder/core/application/pullSecretsToEnv/PullSecretsToEnvCommandHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"PullSecretsToEnvCommandHandler.js","sourceRoot":"","sources":["../../../../../src/envilder/core/application/pullSecretsToEnv/PullSecretsToEnvCommandHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAKxE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAIhE,IAAM,8BAA8B,sCAApC,MAAM,8BAA8B;IAGzC,YAEE,cAA+B,EAEd,aAA6B,EACN,MAAe,EAEvD,YAA2B;6BAHV,aAAa;sBACU,MAAM;QAI9C,IAAI,CAAC,cAAc,GAAG,IAAI,cAAc,CACtC,cAAc,EACd,MAAM,EACN,YAAY,CACb,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACG,MAAM,CAAC,OAAgC;;YAC3C,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAC1C,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAA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iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC;YACpE,CAAC;YAED,OAAO;gBACL,SAAS,EAAE,oBAAoB;gBAC/B,aAAa,EAAE,QAAQ,CAAC,MAAM;gBAC9B,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM;aACzC,CAAC;QACJ,CAAC;KAAA;IAEO,MAAM,CAAC,YAAY,CACzB,aAAqB,EACrB,UAAkB,EAClB,WAAmB;QAEnB,OAAO,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAC5D,aAAa,aAAa,IAAI,UAAU,yBAAyB,CAClE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC;IACpD,CAAC;CACF,CAAA;AArGY,8BAA8B;IAD1C,UAAU,EAAE;IAKR,WAAA,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAA;IAE7B,WAAA,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;IAE5B,WAAA,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACrB,WAAA,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;;GATnB,8BAA8B,CAqG1C"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type SecretFetchFailure } from '../../domain/errors/DomainErrors.js';
|
|
2
|
+
import type { ILogger } from '../../domain/ports/ILogger.js';
|
|
3
|
+
import type { ISecretMasker } from '../../domain/ports/ISecretMasker.js';
|
|
4
|
+
import type { ISecretProvider } from '../../domain/ports/ISecretProvider.js';
|
|
5
|
+
export type ResolvedSecret = {
|
|
6
|
+
status: 'resolved';
|
|
7
|
+
envVar: string;
|
|
8
|
+
value: string;
|
|
9
|
+
masked: string;
|
|
10
|
+
};
|
|
11
|
+
export type UnresolvedSecret = {
|
|
12
|
+
status: 'warning';
|
|
13
|
+
envVar: string;
|
|
14
|
+
path: string;
|
|
15
|
+
reason: 'not-found' | 'empty';
|
|
16
|
+
};
|
|
17
|
+
export type FailedSecret = {
|
|
18
|
+
status: 'error';
|
|
19
|
+
envVar: string;
|
|
20
|
+
/** Already masked. */
|
|
21
|
+
path: string;
|
|
22
|
+
reason: string;
|
|
23
|
+
};
|
|
24
|
+
export type SecretOutcome = ResolvedSecret | UnresolvedSecret | FailedSecret;
|
|
25
|
+
export type SecretResolution = {
|
|
26
|
+
/** One outcome per mapping, in map-file order. */
|
|
27
|
+
outcomes: SecretOutcome[];
|
|
28
|
+
resolved: ResolvedSecret[];
|
|
29
|
+
warnings: UnresolvedSecret[];
|
|
30
|
+
errors: FailedSecret[];
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Resolves the secrets declared in a map file and presents the outcome.
|
|
34
|
+
*
|
|
35
|
+
* Shared by every mode that reads secrets (pull and exec) so the outcomes,
|
|
36
|
+
* masking, failure reasons and the per-secret block stay identical. Each mode
|
|
37
|
+
* decides what to do with missing or empty secrets: pull skips them, exec
|
|
38
|
+
* refuses to start the child.
|
|
39
|
+
*/
|
|
40
|
+
export declare class SecretResolver {
|
|
41
|
+
private readonly secretProvider;
|
|
42
|
+
private readonly logger;
|
|
43
|
+
private readonly secretMasker;
|
|
44
|
+
constructor(secretProvider: ISecretProvider, logger: ILogger, secretMasker: ISecretMasker);
|
|
45
|
+
/**
|
|
46
|
+
* Fetches every mapped secret concurrently. Every resolved value is
|
|
47
|
+
* registered with the secret masker as soon as it is known. Expired
|
|
48
|
+
* credentials and SSO sessions propagate so callers can recover; any other
|
|
49
|
+
* provider failure becomes an error outcome with a masked path.
|
|
50
|
+
*/
|
|
51
|
+
resolve(mappings: Record<string, string>): Promise<SecretResolution>;
|
|
52
|
+
/**
|
|
53
|
+
* Builds the failure entry used by `SecretsFetchError` for an outcome that
|
|
54
|
+
* did not resolve. Missing and empty secrets use the reasons `not found`
|
|
55
|
+
* and `empty`.
|
|
56
|
+
*/
|
|
57
|
+
static toFailure(outcome: UnresolvedSecret | FailedSecret): SecretFetchFailure;
|
|
58
|
+
/**
|
|
59
|
+
* Logs the per-secret block: resolved secrets with masked values, then the
|
|
60
|
+
* skipped ones as warnings.
|
|
61
|
+
*/
|
|
62
|
+
logSecretsSection(resolved: ResolvedSecret[], warnings: UnresolvedSecret[]): void;
|
|
63
|
+
private logSkippedWarnings;
|
|
64
|
+
private resolveOne;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=SecretResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SecretResolver.d.ts","sourceRoot":"","sources":["../../../../../src/envilder/core/application/secretResolution/SecretResolver.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,kBAAkB,EAExB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAG7E,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,gBAAgB,GAAG,YAAY,CAAC;AAE7E,MAAM,MAAM,gBAAgB,GAAG;IAC7B,kDAAkD;IAClD,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,MAAM,EAAE,YAAY,EAAE,CAAC;CACxB,CAAC;AAKF;;;;;;;GAOG;AACH,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAH/B,YACmB,cAAc,EAAE,eAAe,EAC/B,MAAM,EAAE,OAAO,EACf,YAAY,EAAE,aAAa,EAC1C;IAEJ;;;;;OAKG;IACG,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAmBzE;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAS,CACd,OAAO,EAAE,gBAAgB,GAAG,YAAY,GACvC,kBAAkB,CAapB;IAED;;;OAGG;IACH,iBAAiB,CACf,QAAQ,EAAE,cAAc,EAAE,EAC1B,QAAQ,EAAE,gBAAgB,EAAE,GAC3B,IAAI,CAeN;IAED,OAAO,CAAC,kBAAkB;YAmBZ,UAAU;CAkCzB"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import pc from 'picocolors';
|
|
11
|
+
import { EnvironmentVariable } from '../../domain/EnvironmentVariable.js';
|
|
12
|
+
import { ExpiredCredentialsError, SsoSessionExpiredError, } from '../../domain/errors/DomainErrors.js';
|
|
13
|
+
import { describeError } from '../../infrastructure/describeError.js';
|
|
14
|
+
const LABEL_WIDTH = 20;
|
|
15
|
+
const RULE = pc.yellow('\u2501'.repeat(60));
|
|
16
|
+
/**
|
|
17
|
+
* Resolves the secrets declared in a map file and presents the outcome.
|
|
18
|
+
*
|
|
19
|
+
* Shared by every mode that reads secrets (pull and exec) so the outcomes,
|
|
20
|
+
* masking, failure reasons and the per-secret block stay identical. Each mode
|
|
21
|
+
* decides what to do with missing or empty secrets: pull skips them, exec
|
|
22
|
+
* refuses to start the child.
|
|
23
|
+
*/
|
|
24
|
+
export class SecretResolver {
|
|
25
|
+
constructor(secretProvider, logger, secretMasker) {
|
|
26
|
+
this.secretProvider = secretProvider;
|
|
27
|
+
this.logger = logger;
|
|
28
|
+
this.secretMasker = secretMasker;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Fetches every mapped secret concurrently. Every resolved value is
|
|
32
|
+
* registered with the secret masker as soon as it is known. Expired
|
|
33
|
+
* credentials and SSO sessions propagate so callers can recover; any other
|
|
34
|
+
* provider failure becomes an error outcome with a masked path.
|
|
35
|
+
*/
|
|
36
|
+
resolve(mappings) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const outcomes = yield Promise.all(Object.entries(mappings).map(([envVar, secretName]) => this.resolveOne(envVar, secretName)));
|
|
39
|
+
return {
|
|
40
|
+
outcomes,
|
|
41
|
+
resolved: outcomes.filter((outcome) => outcome.status === 'resolved'),
|
|
42
|
+
warnings: outcomes.filter((outcome) => outcome.status === 'warning'),
|
|
43
|
+
errors: outcomes.filter((outcome) => outcome.status === 'error'),
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Builds the failure entry used by `SecretsFetchError` for an outcome that
|
|
49
|
+
* did not resolve. Missing and empty secrets use the reasons `not found`
|
|
50
|
+
* and `empty`.
|
|
51
|
+
*/
|
|
52
|
+
static toFailure(outcome) {
|
|
53
|
+
if (outcome.status === 'error') {
|
|
54
|
+
return {
|
|
55
|
+
envVar: outcome.envVar,
|
|
56
|
+
path: outcome.path,
|
|
57
|
+
reason: outcome.reason,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
envVar: outcome.envVar,
|
|
62
|
+
path: EnvironmentVariable.maskSecretPath(outcome.path),
|
|
63
|
+
reason: outcome.reason === 'not-found' ? 'not found' : 'empty',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Logs the per-secret block: resolved secrets with masked values, then the
|
|
68
|
+
* skipped ones as warnings.
|
|
69
|
+
*/
|
|
70
|
+
logSecretsSection(resolved, warnings) {
|
|
71
|
+
if (resolved.length === 0 && warnings.length === 0) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this.logger.info(`\n${pc.bold(pc.yellow('\u{1FA99} RESOLVING SECRETS'))}`);
|
|
75
|
+
this.logger.info(RULE);
|
|
76
|
+
for (const outcome of resolved) {
|
|
77
|
+
this.logger.info(` ${pc.green('\u2713 ')}${pc.bold(pad(outcome.envVar))}${pc.dim('\u2192 ')}${pc.dim(outcome.masked)}`);
|
|
78
|
+
}
|
|
79
|
+
this.logSkippedWarnings(warnings);
|
|
80
|
+
}
|
|
81
|
+
logSkippedWarnings(warnings) {
|
|
82
|
+
for (const outcome of warnings) {
|
|
83
|
+
const maskedPath = EnvironmentVariable.maskSecretPath(outcome.path);
|
|
84
|
+
if (outcome.reason === 'not-found') {
|
|
85
|
+
this.logger.warn(` ${pc.red('\u2717 ')}${pc.bold(pc.red(pad(outcome.envVar)))} ${pc.red(`secret not found (path: ${maskedPath}) \u2014 skipped`)}`);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
this.logger.warn(` ${pc.yellow('\u26A0 ')}${pc.bold(pad(outcome.envVar))} ${pc.dim(`no value found (path: ${maskedPath}) \u2014 skipped`)}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
resolveOne(envVar, secretName) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
try {
|
|
94
|
+
const value = yield this.secretProvider.getSecret(secretName);
|
|
95
|
+
if (value === undefined) {
|
|
96
|
+
return {
|
|
97
|
+
status: 'warning',
|
|
98
|
+
envVar,
|
|
99
|
+
path: secretName,
|
|
100
|
+
reason: 'not-found',
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (value === '') {
|
|
104
|
+
return { status: 'warning', envVar, path: secretName, reason: 'empty' };
|
|
105
|
+
}
|
|
106
|
+
this.secretMasker.mask(value);
|
|
107
|
+
const masked = new EnvironmentVariable(envVar, value, true).maskedValue;
|
|
108
|
+
return { status: 'resolved', envVar, value, masked };
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
if (error instanceof ExpiredCredentialsError ||
|
|
112
|
+
error instanceof SsoSessionExpiredError) {
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
const maskedPath = EnvironmentVariable.maskSecretPath(secretName);
|
|
116
|
+
const reason = describeErrorReason(error, maskedPath);
|
|
117
|
+
return { status: 'error', envVar, path: maskedPath, reason };
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function describeErrorReason(error, maskedPath) {
|
|
123
|
+
const message = describeError(error);
|
|
124
|
+
const duplicatedPrefix = `${maskedPath}: `;
|
|
125
|
+
return message.startsWith(duplicatedPrefix)
|
|
126
|
+
? message.slice(duplicatedPrefix.length)
|
|
127
|
+
: message;
|
|
128
|
+
}
|
|
129
|
+
function pad(name) {
|
|
130
|
+
return name.padEnd(LABEL_WIDTH);
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=SecretResolver.js.map
|