9 from argparse
import Namespace
15 Report formats supported by the script.
26 Hold the various shared flags and data
28 :ivar nomos: run nomos scanner
29 :ivar ojo: run ojo scanner
30 :ivar copyright: run copyright scanner
31 :ivar keyword: run keyword scanner
32 :ivar repo: scan whole repo or just diff
33 :ivar differential: scan between two versions of a repo
34 :ivar scan_dir: Scan a particular subdirectory
35 :ivar tags: tuple of length 2: (from_tag , to_tag) to scan
36 :ivar diff_dir: directory to scan
37 :ivar dir_path: Path to subdirectory to scan
38 :ivar keyword_conf_file_path: path to custom keyword.conf file passed by user
39 :ivar allowlist_path: path to allowlist.json file
40 :ivar allowlist: information from allowlist.json
41 :ivar report_format: Report format to use
42 :ivar scan_only_deps: Scan only dependencies
43 :ivar sbom_path: Path to sbom file
47 copyright: bool =
False
50 differential: bool =
False
51 scan_dir: bool =
False
53 diff_dir: str = os.getcwd()
55 keyword_conf_file_path : str =
''
56 allowlist_path: str =
None
57 allowlist: dict[str, list[str]] = {
61 report_format: ReportFormat = ReportFormat.TEXT
62 scan_only_deps: bool =
False
67 Update options based on argsparse values.
69 :param args: Argparse from cli
71 if "nomos" in args.operation:
72 self.
nomosnomos =
True
73 if "copyright" in args.operation:
75 if "keyword" in args.operation:
77 if "ojo" in args.operation:
79 if 'repo' in args.operation
and 'differential' in args.operation:
80 raise ValueError(
"You can only specify either 'repo' or 'differential' scans at a time.")
81 if "repo" in args.operation:
83 if "differential" in args.operation:
85 if 'scan-only-deps' in args.operation:
87 if "scan-dir" in args.operation:
89 if self.
scan_dirscan_dir
and args.dir_path !=
'':
90 self.
dir_pathdir_path = args.dir_path
91 if args.tags
is not None and self.
differentialdifferential
and len(args.tags) == 2:
92 self.
tagstags = (args.tags[0],args.tags[1])
93 if args.allowlist_path:
95 if self.
nomosnomos
is False and self.
ojoojo
is False and self.
copyrightcopyright
is False \
96 and self.
keywordkeyword
is False:
97 self.
nomosnomos =
True
102 if self.
keywordkeyword
and args.keyword_conf:
def update_args(self, Namespace args)