2020def _add_required_group (parser ):
2121 required_group = parser .add_argument_group ('required arguments' )
2222 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
2526 )
2627
2728
@@ -54,21 +55,27 @@ def _add_optional_group(parser):
5455 action = 'store_true' ,
5556 default = False
5657 )
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+ )
5764 optional_group .add_argument (
5865 '-m' , '--blackbox-mapping-file' ,
5966 help = 'Input blackbox mapping file.' ,
6067 type = str ,
6168 default = default_blackbox_mapping_file
6269 )
6370 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
6875 )
6976 optional_group .add_argument (
7077 '-o' , '--output' ,
71- help = 'write report to filename' ,
78+ help = 'Write report to filename' ,
7279 dest = 'output_file' ,
7380 action = 'store' ,
7481 type = argparse .FileType ('w' ),
@@ -78,11 +85,13 @@ def _add_optional_group(parser):
7885 '--ignore-nosec' ,
7986 dest = 'ignore_nosec' ,
8087 action = 'store_true' ,
81- help = 'do not skip lines with # nosec comments'
88+ help = 'Do not skip lines with # nosec comments'
8289 )
8390 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'
8695 )
8796 optional_group .add_argument (
8897 '-x' , '--exclude' ,
@@ -108,39 +117,18 @@ def _add_optional_group(parser):
108117 )
109118
110119
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-
132120def parse_args (args ):
133121 if len (args ) == 0 :
134122 args .append ('-h' )
135123 parser = argparse .ArgumentParser (prog = 'python -m pyt' )
124+
125+ # Hack to in order to list required args above optional
136126 parser ._action_groups .pop ()
127+
137128 _add_required_group (parser )
138129 _add_optional_group (parser )
139- _add_print_group (parser )
140130
141131 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' )
146134 return args
0 commit comments