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
44 :ivar parser: Parser instance to hold list of parsed components
48 copyright: bool =
False
51 differential: bool =
False
52 scan_dir: bool =
False
53 tags: tuple = (
'',
'')
54 diff_dir: str = os.getcwd()
56 keyword_conf_file_path: str =
''
57 allowlist_path: str =
None
58 allowlist: dict[str, list[str]] = {
62 report_format: ReportFormat = ReportFormat.TEXT
63 scan_only_deps: bool =
False
69 Update options based on argsparse values.
71 :param args: Argparse from cli
74 operations = set(args.operation)
if hasattr(args,
'operation')
else set()
76 self.
nomosnomos =
'nomos' in operations
77 self.
copyrightcopyright =
'copyright' in operations
78 self.
keywordkeyword =
'keyword' in operations
79 self.
ojoojo =
'ojo' in operations
81 if 'repo' in operations
and 'differential' in operations:
83 "You can only specify either 'repo' or 'differential' scans at a time."
86 self.
reporepo =
'repo' in operations
87 self.
differentialdifferential =
'differential' in operations
89 self.
scan_dirscan_dir =
'scan-dir' in operations
91 if self.
scan_dirscan_dir
and args.dir_path !=
'':
92 self.
dir_pathdir_path = args.dir_path
93 if args.tags
is not None and self.
differentialdifferential
and len(args.tags) == 2:
94 self.
tagstags = (args.tags[0], args.tags[1])
95 if args.allowlist_path:
103 if self.
keywordkeyword
and args.keyword_conf:
def update_args(self, Namespace args)