pepr 0.31.1 → 0.32.1
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/package.json +6 -6
- package/src/lib/assets/helm.ts +18 -0
- package/src/lib/assets/index.ts +3 -1
- package/src/lib/assets/yaml.ts +35 -0
- package/src/lib/controller/index.ts +3 -3
- package/src/lib/controller/store.ts +7 -3
- package/src/lib/mutate-processor.ts +17 -6
- package/src/runtime/controller.ts +2 -2
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -2786
- package/dist/controller.js +0 -164
- package/dist/lib/assets/deploy.d.ts +0 -3
- package/dist/lib/assets/deploy.d.ts.map +0 -1
- package/dist/lib/assets/destroy.d.ts +0 -2
- package/dist/lib/assets/destroy.d.ts.map +0 -1
- package/dist/lib/assets/helm.d.ts +0 -5
- package/dist/lib/assets/helm.d.ts.map +0 -1
- package/dist/lib/assets/index.d.ts +0 -24
- package/dist/lib/assets/index.d.ts.map +0 -1
- package/dist/lib/assets/loader.d.ts +0 -8
- package/dist/lib/assets/loader.d.ts.map +0 -1
- package/dist/lib/assets/networking.d.ts +0 -7
- package/dist/lib/assets/networking.d.ts.map +0 -1
- package/dist/lib/assets/pods.d.ts +0 -126
- package/dist/lib/assets/pods.d.ts.map +0 -1
- package/dist/lib/assets/rbac.d.ts +0 -14
- package/dist/lib/assets/rbac.d.ts.map +0 -1
- package/dist/lib/assets/store.d.ts +0 -7
- package/dist/lib/assets/store.d.ts.map +0 -1
- package/dist/lib/assets/webhooks.d.ts +0 -6
- package/dist/lib/assets/webhooks.d.ts.map +0 -1
- package/dist/lib/assets/yaml.d.ts +0 -5
- package/dist/lib/assets/yaml.d.ts.map +0 -1
- package/dist/lib/capability.d.ts +0 -66
- package/dist/lib/capability.d.ts.map +0 -1
- package/dist/lib/controller/index.d.ts +0 -10
- package/dist/lib/controller/index.d.ts.map +0 -1
- package/dist/lib/controller/store.d.ts +0 -7
- package/dist/lib/controller/store.d.ts.map +0 -1
- package/dist/lib/errors.d.ts +0 -12
- package/dist/lib/errors.d.ts.map +0 -1
- package/dist/lib/filter.d.ts +0 -11
- package/dist/lib/filter.d.ts.map +0 -1
- package/dist/lib/helpers.d.ts +0 -34
- package/dist/lib/helpers.d.ts.map +0 -1
- package/dist/lib/included-files.d.ts +0 -2
- package/dist/lib/included-files.d.ts.map +0 -1
- package/dist/lib/k8s.d.ts +0 -132
- package/dist/lib/k8s.d.ts.map +0 -1
- package/dist/lib/logger.d.ts +0 -3
- package/dist/lib/logger.d.ts.map +0 -1
- package/dist/lib/metrics.d.ts +0 -39
- package/dist/lib/metrics.d.ts.map +0 -1
- package/dist/lib/module.d.ts +0 -62
- package/dist/lib/module.d.ts.map +0 -1
- package/dist/lib/mutate-processor.d.ts +0 -5
- package/dist/lib/mutate-processor.d.ts.map +0 -1
- package/dist/lib/mutate-request.d.ts +0 -79
- package/dist/lib/mutate-request.d.ts.map +0 -1
- package/dist/lib/queue.d.ts +0 -19
- package/dist/lib/queue.d.ts.map +0 -1
- package/dist/lib/schedule.d.ts +0 -76
- package/dist/lib/schedule.d.ts.map +0 -1
- package/dist/lib/storage.d.ts +0 -83
- package/dist/lib/storage.d.ts.map +0 -1
- package/dist/lib/tls.d.ts +0 -18
- package/dist/lib/tls.d.ts.map +0 -1
- package/dist/lib/types.d.ts +0 -192
- package/dist/lib/types.d.ts.map +0 -1
- package/dist/lib/utils.d.ts +0 -23
- package/dist/lib/utils.d.ts.map +0 -1
- package/dist/lib/validate-processor.d.ts +0 -4
- package/dist/lib/validate-processor.d.ts.map +0 -1
- package/dist/lib/validate-request.d.ts +0 -55
- package/dist/lib/validate-request.d.ts.map +0 -1
- package/dist/lib/watch-processor.d.ts +0 -10
- package/dist/lib/watch-processor.d.ts.map +0 -1
- package/dist/lib.d.ts +0 -11
- package/dist/lib.d.ts.map +0 -1
- package/dist/lib.js +0 -1794
- package/dist/lib.js.map +0 -7
- package/dist/runtime/controller.d.ts +0 -3
- package/dist/runtime/controller.d.ts.map +0 -1
- package/dist/sdk/sdk.d.ts +0 -38
- package/dist/sdk/sdk.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"engines": {
|
|
10
10
|
"node": ">=18.0.0"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.
|
|
12
|
+
"version": "0.32.1",
|
|
13
13
|
"main": "dist/lib.js",
|
|
14
14
|
"types": "dist/lib.d.ts",
|
|
15
15
|
"scripts": {
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"@types/ramda": "0.30.0",
|
|
36
36
|
"express": "4.19.2",
|
|
37
37
|
"fast-json-patch": "3.1.1",
|
|
38
|
-
"kubernetes-fluent-client": "2.6.
|
|
39
|
-
"pino": "9.
|
|
40
|
-
"pino-pretty": "11.
|
|
38
|
+
"kubernetes-fluent-client": "2.6.1",
|
|
39
|
+
"pino": "9.2.0",
|
|
40
|
+
"pino-pretty": "11.2.1",
|
|
41
41
|
"prom-client": "15.1.2",
|
|
42
|
-
"ramda": "0.30.
|
|
42
|
+
"ramda": "0.30.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@commitlint/cli": "19.3.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@types/uuid": "9.0.8",
|
|
54
54
|
"jest": "29.7.0",
|
|
55
55
|
"nock": "13.5.4",
|
|
56
|
-
"ts-jest": "29.1.
|
|
56
|
+
"ts-jest": "29.1.4"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@typescript-eslint/eslint-plugin": "6.15.0",
|
package/src/lib/assets/helm.ts
CHANGED
|
@@ -70,6 +70,9 @@ export function watcherDeployTemplate(buildTimestamp: string) {
|
|
|
70
70
|
metadata:
|
|
71
71
|
annotations:
|
|
72
72
|
buildTimestamp: "${buildTimestamp}"
|
|
73
|
+
{{- if .Values.watcher.podAnnotations }}
|
|
74
|
+
{{- toYaml .Values.watcher.podAnnotations | nindent 8 }}
|
|
75
|
+
{{- end }}
|
|
73
76
|
labels:
|
|
74
77
|
app: {{ .Values.uuid }}-watcher
|
|
75
78
|
pepr.dev/controller: watcher
|
|
@@ -111,6 +114,9 @@ export function watcherDeployTemplate(buildTimestamp: string) {
|
|
|
111
114
|
- name: module
|
|
112
115
|
mountPath: /app/load
|
|
113
116
|
readOnly: true
|
|
117
|
+
{{- if .Values.watcher.extraVolumeMounts }}
|
|
118
|
+
{{- toYaml .Values.watcher.extraVolumeMounts | nindent 12 }}
|
|
119
|
+
{{- end }}
|
|
114
120
|
volumes:
|
|
115
121
|
- name: tls-certs
|
|
116
122
|
secret:
|
|
@@ -118,6 +124,9 @@ export function watcherDeployTemplate(buildTimestamp: string) {
|
|
|
118
124
|
- name: module
|
|
119
125
|
secret:
|
|
120
126
|
secretName: {{ .Values.uuid }}-module
|
|
127
|
+
{{- if .Values.watcher.extraVolumes }}
|
|
128
|
+
{{- toYaml .Values.watcher.extraVolumes | nindent 8 }}
|
|
129
|
+
{{- end }}
|
|
121
130
|
`;
|
|
122
131
|
}
|
|
123
132
|
|
|
@@ -142,6 +151,9 @@ export function admissionDeployTemplate(buildTimestamp: string) {
|
|
|
142
151
|
metadata:
|
|
143
152
|
annotations:
|
|
144
153
|
buildTimestamp: "${buildTimestamp}"
|
|
154
|
+
{{- if .Values.admission.podAnnotations }}
|
|
155
|
+
{{- toYaml .Values.admission.podAnnotations | nindent 8 }}
|
|
156
|
+
{{- end }}
|
|
145
157
|
labels:
|
|
146
158
|
app: {{ .Values.uuid }}
|
|
147
159
|
pepr.dev/controller: admission
|
|
@@ -187,6 +199,9 @@ export function admissionDeployTemplate(buildTimestamp: string) {
|
|
|
187
199
|
- name: module
|
|
188
200
|
mountPath: /app/load
|
|
189
201
|
readOnly: true
|
|
202
|
+
{{- if .Values.admission.extraVolumeMounts }}
|
|
203
|
+
{{- toYaml .Values.admission.extraVolumeMounts | nindent 12 }}
|
|
204
|
+
{{- end }}
|
|
190
205
|
volumes:
|
|
191
206
|
- name: tls-certs
|
|
192
207
|
secret:
|
|
@@ -197,5 +212,8 @@ export function admissionDeployTemplate(buildTimestamp: string) {
|
|
|
197
212
|
- name: module
|
|
198
213
|
secret:
|
|
199
214
|
secretName: {{ .Values.uuid }}-module
|
|
215
|
+
{{- if .Values.admission.extraVolumes }}
|
|
216
|
+
{{- toYaml .Values.admission.extraVolumes | nindent 8 }}
|
|
217
|
+
{{- end }}
|
|
200
218
|
`;
|
|
201
219
|
}
|
package/src/lib/assets/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { CapabilityExport } from "../types";
|
|
|
9
9
|
import { WebhookIgnore } from "../k8s";
|
|
10
10
|
import { deploy } from "./deploy";
|
|
11
11
|
import { loadCapabilities } from "./loader";
|
|
12
|
-
import { allYaml, zarfYaml, overridesFile } from "./yaml";
|
|
12
|
+
import { allYaml, zarfYaml, overridesFile, zarfYamlChart } from "./yaml";
|
|
13
13
|
import { namespaceComplianceValidator, replaceString } from "../helpers";
|
|
14
14
|
import { createDirectoryIfNotExists, dedent } from "../helpers";
|
|
15
15
|
import { resolve } from "path";
|
|
@@ -59,6 +59,8 @@ export class Assets {
|
|
|
59
59
|
|
|
60
60
|
zarfYaml = (path: string) => zarfYaml(this, path);
|
|
61
61
|
|
|
62
|
+
zarfYamlChart = (path: string) => zarfYamlChart(this, path);
|
|
63
|
+
|
|
62
64
|
allYaml = async (rbacMode: string) => {
|
|
63
65
|
this.capabilities = await loadCapabilities(this.path);
|
|
64
66
|
// give error if namespaces are not respected
|
package/src/lib/assets/yaml.ts
CHANGED
|
@@ -68,8 +68,11 @@ export async function overridesFile({ hash, name, image, config, apiToken }: Ass
|
|
|
68
68
|
drop: ["ALL"],
|
|
69
69
|
},
|
|
70
70
|
},
|
|
71
|
+
podAnnotations: {},
|
|
71
72
|
nodeSelector: {},
|
|
72
73
|
tolerations: [],
|
|
74
|
+
extraVolumeMounts: [],
|
|
75
|
+
extraVolumes: [],
|
|
73
76
|
affinity: {},
|
|
74
77
|
},
|
|
75
78
|
watcher: {
|
|
@@ -115,7 +118,10 @@ export async function overridesFile({ hash, name, image, config, apiToken }: Ass
|
|
|
115
118
|
},
|
|
116
119
|
nodeSelector: {},
|
|
117
120
|
tolerations: [],
|
|
121
|
+
extraVolumeMounts: [],
|
|
122
|
+
extraVolumes: [],
|
|
118
123
|
affinity: {},
|
|
124
|
+
podAnnotations: {},
|
|
119
125
|
},
|
|
120
126
|
};
|
|
121
127
|
if (process.env.PEPR_MODE === "dev") {
|
|
@@ -155,6 +161,35 @@ export function zarfYaml({ name, image, config }: Assets, path: string) {
|
|
|
155
161
|
return dumpYaml(zarfCfg, { noRefs: true });
|
|
156
162
|
}
|
|
157
163
|
|
|
164
|
+
export function zarfYamlChart({ name, image, config }: Assets, path: string) {
|
|
165
|
+
const zarfCfg = {
|
|
166
|
+
kind: "ZarfPackageConfig",
|
|
167
|
+
metadata: {
|
|
168
|
+
name,
|
|
169
|
+
description: `Pepr Module: ${config.description}`,
|
|
170
|
+
url: "https://github.com/defenseunicorns/pepr",
|
|
171
|
+
version: `${config.appVersion || "0.0.1"}`,
|
|
172
|
+
},
|
|
173
|
+
components: [
|
|
174
|
+
{
|
|
175
|
+
name: "module",
|
|
176
|
+
required: true,
|
|
177
|
+
charts: [
|
|
178
|
+
{
|
|
179
|
+
name: "module",
|
|
180
|
+
namespace: "pepr-system",
|
|
181
|
+
version: `${config.appVersion || "0.0.1"}`,
|
|
182
|
+
localPath: path,
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
images: [image],
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
return dumpYaml(zarfCfg, { noRefs: true });
|
|
191
|
+
}
|
|
192
|
+
|
|
158
193
|
export async function allYaml(assets: Assets, rbacMode: string) {
|
|
159
194
|
const { name, tls, apiToken, path } = assets;
|
|
160
195
|
|
|
@@ -182,7 +182,7 @@ export class Controller {
|
|
|
182
182
|
try {
|
|
183
183
|
res.send(await this.#metricsCollector.getMetrics());
|
|
184
184
|
} catch (err) {
|
|
185
|
-
Log.error(err);
|
|
185
|
+
Log.error(err, `Error getting metrics`);
|
|
186
186
|
res.status(500).send("Internal Server Error");
|
|
187
187
|
}
|
|
188
188
|
};
|
|
@@ -277,7 +277,7 @@ export class Controller {
|
|
|
277
277
|
|
|
278
278
|
this.#metricsCollector.observeEnd(startTime, admissionKind);
|
|
279
279
|
} catch (err) {
|
|
280
|
-
Log.error(err);
|
|
280
|
+
Log.error(err, `Error processing ${admissionKind} request`);
|
|
281
281
|
res.status(500).send("Internal Server Error");
|
|
282
282
|
this.#metricsCollector.error();
|
|
283
283
|
}
|
|
@@ -319,7 +319,7 @@ export class Controller {
|
|
|
319
319
|
try {
|
|
320
320
|
res.send("OK");
|
|
321
321
|
} catch (err) {
|
|
322
|
-
Log.error(err);
|
|
322
|
+
Log.error(err, `Error processing health check`);
|
|
323
323
|
res.status(500).send("Internal Server Error");
|
|
324
324
|
}
|
|
325
325
|
}
|
|
@@ -167,9 +167,13 @@ export class PeprControllerStore {
|
|
|
167
167
|
} catch (err) {
|
|
168
168
|
Log.error(err, "Pepr store update failure");
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
if (err.status === 422) {
|
|
171
|
+
Object.keys(sendCache).forEach(key => delete sendCache[key]);
|
|
172
|
+
} else {
|
|
173
|
+
// On failure to update, re-add the operations to the cache to be retried
|
|
174
|
+
for (const idx of indexes) {
|
|
175
|
+
sendCache[idx] = payload[Number(idx)];
|
|
176
|
+
}
|
|
173
177
|
}
|
|
174
178
|
}
|
|
175
179
|
};
|
|
@@ -84,22 +84,33 @@ export async function mutateProcessor(
|
|
|
84
84
|
// Add annotations to the request to indicate that the capability succeeded
|
|
85
85
|
updateStatus("succeeded");
|
|
86
86
|
} catch (e) {
|
|
87
|
-
Log.warn(actionMetadata, `Action failed: ${e}`);
|
|
88
87
|
updateStatus("warning");
|
|
89
|
-
|
|
90
|
-
// Annoying ts false positive
|
|
91
88
|
response.warnings = response.warnings || [];
|
|
92
|
-
|
|
89
|
+
|
|
90
|
+
let errorMessage = "";
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
if (e.message && e.message !== "[object Object]") {
|
|
94
|
+
errorMessage = e.message;
|
|
95
|
+
} else {
|
|
96
|
+
throw new Error("An error occurred in the mutate action.");
|
|
97
|
+
}
|
|
98
|
+
} catch (e) {
|
|
99
|
+
errorMessage = "An error occurred with the mutate action.";
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
Log.error(actionMetadata, `Action failed: ${errorMessage}`);
|
|
103
|
+
response.warnings.push(`Action failed: ${errorMessage}`);
|
|
93
104
|
|
|
94
105
|
switch (config.onError) {
|
|
95
106
|
case Errors.reject:
|
|
96
|
-
Log.error(actionMetadata, `Action failed: ${
|
|
107
|
+
Log.error(actionMetadata, `Action failed: ${errorMessage}`);
|
|
97
108
|
response.result = "Pepr module configured to reject on error";
|
|
98
109
|
return response;
|
|
99
110
|
|
|
100
111
|
case Errors.audit:
|
|
101
112
|
response.auditAnnotations = response.auditAnnotations || {};
|
|
102
|
-
response.auditAnnotations[Date.now()] =
|
|
113
|
+
response.auditAnnotations[Date.now()] = `Action failed: ${errorMessage}`;
|
|
103
114
|
break;
|
|
104
115
|
}
|
|
105
116
|
}
|
|
@@ -67,9 +67,9 @@ const startup = async () => {
|
|
|
67
67
|
validateHash(hash);
|
|
68
68
|
runModule(hash);
|
|
69
69
|
} catch (err) {
|
|
70
|
-
Log.error(err);
|
|
70
|
+
Log.error(err, `Error starting Pepr Store CRD`);
|
|
71
71
|
process.exit(1);
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
startup().catch(err => Log.error(err));
|
|
75
|
+
startup().catch(err => Log.error(err, `Error starting Pepr Controller`));
|
package/dist/cli.d.ts
DELETED
package/dist/cli.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|