20
20
def _add_required_group (parser ):
21
21
required_group = parser .add_argument_group ('required arguments' )
22
22
required_group .add_argument (
23
- 'targets' , metavar = 'targets' , type = str , nargs = '+' ,
24
- help = 'source file(s) or directory(s) to be tested'
23
+ 'targets' , metavar = 'targets' , nargs = '+' ,
24
+ help = 'source file(s) or directory(s) to be scanned' ,
25
+ type = str
25
26
)
26
27
27
28
@@ -54,21 +55,27 @@ def _add_optional_group(parser):
54
55
action = 'store_true' ,
55
56
default = False
56
57
)
58
+ optional_group .add_argument (
59
+ '-t' , '--trigger-word-file' ,
60
+ help = 'Input file with a list of sources and sinks' ,
61
+ type = str ,
62
+ default = default_trigger_word_file
63
+ )
57
64
optional_group .add_argument (
58
65
'-m' , '--blackbox-mapping-file' ,
59
66
help = 'Input blackbox mapping file.' ,
60
67
type = str ,
61
68
default = default_blackbox_mapping_file
62
69
)
63
70
optional_group .add_argument (
64
- '-t ' , '--trigger-word-file ' ,
65
- help = 'Input file with a list of sources and sinks ' ,
66
- type = str ,
67
- default = default_trigger_word_file
71
+ '-i ' , '--interactive ' ,
72
+ help = 'Will ask you about each blackbox function call in vulnerability chains. ' ,
73
+ action = 'store_true' ,
74
+ default = False
68
75
)
69
76
optional_group .add_argument (
70
77
'-o' , '--output' ,
71
- help = 'write report to filename' ,
78
+ help = 'Write report to filename' ,
72
79
dest = 'output_file' ,
73
80
action = 'store' ,
74
81
type = argparse .FileType ('w' ),
@@ -78,11 +85,13 @@ def _add_optional_group(parser):
78
85
'--ignore-nosec' ,
79
86
dest = 'ignore_nosec' ,
80
87
action = 'store_true' ,
81
- help = 'do not skip lines with # nosec comments'
88
+ help = 'Do not skip lines with # nosec comments'
82
89
)
83
90
optional_group .add_argument (
84
- '-r' , '--recursive' , dest = 'recursive' ,
85
- action = 'store_true' , help = 'find and process files in subdirectories'
91
+ '-r' , '--recursive' ,
92
+ dest = 'recursive' ,
93
+ action = 'store_true' ,
94
+ help = 'Find and process files in subdirectories'
86
95
)
87
96
optional_group .add_argument (
88
97
'-x' , '--exclude' ,
@@ -108,39 +117,18 @@ def _add_optional_group(parser):
108
117
)
109
118
110
119
111
- def _add_print_group (parser ):
112
- print_group = parser .add_argument_group ('print arguments' )
113
- print_group .add_argument (
114
- '-trim' , '--trim-reassigned-in' ,
115
- help = 'Trims the reassigned list to just the vulnerability chain.' ,
116
- action = 'store_true' ,
117
- default = True
118
- )
119
- print_group .add_argument (
120
- '-i' , '--interactive' ,
121
- help = 'Will ask you about each blackbox function call in vulnerability chains.' ,
122
- action = 'store_true' ,
123
- default = False
124
- )
125
-
126
-
127
- def _check_required_and_mutually_exclusive_args (parser , args ):
128
- if args .targets is None :
129
- parser .error ('The targets argument is required' )
130
-
131
-
132
120
def parse_args (args ):
133
121
if len (args ) == 0 :
134
122
args .append ('-h' )
135
123
parser = argparse .ArgumentParser (prog = 'python -m pyt' )
124
+
125
+ # Hack to in order to list required args above optional
136
126
parser ._action_groups .pop ()
127
+
137
128
_add_required_group (parser )
138
129
_add_optional_group (parser )
139
- _add_print_group (parser )
140
130
141
131
args = parser .parse_args (args )
142
- _check_required_and_mutually_exclusive_args (
143
- parser ,
144
- args
145
- )
132
+ if args .targets is None :
133
+ parser .error ('The targets argument is required' )
146
134
return args
0 commit comments