forked from buzzcode/veracode-flaws-to-issues
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcli.js
executable file
·52 lines (44 loc) · 1.59 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// entry point when called via CLI (mostly for testing)
//
const program = require('commander');
const dotenv = require('dotenv');
const importFlaws = require('./importer').importFlaws;
dotenv.config();
var githubOwner = process.env.GITHUB_OWNER;
var githubRepo = process.env.GITHUB_REPO;
var githubToken = process.env.GITHUB_TOKEN;
var waitTime = process.env.WAIT_TIME;
program
.version('0.0.1')
.requiredOption('-r, --results <path>', 'Scan results file to create issues from', 'filtered_results.json')
.option('-go, --github-owner <string>', 'GitHub owner name')
.option('-gr, --github-repo <string>', 'GitHub repo name')
.option('-t, --token <string>', 'GitHub auth token')
.option('-w, --wait-time <integer>', 'Seconds to wait between adding Issues to GitHub, for rate-limiting (default: 2 seconds)')
.parse()
try {
let opts = program.opts();
// cmd-line opts override env vars
if(opts.githubOwner !== undefined)
githubOwner = opts.githubOwner;
if(opts.githubRepo !== undefined)
githubRepo = opts.githubRepo;
if(opts.githubToken !== undefined)
githubToken = opts.githubToken;
if(opts.waitTime !== undefined)
waitTime = opts.waitTime;
else if(waitTime === undefined)
waitTime = 2;
// do the thing
importFlaws(
{resultsFile: opts['results'],
githubOwner: githubOwner,
githubRepo: githubRepo,
githubToken: githubToken,
waitTime: waitTime}
)
.catch(error => {console.error(`Failure at ${error.stack}`)});
} catch (error) {
console.error(error.stack);
}