9 from argparse
import Namespace
15 Report formats supported by the script.
29 Hold the various shared flags and data
31 :ivar nomos: run nomos scanner
32 :ivar ojo: run ojo scanner
33 :ivar copyright: run copyright scanner
34 :ivar keyword: run keyword scanner
35 :ivar repo: scan whole repo or just diff
36 :ivar differential: scan between two versions of a repo
37 :ivar scan_dir: Scan a particular subdirectory
38 :ivar tags: tuple of length 2: (from_tag , to_tag) to scan
39 :ivar diff_dir: directory to scan
40 :ivar dir_path: Path to subdirectory to scan
41 :ivar keyword_conf_file_path: path to custom keyword.conf file passed by user
42 :ivar allowlist_path: path to allowlist.json file
43 :ivar allowlist: information from allowlist.json
44 :ivar report_format: Report format to use
45 :ivar scan_only_deps: Scan only dependencies
46 :ivar sbom_path: Path to sbom file
47 :ivar parser: Parser instance to hold list of parsed components
51 copyright: bool =
False
54 differential: bool =
False
55 scan_dir: bool =
False
56 tags: tuple = (
'',
'')
57 diff_dir: str = os.getcwd()
59 keyword_conf_file_path: str =
''
60 allowlist_path: str =
None
61 allowlist: dict[str, list[str]] = {
65 report_format: ReportFormat = ReportFormat.TEXT
66 scan_only_deps: bool =
False
72 Update options based on argsparse values.
74 :param args: Argparse from cli
77 operations = set(args.operation)
if hasattr(args,
'operation')
else set()
79 self.
nomosnomos =
'nomos' in operations
80 self.
copyrightcopyright =
'copyright' in operations
81 self.
keywordkeyword =
'keyword' in operations
82 self.
ojoojo =
'ojo' in operations
84 if 'repo' in operations
and 'differential' in operations:
86 "You can only specify either 'repo' or 'differential' scans at a time."
89 self.
reporepo =
'repo' in operations
90 self.
differentialdifferential =
'differential' in operations
92 self.
scan_dirscan_dir =
'scan-dir' in operations
94 if self.
scan_dirscan_dir
and args.dir_path !=
'':
95 self.
dir_pathdir_path = args.dir_path
96 if args.tags
is not None and self.
differentialdifferential
and len(args.tags) == 2:
97 self.
tagstags = (args.tags[0], args.tags[1])
98 if args.allowlist_path:
106 if self.
keywordkeyword
and args.keyword_conf:
def update_args(self, Namespace args)