@catladder/cli 0.0.0-prettier-cbceeed9 → 0.0.0-rails-cloud-run-wip-7bc25e04
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/CONTRIBUTING.md +17 -12
- package/README.md +19 -12
- 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 +2 -4
- package/dist/apps/catenv/catenv.js +12 -89
- package/dist/apps/catenv/catenv.js.map +1 -1
- package/dist/apps/catenv/printVariables.d.ts +3 -0
- package/dist/apps/catenv/printVariables.js +115 -0
- package/dist/apps/catenv/printVariables.js.map +1 -0
- package/dist/apps/catenv/types.d.ts +5 -0
- package/dist/apps/catenv/types.js +3 -0
- package/dist/apps/catenv/types.js.map +1 -0
- package/dist/apps/catenv/utils.d.ts +12 -0
- package/dist/apps/catenv/utils.js +108 -0
- package/dist/apps/catenv/utils.js.map +1 -0
- package/dist/apps/catenv/writeDotEnvFiles.d.ts +3 -0
- package/dist/apps/catenv/writeDotEnvFiles.js +94 -0
- package/dist/apps/catenv/writeDotEnvFiles.js.map +1 -0
- package/dist/apps/catenv/writeEnvDTs.d.ts +3 -0
- package/dist/apps/catenv/writeEnvDTs.js +114 -0
- package/dist/apps/catenv/writeEnvDTs.js.map +1 -0
- package/dist/apps/cli/commands/cloudSQL/commandRestoreDb.js +22 -29
- package/dist/apps/cli/commands/cloudSQL/commandRestoreDb.js.map +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js.map +1 -1
- package/dist/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.d.ts +3 -0
- package/dist/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.js +189 -0
- package/dist/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.js.map +1 -0
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js +28 -65
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -1
- package/dist/apps/cli/commands/project/commandConfigSecrets.js +46 -7
- package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -1
- package/dist/apps/cli/commands/project/commandEnvVars.js +1 -1
- package/dist/apps/cli/commands/project/commandEnvVars.js.map +1 -1
- package/dist/apps/cli/commands/project/commandGetShell.js +9 -6
- package/dist/apps/cli/commands/project/commandGetShell.js.map +1 -1
- package/dist/apps/cli/commands/project/commandSecurityEvaluate.d.ts +3 -0
- package/dist/apps/cli/commands/project/{setup/setupCloudSQL.js → commandSecurityEvaluate.js} +29 -15
- package/dist/apps/cli/commands/project/commandSecurityEvaluate.js.map +1 -0
- package/dist/apps/cli/commands/project/index.js +4 -0
- package/dist/apps/cli/commands/project/index.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/setupContext.js +3 -10
- package/dist/apps/cli/commands/project/setup/setupContext.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/setupKubernetes.js +16 -5
- package/dist/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -1
- package/dist/apps/cli/verify/migration/migrateSecrets.js +3 -1
- package/dist/apps/cli/verify/migration/migrateSecrets.js.map +1 -1
- package/dist/bundles/catci/index.js +71390 -0
- package/dist/bundles/catenv/index.js +2939 -836
- package/dist/bundles/cli/index.js +47314 -40878
- package/dist/catci.d.ts +1 -0
- package/dist/catci.js +5 -0
- package/dist/catci.js.map +1 -0
- package/dist/config/getProjectConfig.d.ts +6 -3
- package/dist/config/getProjectConfig.js +54 -15
- package/dist/config/getProjectConfig.js.map +1 -1
- package/dist/config/parseChoice.js.map +1 -1
- package/dist/gcloud/cloudSql/copyDb.d.ts +12 -0
- package/dist/gcloud/cloudSql/copyDb.js +64 -0
- package/dist/gcloud/cloudSql/copyDb.js.map +1 -0
- package/dist/gcloud/cloudSql/startProxy.d.ts +10 -0
- package/dist/gcloud/cloudSql/startProxy.js +121 -0
- package/dist/gcloud/cloudSql/startProxy.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/dist/utils/getEditor.js +16 -8
- package/dist/utils/getEditor.js.map +1 -1
- package/dist/utils/gitlab.d.ts +4 -4
- package/dist/utils/gitlab.js.map +1 -1
- package/package.json +57 -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 +11 -62
- package/src/apps/catenv/printVariables.ts +58 -0
- package/src/apps/catenv/types.ts +6 -0
- package/src/apps/catenv/utils.ts +49 -0
- package/src/apps/catenv/writeDotEnvFiles.ts +44 -0
- package/src/apps/catenv/writeEnvDTs.ts +71 -0
- package/src/apps/cli/commands/cloudSQL/commandRestoreDb.ts +24 -57
- package/src/apps/cli/commands/mongodb/projectMongoPortForward.ts +5 -2
- package/src/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.ts +175 -0
- package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +32 -54
- package/src/apps/cli/commands/project/commandConfigSecrets.ts +40 -4
- package/src/apps/cli/commands/project/commandEnvVars.ts +5 -2
- package/src/apps/cli/commands/project/commandGetShell.ts +8 -5
- package/src/apps/cli/commands/project/commandSecurityEvaluate.ts +26 -0
- package/src/apps/cli/commands/project/index.ts +4 -0
- package/src/apps/cli/commands/project/setup/setupContext.ts +2 -5
- package/src/apps/cli/commands/project/setup/setupKubernetes.ts +27 -6
- package/src/apps/cli/verify/migration/migrateSecrets.ts +6 -1
- package/src/catci.ts +3 -0
- package/src/config/getProjectConfig.ts +59 -23
- package/src/config/parseChoice.ts +1 -1
- package/src/gcloud/cloudSql/copyDb.ts +57 -0
- package/src/gcloud/cloudSql/startProxy.ts +74 -0
- package/src/gcloud/serviceAccounts.ts +2 -1
- package/src/types/child-process-promise.d.ts +2 -1
- package/src/utils/getEditor.ts +4 -1
- package/src/utils/gitlab.ts +4 -4
- package/tsconfig.json +1 -1
- package/dist/apps/cli/commands/project/setup/setupCloudSQL.d.ts +0 -3
- package/dist/apps/cli/commands/project/setup/setupCloudSQL.js.map +0 -1
- package/src/apps/cli/commands/project/setup/setupCloudSQL.ts +0 -22
package/CONTRIBUTING.md
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
#### Atomic commits
|
|
4
4
|
|
|
5
|
-
If possible, make [atomic commits](https://en.wikipedia.org/wiki/Atomic_commit), which means:
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
5
|
+
If possible, make [atomic commits](https://en.wikipedia.org/wiki/Atomic_commit), which means that a commit should:
|
|
6
|
+
|
|
7
|
+
- Contain exactly one self-contained functional change
|
|
8
|
+
- Not depend on changes in one of your later commits
|
|
9
|
+
- Not create an inconsistent state (such as test errors, linting errors, partial fix, feature with documentation etc…)
|
|
9
10
|
|
|
10
11
|
A complex feature can be broken down into multiple commits as long as each one maintains a consistent state and consists of a self-contained change.
|
|
11
12
|
|
|
@@ -27,7 +28,8 @@ The **footer** can contain a [closing reference to an issue](https://help.github
|
|
|
27
28
|
|
|
28
29
|
#### Revert
|
|
29
30
|
|
|
30
|
-
If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit.
|
|
31
|
+
If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit.
|
|
32
|
+
In the body, it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted.
|
|
31
33
|
|
|
32
34
|
#### Type
|
|
33
35
|
|
|
@@ -42,25 +44,28 @@ The type must be one of the following:
|
|
|
42
44
|
| **fix** | A bug fix |
|
|
43
45
|
| **perf** | A code change that improves performance |
|
|
44
46
|
| **refactor** | A code change that neither fixes a bug nor adds a feature |
|
|
45
|
-
| **style** | Changes that do not affect the meaning of the code (white-space, formatting, missing
|
|
47
|
+
| **style** | Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc) |
|
|
46
48
|
| **test** | Adding missing tests or correcting existing tests |
|
|
47
49
|
|
|
48
50
|
#### Subject
|
|
49
51
|
|
|
50
|
-
The subject contains succinct description of the change:
|
|
52
|
+
The subject contains a succinct description of the change:
|
|
51
53
|
|
|
52
54
|
- use the imperative, present tense: "change" not "changed" nor "changes"
|
|
53
|
-
- don't capitalize first letter
|
|
55
|
+
- don't capitalize the first letter
|
|
54
56
|
- no dot (.) at the end
|
|
55
57
|
|
|
56
58
|
#### Body
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
|
|
60
|
+
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
|
|
61
|
+
The body should include the motivation for the change and contrast this with previous behaviour.
|
|
59
62
|
|
|
60
63
|
#### Footer
|
|
64
|
+
|
|
61
65
|
The footer should contain any information about **Breaking Changes** and is also the place to reference GitLab issues that this commit **Closes**.
|
|
62
66
|
|
|
63
|
-
**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines.
|
|
67
|
+
**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines.
|
|
68
|
+
The rest of the commit message is then used for this.
|
|
64
69
|
|
|
65
70
|
#### Examples
|
|
66
71
|
|
|
@@ -80,4 +85,4 @@ perf(pencil): remove graphiteWidth option`
|
|
|
80
85
|
BREAKING CHANGE: The graphiteWidth option has been removed.
|
|
81
86
|
|
|
82
87
|
The default graphite width of 10mm is always used for performance reasons.
|
|
83
|
-
```
|
|
88
|
+
```
|
package/README.md
CHANGED
|
@@ -1,34 +1,41 @@
|
|
|
1
1
|
# catladder 🐱 🔧
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Panter cli tool for Kubernetes.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```sh
|
|
8
|
+
# yarn users
|
|
9
|
+
yarn global add @catladder/cli
|
|
10
|
+
# npm users
|
|
11
|
+
npm install -g @catladder/cli
|
|
12
|
+
```
|
|
8
13
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
`npm install -g @catladder/cli`
|
|
12
|
-
|
|
13
|
-
_Note: if you have `@panter/catladder` installed upgrade it to >=4.0.0 before installing `@catladder/cli`_
|
|
14
|
+
> **Note**: If you have [@catladder/pipeline](https://www.npmjs.com/package/@catladder/pipeline) installed, upgrade it to >=4.0.0 before installing [@catladder/cli](https://www.npmjs.com/package/@catladder/cli).
|
|
14
15
|
|
|
15
16
|
## Getting started
|
|
16
17
|
|
|
17
|
-
You'll need
|
|
18
|
+
You'll need:
|
|
18
19
|
|
|
19
20
|
- Google Cloud SDK ([see installation instructions](https://cloud.google.com/sdk/docs/install))
|
|
20
21
|
- Kubectl ([see installation instructions](https://kubernetes.io/docs/tasks/tools/))
|
|
21
22
|
- Cloud SQL Auth proxy ([see installation instructions](https://cloud.google.com/sql/docs/postgres/sql-proxy#install))
|
|
22
23
|
|
|
23
|
-
Afterwards you need to connect to your cluster, e.g. `gcloud container clusters get-credentials clustername --zone google-zone --project google-project-id`
|
|
24
|
-
In most cases you'll find the details on the Google Cloud [cluster overview ](https://console.cloud.google.com/kubernetes/list?project=skynet-164509)
|
|
24
|
+
Afterwards, you need to connect to your cluster, e.g. `gcloud container clusters get-credentials clustername --zone google-zone --project google-project-id`
|
|
25
|
+
In most cases, you'll find the details on the Google Cloud [cluster overview ](https://console.cloud.google.com/kubernetes/list?project=skynet-164509)
|
|
25
26
|
|
|
26
27
|
It just works™
|
|
27
28
|
|
|
28
29
|
## Preferences
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
Catladder stores some preferences in `~/.catladder/preferences.yml` in case you want to change settings.
|
|
31
32
|
|
|
32
33
|
## Contribution
|
|
33
34
|
|
|
34
|
-
Check the
|
|
35
|
+
Check the documentation [here](https://git.panter.ch/catladder/catladder/-/tree/main/cli/CONTRIBUTING.md).
|
|
36
|
+
|
|
37
|
+
### Adding packages in cli
|
|
38
|
+
|
|
39
|
+
if you add npm libs in cli, make sure to add them as dev-dependencies.
|
|
40
|
+
|
|
41
|
+
the reason is that we bundle all dependencies in the cli package, so that if you add that to your project, it won't install all @catladder/cli's dependencies.
|
package/bin/catci
ADDED
package/bin/catci-dev
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runCatCi(): Promise<void>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
+
if (ar || !(i in from)) {
|
|
41
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
+
ar[i] = from[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
+
};
|
|
47
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
+
};
|
|
50
|
+
exports.__esModule = true;
|
|
51
|
+
exports.runCatCi = void 0;
|
|
52
|
+
var vorpal_1 = __importDefault(require("vorpal"));
|
|
53
|
+
var packageInfos_1 = __importDefault(require("../../packageInfos"));
|
|
54
|
+
var commands_1 = __importDefault(require("./commands/security/commands"));
|
|
55
|
+
function reconstructArgs(args) {
|
|
56
|
+
return __spreadArray([args[0]], args.slice(1).map(function (arg) { return "\"".concat(arg, "\""); }), true).join(" ");
|
|
57
|
+
}
|
|
58
|
+
function runCatCi() {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
+
var vorpal, isInteractive, args;
|
|
61
|
+
return __generator(this, function (_a) {
|
|
62
|
+
switch (_a.label) {
|
|
63
|
+
case 0:
|
|
64
|
+
vorpal = new vorpal_1["default"]();
|
|
65
|
+
process.exitCode = 0;
|
|
66
|
+
vorpal.delimiter("catci $").history("catci").version(packageInfos_1["default"].version);
|
|
67
|
+
(0, commands_1["default"])(vorpal);
|
|
68
|
+
isInteractive = process.argv.length <= 2;
|
|
69
|
+
if (!isInteractive) return [3 /*break*/, 1];
|
|
70
|
+
vorpal.log("Catladder CI Tools \uD83D\uDE3B\uD83D\uDD28 version ".concat(packageInfos_1["default"].version)).show();
|
|
71
|
+
return [3 /*break*/, 3];
|
|
72
|
+
case 1:
|
|
73
|
+
process.exitCode = 1;
|
|
74
|
+
args = reconstructArgs(process.argv.slice(2));
|
|
75
|
+
return [4 /*yield*/, vorpal.exec(args)];
|
|
76
|
+
case 2:
|
|
77
|
+
_a.sent();
|
|
78
|
+
process.exit();
|
|
79
|
+
_a.label = 3;
|
|
80
|
+
case 3: return [2 /*return*/];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
exports.runCatCi = runCatCi;
|
|
86
|
+
//# sourceMappingURL=catci.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catci.js","sourceRoot":"","sources":["../../../src/apps/catci/catci.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA4B;AAC5B,oEAA6C;AAC7C,0EAA4D;AAE5D,SAAS,eAAe,CAAC,IAAc;IACrC,OAAO,eAAC,IAAI,CAAC,CAAC,CAAC,GAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,UAAC,GAAG,IAAK,OAAA,YAAI,GAAG,OAAG,EAAV,CAAU,CAAC,QAAE,IAAI,CAAC,GAAG,CAAC,CAAC;AACxE,CAAC;AAED,SAAsB,QAAQ;;;;;;oBACtB,MAAM,GAAG,IAAI,mBAAM,EAAE,CAAC;oBAE5B,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;oBACrB,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,yBAAW,CAAC,OAAO,CAAC,CAAC;oBAE1E,IAAA,qBAAgB,EAAC,MAAM,CAAC,CAAC;oBAEnB,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;yBAC3C,aAAa,EAAb,wBAAa;oBACf,MAAM,CAAC,GAAG,CAAC,8DAAmC,yBAAW,CAAC,OAAO,CAAE,CAAC,CAAC,IAAI,EAAE,CAAC;;;oBAE5E,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;oBACf,IAAI,GAAG,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;oBACpD,qBAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAA;;oBAAvB,SAAuB,CAAC;oBACxB,OAAO,CAAC,IAAI,EAAE,CAAC;;;;;;CAElB;AAjBD,4BAiBC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare function makeTemplate(): string;
|
|
2
|
+
export declare type SecurityEvaluation = {
|
|
3
|
+
topics: {
|
|
4
|
+
description: string;
|
|
5
|
+
responsibles: string[];
|
|
6
|
+
note: string;
|
|
7
|
+
isUnknown: boolean;
|
|
8
|
+
isAnswered: boolean;
|
|
9
|
+
isSecured: boolean;
|
|
10
|
+
}[];
|
|
11
|
+
score: {
|
|
12
|
+
rating: number;
|
|
13
|
+
totalTopics: number;
|
|
14
|
+
answeredTopics: number;
|
|
15
|
+
securedTopics: number;
|
|
16
|
+
unknownTopics: number;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare function evaluateDocument(document: string): SecurityEvaluation;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.evaluateDocument = exports.makeTemplate = void 0;
|
|
7
|
+
var topics_json_1 = __importDefault(require("./topics.json"));
|
|
8
|
+
var allTopics = topics_json_1["default"];
|
|
9
|
+
var checkYes = "✅";
|
|
10
|
+
var checkNo = "❌";
|
|
11
|
+
var checkPlaceholder = "".concat(checkYes, "/").concat(checkNo);
|
|
12
|
+
var responsiblePlaceholder = "@...";
|
|
13
|
+
var rows = [
|
|
14
|
+
["Responsible", checkPlaceholder, "Description", "Note", "More Information"],
|
|
15
|
+
].concat(allTopics.map(function (t) { return [
|
|
16
|
+
Array(t.responsibles).fill(responsiblePlaceholder).join(", "),
|
|
17
|
+
checkPlaceholder,
|
|
18
|
+
t.description,
|
|
19
|
+
"",
|
|
20
|
+
t.more,
|
|
21
|
+
]; }));
|
|
22
|
+
function makeTable(rows) {
|
|
23
|
+
var colWidths = calculateColumnWidths(rows);
|
|
24
|
+
return "\n".concat(makeRow(rows[0], colWidths, " "), "\n").concat(makeRow(rows[0].map(function () { return ""; }), colWidths, "-"), "\n").concat(rows
|
|
25
|
+
.slice(1)
|
|
26
|
+
.map(function (row) { return makeRow(row, colWidths, " "); })
|
|
27
|
+
.join("\n"), "\n");
|
|
28
|
+
}
|
|
29
|
+
function calculateColumnWidths(rows) {
|
|
30
|
+
var columnCount = rows[0].length;
|
|
31
|
+
return Array.from({ length: columnCount }, function (_, i) { return i; }).map(function (columnIndex) {
|
|
32
|
+
return Math.max.apply(Math, rows.map(function (row) { return row[columnIndex].length; }));
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function makeRow(row, colWidths, fillString) {
|
|
36
|
+
return "| ".concat(row
|
|
37
|
+
.map(function (cell, i) { return cell.padEnd(colWidths[i], fillString); })
|
|
38
|
+
.join(" | "), " |");
|
|
39
|
+
}
|
|
40
|
+
function makeTemplate() {
|
|
41
|
+
return "\n# Security Audit Report\n\nA security audit report document is a comprehensive assessment of an application's security posture, containing security topics that auditors can mark to indicate the state of various security aspects.\n\nIt serves as a structured guide for security team to evaluate different security factors such as authentication, authorization, data encryption, input validation, and more.\n\n## General Information\n\n- Project Owner is @...\n- Dev team:\n - @...\n - @...\n - @...\n\n## Project Security\n\n".concat(makeTable(rows), "\n\n");
|
|
42
|
+
}
|
|
43
|
+
exports.makeTemplate = makeTemplate;
|
|
44
|
+
function evaluateDocument(document) {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
var rawRows = (_b = (_a = document.match(/^\s*\|.*?\|\s*$/gm)) === null || _a === void 0 ? void 0 : _a.map(function (row) { return row.trim(); })) !== null && _b !== void 0 ? _b : [];
|
|
47
|
+
var matchedRows = rawRows
|
|
48
|
+
.map(function (row) { return row.split("|").map(function (col) { return col.trim(); }); })
|
|
49
|
+
.slice(2);
|
|
50
|
+
var knownTopics = new Set(allTopics.map(function (t) { return t.description; }));
|
|
51
|
+
var topics = matchedRows.map(function (col) {
|
|
52
|
+
var responsibles = col[1].split(", ");
|
|
53
|
+
var answer = col[2];
|
|
54
|
+
var description = col[3];
|
|
55
|
+
var note = col[4];
|
|
56
|
+
var isUnknown = !knownTopics.has(description);
|
|
57
|
+
var isAnswered = !isUnknown &&
|
|
58
|
+
!answer.includes(checkPlaceholder) &&
|
|
59
|
+
!responsibles.some(function (responsible) {
|
|
60
|
+
return responsible.includes(responsiblePlaceholder);
|
|
61
|
+
});
|
|
62
|
+
var isSecured = !isUnknown && isAnswered && answer.includes(checkYes);
|
|
63
|
+
return {
|
|
64
|
+
responsibles: responsibles,
|
|
65
|
+
answer: answer,
|
|
66
|
+
description: description,
|
|
67
|
+
note: note,
|
|
68
|
+
isUnknown: isUnknown,
|
|
69
|
+
isAnswered: isAnswered,
|
|
70
|
+
isSecured: isSecured
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
var totalTopics = allTopics.length;
|
|
74
|
+
var answeredTopics = topics.filter(function (t) { return t.isAnswered; }).length;
|
|
75
|
+
var securedTopics = topics.filter(function (t) { return t.isSecured; }).length;
|
|
76
|
+
var unknownTopics = topics.filter(function (t) { return t.isUnknown; }).length;
|
|
77
|
+
var rating = Math.round((securedTopics / totalTopics) * 100);
|
|
78
|
+
return {
|
|
79
|
+
topics: topics,
|
|
80
|
+
score: {
|
|
81
|
+
rating: rating,
|
|
82
|
+
totalTopics: totalTopics,
|
|
83
|
+
answeredTopics: answeredTopics,
|
|
84
|
+
securedTopics: securedTopics,
|
|
85
|
+
unknownTopics: unknownTopics
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
exports.evaluateDocument = evaluateDocument;
|
|
90
|
+
//# sourceMappingURL=auditDocument.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auditDocument.js","sourceRoot":"","sources":["../../../../../src/apps/catci/commands/security/auditDocument.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAuC;AAQvC,IAAM,SAAS,GAAY,wBAAU,CAAC;AAEtC,IAAM,QAAQ,GAAG,GAAG,CAAC;AACrB,IAAM,OAAO,GAAG,GAAG,CAAC;AAEpB,IAAM,gBAAgB,GAAG,UAAG,QAAQ,cAAI,OAAO,CAAE,CAAC;AAClD,IAAM,sBAAsB,GAAG,MAAM,CAAC;AACtC,IAAM,IAAI,GAAG;IACX,CAAC,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,EAAE,kBAAkB,CAAC;CAC7E,CAAC,MAAM,CACN,SAAS,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA;IACnB,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;IAC7D,gBAAgB;IAChB,CAAC,CAAC,WAAW;IACb,EAAE;IACF,CAAC,CAAC,IAAI;CACP,EANoB,CAMpB,CAAC,CACH,CAAC;AAEF,SAAS,SAAS,CAAC,IAAgB;IACjC,IAAM,SAAS,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAE9C,OAAO,YACP,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,eAChC,OAAO,CACP,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,cAAM,OAAA,EAAE,EAAF,CAAE,CAAC,EACrB,SAAS,EACT,GAAG,CACJ,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AAA;SACV,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC;IACrC,IAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,UAAU,EAAZ,CAAY,CAAC,CAAC,MAAM,CAAC;IACjE,IAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,SAAS,EAAX,CAAW,CAAC,CAAC,MAAM,CAAC;IAC/D,IAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,SAAS,EAAX,CAAW,CAAC,CAAC,MAAM,CAAC;IAE/D,IAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,aAAa,GAAG,WAAW,CAAC,GAAG,GAAG,CAAC,CAAC;IAE/D,OAAO;QACL,MAAM,QAAA;QACN,KAAK,EAAE;YACL,MAAM,QAAA;YACN,WAAW,aAAA;YACX,cAAc,gBAAA;YACd,aAAa,eAAA;YACb,aAAa,eAAA;SACd;KACF,CAAC;AACJ,CAAC;AAnDD,4CAmDC"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
exports.__esModule = true;
|
|
39
|
+
var evaluateSecurityAudit_1 = require("./evaluateSecurityAudit");
|
|
40
|
+
var rest_1 = require("@gitbeaker/rest");
|
|
41
|
+
var createSecurityAuditMergeRequest_1 = require("./createSecurityAuditMergeRequest");
|
|
42
|
+
var ts_results_es_1 = require("ts-results-es");
|
|
43
|
+
var GITLAB_HOST = "https://git.panter.ch";
|
|
44
|
+
function default_1(vorpal) {
|
|
45
|
+
commandCiJob(vorpal);
|
|
46
|
+
commandEvaluate(vorpal);
|
|
47
|
+
commandCreate(vorpal);
|
|
48
|
+
}
|
|
49
|
+
exports["default"] = default_1;
|
|
50
|
+
function resultAsExitCode(func) {
|
|
51
|
+
var _this = this;
|
|
52
|
+
return function (args) { return __awaiter(_this, void 0, void 0, function () {
|
|
53
|
+
var result;
|
|
54
|
+
return __generator(this, function (_a) {
|
|
55
|
+
switch (_a.label) {
|
|
56
|
+
case 0: return [4 /*yield*/, func(args)];
|
|
57
|
+
case 1:
|
|
58
|
+
result = _a.sent();
|
|
59
|
+
process.exitCode = result.isErr() ? 1 : 0;
|
|
60
|
+
return [2 /*return*/];
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}); };
|
|
64
|
+
}
|
|
65
|
+
function commandCiJob(vorpal) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
+
var _this = this;
|
|
68
|
+
return __generator(this, function (_a) {
|
|
69
|
+
vorpal
|
|
70
|
+
.command("security-audit-ci-job <path> <token> <mainBranch> <projectId> <userId>", "Evaluates security audit document. If the document can't be evaluated or does not exist, creates a new MR with security audit document template.\n\n<path> root path of a project with security audit document (".concat(createSecurityAuditMergeRequest_1.SECURITY_AUDIT_FILE_NAME, ")\n<token> gitlab token with 'api' scopes and permissions to create a new branch\n<main-branch> main branch name\n<project-id> project id to create security audit for\n<user-id> gitlab user id that will be assignee of the audit\n"))
|
|
71
|
+
.action(resultAsExitCode(function (args) { return __awaiter(_this, void 0, void 0, function () {
|
|
72
|
+
var evaluation, token, mainBranch, projectId, userId, api, mr;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0: return [4 /*yield*/, (0, evaluateSecurityAudit_1.evaluateSecurityAudit)({ path: args.path })];
|
|
76
|
+
case 1:
|
|
77
|
+
evaluation = _a.sent();
|
|
78
|
+
if (!evaluation.isErr()) return [3 /*break*/, 3];
|
|
79
|
+
console.log("could not evaluate security audit document");
|
|
80
|
+
console.log("creating new merge request with security audit template...");
|
|
81
|
+
token = args.token, mainBranch = args.mainBranch, projectId = args.projectId, userId = args.userId;
|
|
82
|
+
api = new rest_1.Gitlab({
|
|
83
|
+
host: GITLAB_HOST,
|
|
84
|
+
token: token
|
|
85
|
+
});
|
|
86
|
+
return [4 /*yield*/, (0, createSecurityAuditMergeRequest_1.createSecurityAuditMergeRequest)({
|
|
87
|
+
api: api,
|
|
88
|
+
mainBranch: mainBranch,
|
|
89
|
+
projectId: projectId,
|
|
90
|
+
userId: parseInt(userId)
|
|
91
|
+
})];
|
|
92
|
+
case 2:
|
|
93
|
+
mr = _a.sent();
|
|
94
|
+
if (mr.isErr()) {
|
|
95
|
+
console.error("could not create merge request with security audit template: ".concat(mr.error));
|
|
96
|
+
return [2 /*return*/, mr];
|
|
97
|
+
}
|
|
98
|
+
console.log("security audit merge request created successfully");
|
|
99
|
+
console.log("please finish the MR by updating SECURITY.md document: ".concat(mr.value.web_url));
|
|
100
|
+
return [2 /*return*/, (0, ts_results_es_1.Err)("merge request created")];
|
|
101
|
+
case 3:
|
|
102
|
+
if (evaluation.value.score.answeredTopics === 0) {
|
|
103
|
+
console.error("audit document has no answered topics");
|
|
104
|
+
console.error("please answer security topics in ".concat(createSecurityAuditMergeRequest_1.SECURITY_AUDIT_FILE_NAME, " by adding responsible people and check/cross in the table"));
|
|
105
|
+
return [2 /*return*/, (0, ts_results_es_1.Err)("audit document has no answered topics")];
|
|
106
|
+
}
|
|
107
|
+
console.log((0, evaluateSecurityAudit_1.makeSecurityAuditOverview)(evaluation.value));
|
|
108
|
+
return [2 /*return*/, (0, ts_results_es_1.Ok)({})];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}); }));
|
|
112
|
+
return [2 /*return*/];
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function commandEvaluate(vorpal) {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
+
var _this = this;
|
|
119
|
+
return __generator(this, function (_a) {
|
|
120
|
+
vorpal
|
|
121
|
+
.command("security-audit-evaluate <path>", "Evaluates security audit document in given <path>")
|
|
122
|
+
.action(resultAsExitCode(function (args) { return __awaiter(_this, void 0, void 0, function () {
|
|
123
|
+
var result;
|
|
124
|
+
return __generator(this, function (_a) {
|
|
125
|
+
switch (_a.label) {
|
|
126
|
+
case 0:
|
|
127
|
+
console.log("evaluating security audit document...");
|
|
128
|
+
return [4 /*yield*/, (0, evaluateSecurityAudit_1.evaluateSecurityAudit)({ path: args.path })];
|
|
129
|
+
case 1:
|
|
130
|
+
result = _a.sent();
|
|
131
|
+
if (result.isErr()) {
|
|
132
|
+
console.error(result.error);
|
|
133
|
+
console.error("please make sure the security audit document ".concat(createSecurityAuditMergeRequest_1.SECURITY_AUDIT_FILE_NAME, " is in the repository"));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
console.log((0, evaluateSecurityAudit_1.makeSecurityAuditOverview)(result.value));
|
|
137
|
+
}
|
|
138
|
+
return [2 /*return*/, result];
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}); }));
|
|
142
|
+
return [2 /*return*/];
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function commandCreate(vorpal) {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
148
|
+
var _this = this;
|
|
149
|
+
return __generator(this, function (_a) {
|
|
150
|
+
vorpal
|
|
151
|
+
.command("security-audit-create <token> <mainBranch> <projectId> <userId>", "Creates a MR in given project with the latest security audit template document\n\n<token> gitlab token with 'api' scopes and permissions to create a new branch\n<main-branch> main branch name\n<project-id> project id to create security audit for\n<user-id> gitlab user id that will be assignee of the audit\n")
|
|
152
|
+
.action(resultAsExitCode(function (args) { return __awaiter(_this, void 0, void 0, function () {
|
|
153
|
+
var token, mainBranch, projectId, userId, api, result;
|
|
154
|
+
return __generator(this, function (_a) {
|
|
155
|
+
switch (_a.label) {
|
|
156
|
+
case 0:
|
|
157
|
+
token = args.token, mainBranch = args.mainBranch, projectId = args.projectId, userId = args.userId;
|
|
158
|
+
api = new rest_1.Gitlab({
|
|
159
|
+
host: GITLAB_HOST,
|
|
160
|
+
token: token
|
|
161
|
+
});
|
|
162
|
+
return [4 /*yield*/, (0, createSecurityAuditMergeRequest_1.createSecurityAuditMergeRequest)({
|
|
163
|
+
api: api,
|
|
164
|
+
mainBranch: mainBranch,
|
|
165
|
+
projectId: projectId,
|
|
166
|
+
userId: parseInt(userId)
|
|
167
|
+
})];
|
|
168
|
+
case 1:
|
|
169
|
+
result = _a.sent();
|
|
170
|
+
if (result.isErr()) {
|
|
171
|
+
console.error("could not create security audit merge request: ".concat(result.error));
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
console.log("security audit merge request created successfully");
|
|
175
|
+
console.log("please finish the MR by updating SECURITY.md document: ".concat(result.value.web_url));
|
|
176
|
+
}
|
|
177
|
+
return [2 /*return*/, result];
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}); }));
|
|
181
|
+
return [2 /*return*/];
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../../../../src/apps/catci/commands/security/commands.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iEAGiC;AACjC,wCAAyC;AACzC,qFAG2C;AAC3C,+CAAqD;AAErD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{ Err } from "ts-results-es";
|
|
3
|
+
export declare const SECURITY_AUDIT_FILE_NAME: "SECURITY.md";
|
|
4
|
+
export declare function createSecurityAuditMergeRequest({ projectId, mainBranch, userId, api, }: {
|
|
5
|
+
projectId: string;
|
|
6
|
+
mainBranch: string;
|
|
7
|
+
userId: number;
|
|
8
|
+
api: Gitlab;
|
|
9
|
+
}): Promise<Err<string> | import("ts-results-es").Ok<import("@gitbeaker/core").ExpandedMergeRequestSchema>>;
|