@aikidosec/ci-api-client 1.0.3 → 1.0.4
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/.editorconfig +18 -18
- package/.env +1 -1
- package/.prettierrc +10 -10
- package/CONTRIBUTING.md +30 -30
- package/LICENSE +21 -21
- package/README.md +80 -80
- package/RELEASING.md +26 -26
- package/lib/index.js +1 -1
- package/lib/output.js +18 -24
- package/package.json +51 -48
- package/src/aikidoApi.ts +148 -148
- package/src/commands/apiKey.ts +34 -33
- package/src/commands/scan.ts +373 -373
- package/src/commands/upload.ts +184 -184
- package/src/configuration.ts +21 -21
- package/src/index.ts +64 -64
- package/src/output.ts +82 -87
- package/tsconfig.json +27 -27
- package/.npmrc +0 -0
package/src/output.ts
CHANGED
|
@@ -1,87 +1,82 @@
|
|
|
1
|
-
import ora, { Ora } from 'ora';
|
|
2
|
-
import { program } from './index.js';
|
|
3
|
-
import { AxiosError } from 'axios';
|
|
4
|
-
import chalk from 'chalk';
|
|
5
|
-
|
|
6
|
-
// Output a console message
|
|
7
|
-
export const outputLog = (message: string): void => {
|
|
8
|
-
if (!process.env.QUIET) {
|
|
9
|
-
console.log(message);
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// Output some message, var, .. if --debug was provided
|
|
14
|
-
export const outputDebug = (variable: any): void => {
|
|
15
|
-
if (process.env.CLI_DEBUG == true || process.env.CLI_DEBUG == 'true') {
|
|
16
|
-
console.log(
|
|
17
|
-
chalk.blue(
|
|
18
|
-
typeof variable == 'object' ? JSON.stringify(variable) : variable
|
|
19
|
-
)
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// Output an error message
|
|
25
|
-
// Error output should not take into account the global "quiet" option
|
|
26
|
-
export const outputError = (message: string, exitCode: number = 1): void => {
|
|
27
|
-
program.error(message, {
|
|
28
|
-
exitCode,
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const outputHttpError = (axiosError: AxiosError): void => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
spinner.color = 'magenta';
|
|
84
|
-
spinner.start();
|
|
85
|
-
|
|
86
|
-
return spinner;
|
|
87
|
-
};
|
|
1
|
+
import ora, { Ora } from 'ora';
|
|
2
|
+
import { program } from './index.js';
|
|
3
|
+
import { AxiosError } from 'axios';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
|
|
6
|
+
// Output a console message
|
|
7
|
+
export const outputLog = (message: string): void => {
|
|
8
|
+
if (!process.env.QUIET) {
|
|
9
|
+
console.log(message);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// Output some message, var, .. if --debug was provided
|
|
14
|
+
export const outputDebug = (variable: any): void => {
|
|
15
|
+
if (process.env.CLI_DEBUG == true || process.env.CLI_DEBUG == 'true') {
|
|
16
|
+
console.log(
|
|
17
|
+
chalk.blue(
|
|
18
|
+
typeof variable == 'object' ? JSON.stringify(variable) : variable
|
|
19
|
+
)
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Output an error message
|
|
25
|
+
// Error output should not take into account the global "quiet" option
|
|
26
|
+
export const outputError = (message: string, exitCode: number = 1): void => {
|
|
27
|
+
program.error(message, {
|
|
28
|
+
exitCode,
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const outputHttpError = (axiosError: AxiosError): void => {
|
|
33
|
+
outputDebug(axiosError);
|
|
34
|
+
|
|
35
|
+
if (axiosError.isAxiosError) {
|
|
36
|
+
if (axiosError.response) {
|
|
37
|
+
const statusStr = `${axiosError.response.status} ${axiosError.response.statusText}`;
|
|
38
|
+
switch (axiosError.response.status) {
|
|
39
|
+
case 401:
|
|
40
|
+
return outputError(
|
|
41
|
+
`${statusStr}: The provided api key is most likely no longer valid and has been rotated or revoked. Visit https://app.aikido.dev/settings/integrations/continuous-integration to generate a new key.`
|
|
42
|
+
);
|
|
43
|
+
case 403:
|
|
44
|
+
return outputError(
|
|
45
|
+
`${statusStr}: Could not authenticate with the Aikido API. Please verify your Aikdio API key.`
|
|
46
|
+
);
|
|
47
|
+
case 500:
|
|
48
|
+
return outputError(
|
|
49
|
+
`${statusStr}: Something went wrong contacting the Aikido API. Please try again later.`
|
|
50
|
+
);
|
|
51
|
+
default:
|
|
52
|
+
return outputError(
|
|
53
|
+
`${statusStr}: ${
|
|
54
|
+
axiosError.response.data ?? ''
|
|
55
|
+
} Please contact us if this problem persists.`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return outputError(`${axiosError.name}: ${axiosError.message}`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return outputError(
|
|
64
|
+
'Unexpected error occurred. Please contact us if this problem persists.'
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// Start a new spinner
|
|
69
|
+
// The result of this function can be null if the global "quiet" option
|
|
70
|
+
// was set. Spinners should always be treated as optionals
|
|
71
|
+
// (e.g. mySpinner?.stop())
|
|
72
|
+
export const startSpinner = (message: string): Ora | null => {
|
|
73
|
+
if (process.env.QUIET) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const spinner = ora(message);
|
|
78
|
+
spinner.color = 'magenta';
|
|
79
|
+
spinner.start();
|
|
80
|
+
|
|
81
|
+
return spinner;
|
|
82
|
+
};
|
package/tsconfig.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "es2020",
|
|
5
|
-
"outDir": "lib",
|
|
6
|
-
"rootDir": "src",
|
|
7
|
-
"strict": true,
|
|
8
|
-
"declaration": true,
|
|
9
|
-
|
|
10
|
-
/* Use Node ECMAScript modules */
|
|
11
|
-
"moduleResolution": "nodenext",
|
|
12
|
-
|
|
13
|
-
/* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
14
|
-
"esModuleInterop": true,
|
|
15
|
-
|
|
16
|
-
/* Skip type checking of declaration files. */
|
|
17
|
-
"skipLibCheck": true,
|
|
18
|
-
|
|
19
|
-
/* Remove comments in target files */
|
|
20
|
-
"removeComments": true,
|
|
21
|
-
|
|
22
|
-
/* Disallow inconsistently-cased references to the same file. */
|
|
23
|
-
"forceConsistentCasingInFileNames": true
|
|
24
|
-
},
|
|
25
|
-
"include": [".env", ".env.*", "src/*.ts", "src/**/*.ts"],
|
|
26
|
-
"exclude": ["lib", "dist", "node_modules"]
|
|
27
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "es2020",
|
|
5
|
+
"outDir": "lib",
|
|
6
|
+
"rootDir": "src",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"declaration": true,
|
|
9
|
+
|
|
10
|
+
/* Use Node ECMAScript modules */
|
|
11
|
+
"moduleResolution": "nodenext",
|
|
12
|
+
|
|
13
|
+
/* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
14
|
+
"esModuleInterop": true,
|
|
15
|
+
|
|
16
|
+
/* Skip type checking of declaration files. */
|
|
17
|
+
"skipLibCheck": true,
|
|
18
|
+
|
|
19
|
+
/* Remove comments in target files */
|
|
20
|
+
"removeComments": true,
|
|
21
|
+
|
|
22
|
+
/* Disallow inconsistently-cased references to the same file. */
|
|
23
|
+
"forceConsistentCasingInFileNames": true
|
|
24
|
+
},
|
|
25
|
+
"include": [".env", ".env.*", "src/*.ts", "src/**/*.ts"],
|
|
26
|
+
"exclude": ["lib", "dist", "node_modules"]
|
|
27
|
+
}
|
package/.npmrc
DELETED
|
File without changes
|