@catladder/cli 0.0.0-next-52feb889 → 0.0.0-next-c177efda
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/dist/bundles/catci/index.js +19 -0
- package/dist/bundles/catenv/index.js +88 -13
- package/dist/bundles/cli/index.js +88 -13
- package/dist/bundles/runner-images/semantic-release/Dockerfile +2 -7
- package/dist/bundles/runner-images/semantic-release/scripts/semanticRelease +18 -1
- package/dist/bundles/runner-images/semantic-release-central.Dockerfile +34 -0
- package/dist/cli/src/catci.d.ts +1 -0
- package/dist/cli/src/catci.js +100 -0
- package/dist/cli/src/catci.js.map +1 -0
- package/dist/pipeline/src/backends/github/GithubBackend.js +4 -1
- package/dist/pipeline/src/backends/github/GithubBackend.js.map +1 -1
- package/dist/pipeline/src/backends/gitlab/GitlabBackend.js +9 -2
- package/dist/pipeline/src/backends/gitlab/GitlabBackend.js.map +1 -1
- package/dist/pipeline/src/backends/gitlab/gitlabReleaseJobs.d.ts +2 -1
- package/dist/pipeline/src/backends/gitlab/gitlabReleaseJobs.js +11 -4
- package/dist/pipeline/src/backends/gitlab/gitlabReleaseJobs.js.map +1 -1
- package/dist/pipeline/src/bash/bashEscape.js +5 -1
- package/dist/pipeline/src/bash/bashEscape.js.map +1 -1
- package/dist/pipeline/src/build/types.d.ts +1 -1
- package/dist/pipeline/src/catci/shippedCatci.d.ts +8 -0
- package/dist/pipeline/src/catci/shippedCatci.js +39 -0
- package/dist/pipeline/src/catci/shippedCatci.js.map +1 -0
- package/dist/pipeline/src/constants.js +1 -1
- package/dist/pipeline/src/context/getEnvironmentVariables.d.ts +1 -1
- package/dist/pipeline/src/customImages/shippedImages.d.ts +5 -3
- package/dist/pipeline/src/customImages/shippedImages.js +6 -4
- package/dist/pipeline/src/customImages/shippedImages.js.map +1 -1
- package/dist/pipeline/src/deploy/types/index.d.ts +2 -2
- package/dist/pipeline/src/pipeline/generatePipelineFiles.js +6 -0
- package/dist/pipeline/src/pipeline/generatePipelineFiles.js.map +1 -1
- package/dist/pipeline/src/types/config.d.ts +3 -3
- package/dist/runner-images/semantic-release/Dockerfile +2 -7
- package/dist/runner-images/semantic-release/scripts/semanticRelease +18 -1
- package/dist/runner-images/semantic-release-central.Dockerfile +34 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/scripts/bundle +4 -0
- package/src/catci.ts +123 -0
package/package.json
CHANGED
package/scripts/bundle
CHANGED
|
@@ -2,3 +2,7 @@
|
|
|
2
2
|
ncc build dist/cli/src/catenv.js -o dist/bundles/catenv $( ((SHOULD_MINIFY == 1)) && printf %s '-m')
|
|
3
3
|
|
|
4
4
|
ncc build dist/cli/src/cli.js -o dist/bundles/cli $( ((SHOULD_MINIFY == 1)) && printf %s '-m')
|
|
5
|
+
|
|
6
|
+
# catci: minimal CI companion, materialized into .catladder-generated by
|
|
7
|
+
# pipeline generation (always minified — it is committed to consumer repos)
|
|
8
|
+
ncc build dist/cli/src/catci.js -o dist/bundles/catci -m --no-source-map-register
|
package/src/catci.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* catci — catladder's CI companion.
|
|
3
|
+
*
|
|
4
|
+
* A minimal, treeshaken bundle of the CLI commands that CI jobs need.
|
|
5
|
+
* It is materialized into `.catladder-generated/catci/` by pipeline
|
|
6
|
+
* generation, so jobs can run it with plain `node` — always the exact
|
|
7
|
+
* version that generated the pipeline, with no install step and no
|
|
8
|
+
* catladder baked into job images.
|
|
9
|
+
*
|
|
10
|
+
* Deliberately no CLI framework: the surface is tiny and the callers
|
|
11
|
+
* are generated scripts, not humans.
|
|
12
|
+
*/
|
|
13
|
+
import { Gitlab } from "@gitbeaker/rest";
|
|
14
|
+
import {
|
|
15
|
+
evaluateSecurityAudit,
|
|
16
|
+
makeSecurityAuditOverview,
|
|
17
|
+
} from "./security/evaluateSecurityAudit";
|
|
18
|
+
import {
|
|
19
|
+
createSecurityAuditMergeRequest,
|
|
20
|
+
SECURITY_AUDIT_FILE_NAME,
|
|
21
|
+
} from "./security/createSecurityAuditMergeRequest";
|
|
22
|
+
|
|
23
|
+
const GITLAB_HOST = "https://git.panter.ch";
|
|
24
|
+
|
|
25
|
+
const USAGE = `catci — catladder CI companion
|
|
26
|
+
|
|
27
|
+
usage:
|
|
28
|
+
catci security-audit ci-job <path> <gitlab-token> <main-branch> <project-id> <user-id>
|
|
29
|
+
evaluates ${SECURITY_AUDIT_FILE_NAME}; creates a gitlab MR with the
|
|
30
|
+
audit template when the document is missing (and exits 1)
|
|
31
|
+
|
|
32
|
+
catci security-audit check <path>
|
|
33
|
+
evaluates ${SECURITY_AUDIT_FILE_NAME}; exits 1 with instructions when
|
|
34
|
+
the document is missing or unanswered (no remediation — works on
|
|
35
|
+
any CI, including github)
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
const fail = (message: string): never => {
|
|
39
|
+
console.error(message);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* shared gate: evaluates the audit document and prints the overview.
|
|
45
|
+
* Returns null when the document could not be evaluated (missing or
|
|
46
|
+
* unparseable) so the caller can decide on remediation.
|
|
47
|
+
*/
|
|
48
|
+
const evaluateGate = async (path: string) => {
|
|
49
|
+
const evaluation = await evaluateSecurityAudit({ path });
|
|
50
|
+
if (evaluation.isErr()) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
if (evaluation.value.score.answeredTopics === 0) {
|
|
54
|
+
fail(
|
|
55
|
+
`audit document has no answered topics\n` +
|
|
56
|
+
`please answer security topics in ${SECURITY_AUDIT_FILE_NAME} by adding responsible people and check/cross in the table`,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
console.log(makeSecurityAuditOverview(evaluation.value));
|
|
60
|
+
return evaluation.value;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const securityAuditCheck = async (path: string) => {
|
|
64
|
+
const evaluation = await evaluateGate(path);
|
|
65
|
+
if (!evaluation) {
|
|
66
|
+
fail(
|
|
67
|
+
`could not evaluate ${SECURITY_AUDIT_FILE_NAME}\n` +
|
|
68
|
+
`please add a ${SECURITY_AUDIT_FILE_NAME} security audit document to the repository ` +
|
|
69
|
+
`(run \`catladder security audit create\` locally to generate the template)`,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const securityAuditCiJob = async (
|
|
75
|
+
path: string,
|
|
76
|
+
token: string,
|
|
77
|
+
mainBranch: string,
|
|
78
|
+
projectId: string,
|
|
79
|
+
userId: string,
|
|
80
|
+
) => {
|
|
81
|
+
const evaluation = await evaluateGate(path);
|
|
82
|
+
if (evaluation) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
console.log("could not evaluate security audit document");
|
|
86
|
+
console.log("creating new merge request with security audit template...");
|
|
87
|
+
|
|
88
|
+
const api = new Gitlab({ host: GITLAB_HOST, token });
|
|
89
|
+
const mr = await createSecurityAuditMergeRequest({
|
|
90
|
+
api,
|
|
91
|
+
mainBranch,
|
|
92
|
+
projectId,
|
|
93
|
+
userId: parseInt(userId),
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
if (mr.isErr()) {
|
|
97
|
+
fail(
|
|
98
|
+
`could not create merge request with security audit template: ${mr.error}`,
|
|
99
|
+
);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
console.log("security audit merge request created successfully");
|
|
103
|
+
console.log(
|
|
104
|
+
`please finish the MR by updating ${SECURITY_AUDIT_FILE_NAME}: ${mr.value.web_url}`,
|
|
105
|
+
);
|
|
106
|
+
process.exit(1);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const main = async () => {
|
|
110
|
+
const [group, command, ...args] = process.argv.slice(2);
|
|
111
|
+
if (group === "security-audit" && command === "ci-job" && args.length === 5) {
|
|
112
|
+
const [path, token, mainBranch, projectId, userId] = args;
|
|
113
|
+
return securityAuditCiJob(path, token, mainBranch, projectId, userId);
|
|
114
|
+
}
|
|
115
|
+
if (group === "security-audit" && command === "check" && args.length === 1) {
|
|
116
|
+
return securityAuditCheck(args[0]);
|
|
117
|
+
}
|
|
118
|
+
fail(USAGE);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
main().catch((error) => {
|
|
122
|
+
fail(`catci failed: ${error instanceof Error ? error.message : error}`);
|
|
123
|
+
});
|