This repository has been archived by the owner on Jan 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·47 lines (35 loc) · 1.49 KB
/
main.py
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
#! python3
from argparse import ArgumentParser
import parse
import database
import detect
def main():
"""Main function to parse command line arguments."""
parser = ArgumentParser(
description="A simple Vulnerable Dependency Finder for Maven")
parser.add_argument("mode", type=str,
choices=["detectOnly", "doAll"], help="""
Modes for running the program. detectOnly consults the existing knowledge
base to list all vulnerable dependencies. doAll erases and rebuilds the
knowledge base before detection.""")
parser.add_argument("path", type=str, nargs='?',
default="./pom.xml",
help="Path to Maven project file.")
parser.add_argument("--years", "-y", type=int, nargs='?',
default=2, help="""
Number of years of CVD feeds to fetch. The default is 2, i.e. data from the
current year and the past year will be fetched.""")
args = parser.parse_args()
if args.mode == "detectOnly":
print("Detecting vulnerable dependencies for Maven project at path: "
f"{args.path}")
detect.match_all(detect.parse_xml(args.path))
elif args.mode == "doAll":
print("Rebuild vulnerability database and detect for Maven project at "
f"{args.path}")
data = parse.parse_years(args.years)
database.write_db(data)
database.cleanup_db()
detect.match_all(detect.parse_xml(args.path))
if __name__ == "__main__":
main()