@catladder/cli 0.0.0-refactor-cloud-run-825d7e86 → 0.0.0-refactore-catenv-command-validates-argument-78d05852
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/bin/catci +3 -0
- package/bin/catci-dev +3 -0
- package/dist/apps/catci/catci.d.ts +1 -0
- package/dist/apps/catci/catci.js +86 -0
- package/dist/apps/catci/catci.js.map +1 -0
- package/dist/apps/catci/commands/security/auditDocument.d.ts +19 -0
- package/dist/apps/catci/commands/security/auditDocument.js +90 -0
- package/dist/apps/catci/commands/security/auditDocument.js.map +1 -0
- package/dist/apps/catci/commands/security/commands.d.ts +2 -0
- package/dist/apps/catci/commands/security/commands.js +185 -0
- package/dist/apps/catci/commands/security/commands.js.map +1 -0
- package/dist/apps/catci/commands/security/createSecurityAuditMergeRequest.d.ts +9 -0
- package/dist/apps/catci/commands/security/createSecurityAuditMergeRequest.js +112 -0
- package/dist/apps/catci/commands/security/createSecurityAuditMergeRequest.js.map +1 -0
- package/dist/apps/catci/commands/security/evaluateSecurityAudit.d.ts +5 -0
- package/dist/apps/catci/commands/security/evaluateSecurityAudit.js +76 -0
- package/dist/apps/catci/commands/security/evaluateSecurityAudit.js.map +1 -0
- package/dist/apps/catci/commands/security/topics.json +112 -0
- package/dist/apps/catenv/catenv.d.ts +1 -2
- package/dist/apps/catenv/catenv.js +4 -2
- package/dist/apps/catenv/catenv.js.map +1 -1
- package/dist/apps/cli/commands/project/commandSecurityEvaluate.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandSecurityEvaluate.js +70 -0
- package/dist/apps/cli/commands/project/commandSecurityEvaluate.js.map +1 -0
- package/dist/apps/cli/commands/project/index.js +2 -0
- package/dist/apps/cli/commands/project/index.js.map +1 -1
- package/dist/bundles/catci/index.js +71390 -0
- package/dist/bundles/catenv/index.js +114 -47
- package/dist/bundles/cli/index.js +2195 -1063
- package/dist/catci.d.ts +1 -0
- package/dist/catci.js +5 -0
- package/dist/catci.js.map +1 -0
- package/dist/catenv.js +1 -3
- package/dist/catenv.js.map +1 -1
- package/dist/config/getProjectConfig.js +6 -9
- package/dist/config/getProjectConfig.js.map +1 -1
- package/dist/config/parseChoiceArgument.d.ts +13 -0
- package/dist/config/parseChoiceArgument.js +43 -0
- package/dist/config/parseChoiceArgument.js.map +1 -0
- package/dist/gcloud/serviceAccounts.js +3 -1
- package/dist/gcloud/serviceAccounts.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -5
- package/scripts/bundle +2 -0
- package/src/apps/catci/catci.ts +26 -0
- package/src/apps/catci/commands/security/auditDocument.ts +150 -0
- package/src/apps/catci/commands/security/commands.ts +161 -0
- package/src/apps/catci/commands/security/createSecurityAuditMergeRequest.ts +98 -0
- package/src/apps/catci/commands/security/evaluateSecurityAudit.ts +30 -0
- package/src/apps/catci/commands/security/topics.json +120 -0
- package/src/apps/catenv/catenv.ts +8 -6
- package/src/apps/cli/commands/project/commandSecurityEvaluate.ts +26 -0
- package/src/apps/cli/commands/project/index.ts +2 -0
- package/src/catci.ts +3 -0
- package/src/catenv.ts +2 -6
- package/src/config/getProjectConfig.ts +9 -11
- package/src/config/parseChoiceArgument.ts +50 -0
- package/src/gcloud/serviceAccounts.ts +2 -1
|
@@ -26,6 +26,7 @@ import commandTriggerCronjob from "./commandTriggerCronjob";
|
|
|
26
26
|
import commandOpenGrafanaPod from "./commandOpenGrafanaPod";
|
|
27
27
|
import commandSecretsClearBackups from "./commandSecretsClearBackups";
|
|
28
28
|
import commandProjectRestoreDb from "./cloudSql/commandProjectRestoreDb";
|
|
29
|
+
import commandSecurityEvaluate from "./commandSecurityEvaluate";
|
|
29
30
|
|
|
30
31
|
export default async (vorpal: Vorpal) => {
|
|
31
32
|
commandSetup(vorpal);
|
|
@@ -61,4 +62,5 @@ export default async (vorpal: Vorpal) => {
|
|
|
61
62
|
|
|
62
63
|
commandGetMyTotalWorktime(vorpal);
|
|
63
64
|
commandMigrateHelm3(vorpal);
|
|
65
|
+
commandSecurityEvaluate(vorpal);
|
|
64
66
|
};
|
package/src/catci.ts
ADDED
package/src/catenv.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import catenv from
|
|
1
|
+
import catenv from './apps/catenv/catenv';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const choice = process.argv[2] ? parseChoice(process.argv[2]) : null;
|
|
6
|
-
|
|
7
|
-
catenv(choice).then(() => {
|
|
3
|
+
catenv().then(() => {
|
|
8
4
|
// we have to exit manually, because we have some file watches
|
|
9
5
|
process.exit();
|
|
10
6
|
});
|
|
@@ -134,17 +134,15 @@ const resolveSecrets = async (
|
|
|
134
134
|
.map(([key, value]) => {
|
|
135
135
|
const secretKey = set.secretEnvVarKeys.find((k) => k.key === key);
|
|
136
136
|
|
|
137
|
-
if (secretKey) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
return [key, value];
|
|
137
|
+
if (secretKey?.hidden || value === undefined) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
for (const variable of allVariablesInGitlab) {
|
|
142
|
+
value = value.replace(
|
|
143
|
+
new RegExp("\\$" + variable.key, "g"),
|
|
144
|
+
variable.value
|
|
145
|
+
);
|
|
148
146
|
}
|
|
149
147
|
return [key, value];
|
|
150
148
|
})
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Config, EnvType } from '@catladder/pipeline';
|
|
2
|
+
import { ENV_TYPES, isKnowEnvType } from '@catladder/pipeline';
|
|
3
|
+
import type { Choice } from '../apps/catenv/types';
|
|
4
|
+
|
|
5
|
+
const envTypes = Object.keys(ENV_TYPES);
|
|
6
|
+
|
|
7
|
+
export const getEnvComponentArgument = (): {
|
|
8
|
+
env: EnvType;
|
|
9
|
+
componentName?: string | undefined;
|
|
10
|
+
} => {
|
|
11
|
+
const componentMatch = `([a-zA-Z0-9_-]+)`;
|
|
12
|
+
const argRegexp = new RegExp(
|
|
13
|
+
`^((${envTypes.join('|')}):${componentMatch}|${componentMatch})$`
|
|
14
|
+
);
|
|
15
|
+
const envComponent = process.argv[2] ?? '';
|
|
16
|
+
const [, , env = 'local', componentNameWithEnv, onlyComponentName] =
|
|
17
|
+
argRegexp.exec(envComponent);
|
|
18
|
+
if (!isKnowEnvType(env)) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
`invalid env type! ${env}.\nEnv must be one of: ${envTypes.join(', ')}`
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
if (componentNameWithEnv?.length) {
|
|
24
|
+
return { env, componentName: componentNameWithEnv };
|
|
25
|
+
}
|
|
26
|
+
if (onlyComponentName?.length) {
|
|
27
|
+
return { env, componentName: onlyComponentName };
|
|
28
|
+
}
|
|
29
|
+
return { env };
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Parses the environment component argument and returns a Choice object.
|
|
34
|
+
* @param envComponent - The environment component argument to parse.
|
|
35
|
+
* @returns The parsed Choice object.
|
|
36
|
+
* @throws Error if the env type is invalid.
|
|
37
|
+
*/
|
|
38
|
+
export const parseChoiceArgument = ({ components }: Config): Choice => {
|
|
39
|
+
const { env, componentName } = getEnvComponentArgument();
|
|
40
|
+
const componentNames = Object.keys(components);
|
|
41
|
+
if (componentName?.length && !componentNames.includes(componentName)) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
`invalid component name! Component must be one of: ${componentNames.join(', ')}`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
if (componentName?.length) {
|
|
47
|
+
return { env, componentName };
|
|
48
|
+
}
|
|
49
|
+
return { env };
|
|
50
|
+
};
|
|
@@ -69,7 +69,8 @@ const upsertGcloudServiceAccount = async (
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
return await exec(
|
|
72
|
-
|
|
72
|
+
// on some platforms /dev/stdout is not available without the pipe
|
|
73
|
+
`gcloud iam service-accounts keys create /dev/stdout --iam-account=${fullIdentifier} | cat`
|
|
73
74
|
).then((o) => o.stdout);
|
|
74
75
|
};
|
|
75
76
|
|