timonel 3.1.1 → 3.1.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/CHANGELOG.md +7 -0
- package/README.md +323 -695
- package/dist/cli.js +275 -15
- package/dist/index.d.ts +5 -1
- package/dist/index.js +12 -0
- package/dist/lib/helm.d.ts +471 -0
- package/dist/lib/helm.js +483 -0
- package/dist/lib/helmChartWriter.d.ts +157 -0
- package/dist/lib/helmChartWriter.js +171 -1
- package/dist/lib/policy/configurationLoader.d.ts +132 -0
- package/dist/lib/policy/configurationLoader.js +132 -0
- package/dist/lib/policy/errorContextGenerator.d.ts +89 -0
- package/dist/lib/policy/errorContextGenerator.js +99 -2
- package/dist/lib/policy/errors.d.ts +35 -0
- package/dist/lib/policy/errors.js +36 -0
- package/dist/lib/policy/index.d.ts +9 -0
- package/dist/lib/policy/index.js +16 -0
- package/dist/lib/policy/parallelExecutor.d.ts +90 -0
- package/dist/lib/policy/parallelExecutor.js +86 -3
- package/dist/lib/policy/pluginLoader.d.ts +92 -0
- package/dist/lib/policy/pluginLoader.js +92 -1
- package/dist/lib/policy/pluginRegistry.d.ts +54 -0
- package/dist/lib/policy/pluginRegistry.js +56 -0
- package/dist/lib/policy/policyEngine.d.ts +137 -0
- package/dist/lib/policy/policyEngine.js +191 -5
- package/dist/lib/policy/resultAggregator.d.ts +46 -0
- package/dist/lib/policy/resultAggregator.js +69 -1
- package/dist/lib/policy/resultFormatter.d.ts +88 -0
- package/dist/lib/policy/resultFormatter.js +101 -0
- package/dist/lib/policy/types.d.ts +136 -0
- package/dist/lib/policy/types.js +8 -0
- package/dist/lib/policy/validationCache.d.ts +146 -0
- package/dist/lib/policy/validationCache.js +142 -6
- package/dist/lib/resources/baseResourceProvider.d.ts +45 -0
- package/dist/lib/resources/baseResourceProvider.js +48 -1
- package/dist/lib/resources/cloud/aws/awsResources.d.ts +192 -0
- package/dist/lib/resources/cloud/aws/awsResources.js +163 -1
- package/dist/lib/resources/cloud/aws/karpenterResources.d.ts +131 -0
- package/dist/lib/resources/cloud/aws/karpenterResources.js +77 -0
- package/dist/lib/rutter.d.ts +381 -3
- package/dist/lib/rutter.js +439 -28
- package/dist/lib/security.d.ts +123 -0
- package/dist/lib/security.js +162 -4
- package/dist/lib/templates/flexible-subchart.d.ts +52 -0
- package/dist/lib/templates/flexible-subchart.js +70 -0
- package/dist/lib/templates/umbrella-chart.d.ts +27 -0
- package/dist/lib/templates/umbrella-chart.js +89 -0
- package/dist/lib/types.d.ts +26 -0
- package/dist/lib/umbrella.d.ts +23 -0
- package/dist/lib/umbrella.js +23 -0
- package/dist/lib/umbrellaRutter.d.ts +75 -0
- package/dist/lib/umbrellaRutter.js +82 -2
- package/dist/lib/utils/envVarsLoader.d.ts +49 -0
- package/dist/lib/utils/envVarsLoader.js +53 -0
- package/dist/lib/utils/helmConstructSerializer.d.ts +17 -0
- package/dist/lib/utils/helmConstructSerializer.js +22 -0
- package/dist/lib/utils/helmControlStructures.d.ts +194 -0
- package/dist/lib/utils/helmControlStructures.js +180 -0
- package/dist/lib/utils/helmHelpers/envHelpers.d.ts +13 -0
- package/dist/lib/utils/helmHelpers/envHelpers.js +13 -0
- package/dist/lib/utils/helmHelpers/gitopsHelpers.d.ts +13 -0
- package/dist/lib/utils/helmHelpers/gitopsHelpers.js +13 -0
- package/dist/lib/utils/helmHelpers/index.d.ts +74 -0
- package/dist/lib/utils/helmHelpers/index.js +85 -1
- package/dist/lib/utils/helmHelpers/observabilityHelpers.d.ts +13 -0
- package/dist/lib/utils/helmHelpers/observabilityHelpers.js +13 -0
- package/dist/lib/utils/helmHelpers/types.d.ts +23 -0
- package/dist/lib/utils/helmHelpers/types.js +4 -0
- package/dist/lib/utils/helmHelpers/validationHelpers.d.ts +13 -0
- package/dist/lib/utils/helmHelpers/validationHelpers.js +13 -0
- package/dist/lib/utils/helmHelpers.d.ts +62 -0
- package/dist/lib/utils/helmHelpers.js +77 -0
- package/dist/lib/utils/helmYamlSerializer.d.ts +77 -0
- package/dist/lib/utils/helmYamlSerializer.js +398 -21
- package/dist/lib/utils/logger.d.ts +153 -0
- package/dist/lib/utils/logger.js +170 -2
- package/dist/lib/utils/valuesRef.d.ts +181 -50
- package/dist/lib/utils/valuesRef.js +168 -170
- package/dist/lib/validation/inputValidator.d.ts +45 -0
- package/dist/lib/validation/inputValidator.js +67 -2
- package/dist/types/index.d.ts +34 -0
- package/dist/types/index.js +3 -0
- package/package.json +31 -38
|
@@ -1,14 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-safe Helm values reference system.
|
|
3
|
+
*
|
|
4
|
+
* ValuesRef exposes the shape of the caller-provided values interface while
|
|
5
|
+
* preserving a runtime proxy that renders Helm expressions.
|
|
6
|
+
*/
|
|
1
7
|
import { createHelmExpression } from './helmControlStructures.js';
|
|
2
8
|
const HELM_VALUE_SYMBOL = Symbol('HelmValue');
|
|
9
|
+
/** Escape a JavaScript string as a Helm double-quoted string literal. */
|
|
10
|
+
function helmStringLiteral(value) {
|
|
11
|
+
return `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
|
12
|
+
}
|
|
13
|
+
/** Convert a typed Helm reference or scalar into a Helm expression argument. */
|
|
3
14
|
function serializeValue(value) {
|
|
4
|
-
if (
|
|
15
|
+
if (isHelmValue(value)) {
|
|
5
16
|
return value.__path;
|
|
6
17
|
}
|
|
7
|
-
|
|
8
|
-
return `"${value}"`;
|
|
9
|
-
}
|
|
10
|
-
return String(value);
|
|
18
|
+
return typeof value === 'string' ? helmStringLiteral(value) : String(value);
|
|
11
19
|
}
|
|
20
|
+
/** Append a property segment while preserving scoped `.` semantics. */
|
|
21
|
+
function appendPropertyPath(path, property) {
|
|
22
|
+
return path === '.' ? `.${property}` : `${path}.${property}`;
|
|
23
|
+
}
|
|
24
|
+
/** Create a validated, composable Helm condition marker. */
|
|
12
25
|
function createCondition(condition) {
|
|
13
26
|
if (!condition || typeof condition !== 'string') {
|
|
14
27
|
throw new Error('Condition must be a non-empty string');
|
|
@@ -16,258 +29,243 @@ function createCondition(condition) {
|
|
|
16
29
|
return {
|
|
17
30
|
[HELM_VALUE_SYMBOL]: true,
|
|
18
31
|
__condition: condition,
|
|
32
|
+
/** Negate the current condition. */
|
|
19
33
|
not() {
|
|
20
34
|
return createCondition(`not (${this.__condition})`);
|
|
21
35
|
},
|
|
36
|
+
/** Combine the current condition with another using Helm `and`. */
|
|
22
37
|
and(other) {
|
|
23
38
|
if (!other || typeof other.__condition !== 'string') {
|
|
24
39
|
throw new Error('Invalid HelmCondition provided to and()');
|
|
25
40
|
}
|
|
26
41
|
return createCondition(`and (${this.__condition}) (${other.__condition})`);
|
|
27
42
|
},
|
|
43
|
+
/** Combine the current condition with another using Helm `or`. */
|
|
28
44
|
or(other) {
|
|
29
45
|
if (!other || typeof other.__condition !== 'string') {
|
|
30
46
|
throw new Error('Invalid HelmCondition provided to or()');
|
|
31
47
|
}
|
|
32
48
|
return createCondition(`or (${this.__condition}) (${other.__condition})`);
|
|
33
49
|
},
|
|
50
|
+
/** Return the raw condition body. */
|
|
34
51
|
toString() {
|
|
35
52
|
return this.__condition;
|
|
36
53
|
},
|
|
37
54
|
};
|
|
38
55
|
}
|
|
39
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Creates the runtime proxy used by ValuesRef and by serializer callback scopes.
|
|
58
|
+
* This function is intentionally not re-exported from the package root.
|
|
59
|
+
*/
|
|
60
|
+
export function createHelmValueProxy(path) {
|
|
40
61
|
const baseObject = Object.create(null);
|
|
41
|
-
baseObject.__helmExpression = true;
|
|
42
|
-
baseObject.value = `{{ ${path} }}`;
|
|
43
62
|
const handler = {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
getOwnPropertyDescriptor(target, prop) {
|
|
48
|
-
if (prop === '__helmExpression') {
|
|
49
|
-
return { value: true, writable: false, enumerable: true, configurable: true };
|
|
50
|
-
}
|
|
51
|
-
if (prop === 'value') {
|
|
52
|
-
return { value: `{{ ${path} }}`, writable: false, enumerable: true, configurable: true };
|
|
53
|
-
}
|
|
54
|
-
return undefined;
|
|
55
|
-
},
|
|
56
|
-
has(target, prop) {
|
|
57
|
-
if (prop === HELM_VALUE_SYMBOL)
|
|
58
|
-
return true;
|
|
59
|
-
if (prop === '__helmExpression')
|
|
60
|
-
return true;
|
|
61
|
-
if (prop === 'value')
|
|
62
|
-
return true;
|
|
63
|
-
return false;
|
|
63
|
+
/** Expose only Timonel's internal marker through the Proxy `in` trap. */
|
|
64
|
+
has(_target, prop) {
|
|
65
|
+
return prop === HELM_VALUE_SYMBOL;
|
|
64
66
|
},
|
|
65
|
-
|
|
67
|
+
/** Resolve helper methods, runtime markers, and nested typed property proxies. */
|
|
68
|
+
get(_target, prop) {
|
|
66
69
|
if (prop === HELM_VALUE_SYMBOL)
|
|
67
70
|
return true;
|
|
68
71
|
if (prop === '__path')
|
|
69
72
|
return path;
|
|
70
73
|
if (prop === '__type')
|
|
71
74
|
return undefined;
|
|
72
|
-
if (prop ===
|
|
73
|
-
return
|
|
74
|
-
if (prop === 'value')
|
|
75
|
-
return `{{ ${path} }}`;
|
|
75
|
+
if (prop === Symbol.toPrimitive)
|
|
76
|
+
return () => path;
|
|
76
77
|
if (prop === 'toJSON') {
|
|
77
|
-
return () =>
|
|
78
|
+
return () => `{{ ${path} }}`;
|
|
78
79
|
}
|
|
79
|
-
if (typeof prop
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
};
|
|
157
|
-
case 'ifElse':
|
|
158
|
-
return (condition, thenValue, elseValue) => {
|
|
159
|
-
const condStr = condition.__condition;
|
|
160
|
-
return createValueProxy(`(ternary ${serializeValue(thenValue)} ${serializeValue(elseValue)} (${condStr}))`);
|
|
161
|
-
};
|
|
162
|
-
case 'range':
|
|
163
|
-
return (callback) => ({
|
|
164
|
-
__helmRange: true,
|
|
165
|
-
source: createValueProxy(path),
|
|
166
|
-
callback,
|
|
167
|
-
});
|
|
168
|
-
case 'with':
|
|
169
|
-
return (callback) => {
|
|
170
|
-
const ctxProxy = { __path: '.', [HELM_VALUE_SYMBOL]: true };
|
|
171
|
-
const content = callback(ctxProxy);
|
|
172
|
-
let contentStr;
|
|
173
|
-
if (typeof content === 'object' &&
|
|
174
|
-
content !== null &&
|
|
175
|
-
'__helmExpression' in content) {
|
|
176
|
-
const helmExpr = content;
|
|
177
|
-
contentStr = helmExpr.value;
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
contentStr = String(content);
|
|
181
|
-
}
|
|
182
|
-
const marker = `__FIELD_WITH_MARKER__:${path}:${contentStr}`;
|
|
183
|
-
return createHelmExpression(marker);
|
|
80
|
+
if (typeof prop !== 'string')
|
|
81
|
+
return undefined;
|
|
82
|
+
switch (prop) {
|
|
83
|
+
case 'at':
|
|
84
|
+
return (key) => createHelmValueProxy(appendPropertyPath(path, key));
|
|
85
|
+
case 'eq':
|
|
86
|
+
return (value) => createCondition(`eq ${path} ${serializeValue(value)}`);
|
|
87
|
+
case 'ne':
|
|
88
|
+
return (value) => createCondition(`ne ${path} ${serializeValue(value)}`);
|
|
89
|
+
case 'gt':
|
|
90
|
+
return (value) => createCondition(`gt ${path} ${serializeValue(value)}`);
|
|
91
|
+
case 'ge':
|
|
92
|
+
return (value) => createCondition(`ge ${path} ${serializeValue(value)}`);
|
|
93
|
+
case 'lt':
|
|
94
|
+
return (value) => createCondition(`lt ${path} ${serializeValue(value)}`);
|
|
95
|
+
case 'le':
|
|
96
|
+
return (value) => createCondition(`le ${path} ${serializeValue(value)}`);
|
|
97
|
+
case 'not':
|
|
98
|
+
return () => createCondition(`not ${path}`);
|
|
99
|
+
case 'and':
|
|
100
|
+
return (other) => createCondition(`and ${path} (${other.__condition})`);
|
|
101
|
+
case 'or':
|
|
102
|
+
return (other) => createCondition(`or ${path} (${other.__condition})`);
|
|
103
|
+
case 'default':
|
|
104
|
+
return (defaultValue) => createHelmValueProxy(`${path} | default ${serializeValue(defaultValue)}`);
|
|
105
|
+
case 'quote':
|
|
106
|
+
return () => createHelmValueProxy(`(${path} | quote)`);
|
|
107
|
+
case 'upper':
|
|
108
|
+
return () => createHelmValueProxy(`(${path} | upper)`);
|
|
109
|
+
case 'lower':
|
|
110
|
+
return () => createHelmValueProxy(`(${path} | lower)`);
|
|
111
|
+
case 'title':
|
|
112
|
+
return () => createHelmValueProxy(`(${path} | title)`);
|
|
113
|
+
case 'trim':
|
|
114
|
+
return () => createHelmValueProxy(`(${path} | trim)`);
|
|
115
|
+
case 'trimPrefix':
|
|
116
|
+
return (prefix) => createHelmValueProxy(`(${path} | trimPrefix ${helmStringLiteral(prefix)})`);
|
|
117
|
+
case 'trimSuffix':
|
|
118
|
+
return (suffix) => createHelmValueProxy(`(${path} | trimSuffix ${helmStringLiteral(suffix)})`);
|
|
119
|
+
case 'replace':
|
|
120
|
+
return (old, newStr) => createHelmValueProxy(`(${path} | replace ${helmStringLiteral(old)} ${helmStringLiteral(newStr)})`);
|
|
121
|
+
case 'contains':
|
|
122
|
+
return (substr) => createCondition(`contains ${helmStringLiteral(substr)} ${path}`);
|
|
123
|
+
case 'hasPrefix':
|
|
124
|
+
return (prefix) => createCondition(`hasPrefix ${helmStringLiteral(prefix)} ${path}`);
|
|
125
|
+
case 'hasSuffix':
|
|
126
|
+
return (suffix) => createCondition(`hasSuffix ${helmStringLiteral(suffix)} ${path}`);
|
|
127
|
+
case 'trunc':
|
|
128
|
+
return (length) => createHelmValueProxy(`(${path} | trunc ${length})`);
|
|
129
|
+
case 'kindIs':
|
|
130
|
+
return (kind) => createCondition(`kindIs ${helmStringLiteral(kind)} ${path}`);
|
|
131
|
+
case 'hasKey':
|
|
132
|
+
return (key) => createCondition(`hasKey ${path} ${helmStringLiteral(key)}`);
|
|
133
|
+
case 'toYaml':
|
|
134
|
+
return () => createHelmValueProxy(`${path} | toYaml`);
|
|
135
|
+
case 'toJson':
|
|
136
|
+
return () => createHelmValueProxy(`${path} | toJson`);
|
|
137
|
+
case 'nindent':
|
|
138
|
+
return (spaces) => createHelmValueProxy(`${path} | nindent ${spaces}`);
|
|
139
|
+
case 'indent':
|
|
140
|
+
return (spaces) => createHelmValueProxy(`${path} | indent ${spaces}`);
|
|
141
|
+
case 'toExpression':
|
|
142
|
+
return () => createHelmExpression(`{{ ${path} }}`);
|
|
143
|
+
case 'if':
|
|
144
|
+
return (condition, thenValue) => {
|
|
145
|
+
const helmCondition = isHelmCondition(condition)
|
|
146
|
+
? condition
|
|
147
|
+
: isHelmValue(condition)
|
|
148
|
+
? createCondition(condition.__path)
|
|
149
|
+
: undefined;
|
|
150
|
+
if (!helmCondition) {
|
|
151
|
+
throw new Error('v.if() requires a HelmCondition or HelmValue as the first argument');
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
__helmFieldConditional: true,
|
|
155
|
+
condition: helmCondition,
|
|
156
|
+
thenValue,
|
|
184
157
|
};
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
158
|
+
};
|
|
159
|
+
case 'ifElse':
|
|
160
|
+
return (condition, thenValue, elseValue) => createHelmValueProxy(`(ternary ${serializeValue(thenValue)} ${serializeValue(elseValue)} (${condition.__condition}))`);
|
|
161
|
+
case 'range':
|
|
162
|
+
return (callback) => ({
|
|
163
|
+
__helmRange: true,
|
|
164
|
+
source: createHelmValueProxy(path),
|
|
165
|
+
callback,
|
|
166
|
+
});
|
|
167
|
+
case 'with':
|
|
168
|
+
return (callback) => ({
|
|
169
|
+
__helmWith: true,
|
|
170
|
+
source: createHelmValueProxy(path),
|
|
171
|
+
callback,
|
|
172
|
+
});
|
|
173
|
+
case 'toString':
|
|
174
|
+
return () => `{{ ${path} }}`;
|
|
175
|
+
case 'valueOf':
|
|
176
|
+
return () => path;
|
|
177
|
+
default:
|
|
178
|
+
return createHelmValueProxy(appendPropertyPath(path, prop));
|
|
192
179
|
}
|
|
193
|
-
return undefined;
|
|
194
180
|
},
|
|
195
181
|
};
|
|
196
182
|
return new Proxy(baseObject, handler);
|
|
197
183
|
}
|
|
184
|
+
/** Creates a type-safe reference tree rooted at `.Values`. */
|
|
198
185
|
export function valuesRef() {
|
|
199
|
-
const values =
|
|
186
|
+
const values = createHelmValueProxy('.Values');
|
|
200
187
|
const helpers = {
|
|
188
|
+
/** Implement the root Helm `include` helper. */
|
|
201
189
|
include(templateName, context = '.') {
|
|
202
190
|
const ctx = context === '.' ? '.' : context.__path;
|
|
203
|
-
return
|
|
191
|
+
return createHelmValueProxy(`(include ${helmStringLiteral(templateName)} ${ctx})`);
|
|
204
192
|
},
|
|
193
|
+
/** Implement the root Helm `printf` helper. */
|
|
205
194
|
printf(format, ...args) {
|
|
206
|
-
const argsStr = args
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
return createValueProxy(`(printf "${format}" ${argsStr})`);
|
|
195
|
+
const argsStr = args.map((arg) => serializeValue(arg)).join(' ');
|
|
196
|
+
const suffix = argsStr ? ` ${argsStr}` : '';
|
|
197
|
+
return createHelmValueProxy(`(printf ${helmStringLiteral(format)}${suffix})`);
|
|
210
198
|
},
|
|
211
199
|
release: {
|
|
212
|
-
name:
|
|
213
|
-
namespace:
|
|
214
|
-
service:
|
|
215
|
-
isUpgrade:
|
|
216
|
-
isInstall:
|
|
217
|
-
revision:
|
|
200
|
+
name: createHelmValueProxy('.Release.Name'),
|
|
201
|
+
namespace: createHelmValueProxy('.Release.Namespace'),
|
|
202
|
+
service: createHelmValueProxy('.Release.Service'),
|
|
203
|
+
isUpgrade: createHelmValueProxy('.Release.IsUpgrade'),
|
|
204
|
+
isInstall: createHelmValueProxy('.Release.IsInstall'),
|
|
205
|
+
revision: createHelmValueProxy('.Release.Revision'),
|
|
218
206
|
},
|
|
219
207
|
chart: {
|
|
220
|
-
name:
|
|
221
|
-
version:
|
|
222
|
-
appVersion:
|
|
223
|
-
type:
|
|
208
|
+
name: createHelmValueProxy('.Chart.Name'),
|
|
209
|
+
version: createHelmValueProxy('.Chart.Version'),
|
|
210
|
+
appVersion: createHelmValueProxy('.Chart.AppVersion'),
|
|
211
|
+
type: createHelmValueProxy('.Chart.Type'),
|
|
224
212
|
},
|
|
225
213
|
capabilities: {
|
|
226
214
|
kubeVersion: {
|
|
227
|
-
version:
|
|
228
|
-
major:
|
|
229
|
-
minor:
|
|
215
|
+
version: createHelmValueProxy('.Capabilities.KubeVersion.Version'),
|
|
216
|
+
major: createHelmValueProxy('.Capabilities.KubeVersion.Major'),
|
|
217
|
+
minor: createHelmValueProxy('.Capabilities.KubeVersion.Minor'),
|
|
230
218
|
},
|
|
231
219
|
apiVersions: {
|
|
220
|
+
/** Test `.Capabilities.APIVersions` for an advertised API. */
|
|
232
221
|
has(apiVersion) {
|
|
233
|
-
return createCondition(`.Capabilities.APIVersions.Has
|
|
222
|
+
return createCondition(`.Capabilities.APIVersions.Has ${helmStringLiteral(apiVersion)}`);
|
|
234
223
|
},
|
|
235
224
|
},
|
|
236
225
|
},
|
|
226
|
+
/** Build a condition from a caller-supplied Helm condition body. */
|
|
237
227
|
rawCondition(condition) {
|
|
238
228
|
return createCondition(condition);
|
|
239
229
|
},
|
|
240
230
|
};
|
|
241
231
|
return new Proxy(values, {
|
|
232
|
+
/** Route reserved root helper names before delegating to the values proxy. */
|
|
242
233
|
get(target, prop) {
|
|
243
|
-
if (prop
|
|
244
|
-
return helpers
|
|
234
|
+
if (Object.prototype.hasOwnProperty.call(helpers, prop)) {
|
|
235
|
+
return Reflect.get(helpers, prop);
|
|
245
236
|
}
|
|
246
|
-
return target
|
|
237
|
+
return Reflect.get(target, prop);
|
|
247
238
|
},
|
|
248
239
|
});
|
|
249
240
|
}
|
|
241
|
+
/** Check if a value is a Helm value proxy. */
|
|
250
242
|
export function isHelmValue(value) {
|
|
251
243
|
return typeof value === 'object' && value !== null && HELM_VALUE_SYMBOL in value;
|
|
252
244
|
}
|
|
245
|
+
/** Check if a value is a Helm condition. */
|
|
253
246
|
export function isHelmCondition(value) {
|
|
254
247
|
return (typeof value === 'object' &&
|
|
255
248
|
value !== null &&
|
|
256
249
|
HELM_VALUE_SYMBOL in value &&
|
|
257
250
|
'__condition' in value);
|
|
258
251
|
}
|
|
252
|
+
/** Check if a value is a field-level conditional. */
|
|
259
253
|
export function isHelmFieldConditional(value) {
|
|
260
254
|
return typeof value === 'object' && value !== null && '__helmFieldConditional' in value;
|
|
261
255
|
}
|
|
256
|
+
/** Check if a value is a range block. */
|
|
262
257
|
export function isHelmRange(value) {
|
|
263
258
|
return typeof value === 'object' && value !== null && '__helmRange' in value;
|
|
264
259
|
}
|
|
260
|
+
/** Check if a value is a with block. */
|
|
265
261
|
export function isHelmWith(value) {
|
|
266
262
|
return typeof value === 'object' && value !== null && '__helmWith' in value;
|
|
267
263
|
}
|
|
264
|
+
/** Serialize a Helm value reference to template syntax. */
|
|
268
265
|
export function serializeHelmValue(value) {
|
|
269
266
|
return `{{ ${value.__path} }}`;
|
|
270
267
|
}
|
|
268
|
+
/** Serialize a Helm condition body. */
|
|
271
269
|
export function serializeHelmCondition(condition) {
|
|
272
270
|
return condition.__condition;
|
|
273
271
|
}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Input validation utilities for the Policy Engine
|
|
3
|
+
* Provides comprehensive validation for all user inputs to prevent
|
|
4
|
+
* injection attacks and malformed data processing
|
|
5
|
+
*/
|
|
1
6
|
import type { PolicyConfig, PolicyContext, PolicyRule, PluginConfig } from '../../types/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Validation configuration options
|
|
9
|
+
*/
|
|
2
10
|
export interface ValidationOptions {
|
|
3
11
|
maxStringLength?: number;
|
|
4
12
|
maxArrayLength?: number;
|
|
@@ -6,20 +14,57 @@ export interface ValidationOptions {
|
|
|
6
14
|
allowedProtocols?: string[];
|
|
7
15
|
sanitizeStrings?: boolean;
|
|
8
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Input validator class for policy engine inputs
|
|
19
|
+
*/
|
|
9
20
|
export declare class InputValidator {
|
|
10
21
|
private options;
|
|
11
22
|
constructor(options?: ValidationOptions);
|
|
23
|
+
/**
|
|
24
|
+
* Validates a PolicyConfig object
|
|
25
|
+
*/
|
|
12
26
|
validatePolicyConfig(config: unknown): PolicyConfig;
|
|
27
|
+
/**
|
|
28
|
+
* Validates a PolicyRule object
|
|
29
|
+
*/
|
|
13
30
|
validatePolicyRule(rule: unknown): PolicyRule;
|
|
31
|
+
/**
|
|
32
|
+
* Validates a PolicyContext object
|
|
33
|
+
*/
|
|
14
34
|
validatePolicyContext(context: unknown): PolicyContext;
|
|
35
|
+
/**
|
|
36
|
+
* Validates a PluginConfig object
|
|
37
|
+
*/
|
|
15
38
|
validatePluginConfig(config: unknown): PluginConfig;
|
|
39
|
+
/**
|
|
40
|
+
* Validates string length against maximum allowed
|
|
41
|
+
*/
|
|
16
42
|
private validateStringLength;
|
|
43
|
+
/**
|
|
44
|
+
* Validates array length against maximum allowed
|
|
45
|
+
*/
|
|
17
46
|
private validateArrayLength;
|
|
47
|
+
/**
|
|
48
|
+
* Validates object depth to prevent deeply nested objects
|
|
49
|
+
*/
|
|
18
50
|
private validateObjectDepth;
|
|
51
|
+
/**
|
|
52
|
+
* Sanitizes a string by removing potentially dangerous characters
|
|
53
|
+
* Focuses on policy configuration validation, not HTML sanitization
|
|
54
|
+
*/
|
|
19
55
|
private sanitizeString;
|
|
56
|
+
/**
|
|
57
|
+
* Sanitizes an object recursively
|
|
58
|
+
*/
|
|
20
59
|
private sanitizeObject;
|
|
21
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Default input validator instance
|
|
63
|
+
*/
|
|
22
64
|
export declare const defaultValidator: InputValidator;
|
|
65
|
+
/**
|
|
66
|
+
* Convenience functions for common validation scenarios
|
|
67
|
+
*/
|
|
23
68
|
export declare const validatePolicyConfig: (config: unknown) => PolicyConfig;
|
|
24
69
|
export declare const validatePolicyRule: (rule: unknown) => PolicyRule;
|
|
25
70
|
export declare const validatePolicyContext: (context: unknown) => PolicyContext;
|