fuzzr 0.9.9

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fuzzr might be problematic. Click here for more details.

data/lib/fuzz/log.rb ADDED
@@ -0,0 +1,97 @@
1
+ #--------------------------------------------------------------------
2
+ # @file log.rb
3
+ # @author Martin Corino
4
+ #
5
+ # @brief Fuzz logging support
6
+ #
7
+ # @copyright Copyright (c) Remedy IT Expertise BV
8
+ #--------------------------------------------------------------------
9
+ require 'fuzz/console'
10
+
11
+ module Fuzz
12
+
13
+ #
14
+ # Default Reporting/Logging
15
+ #
16
+ class Reporter
17
+ def initialize(output = Fuzz::Console)
18
+ @output = output
19
+ klass = class << self; self; end
20
+ klass.__send__(:include, @output.colorizer_include)
21
+ end
22
+
23
+ attr_reader :output
24
+
25
+ def log_error(msg)
26
+ output.error_println 'Fuzz - ', red(bold 'ERROR'), ' : ', msg
27
+ end
28
+
29
+ def log_warning(msg)
30
+ output.error_println 'Fuzz - ', yellow(bold 'WARNING'), ' : ', msg
31
+ end
32
+
33
+ def log_info(msg)
34
+ output.println 'Fuzz - ', msg
35
+ end
36
+
37
+ def show_error(msg)
38
+ log_error(msg)
39
+ end
40
+
41
+ def show_warning(msg)
42
+ log_error(msg)
43
+ end
44
+
45
+ def show_msg(msg)
46
+ log(msg)
47
+ end
48
+ end
49
+
50
+ module LogMethods
51
+ def log_fatal(msg, rc=1)
52
+ Fuzz.reporter.log_error(msg)
53
+ exit rc
54
+ end
55
+
56
+ def log_error(msg)
57
+ Fuzz.reporter.log_error(msg)
58
+ end
59
+
60
+ def log_warning(msg)
61
+ Fuzz.reporter.log_warning(msg)
62
+ end
63
+
64
+ def log_info(msg)
65
+ Fuzz.reporter.log_info(msg)
66
+ end
67
+
68
+ def log(lvl, msg)
69
+ Fuzz.reporter.log_info(msg) if lvl <= verbosity
70
+ end
71
+
72
+ def show_error(msg)
73
+ Fuzz.reporter.show_error(msg)
74
+ end
75
+
76
+ def show_warning(msg)
77
+ Fuzz.reporter.show_warning(msg)
78
+ end
79
+
80
+ def show_msg(msg)
81
+ Fuzz.reporter.show_msg(msg)
82
+ end
83
+
84
+ def verbosity
85
+ Fuzz.verbosity
86
+ end
87
+
88
+ def verbose?
89
+ verbosity > 1
90
+ end
91
+
92
+ def silent?
93
+ verbosity < 1
94
+ end
95
+ end
96
+
97
+ end # Fuzz
@@ -0,0 +1,208 @@
1
+ #--------------------------------------------------------------------
2
+ # @file options.rb
3
+ # @author Martin Corino
4
+ #
5
+ # @brief Options module for fuzz
6
+ #
7
+ # @copyright Copyright (c) Remedy IT Expertise BV
8
+ #--------------------------------------------------------------------
9
+
10
+ require 'ostruct'
11
+ require 'yaml'
12
+ require 'fuzz/log'
13
+
14
+ module Fuzz
15
+
16
+ FUZZRC = '.fuzzrc'
17
+ FUZZRC_GLOBAL = File.expand_path(File.join(ENV['HOME'] || ENV['HOMEPATH'] || '~', FUZZRC))
18
+
19
+ OPTIONS = OpenStruct.new
20
+
21
+ class << OPTIONS
22
+
23
+ include Fuzz::LogMethods
24
+
25
+ def options
26
+ self
27
+ end
28
+
29
+ class Config < OpenStruct
30
+
31
+ include Fuzz::LogMethods
32
+
33
+ def initialize(hash=nil)
34
+ super
35
+ @table = _merge(_defaults, @table)
36
+ end
37
+
38
+ def options
39
+ Fuzz.options
40
+ end
41
+
42
+ def merge(from)
43
+ _merge(@table, from)
44
+ self
45
+ end
46
+
47
+ def load(rcpath)
48
+ log(3, "Loading #{FUZZRC} from #{rcpath}")
49
+ _cfg = YAML.load(IO.read(rcpath))
50
+ log(4, "Read from #{rcpath}: [#{_cfg}]")
51
+ # handle automatic env var expansion in fzzr_paths
52
+ _cfg[:fzzr_paths] = (_cfg[:fzzr_paths] || []).collect do |p|
53
+ log(5, "Examining fzzr_path [#{p}]")
54
+ # for paths coming from rc files environment vars are immediately expanded and
55
+ p.gsub!(/\$([^\s\/]+)/) { |m| ENV[$1] }
56
+ log(6, "Expanded fzzr_path [#{p}]")
57
+ # resulting relative paths converted to absolute paths
58
+ if File.directory?(p) # relative to working dir?
59
+ p = File.expand_path(p)
60
+ else # relative to rc location?
61
+ _fp = File.expand_path(File.join(File.dirname(rcpath), p))
62
+ log(4, "Ignoring invalid fuzzer search path #{p} configured in #{rcpath}") unless File.directory?(_fp)
63
+ p = _fp
64
+ end
65
+ log(4, "Adding fuzzer search path: #{p}")
66
+ p
67
+ end
68
+ merge(_cfg)
69
+ end
70
+
71
+ def save(rcpath)
72
+ File.open(rcpath, 'w') {|f| f << YAML.dump(@table) }
73
+ end
74
+
75
+ protected
76
+
77
+ def _defaults
78
+ {
79
+ :brix_paths => []
80
+ }
81
+ end
82
+
83
+ def _merge(to, from)
84
+ from.each_pair do |(k,v)|
85
+ k = k.to_sym
86
+ if to.has_key?(k)
87
+ case to[k]
88
+ when Array
89
+ to[k].concat v
90
+ when Hash
91
+ to[k].merge!(v)
92
+ when OpenStruct
93
+ _merge(to[k].__send__(:table), v)
94
+ else
95
+ to[k] = v
96
+ end
97
+ else
98
+ to[k] = v
99
+ end
100
+ end
101
+ to
102
+ end
103
+
104
+ end
105
+
106
+ protected
107
+
108
+ def _defaults
109
+ {
110
+ :verbose => (ENV['FUZZ_VERBOSE'] || 1).to_i,
111
+ :recurse => true,
112
+ :apply_fix => false,
113
+ :config => Config.new({
114
+ :follow_symlink => true,
115
+ :exts => [],
116
+ :filenames => [],
117
+ :excludes => [],
118
+ :add_files => false,
119
+ :fzzr_paths => [],
120
+ :fzzr_opts => {},
121
+ :fzzr_excludes => []
122
+ })
123
+ }
124
+ end
125
+
126
+ def _rc_paths
127
+ @rc_paths ||= []
128
+ end
129
+ def _loaded_rc_paths
130
+ @loaded_rc_paths ||= []
131
+ end
132
+
133
+ def _add_rcpath(path)
134
+ if _loaded_rc_paths.include?(File.expand_path(path))
135
+ log(3, "ignoring already loaded rc : #{path}")
136
+ else
137
+ log(3, "adding rc path : #{path}")
138
+ _rc_paths << path
139
+ end
140
+ _rc_paths
141
+ end
142
+
143
+ public
144
+
145
+ def reset
146
+ @table.clear
147
+ @table.merge!(_defaults)
148
+ _rc_paths.clear
149
+ _rc_paths << FUZZRC_GLOBAL
150
+ _loaded_rc_paths.clear
151
+ (ENV['FUZZRC'] || '').split(/:|;/).each do |p|
152
+ _add_rcpath(p)
153
+ end
154
+ end
155
+
156
+ def load_config
157
+ # first collect config from known (standard and configured) locations
158
+ _rc_paths.collect {|path| File.expand_path(path) }.each do |rcp|
159
+ log(3, "Testing rc path #{rcp}")
160
+ if File.readable?(rcp) && !_loaded_rc_paths.include?(rcp)
161
+ _cfg = Config.new.load(rcp)
162
+ self[:config].merge(_cfg)
163
+ _loaded_rc_paths << rcp
164
+ else
165
+ log(3, "Ignoring #{File.readable?(rcp) ? 'already loaded' : 'inaccessible'} rc path #{rcp}")
166
+ end
167
+ end
168
+ # now scan working path for any rc files unless specified otherwise
169
+ unless self[:no_rc_scan]
170
+ _cwd = File.expand_path(Dir.getwd)
171
+ log(3, "scanning working path #{_cwd} for rc files")
172
+ # first collect any rc files found
173
+ _rcpaths = []
174
+ begin
175
+ _rcp = File.join(_cwd, FUZZRC)
176
+ if File.readable?(_rcp) && !_loaded_rc_paths.include?(_rcp)
177
+ _rcpaths << _rcp
178
+ else
179
+ log(3, "Ignoring #{File.readable?(_rcp) ? 'already loaded' : 'inaccessible'} rc path #{_rcp}")
180
+ end
181
+ break if /\A(.:(\\|\/)|\.|\/)\Z/ =~ _cwd
182
+ _cwd = File.dirname(_cwd)
183
+ end while true
184
+ # now load them in reverse order
185
+ _rcpaths.reverse.each do |_rcp|
186
+ _cfg = Config.new.load(_rcp)
187
+ self[:config].merge(_cfg)
188
+ _loaded_rc_paths << _rcp
189
+ end
190
+ end
191
+ # lastly merge config specified by user on commandline
192
+ self[:config].merge(user_config)
193
+ end
194
+
195
+ def add_config(rcpath)
196
+ log_fatal("inaccessible rc path specified : #{rcpath}") unless File.readable?(rcpath)
197
+ _add_rcpath(rcpath)
198
+ end
199
+
200
+ def user_config
201
+ @user_config ||= Config.new
202
+ end
203
+
204
+ end # OPTIONS class
205
+
206
+ OPTIONS.reset # initialize
207
+
208
+ end # Fuzz
@@ -0,0 +1,85 @@
1
+ #--------------------------------------------------------------------
2
+ # @file screen.rb
3
+ # @author Martin Corino
4
+ #
5
+ # @brief Fuzz screen wrapper
6
+ #
7
+ # @copyright Copyright (c) Remedy IT Expertise BV
8
+ #--------------------------------------------------------------------
9
+ require 'fuzz/system'
10
+
11
+ module Fuzz
12
+
13
+ class Screen
14
+
15
+ class Color
16
+ def initialize(code)
17
+ @code = code
18
+ end
19
+ attr_reader :code
20
+ def to_s
21
+ ''
22
+ end
23
+ alias :to_str :to_s
24
+ end
25
+
26
+ COLORS = {
27
+ black: [Color.new("\e[30m"), Color.new("\e[m")],
28
+ red: [Color.new("\e[31m"), Color.new("\e[m")],
29
+ green: [Color.new("\e[32m"), Color.new("\e[m")],
30
+ yellow: [Color.new("\e[33m"), Color.new("\e[m")],
31
+ blue: [Color.new("\e[34m"), Color.new("\e[m")],
32
+ magenta: [Color.new("\e[34m"), Color.new("\e[m")],
33
+ bold: [Color.new("\e[1m"), Color.new("\e[m")],
34
+ reverse: [Color.new("\e[7m"), Color.new("\e[m")],
35
+ underline:[Color.new("\e[4m"), Color.new("\e[m")]
36
+ }
37
+
38
+ module ColorizeMethods
39
+ def self.included(mod)
40
+ Screen::COLORS.keys.each do |color|
41
+ mod.module_eval <<-EOT, __FILE__, __LINE__+1
42
+ def #{color}(s)
43
+ [Fuzz::Screen::COLORS[:#{color}].first, s, Fuzz::Screen::COLORS[:#{color}].last]
44
+ end
45
+ EOT
46
+ end
47
+ end
48
+ end
49
+
50
+ def initialize(output = STDOUT, input = STDIN, errout = STDERR)
51
+ @output = output
52
+ @input = input
53
+ @errout = errout
54
+ @colorize = output.tty? && Fuzz::Sys.has_ansi?
55
+ end
56
+
57
+ attr_reader :input, :output, :errout
58
+
59
+ def colorize?
60
+ @colorize
61
+ end
62
+
63
+ def output_cols
64
+ 80
65
+ end
66
+
67
+ def print(*args)
68
+ output.print args.flatten.collect {|a| (colorize? && Color === a) ? a.code : a }.join
69
+ end
70
+
71
+ def println(*args)
72
+ output.puts args.flatten.collect {|a| (colorize? && Color === a) ? a.code : a }.join
73
+ end
74
+
75
+ def error_print(*args)
76
+ errout.print args.flatten.collect {|a| (colorize? && Color === a) ? a.code : a }.join
77
+ end
78
+
79
+ def error_println(*args)
80
+ errout.puts args.flatten.collect {|a| (colorize? && Color === a) ? a.code : a }.join
81
+ end
82
+
83
+ end # Screen
84
+
85
+ end # Fuzz
@@ -0,0 +1,57 @@
1
+ #--------------------------------------------------------------------
2
+ # @file system.rb
3
+ # @author Martin Corino
4
+ #
5
+ # @brief System support for Fuzz
6
+ #
7
+ # @copyright Copyright (c) Remedy IT Expertise BV
8
+ #--------------------------------------------------------------------
9
+ require 'fileutils'
10
+
11
+ module Fuzz
12
+
13
+ module Sys
14
+
15
+ module SysMethods
16
+
17
+ def mswin?
18
+ /mingw/ =~ RUBY_PLATFORM ? true : false
19
+ end
20
+
21
+ def has_ansi?
22
+ # only ANSI escape code support on Windows
23
+ # if ANSICON (https://github.com/adoxa/ansicon) installed
24
+ (!mswin?) || ENV['ANSICON']
25
+ end
26
+
27
+ def in_dir(dir, &block)
28
+ STDERR.puts "cd #{dir}" if Fuzz.verbose?
29
+ rc = if Fuzz.dryrun?
30
+ yield if block_given?
31
+ else
32
+ Dir.chdir(dir, &block)
33
+ end
34
+ STDERR.puts "cd -" if Fuzz.verbose?
35
+ rc
36
+ end
37
+ def mv(src, tgt)
38
+ FileUtils.move(src, tgt, :verbose => Fuzz.verbose?)
39
+ end
40
+
41
+ def cp(src, tgt)
42
+ FileUtils.copy(src, tgt, :verbose => Fuzz.verbose?)
43
+ end
44
+
45
+ def chmod(mode, path)
46
+ FileUtils.chmod(mode, path, :verbose => Fuzz.verbose?)
47
+ end
48
+
49
+ end # SysMethods
50
+
51
+ class << self
52
+ include Sys::SysMethods
53
+ end
54
+
55
+ end # Sys
56
+
57
+ end # Fuzz
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+ # -------------------------------------------------------------------
3
+ # version.rb - TAOX11 fuzz checker
4
+ #
5
+ # Author: Martin Corino
6
+ #
7
+ # Copyright (c) Remedy IT Expertise BV
8
+ # -------------------------------------------------------------------
9
+
10
+ module Fuzz
11
+
12
+ FUZZ_VERSION_MAJOR = 0
13
+ FUZZ_VERSION_MINOR = 9
14
+ FUZZ_VERSION_RELEASE = 9
15
+ FUZZ_VERSION = "#{FUZZ_VERSION_MAJOR}.#{FUZZ_VERSION_MINOR}.#{FUZZ_VERSION_RELEASE}"
16
+ FUZZ_COPYRIGHT = "Copyright (c) 2012-#{Time.now.year} Remedy IT Expertise BV, The Netherlands".freeze
17
+
18
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fuzzr
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.9
5
+ platform: ruby
6
+ authors:
7
+ - Martin Corino
8
+ - Johnny Willemsen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2021-02-11 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Fuzzer
15
+ email: mcorino@remedy.nl
16
+ executables:
17
+ - fuzz
18
+ extensions: []
19
+ extra_rdoc_files:
20
+ - LICENSE
21
+ - README.rdoc
22
+ files:
23
+ - LICENSE
24
+ - README.rdoc
25
+ - bin/fuzz
26
+ - fuzzers/check_ace_error.excludes
27
+ - fuzzers/check_ace_error.rb
28
+ - fuzzers/check_catch_ex_as_const.rb
29
+ - fuzzers/check_cout_cerr.excludes
30
+ - fuzzers/check_cout_cerr.rb
31
+ - fuzzers/check_executablebit.rb
32
+ - fuzzers/check_exit_keyword.excludes
33
+ - fuzzers/check_exit_keyword.rb
34
+ - fuzzers/check_fileheader.excludes
35
+ - fuzzers/check_fileheader.rb
36
+ - fuzzers/check_filename.excludes
37
+ - fuzzers/check_filename.rb
38
+ - fuzzers/check_id_tag.rb
39
+ - fuzzers/check_new_delete.excludes
40
+ - fuzzers/check_new_delete.rb
41
+ - fuzzers/check_printf_keyword.excludes
42
+ - fuzzers/check_printf_keyword.rb
43
+ - fuzzers/check_taox11_namespace.excludes
44
+ - fuzzers/check_taox11_namespace.rb
45
+ - lib/fuzz/console.rb
46
+ - lib/fuzz/fuzz.rb
47
+ - lib/fuzz/fuzzers/check_whitespace.rb
48
+ - lib/fuzz/fzzr.rb
49
+ - lib/fuzz/log.rb
50
+ - lib/fuzz/options.rb
51
+ - lib/fuzz/screen.rb
52
+ - lib/fuzz/system.rb
53
+ - lib/fuzz/version.rb
54
+ homepage: https://github.com/RemedyIT/fuzzr
55
+ licenses:
56
+ - MIT
57
+ metadata:
58
+ bug_tracker_uri: https://github.com/RemedyIT/fuzzr/issues
59
+ source_code_uri: https://github.com/RemedyIT/fuzzr
60
+ post_install_message:
61
+ rdoc_options:
62
+ - "--main"
63
+ - README.rdoc
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '2.0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubygems_version: 3.1.4
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: fuzzr
81
+ test_files: []