forked from ajinabraham/nodejsscan
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
27 lines (23 loc) · 945 Bytes
/
Copy pathcli.py
File metadata and controls
27 lines (23 loc) · 945 Bytes
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
import json
import argparse
from core.scanner import general_code_analysis
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--directory", nargs='+',
help="Node.js source code directory to scan", required=False)
parser.add_argument("-o", "--output",
help="Output file to save JSON report", required=False)
args = parser.parse_args()
if args.directory:
scan_results = general_code_analysis(args.directory)
if args.output:
with open("./" + str(args.output) + ".json", 'w') as outfile:
json.dump(scan_results, outfile, sort_keys=True,
indent=4, separators=(',', ': '))
else:
print(json.dumps(scan_results, sort_keys=True,
indent=4, separators=(',', ': ')))
else:
parser.print_help()
if __name__ == "__main__":
main()