mobbdev 0.0.28 → 0.0.30
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 +4 -4
- package/README.md +9 -9
- package/bin/cli.mjs +1 -1
- package/dist/index.js +1271 -0
- package/package.json +76 -55
- package/index.mjs +0 -34
- package/src/commands/index.mjs +0 -101
- package/src/constants.mjs +0 -60
- package/src/features/analysis/callback-server.mjs +0 -61
- package/src/features/analysis/git.mjs +0 -50
- package/src/features/analysis/github.mjs +0 -106
- package/src/features/analysis/gql.mjs +0 -198
- package/src/features/analysis/index.mjs +0 -292
- package/src/features/analysis/pack.mjs +0 -31
- package/src/features/analysis/prompts.mjs +0 -55
- package/src/features/analysis/snyk.mjs +0 -110
- package/src/features/analysis/upload-file.mjs +0 -37
- package/src/utils.mjs +0 -30
- package/src/yargs.mjs +0 -141
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import fetch, { FormData, fileFrom, File } from 'node-fetch';
|
|
2
|
-
import Debug from 'debug';
|
|
3
|
-
|
|
4
|
-
const debug = Debug('mobbdev:upload-file');
|
|
5
|
-
|
|
6
|
-
// `file` can be string representing absolute path or buffer.
|
|
7
|
-
export async function uploadFile(file, url, uploadKey, uploadFields) {
|
|
8
|
-
debug('upload file start %s', url);
|
|
9
|
-
debug('upload fields %o', uploadFields);
|
|
10
|
-
debug('upload key %s', uploadKey);
|
|
11
|
-
|
|
12
|
-
const form = new FormData();
|
|
13
|
-
|
|
14
|
-
for (const key in uploadFields) {
|
|
15
|
-
form.append(key, uploadFields[key]);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
form.append('key', uploadKey);
|
|
19
|
-
if (typeof file === 'string') {
|
|
20
|
-
debug('upload file from path %s', file);
|
|
21
|
-
form.append('file', await fileFrom(file));
|
|
22
|
-
} else {
|
|
23
|
-
debug('upload file from buffer');
|
|
24
|
-
form.append('file', new File([file], 'file'));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const response = await fetch(url, {
|
|
28
|
-
method: 'POST',
|
|
29
|
-
body: form,
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
if (!response.ok) {
|
|
33
|
-
debug('error from S3 %s %s', response.body, response.status);
|
|
34
|
-
throw new Error(`Failed to upload the file: ${response.status}`);
|
|
35
|
-
}
|
|
36
|
-
debug('upload file done');
|
|
37
|
-
}
|
package/src/utils.mjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import readline from 'node:readline';
|
|
2
|
-
import { createSpinner as _createSpinner } from 'nanospinner';
|
|
3
|
-
import { PassThrough } from 'stream';
|
|
4
|
-
export const sleep = (ms = 2000) => new Promise((r) => setTimeout(r, ms));
|
|
5
|
-
|
|
6
|
-
export async function keypress() {
|
|
7
|
-
const rl = readline.createInterface({
|
|
8
|
-
input: process.stdin,
|
|
9
|
-
output: process.stdout,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
return new Promise((resolve) => {
|
|
13
|
-
rl.question('', (answer) => {
|
|
14
|
-
rl.close();
|
|
15
|
-
process.stderr.moveCursor(0, -1);
|
|
16
|
-
process.stderr.clearLine(1);
|
|
17
|
-
resolve(answer);
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function Spinner({ ci = false } = {}) {
|
|
23
|
-
return {
|
|
24
|
-
createSpinner: (text, options) =>
|
|
25
|
-
_createSpinner(text, {
|
|
26
|
-
stream: ci ? new PassThrough() : undefined,
|
|
27
|
-
...options,
|
|
28
|
-
}),
|
|
29
|
-
};
|
|
30
|
-
}
|
package/src/yargs.mjs
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import yargs from 'yargs/yargs';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
|
|
4
|
-
import { SCANNERS } from './constants.mjs';
|
|
5
|
-
|
|
6
|
-
const refOption = {
|
|
7
|
-
describe: chalk.bold('reference of the repository (branch, tag, commit)'),
|
|
8
|
-
type: 'string',
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const srcPathOption = {
|
|
12
|
-
alias: 'src-path',
|
|
13
|
-
describe: chalk.bold('Path to the repository folder with the source code'),
|
|
14
|
-
type: 'string',
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const commitHash = {
|
|
18
|
-
alias: 'commit-hash',
|
|
19
|
-
describe: chalk.bold('Hash of the commit'),
|
|
20
|
-
type: 'string',
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const repoOption = {
|
|
24
|
-
alias: 'repo',
|
|
25
|
-
demandOption: true,
|
|
26
|
-
describe: chalk.bold('Github repository URL'),
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const yesOption = {
|
|
30
|
-
alias: 'yes',
|
|
31
|
-
describe: chalk.bold('Skip prompts and use default values'),
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const apiKeyOption = {
|
|
35
|
-
describe: chalk.bold('Mobb authentication api-key'),
|
|
36
|
-
type: 'string',
|
|
37
|
-
};
|
|
38
|
-
const ciOption = {
|
|
39
|
-
describe: chalk.bold(
|
|
40
|
-
'Run in CI mode, prompts and browser will not be opened'
|
|
41
|
-
),
|
|
42
|
-
type: 'boolean',
|
|
43
|
-
default: false,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const parseArgs = (args) => {
|
|
47
|
-
const yargsInstance = yargs(args);
|
|
48
|
-
return yargsInstance
|
|
49
|
-
.updateStrings({
|
|
50
|
-
'Commands:': chalk.yellow.underline.bold('Commands:'),
|
|
51
|
-
'Options:': chalk.yellow.underline.bold('Options:'),
|
|
52
|
-
'Examples:': chalk.yellow.underline.bold('Examples:'),
|
|
53
|
-
'Show help': chalk.bold('Show help'),
|
|
54
|
-
})
|
|
55
|
-
.usage(
|
|
56
|
-
`${chalk.bold(
|
|
57
|
-
'\n Bugsy - Trusted, Automatic Vulnerability Fixer 🕵️♂️\n\n'
|
|
58
|
-
)} ${chalk.yellow.underline.bold('Usage:')} \n $0 ${chalk.green(
|
|
59
|
-
'<command>'
|
|
60
|
-
)} ${chalk.dim('[options]')}
|
|
61
|
-
`
|
|
62
|
-
)
|
|
63
|
-
.version(false)
|
|
64
|
-
.command({
|
|
65
|
-
//
|
|
66
|
-
command: 'scan',
|
|
67
|
-
describe: chalk.bold(
|
|
68
|
-
'Scan your code for vulnerabilities, get automated fixes right away.'
|
|
69
|
-
),
|
|
70
|
-
builder: (yargs) => {
|
|
71
|
-
return yargs.options({
|
|
72
|
-
r: repoOption,
|
|
73
|
-
ref: refOption,
|
|
74
|
-
s: {
|
|
75
|
-
alias: 'scanner',
|
|
76
|
-
choices: Object.values(SCANNERS),
|
|
77
|
-
describe: chalk.bold('Select the scanner to use'),
|
|
78
|
-
},
|
|
79
|
-
y: yesOption,
|
|
80
|
-
['api-key']: apiKeyOption,
|
|
81
|
-
});
|
|
82
|
-
},
|
|
83
|
-
})
|
|
84
|
-
.command({
|
|
85
|
-
command: 'analyze',
|
|
86
|
-
describe: chalk.bold(
|
|
87
|
-
'Provide a vulnerability report and relevant code repository, get automated fixes right away.'
|
|
88
|
-
),
|
|
89
|
-
builder: (yargs) => {
|
|
90
|
-
return yargs
|
|
91
|
-
.options({
|
|
92
|
-
f: {
|
|
93
|
-
alias: 'scan-file',
|
|
94
|
-
demandOption: true,
|
|
95
|
-
describe: chalk.bold(
|
|
96
|
-
'Select the vulnerability report to analyze'
|
|
97
|
-
),
|
|
98
|
-
},
|
|
99
|
-
r: {
|
|
100
|
-
...repoOption,
|
|
101
|
-
demandOption: false,
|
|
102
|
-
},
|
|
103
|
-
p: srcPathOption,
|
|
104
|
-
ref: refOption,
|
|
105
|
-
ch: commitHash,
|
|
106
|
-
y: yesOption,
|
|
107
|
-
['api-key']: apiKeyOption,
|
|
108
|
-
ci: ciOption,
|
|
109
|
-
})
|
|
110
|
-
.check((argv) => {
|
|
111
|
-
if (!argv.srcPath && !argv.repo) {
|
|
112
|
-
throw new Error(
|
|
113
|
-
'You must supply either --src-path or --repo'
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (argv.ci && !argv.apiKey) {
|
|
118
|
-
throw new Error(
|
|
119
|
-
'--ci flag requires --api-key to be provided as well'
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return true;
|
|
124
|
-
});
|
|
125
|
-
},
|
|
126
|
-
})
|
|
127
|
-
.example('$0 scan -r https://github.com/WebGoat/WebGoat')
|
|
128
|
-
.command({
|
|
129
|
-
command: '*',
|
|
130
|
-
handler() {
|
|
131
|
-
yargsInstance.showHelp();
|
|
132
|
-
},
|
|
133
|
-
})
|
|
134
|
-
.strictOptions()
|
|
135
|
-
.help('h')
|
|
136
|
-
.alias('h', 'help')
|
|
137
|
-
.epilog(chalk.bgBlue('Made with ❤️ by Mobb'))
|
|
138
|
-
.showHelpOnFail(true)
|
|
139
|
-
.wrap(Math.min(120, yargsInstance.terminalWidth()))
|
|
140
|
-
.parse();
|
|
141
|
-
};
|