Method: Fuzz.init_optparser
- Defined in:
- lib/fuzz/fuzz.rb
.init_optparser ⇒ Object
parse commandline arguments
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/fuzz/fuzz.rb', line 155 def self.init_optparser script_name = File.basename($0) if not script_name =~ /fuzz/ script_name = "ruby "+$0 end .optparser = opts = OptionParser.new opts. = "Usage: #{script_name} [options] [glob [glob]]\n\n" opts.separator "\n--- [General options] ---\n\n" opts.on('-t', '--filetype', '=EXT', String, 'Defines an alternative filetype to search and scan. Can be specified multiple times.', "Default: #{Fuzz::FileObject.extensions.join('|')}") { |v| (.user_config[:exts] ||= []) << v } opts.on('-f', '--file', '=NAME', String, 'Defines an alternative filename to search and scan. Can be specified multiple times.', "Default: #{Fuzz::FileObject.filenames.join('|')}") { |v| (.user_config[:filenames] ||= []) << v } opts.on('-a', '--add-files', 'Add custom filenames and/or filetype extensions to default list instead of replacing defaults.', 'Default: false') { |v| .user_config[:add_files] = true } opts.on('-S', '--no-symlinks', 'Do not follow symlinks.', 'Default: follow symlinks') { |v| .user_config[:follow_symlink] = false } opts.on('-P', '--fzzr-path', '=PATH', 'Adds search path for Fuzzers.', "Default: loaded from ~/#{FUZZRC} and/or ./#{FUZZRC}") { |v| (.user_config[:fzzr_paths] ||= []) << v.to_s } opts.on('-B', '--blacklist', '=FZZRID', 'Adds Fuzzer ID to list of fuzzers to exclude from Fuzz check.', 'Default: none') { |v| (.user_config[:fzzr_excludes] ||= []) << v.to_sym } opts.on('-X', '--exclude', '=MASK', 'Adds path mask (regular expression) to list to exclude from Fuzz check.', 'Default: none') { |v| (.user_config[:excludes] ||= []) << v } opts.on('-c', '--config', '=FUZZRC', 'Load config from FUZZRC file.', "Default: ~/#{FUZZRC} and/or ./#{FUZZRC}") { |v| .add_config(v) } opts.on('--write-config', '=[FUZZRC]', 'Write config to file and exit.', "Default: ./#{FUZZRC}") { |v| .user_config.save(String === v ? v : FUZZRC) exit } opts.on('--show-config', 'Display config settings and exit.') { |v| .load_config puts YAML.dump(.config.__send__ :table) exit } opts.separator '' opts.on('-o', '--output', '=FILE', String, 'Specifies filename to write Fuzz messages to.', 'Default: stderr') { |v| .output = v } opts.on('-p', '--apply-fix', 'Apply fixes (if any) for Fuzz errors.', 'Default: false') { |v| .apply_fix = true } opts.on('-n', '--no-recurse', 'Prevents directory recursion in file selection.', 'Default: recurse') { |v| .recurse = false } opts.on('-v', '--verbose', 'Run with increased verbosity level. Repeat to increase more.', 'Default: 1') { |v| .verbose += 1 } opts.separator '' opts.on('-L', '--list', 'List available Fuzzers and exit.') { .load_config load_fuzzers puts "TAOX11 fuzz checker #{FUZZ_VERSION_MAJOR}.#{FUZZ_VERSION_MINOR}.#{FUZZ_VERSION_RELEASE}" puts FUZZ_COPYRIGHT puts('%-30s %s' % %w{Fuzzer Description}) puts(('-' * 30)+' '+('-' * 48)) fuzzers.values.each { |fzzr| puts('%-30s %s' % [fzzr.fuzz_id, fzzr.description]) } puts exit } opts.separator "" opts.on('-V', '--version', 'Show version information and exit.') { puts "TAOX11 fuzz checker #{FUZZ_VERSION_MAJOR}.#{FUZZ_VERSION_MINOR}.#{FUZZ_VERSION_RELEASE}" puts FUZZ_COPYRIGHT exit } opts.on('-h', '--help', 'Show this help message.') { .load_config load_fuzzers puts opts; puts; exit } opts.separator "\n--- [Fuzzer options] ---\n\n" end |