@fjall/deploy-core 0.89.2
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/LICENSE +21 -0
- package/dist/src/aws/AwsProvider.d.ts +39 -0
- package/dist/src/aws/AwsProvider.js +1 -0
- package/dist/src/aws/SimpleAwsProvider.d.ts +22 -0
- package/dist/src/aws/SimpleAwsProvider.js +73 -0
- package/dist/src/aws/index.d.ts +4 -0
- package/dist/src/aws/index.js +3 -0
- package/dist/src/aws/organisations/accounts.d.ts +21 -0
- package/dist/src/aws/organisations/accounts.js +99 -0
- package/dist/src/aws/organisations/backup.d.ts +12 -0
- package/dist/src/aws/organisations/backup.js +28 -0
- package/dist/src/aws/organisations/costAllocation.d.ts +12 -0
- package/dist/src/aws/organisations/costAllocation.js +26 -0
- package/dist/src/aws/organisations/identityCentre.d.ts +8 -0
- package/dist/src/aws/organisations/identityCentre.js +19 -0
- package/dist/src/aws/organisations/index.d.ts +16 -0
- package/dist/src/aws/organisations/index.js +12 -0
- package/dist/src/aws/organisations/ipam.d.ts +7 -0
- package/dist/src/aws/organisations/ipam.js +18 -0
- package/dist/src/aws/organisations/organisation.d.ts +12 -0
- package/dist/src/aws/organisations/organisation.js +94 -0
- package/dist/src/aws/organisations/organisationalUnits.d.ts +19 -0
- package/dist/src/aws/organisations/organisationalUnits.js +125 -0
- package/dist/src/aws/organisations/policies.d.ts +7 -0
- package/dist/src/aws/organisations/policies.js +36 -0
- package/dist/src/aws/organisations/ram.d.ts +7 -0
- package/dist/src/aws/organisations/ram.js +15 -0
- package/dist/src/aws/organisations/serviceAccess.d.ts +7 -0
- package/dist/src/aws/organisations/serviceAccess.js +38 -0
- package/dist/src/aws/organisations/trustedAccess.d.ts +7 -0
- package/dist/src/aws/organisations/trustedAccess.js +15 -0
- package/dist/src/aws/organisations/types.d.ts +29 -0
- package/dist/src/aws/organisations/types.js +16 -0
- package/dist/src/aws/utils/CloudFormationFailureAnalyser.d.ts +32 -0
- package/dist/src/aws/utils/CloudFormationFailureAnalyser.js +228 -0
- package/dist/src/aws/utils/cloudformationEvents.d.ts +98 -0
- package/dist/src/aws/utils/cloudformationEvents.js +596 -0
- package/dist/src/aws/utils/errors.d.ts +26 -0
- package/dist/src/aws/utils/errors.js +59 -0
- package/dist/src/aws/utils/regions.d.ts +1 -0
- package/dist/src/aws/utils/regions.js +1 -0
- package/dist/src/aws/utils/stackStatus.d.ts +23 -0
- package/dist/src/aws/utils/stackStatus.js +90 -0
- package/dist/src/index.d.ts +35 -0
- package/dist/src/index.js +45 -0
- package/dist/src/orchestration/applicationDeploy.d.ts +11 -0
- package/dist/src/orchestration/applicationDeploy.js +327 -0
- package/dist/src/orchestration/contextHelpers.d.ts +9 -0
- package/dist/src/orchestration/contextHelpers.js +14 -0
- package/dist/src/orchestration/deploy.d.ts +10 -0
- package/dist/src/orchestration/deploy.js +42 -0
- package/dist/src/orchestration/detectionPipeline.d.ts +23 -0
- package/dist/src/orchestration/detectionPipeline.js +65 -0
- package/dist/src/orchestration/dockerInterface.d.ts +56 -0
- package/dist/src/orchestration/dockerInterface.js +1 -0
- package/dist/src/orchestration/domainInterface.d.ts +37 -0
- package/dist/src/orchestration/domainInterface.js +1 -0
- package/dist/src/orchestration/index.d.ts +8 -0
- package/dist/src/orchestration/index.js +3 -0
- package/dist/src/orchestration/organisationDeploy.d.ts +16 -0
- package/dist/src/orchestration/organisationDeploy.js +382 -0
- package/dist/src/orchestration/organisationSetup.d.ts +42 -0
- package/dist/src/orchestration/organisationSetup.js +227 -0
- package/dist/src/orchestration/resolveOperation.d.ts +10 -0
- package/dist/src/orchestration/resolveOperation.js +53 -0
- package/dist/src/orchestration/serviceFactory.d.ts +15 -0
- package/dist/src/orchestration/serviceFactory.js +16 -0
- package/dist/src/services/application/ApplicationStackService.d.ts +93 -0
- package/dist/src/services/application/ApplicationStackService.js +436 -0
- package/dist/src/services/application/index.d.ts +1 -0
- package/dist/src/services/application/index.js +1 -0
- package/dist/src/services/infrastructure/CdkArgumentBuilder.d.ts +12 -0
- package/dist/src/services/infrastructure/CdkArgumentBuilder.js +67 -0
- package/dist/src/services/infrastructure/CdkCommandRunner.d.ts +30 -0
- package/dist/src/services/infrastructure/CdkCommandRunner.js +241 -0
- package/dist/src/services/infrastructure/CdkErrorFormatter.d.ts +4 -0
- package/dist/src/services/infrastructure/CdkErrorFormatter.js +194 -0
- package/dist/src/services/infrastructure/CdkEventMonitoring.d.ts +19 -0
- package/dist/src/services/infrastructure/CdkEventMonitoring.js +41 -0
- package/dist/src/services/infrastructure/CdkOutputAnalyser.d.ts +43 -0
- package/dist/src/services/infrastructure/CdkOutputAnalyser.js +125 -0
- package/dist/src/services/infrastructure/CdkOutputParser.d.ts +8 -0
- package/dist/src/services/infrastructure/CdkOutputParser.js +33 -0
- package/dist/src/services/infrastructure/CdkProcessManager.d.ts +20 -0
- package/dist/src/services/infrastructure/CdkProcessManager.js +244 -0
- package/dist/src/services/infrastructure/CdkService.d.ts +71 -0
- package/dist/src/services/infrastructure/CdkService.js +254 -0
- package/dist/src/services/infrastructure/CloudFormationService.d.ts +79 -0
- package/dist/src/services/infrastructure/CloudFormationService.js +249 -0
- package/dist/src/services/infrastructure/index.d.ts +8 -0
- package/dist/src/services/infrastructure/index.js +7 -0
- package/dist/src/services/supporting/CdkContextBuilder.d.ts +49 -0
- package/dist/src/services/supporting/CdkContextBuilder.js +44 -0
- package/dist/src/services/supporting/TemplateHashService.d.ts +67 -0
- package/dist/src/services/supporting/TemplateHashService.js +152 -0
- package/dist/src/services/supporting/helpers.d.ts +46 -0
- package/dist/src/services/supporting/helpers.js +81 -0
- package/dist/src/services/supporting/index.d.ts +3 -0
- package/dist/src/services/supporting/index.js +3 -0
- package/dist/src/types/FjallState.d.ts +50 -0
- package/dist/src/types/FjallState.js +118 -0
- package/dist/src/types/ProgressEvent.d.ts +35 -0
- package/dist/src/types/ProgressEvent.js +48 -0
- package/dist/src/types/apiClient.d.ts +34 -0
- package/dist/src/types/apiClient.js +1 -0
- package/dist/src/types/application/ApplicationServiceTypes.d.ts +56 -0
- package/dist/src/types/application/ApplicationServiceTypes.js +30 -0
- package/dist/src/types/application/index.d.ts +1 -0
- package/dist/src/types/application/index.js +1 -0
- package/dist/src/types/callbacks.d.ts +36 -0
- package/dist/src/types/callbacks.js +1 -0
- package/dist/src/types/constants.d.ts +6 -0
- package/dist/src/types/constants.js +6 -0
- package/dist/src/types/credentials.d.ts +30 -0
- package/dist/src/types/credentials.js +1 -0
- package/dist/src/types/deployment/DeploymentServiceTypes.d.ts +23 -0
- package/dist/src/types/deployment/DeploymentServiceTypes.js +1 -0
- package/dist/src/types/deployment/DeploymentTypes.d.ts +29 -0
- package/dist/src/types/deployment/DeploymentTypes.js +1 -0
- package/dist/src/types/deployment/cloudformation.d.ts +14 -0
- package/dist/src/types/deployment/cloudformation.js +1 -0
- package/dist/src/types/deployment/index.d.ts +5 -0
- package/dist/src/types/deployment/index.js +1 -0
- package/dist/src/types/deployment/parallel.d.ts +46 -0
- package/dist/src/types/deployment/parallel.js +10 -0
- package/dist/src/types/errors/CdkError.d.ts +14 -0
- package/dist/src/types/errors/CdkError.js +20 -0
- package/dist/src/types/errors/ServiceError.d.ts +86 -0
- package/dist/src/types/errors/ServiceError.js +119 -0
- package/dist/src/types/events.d.ts +40 -0
- package/dist/src/types/events.js +5 -0
- package/dist/src/types/index.d.ts +20 -0
- package/dist/src/types/index.js +9 -0
- package/dist/src/types/operations.d.ts +193 -0
- package/dist/src/types/operations.js +285 -0
- package/dist/src/types/orgConfig.d.ts +28 -0
- package/dist/src/types/orgConfig.js +11 -0
- package/dist/src/types/params.d.ts +74 -0
- package/dist/src/types/params.js +1 -0
- package/dist/src/types/patternDetection.d.ts +43 -0
- package/dist/src/types/patternDetection.js +92 -0
- package/dist/src/types/validation.d.ts +12 -0
- package/dist/src/types/validation.js +1 -0
- package/dist/src/util/fsHelpers.d.ts +4 -0
- package/dist/src/util/fsHelpers.js +16 -0
- package/dist/src/util/index.d.ts +3 -0
- package/dist/src/util/index.js +3 -0
- package/dist/src/util/securityHelpers.d.ts +31 -0
- package/dist/src/util/securityHelpers.js +124 -0
- package/dist/src/util/singleton.d.ts +2 -0
- package/dist/src/util/singleton.js +9 -0
- package/dist/src/util/sleep.d.ts +4 -0
- package/dist/src/util/sleep.js +4 -0
- package/package.json +42 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security helpers for spawn operations
|
|
3
|
+
*
|
|
4
|
+
* Provides environment variable filtering and credential masking
|
|
5
|
+
* to prevent command injection and credential leakage.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Environment variables that MUST NOT be passed from user input to spawned processes.
|
|
9
|
+
* These can be exploited for:
|
|
10
|
+
* - Code execution hijacking (PATH, NODE_OPTIONS)
|
|
11
|
+
* - Dynamic linker injection (LD_PRELOAD, DYLD_INSERT_LIBRARIES)
|
|
12
|
+
* - Interpreter code injection (PYTHONPATH, RUBYLIB)
|
|
13
|
+
* - Credential/identity hijacking (HOME, AWS_CONFIG_FILE)
|
|
14
|
+
* - Shell injection (BASH_ENV, ENV)
|
|
15
|
+
*/
|
|
16
|
+
export const DANGEROUS_ENV_VARS = new Set([
|
|
17
|
+
// Execution hijacking
|
|
18
|
+
// NOTE: PATH is intentionally NOT included here - it's required for spawn() to find executables
|
|
19
|
+
// See: aiDocs/patterns/spawn-security-pattern.md for rationale
|
|
20
|
+
"NODE_OPTIONS",
|
|
21
|
+
"NODE_PATH",
|
|
22
|
+
"NODE_EXTRA_CA_CERTS",
|
|
23
|
+
"NODE_DEBUG",
|
|
24
|
+
"NODE_PRESERVE_SYMLINKS",
|
|
25
|
+
// Dynamic linker injection (Linux)
|
|
26
|
+
"LD_PRELOAD",
|
|
27
|
+
"LD_LIBRARY_PATH",
|
|
28
|
+
"LD_AUDIT",
|
|
29
|
+
"LD_BIND_NOW",
|
|
30
|
+
// Dynamic linker injection (macOS)
|
|
31
|
+
"DYLD_INSERT_LIBRARIES",
|
|
32
|
+
"DYLD_LIBRARY_PATH",
|
|
33
|
+
"DYLD_FRAMEWORK_PATH",
|
|
34
|
+
// Interpreter code injection
|
|
35
|
+
"PYTHONPATH",
|
|
36
|
+
"PYTHONSTARTUP",
|
|
37
|
+
"PERL5LIB",
|
|
38
|
+
"PERL5OPT",
|
|
39
|
+
"RUBYLIB",
|
|
40
|
+
"RUBYOPT",
|
|
41
|
+
// Credential/identity hijacking
|
|
42
|
+
"HOME",
|
|
43
|
+
"XDG_CONFIG_HOME",
|
|
44
|
+
"AWS_SHARED_CREDENTIALS_FILE",
|
|
45
|
+
"AWS_CONFIG_FILE",
|
|
46
|
+
// Shell injection
|
|
47
|
+
"SHELL",
|
|
48
|
+
"BASH_ENV",
|
|
49
|
+
"ENV",
|
|
50
|
+
"ZDOTDIR"
|
|
51
|
+
]);
|
|
52
|
+
/**
|
|
53
|
+
* Filter dangerous environment variables from a record.
|
|
54
|
+
* Returns a new object with only safe environment variables.
|
|
55
|
+
*/
|
|
56
|
+
export function filterDangerousEnvVars(env) {
|
|
57
|
+
return Object.fromEntries(Object.entries(env).filter(([key]) => !DANGEROUS_ENV_VARS.has(key.toUpperCase())));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Mask sensitive information in output strings to prevent credential leakage.
|
|
61
|
+
* Patterns: postgres://user:pass@host, password=xxx, secret=xxx, apikey=xxx
|
|
62
|
+
*/
|
|
63
|
+
export function maskSensitiveOutput(output) {
|
|
64
|
+
return (output
|
|
65
|
+
// Mask postgres/mysql connection strings with credentials
|
|
66
|
+
.replace(/(\w+:\/\/[^:]+:)[^@]+(@)/gi, "$1***$2")
|
|
67
|
+
// Mask common credential patterns
|
|
68
|
+
.replace(/(password|passwd|secret|api[_-]?key|token|auth|credential)[=:]["']?[^\s"']+/gi, "$1=***")
|
|
69
|
+
// Mask GitHub tokens (ghu_, ghs_, ghp_, github_pat_) appearing as bare values
|
|
70
|
+
.replace(/\b(ghu_|ghs_|ghp_|github_pat_)[A-Za-z0-9_]+/g, "***")
|
|
71
|
+
// Mask AWS secret access keys (40 chars, base64-ish) — only when preceded
|
|
72
|
+
// by a known credential context to avoid false-positive masking of ARNs,
|
|
73
|
+
// physical resource IDs, and other legitimate 40-char strings.
|
|
74
|
+
.replace(/(?<=AWS_SECRET_ACCESS_KEY=|SecretAccessKey[=:]\s*|"secretAccessKey":\s*")[A-Za-z0-9/+=]{40}/g, "***"));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Parse a shell command string into an array of arguments.
|
|
78
|
+
* Handles single quotes, double quotes, and escaped characters.
|
|
79
|
+
*/
|
|
80
|
+
export function parseShellArgs(command) {
|
|
81
|
+
const args = [];
|
|
82
|
+
let current = "";
|
|
83
|
+
let inSingleQuote = false;
|
|
84
|
+
let inDoubleQuote = false;
|
|
85
|
+
let escaped = false;
|
|
86
|
+
for (const char of command) {
|
|
87
|
+
if (escaped) {
|
|
88
|
+
current += char;
|
|
89
|
+
escaped = false;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (char === "\\") {
|
|
93
|
+
escaped = true;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (char === "'" && !inDoubleQuote) {
|
|
97
|
+
inSingleQuote = !inSingleQuote;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (char === '"' && !inSingleQuote) {
|
|
101
|
+
inDoubleQuote = !inDoubleQuote;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (char === " " && !inSingleQuote && !inDoubleQuote) {
|
|
105
|
+
if (current) {
|
|
106
|
+
args.push(current);
|
|
107
|
+
current = "";
|
|
108
|
+
}
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
current += char;
|
|
112
|
+
}
|
|
113
|
+
if (inSingleQuote || inDoubleQuote) {
|
|
114
|
+
// Unbalanced quotes — include the partial token. Callers should validate
|
|
115
|
+
// their input if quote-balancing is required.
|
|
116
|
+
if (current) {
|
|
117
|
+
args.push(current);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else if (current) {
|
|
121
|
+
args.push(current);
|
|
122
|
+
}
|
|
123
|
+
return args;
|
|
124
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fjall/deploy-core",
|
|
3
|
+
"version": "0.89.2",
|
|
4
|
+
"description": "Shared deployment engine for Fjall — used by CLI and webapp worker",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/src/index.js",
|
|
7
|
+
"types": "dist/src/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist/"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"clean": "rm -rf ./dist",
|
|
13
|
+
"build": "npm run clean && tsc",
|
|
14
|
+
"typecheck": "tsc --noEmit",
|
|
15
|
+
"test": "vitest run",
|
|
16
|
+
"test:watch": "vitest",
|
|
17
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
18
|
+
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
19
|
+
"lint": "eslint src/"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18.0.0"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@aws-sdk/client-backup": "^3.1009.0",
|
|
27
|
+
"@aws-sdk/client-cloudformation": "^3.1009.0",
|
|
28
|
+
"@aws-sdk/client-cost-explorer": "^3.1009.0",
|
|
29
|
+
"@aws-sdk/client-ec2": "^3.1009.0",
|
|
30
|
+
"@aws-sdk/client-organizations": "^3.1009.0",
|
|
31
|
+
"@aws-sdk/client-ram": "^3.1009.0",
|
|
32
|
+
"@aws-sdk/client-sso-admin": "^3.1009.0",
|
|
33
|
+
"@aws-sdk/client-sts": "^3.1009.0",
|
|
34
|
+
"@fjall/generator": "^0.89.2",
|
|
35
|
+
"@fjall/util": "^0.89.2",
|
|
36
|
+
"zod": "^4.3.6"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"vitest": "^3.2.3"
|
|
40
|
+
},
|
|
41
|
+
"gitHead": "5bb039ff669fbe96d656ae1467e9986cf4327e92"
|
|
42
|
+
}
|