@aikidosec/ci-api-client 1.0.8 → 1.0.10
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/.env +2 -0
- package/README.md +1 -0
- package/lib/aikidoApi.d.ts +1 -0
- package/lib/aikidoApi.js +10 -1
- package/lib/commands/scan.js +2 -2
- package/lib/commands/scanRelease.d.ts +1 -0
- package/lib/commands/scanRelease.js +6 -2
- package/lib/commands/upload.js +1 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/src/aikidoApi.ts +14 -1
- package/src/commands/scan.ts +2 -2
- package/src/commands/scanRelease.ts +17 -14
- package/src/commands/upload.ts +1 -1
- package/src/index.ts +2 -2
package/.env
CHANGED
package/README.md
CHANGED
|
@@ -80,6 +80,7 @@ Options:
|
|
|
80
80
|
--minimum-severity-level <level> Set the minimum severity level. Accepted options are: LOW, MEDIUM, HIGH and CRITICAL. (choices: "LOW",
|
|
81
81
|
"MEDIUM", "HIGH", "CRITICAL")
|
|
82
82
|
--poll-interval [interval] The poll interval when checking for an updated scan result (preset: 5)
|
|
83
|
+
--base-branch <branchname> Optional: base branch for the release gated scan.
|
|
83
84
|
-h, --help display help for command
|
|
84
85
|
```
|
|
85
86
|
|
package/lib/aikidoApi.d.ts
CHANGED
package/lib/aikidoApi.js
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import { getApiKey } from './configuration.js';
|
|
3
3
|
import { outputDebug } from './output.js';
|
|
4
|
-
const getApiUrl = () =>
|
|
4
|
+
const getApiUrl = () => {
|
|
5
|
+
const apiKey = getApiKey();
|
|
6
|
+
if (apiKey.startsWith('AIK_CI_US_')) {
|
|
7
|
+
return process.env.AIKIDO_US_API || 'https://app.us.aikido.dev';
|
|
8
|
+
}
|
|
9
|
+
if (apiKey.startsWith('AIK_CI_ME_')) {
|
|
10
|
+
return process.env.AIKIDO_ME_API || 'https://app.me.aikido.dev';
|
|
11
|
+
}
|
|
12
|
+
return process.env.AIKIDO_API || 'https://app.aikido.dev';
|
|
13
|
+
};
|
|
5
14
|
const getApiHeaders = () => ({
|
|
6
15
|
'Content-Type': 'application/json',
|
|
7
16
|
'X-AIK-API-SECRET': getApiKey(),
|
package/lib/commands/scan.js
CHANGED
|
@@ -6,7 +6,7 @@ import { outputError, outputHttpError, outputLog, startSpinner, } from '../outpu
|
|
|
6
6
|
async function cli(repoId, baseCommitId, headCommitId, branchName, options, command) {
|
|
7
7
|
const apiKey = getApiKey();
|
|
8
8
|
if (!apiKey) {
|
|
9
|
-
outputError('Please set an api key using: aikido-cli apikey <key>');
|
|
9
|
+
outputError('Please set an api key using: aikido-cli-client apikey <key>');
|
|
10
10
|
}
|
|
11
11
|
const { apiOptions, cliOptions } = parseCliOptions(options);
|
|
12
12
|
let loader;
|
|
@@ -118,7 +118,7 @@ export const scan = async ({ repoId, baseCommitId, headCommitId, branchName, opt
|
|
|
118
118
|
pollStatus();
|
|
119
119
|
};
|
|
120
120
|
const parseCliOptions = (userCliOptions) => {
|
|
121
|
-
const apiOptions = { version: '1.0.
|
|
121
|
+
const apiOptions = { version: '1.0.10' };
|
|
122
122
|
const cliOptions = { pollInterval: 5 };
|
|
123
123
|
if (userCliOptions.pullRequestTitle) {
|
|
124
124
|
apiOptions.pull_request_metadata = {
|
|
@@ -23,6 +23,7 @@ type TScanUserCliOptions = {
|
|
|
23
23
|
failOnIacScan?: boolean;
|
|
24
24
|
minimumSeverityLevel?: string;
|
|
25
25
|
pollInterval?: number;
|
|
26
|
+
baseBranch?: string;
|
|
26
27
|
};
|
|
27
28
|
declare function cli(repoId: string, commitId: string, options: TScanUserCliOptions, command: string): Promise<void>;
|
|
28
29
|
export declare const scan: ({ repoId, commitId, options, pollInterval, onStart, onStartComplete, onStartFail, onScanStart, onNextPoll, onScanComplete, onScanFail, }: TScanArguments) => Promise<void>;
|
|
@@ -6,7 +6,7 @@ import { outputError, outputHttpError, outputLog, startSpinner, } from '../outpu
|
|
|
6
6
|
async function cli(repoId, commitId, options, command) {
|
|
7
7
|
const apiKey = getApiKey();
|
|
8
8
|
if (!apiKey) {
|
|
9
|
-
outputError('Please set an api key using: aikido-cli apikey <key>');
|
|
9
|
+
outputError('Please set an api key using: aikido-cli-client apikey <key>');
|
|
10
10
|
}
|
|
11
11
|
const { apiOptions, cliOptions } = parseCliOptions(options);
|
|
12
12
|
let loader;
|
|
@@ -120,7 +120,7 @@ export const scan = async ({ repoId, commitId, options, pollInterval = 10, onSta
|
|
|
120
120
|
pollStatus();
|
|
121
121
|
};
|
|
122
122
|
const parseCliOptions = (userCliOptions) => {
|
|
123
|
-
const apiOptions = { version: '1.0.
|
|
123
|
+
const apiOptions = { version: '1.0.10' };
|
|
124
124
|
const cliOptions = { pollInterval: 10 };
|
|
125
125
|
if (userCliOptions.pullRequestTitle) {
|
|
126
126
|
apiOptions.pull_request_metadata = {
|
|
@@ -152,6 +152,9 @@ const parseCliOptions = (userCliOptions) => {
|
|
|
152
152
|
if (userCliOptions.minimumSeverityLevel) {
|
|
153
153
|
apiOptions.minimum_severity = userCliOptions.minimumSeverityLevel;
|
|
154
154
|
}
|
|
155
|
+
if (userCliOptions.baseBranch) {
|
|
156
|
+
apiOptions.base_branch = userCliOptions.baseBranch;
|
|
157
|
+
}
|
|
155
158
|
if (userCliOptions.pollInterval &&
|
|
156
159
|
(isNaN(userCliOptions.pollInterval) || userCliOptions.pollInterval <= 0)) {
|
|
157
160
|
outputError('Please provide a valid poll interval');
|
|
@@ -182,6 +185,7 @@ export const cliSetup = (program) => program
|
|
|
182
185
|
.addOption(new Option('--poll-interval [interval]', 'The poll interval when checking for an updated scan result')
|
|
183
186
|
.preset(10)
|
|
184
187
|
.argParser(parseFloat))
|
|
188
|
+
.addOption(new Option('--base-branch <branchname>', 'Base branch for the release gated scan.'))
|
|
185
189
|
.description('Run a release scan of an Aikido repo.')
|
|
186
190
|
.action(cli);
|
|
187
191
|
export default { cli, cliSetup, scan };
|
package/lib/commands/upload.js
CHANGED
|
@@ -7,7 +7,7 @@ import { promisify } from 'util';
|
|
|
7
7
|
async function cli(options, command) {
|
|
8
8
|
const apiKey = getApiKey();
|
|
9
9
|
if (!apiKey) {
|
|
10
|
-
outputError('Please set an api key using: aikido-cli apikey <key>');
|
|
10
|
+
outputError('Please set an api key using: aikido-cli-client apikey <key>');
|
|
11
11
|
}
|
|
12
12
|
const { apiOptions, cliOptions } = await parseCliOptions(options);
|
|
13
13
|
let loader = startSpinner('Uploading custom scan');
|
package/lib/index.js
CHANGED
|
@@ -11,7 +11,7 @@ export const program = new Command();
|
|
|
11
11
|
program
|
|
12
12
|
.name('Aikido API Client')
|
|
13
13
|
.description('CLI api client to easily integrate the Aikido public CI API into custom deploy scripts')
|
|
14
|
-
.version('1.0.
|
|
14
|
+
.version('1.0.10');
|
|
15
15
|
apiKey.cliSetup(program);
|
|
16
16
|
scan.cliSetup(program);
|
|
17
17
|
scanRelease.cliSetup(program);
|
package/package.json
CHANGED
package/src/aikidoApi.ts
CHANGED
|
@@ -2,7 +2,19 @@ import axios from 'axios';
|
|
|
2
2
|
import { getApiKey } from './configuration.js';
|
|
3
3
|
import { outputDebug } from './output.js';
|
|
4
4
|
|
|
5
|
-
const getApiUrl = () =>
|
|
5
|
+
const getApiUrl = () => {
|
|
6
|
+
const apiKey = getApiKey();
|
|
7
|
+
|
|
8
|
+
if (apiKey.startsWith('AIK_CI_US_')) {
|
|
9
|
+
return process.env.AIKIDO_US_API || 'https://app.us.aikido.dev';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (apiKey.startsWith('AIK_CI_ME_')) {
|
|
13
|
+
return process.env.AIKIDO_ME_API || 'https://app.me.aikido.dev';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return process.env.AIKIDO_API || 'https://app.aikido.dev';
|
|
17
|
+
};
|
|
6
18
|
const getApiHeaders = () => ({
|
|
7
19
|
'Content-Type': 'application/json',
|
|
8
20
|
'X-AIK-API-SECRET': getApiKey(),
|
|
@@ -26,6 +38,7 @@ export type TScanApiOptions = {
|
|
|
26
38
|
minimum_severity?: string;
|
|
27
39
|
version: string;
|
|
28
40
|
is_release_gating?: boolean;
|
|
41
|
+
base_branch?: string;
|
|
29
42
|
};
|
|
30
43
|
|
|
31
44
|
export type TStartScanResult = {
|
package/src/commands/scan.ts
CHANGED
|
@@ -76,7 +76,7 @@ async function cli(
|
|
|
76
76
|
const apiKey = getApiKey();
|
|
77
77
|
|
|
78
78
|
if (!apiKey) {
|
|
79
|
-
outputError('Please set an api key using: aikido-cli apikey <key>');
|
|
79
|
+
outputError('Please set an api key using: aikido-cli-client apikey <key>');
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// Process command options and group them into apiOptions hash
|
|
@@ -245,7 +245,7 @@ export const scan = async ({
|
|
|
245
245
|
const parseCliOptions = (userCliOptions: TScanUserCliOptions) => {
|
|
246
246
|
// Version provided to the API corresponds with the version in package.json
|
|
247
247
|
// of the cli client
|
|
248
|
-
const apiOptions: TScanApiOptions = { version: '1.0.
|
|
248
|
+
const apiOptions: TScanApiOptions = { version: '1.0.10' };
|
|
249
249
|
const cliOptions: TScanCliOptions = { pollInterval: 5 };
|
|
250
250
|
|
|
251
251
|
if (userCliOptions.pullRequestTitle) {
|
|
@@ -61,6 +61,7 @@ type TScanUserCliOptions = {
|
|
|
61
61
|
failOnIacScan?: boolean;
|
|
62
62
|
minimumSeverityLevel?: string;
|
|
63
63
|
pollInterval?: number;
|
|
64
|
+
baseBranch?: string;
|
|
64
65
|
};
|
|
65
66
|
|
|
66
67
|
async function cli(
|
|
@@ -69,11 +70,10 @@ async function cli(
|
|
|
69
70
|
options: TScanUserCliOptions,
|
|
70
71
|
command: string
|
|
71
72
|
) {
|
|
72
|
-
|
|
73
73
|
const apiKey = getApiKey();
|
|
74
74
|
|
|
75
75
|
if (!apiKey) {
|
|
76
|
-
outputError('Please set an api key using: aikido-cli apikey <key>');
|
|
76
|
+
outputError('Please set an api key using: aikido-cli-client apikey <key>');
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
// Process command options and group them into apiOptions hash
|
|
@@ -144,12 +144,10 @@ async function cli(
|
|
|
144
144
|
loader?.fail();
|
|
145
145
|
|
|
146
146
|
if (error.response?.status && error.response?.status === 404) {
|
|
147
|
-
if(error.response?.data?.reason_phrase) {
|
|
147
|
+
if (error.response?.data?.reason_phrase) {
|
|
148
148
|
outputError(error.response?.data?.reason_phrase);
|
|
149
149
|
} else {
|
|
150
|
-
outputError(
|
|
151
|
-
'Please verify your repository id or commit SHA'
|
|
152
|
-
);
|
|
150
|
+
outputError('Please verify your repository id or commit SHA');
|
|
153
151
|
}
|
|
154
152
|
} else {
|
|
155
153
|
outputHttpError(error);
|
|
@@ -193,7 +191,6 @@ export const scan = async ({
|
|
|
193
191
|
// Initialize a scan and call onStartComplete, onStartFail
|
|
194
192
|
// handlers where needed
|
|
195
193
|
try {
|
|
196
|
-
|
|
197
194
|
result = await startScan({
|
|
198
195
|
is_release_gating: true,
|
|
199
196
|
head_commit_id: commitId,
|
|
@@ -242,7 +239,7 @@ export const scan = async ({
|
|
|
242
239
|
const parseCliOptions = (userCliOptions: TScanUserCliOptions) => {
|
|
243
240
|
// Version provided to the API corresponds with the version in package.json
|
|
244
241
|
// of the cli client
|
|
245
|
-
const apiOptions: TScanApiOptions = { version: '1.0.
|
|
242
|
+
const apiOptions: TScanApiOptions = { version: '1.0.10' };
|
|
246
243
|
const cliOptions: TScanCliOptions = { pollInterval: 10 };
|
|
247
244
|
|
|
248
245
|
if (userCliOptions.pullRequestTitle) {
|
|
@@ -275,6 +272,9 @@ const parseCliOptions = (userCliOptions: TScanUserCliOptions) => {
|
|
|
275
272
|
if (userCliOptions.minimumSeverityLevel) {
|
|
276
273
|
apiOptions.minimum_severity = userCliOptions.minimumSeverityLevel;
|
|
277
274
|
}
|
|
275
|
+
if (userCliOptions.baseBranch) {
|
|
276
|
+
apiOptions.base_branch = userCliOptions.baseBranch;
|
|
277
|
+
}
|
|
278
278
|
if (
|
|
279
279
|
userCliOptions.pollInterval &&
|
|
280
280
|
(isNaN(userCliOptions.pollInterval) || userCliOptions.pollInterval <= 0)
|
|
@@ -308,12 +308,9 @@ export const cliSetup = (program: Command) =>
|
|
|
308
308
|
).argRequired()
|
|
309
309
|
)
|
|
310
310
|
.addArgument(
|
|
311
|
-
new Argument(
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
)
|
|
315
|
-
.argRequired()
|
|
316
|
-
.argParser(validateCommitId)
|
|
311
|
+
new Argument('<commit_id>', 'The commit you want to scan')
|
|
312
|
+
.argRequired()
|
|
313
|
+
.argParser(validateCommitId)
|
|
317
314
|
)
|
|
318
315
|
.addOption(
|
|
319
316
|
new Option(
|
|
@@ -347,6 +344,12 @@ export const cliSetup = (program: Command) =>
|
|
|
347
344
|
.preset(10)
|
|
348
345
|
.argParser(parseFloat)
|
|
349
346
|
)
|
|
347
|
+
.addOption(
|
|
348
|
+
new Option(
|
|
349
|
+
'--base-branch <branchname>',
|
|
350
|
+
'Base branch for the release gated scan.'
|
|
351
|
+
)
|
|
352
|
+
)
|
|
350
353
|
.description('Run a release scan of an Aikido repo.')
|
|
351
354
|
.action(cli);
|
|
352
355
|
|
package/src/commands/upload.ts
CHANGED
|
@@ -44,7 +44,7 @@ async function cli(options: TUploadUserCliOptions, command: string) {
|
|
|
44
44
|
const apiKey = getApiKey();
|
|
45
45
|
|
|
46
46
|
if (!apiKey) {
|
|
47
|
-
outputError('Please set an api key using: aikido-cli apikey <key>');
|
|
47
|
+
outputError('Please set an api key using: aikido-cli-client apikey <key>');
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// Process command options and group them into apiOptions hash
|
package/src/index.ts
CHANGED
|
@@ -20,7 +20,7 @@ program
|
|
|
20
20
|
.description(
|
|
21
21
|
'CLI api client to easily integrate the Aikido public CI API into custom deploy scripts'
|
|
22
22
|
)
|
|
23
|
-
.version('1.0.
|
|
23
|
+
.version('1.0.10');
|
|
24
24
|
|
|
25
25
|
// Load in all app commands and set them up in the `program` instance
|
|
26
26
|
apiKey.cliSetup(program);
|
|
@@ -57,7 +57,7 @@ program
|
|
|
57
57
|
program
|
|
58
58
|
.option('--plain-output', 'Disables the formatting on output')
|
|
59
59
|
.on('option:plain-output', function () {
|
|
60
|
-
chalk.level = 0 // Disables all formatting for chalk
|
|
60
|
+
chalk.level = 0; // Disables all formatting for chalk
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
// Add global option "--apikey"
|