@aikidosec/ci-api-client 1.0.7 → 1.0.9

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/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
 
@@ -15,6 +15,7 @@ export type TScanApiOptions = {
15
15
  minimum_severity?: string;
16
16
  version: string;
17
17
  is_release_gating?: boolean;
18
+ base_branch?: string;
18
19
  };
19
20
  export type TStartScanResult = {
20
21
  scan_id: number;
@@ -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.7' };
121
+ const apiOptions = { version: '1.0.9' };
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;
@@ -52,7 +52,12 @@ async function cli(repoId, commitId, options, command) {
52
52
  const onFail = (error) => {
53
53
  loader?.fail();
54
54
  if (error.response?.status && error.response?.status === 404) {
55
- outputError('Please verify your commit SHA');
55
+ if (error.response?.data?.reason_phrase) {
56
+ outputError(error.response?.data?.reason_phrase);
57
+ }
58
+ else {
59
+ outputError('Please verify your repository id or commit SHA');
60
+ }
56
61
  }
57
62
  else {
58
63
  outputHttpError(error);
@@ -115,7 +120,7 @@ export const scan = async ({ repoId, commitId, options, pollInterval = 10, onSta
115
120
  pollStatus();
116
121
  };
117
122
  const parseCliOptions = (userCliOptions) => {
118
- const apiOptions = { version: '1.0.7' };
123
+ const apiOptions = { version: '1.0.9' };
119
124
  const cliOptions = { pollInterval: 10 };
120
125
  if (userCliOptions.pullRequestTitle) {
121
126
  apiOptions.pull_request_metadata = {
@@ -147,6 +152,9 @@ const parseCliOptions = (userCliOptions) => {
147
152
  if (userCliOptions.minimumSeverityLevel) {
148
153
  apiOptions.minimum_severity = userCliOptions.minimumSeverityLevel;
149
154
  }
155
+ if (userCliOptions.baseBranch) {
156
+ apiOptions.base_branch = userCliOptions.baseBranch;
157
+ }
150
158
  if (userCliOptions.pollInterval &&
151
159
  (isNaN(userCliOptions.pollInterval) || userCliOptions.pollInterval <= 0)) {
152
160
  outputError('Please provide a valid poll interval');
@@ -177,6 +185,7 @@ export const cliSetup = (program) => program
177
185
  .addOption(new Option('--poll-interval [interval]', 'The poll interval when checking for an updated scan result')
178
186
  .preset(10)
179
187
  .argParser(parseFloat))
188
+ .addOption(new Option('--base-branch <branchname>', 'Base branch for the release gated scan.'))
180
189
  .description('Run a release scan of an Aikido repo.')
181
190
  .action(cli);
182
191
  export default { cli, cliSetup, scan };
@@ -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.7');
14
+ .version('1.0.9');
15
15
  apiKey.cliSetup(program);
16
16
  scan.cliSetup(program);
17
17
  scanRelease.cliSetup(program);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aikidosec/ci-api-client",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "CLI api client to easily integrate the Aikido public CI API into custom deploy scripts",
5
5
  "license": "MIT",
6
6
  "author": "Bert Devriese <bert@builtinbruges.com>",
package/src/aikidoApi.ts CHANGED
@@ -26,6 +26,7 @@ export type TScanApiOptions = {
26
26
  minimum_severity?: string;
27
27
  version: string;
28
28
  is_release_gating?: boolean;
29
+ base_branch?: string;
29
30
  };
30
31
 
31
32
  export type TStartScanResult = {
@@ -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.7' };
248
+ const apiOptions: TScanApiOptions = { version: '1.0.9' };
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(
@@ -73,7 +74,7 @@ async function cli(
73
74
  const apiKey = getApiKey();
74
75
 
75
76
  if (!apiKey) {
76
- outputError('Please set an api key using: aikido-cli apikey <key>');
77
+ outputError('Please set an api key using: aikido-cli-client apikey <key>');
77
78
  }
78
79
 
79
80
  // Process command options and group them into apiOptions hash
@@ -144,9 +145,13 @@ async function cli(
144
145
  loader?.fail();
145
146
 
146
147
  if (error.response?.status && error.response?.status === 404) {
147
- outputError(
148
- 'Please verify your commit SHA'
149
- );
148
+ if(error.response?.data?.reason_phrase) {
149
+ outputError(error.response?.data?.reason_phrase);
150
+ } else {
151
+ outputError(
152
+ 'Please verify your repository id or commit SHA'
153
+ );
154
+ }
150
155
  } else {
151
156
  outputHttpError(error);
152
157
  }
@@ -238,7 +243,7 @@ export const scan = async ({
238
243
  const parseCliOptions = (userCliOptions: TScanUserCliOptions) => {
239
244
  // Version provided to the API corresponds with the version in package.json
240
245
  // of the cli client
241
- const apiOptions: TScanApiOptions = { version: '1.0.7' };
246
+ const apiOptions: TScanApiOptions = { version: '1.0.9' };
242
247
  const cliOptions: TScanCliOptions = { pollInterval: 10 };
243
248
 
244
249
  if (userCliOptions.pullRequestTitle) {
@@ -271,6 +276,9 @@ const parseCliOptions = (userCliOptions: TScanUserCliOptions) => {
271
276
  if (userCliOptions.minimumSeverityLevel) {
272
277
  apiOptions.minimum_severity = userCliOptions.minimumSeverityLevel;
273
278
  }
279
+ if (userCliOptions.baseBranch) {
280
+ apiOptions.base_branch = userCliOptions.baseBranch;
281
+ }
274
282
  if (
275
283
  userCliOptions.pollInterval &&
276
284
  (isNaN(userCliOptions.pollInterval) || userCliOptions.pollInterval <= 0)
@@ -343,6 +351,12 @@ export const cliSetup = (program: Command) =>
343
351
  .preset(10)
344
352
  .argParser(parseFloat)
345
353
  )
354
+ .addOption(
355
+ new Option(
356
+ '--base-branch <branchname>',
357
+ 'Base branch for the release gated scan.'
358
+ )
359
+ )
346
360
  .description('Run a release scan of an Aikido repo.')
347
361
  .action(cli);
348
362
 
@@ -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.7');
23
+ .version('1.0.9');
24
24
 
25
25
  // Load in all app commands and set them up in the `program` instance
26
26
  apiKey.cliSetup(program);