forked from Arachni/arachni
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
255 lines (197 loc) · 8.51 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
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
=begin
Copyright 2010-2014 Tasos Laskos <tasos.laskos@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=end
require 'bundler'
require 'fileutils'
require File.expand_path( File.dirname( __FILE__ ) ) + '/lib/arachni'
begin
require 'rspec'
require 'rspec/core/rake_task'
namespace :spec do
desc 'Run core library tests.'
RSpec::Core::RakeTask.new( :core ) do |t|
t.pattern = FileList[ 'spec/arachni/**/*_spec.rb' ]
end
desc 'Run module tests.'
RSpec::Core::RakeTask.new( :modules ) do |t|
t.pattern = FileList[ 'spec/modules/**/*_spec.rb' ]
end
namespace :modules do
desc 'Run tests for the audit modules.'
RSpec::Core::RakeTask.new( :audit ) do |t|
t.pattern = FileList[ 'spec/modules/audit/**/*_spec.rb' ]
end
desc 'Run tests for the recon modules.'
RSpec::Core::RakeTask.new( :recon ) do |t|
t.pattern = FileList[ 'spec/modules/recon/**/*_spec.rb' ]
end
end
desc 'Run report tests.'
RSpec::Core::RakeTask.new( :reports ) do |t|
t.pattern = FileList[ 'spec/reports/**/*_spec.rb' ]
end
desc 'Run plugin tests.'
RSpec::Core::RakeTask.new( :plugins ) do |t|
t.pattern = FileList[ 'spec/plugins/**/*_spec.rb' ]
end
desc 'Run path-extractor tests.'
RSpec::Core::RakeTask.new( :path_extractors ) do |t|
t.pattern = FileList[ 'spec/path_extractors/**/*_spec.rb' ]
end
desc 'Run external test suites.'
RSpec::Core::RakeTask.new( :external ) do |t|
t.pattern = FileList[ 'spec/external/**/*_spec.rb' ]
end
namespace :external do
desc 'Run the WAVSEP test suite.'
RSpec::Core::RakeTask.new( :wavsep ) do |t|
t.pattern = FileList[ 'spec/external/wavsep/**/**/*_spec.rb' ]
end
namespace :wavsep do
desc 'Run the WAVSEP active tests.'
RSpec::Core::RakeTask.new( :active ) do |t|
t.pattern = FileList[ 'spec/external/wavsep/active/**/*_spec.rb' ]
end
namespace :active do
desc 'Run the WAVSEP XSS tests.'
RSpec::Core::RakeTask.new( :xss ) do |t|
t.pattern = FileList[ 'spec/external/wavsep/active/xss_spec.rb' ]
end
desc 'Run the WAVSEP SQL injection tests.'
RSpec::Core::RakeTask.new( :sqli ) do |t|
t.pattern = FileList[ 'spec/external/wavsep/active/sqli_spec.rb' ]
end
desc 'Run the WAVSEP LFI tests.'
RSpec::Core::RakeTask.new( :lfi ) do |t|
t.pattern = FileList[ 'spec/external/wavsep/active/lfi_spec.rb' ]
end
desc 'Run the WAVSEP RFI tests.'
RSpec::Core::RakeTask.new( :rfi ) do |t|
t.pattern = FileList[ 'spec/external/wavsep/active/rfi_spec.rb' ]
end
end
desc 'Run the WAVSEP false positive tests.'
RSpec::Core::RakeTask.new( :false_positives ) do |t|
t.pattern = FileList[ 'spec/external/wavsep/false_positives/**/*_spec.rb' ]
end
namespace :false_positives do
desc 'Run the WAVSEP XSS false positive tests.'
RSpec::Core::RakeTask.new( :xss ) do |t|
t.pattern = FileList[ 'spec/external/wavsep/false_positives/xss_spec.rb' ]
end
desc 'Run the WAVSEP SQL injection false positive tests.'
RSpec::Core::RakeTask.new( :sqli ) do |t|
t.pattern = FileList[ 'spec/external/wavsep/false_positives/sqli_spec.rb' ]
end
desc 'Run the WAVSEP LFI false positive tests.'
RSpec::Core::RakeTask.new( :lfi ) do |t|
t.pattern = FileList[ 'spec/external/wavsep/false_positives/lfi_spec.rb' ]
end
desc 'Run the WAVSEP RFI false positive tests.'
RSpec::Core::RakeTask.new( :rfi ) do |t|
t.pattern = FileList[ 'spec/external/wavsep/false_positives/rfi_spec.rb' ]
end
end
end
end
desc 'Generate an AFR report for the report tests.'
namespace :generate do
task :afr do
# Run the module tests and save all the issues to put them
# in our AFR report.
FileUtils.touch( "#{Dir.tmpdir}/save_issues" )
Rake::Task['spec:modules'].execute rescue nil
FileUtils.rm( "#{Dir.tmpdir}/save_issues" )
issues = []
File.open( "#{Dir.tmpdir}/issues.yml" ) do |f|
issues = YAML.load_documents( f ).flatten
end
200.times do |i|
# Add remarks to some issues.
issue = issues[rand( issues.size )]
issue.add_remark( :stuff, 'Blah' )
issue.add_remark( :stuff, 'Blah2' )
# Flag some issues are requiring manual verification.
issues[rand( issues.size )].verification = true
end
FileUtils.rm( "#{Dir.tmpdir}/issues.yml" )
Arachni::Options.url = 'http://test.com'
Arachni::Options.audit :forms, :links, :cookies, :headers
# Make all module constants available because the AuditStore
# will need them to make the necessary associations between them
# and the issues.
Arachni::Framework.new.modules.load_all
Arachni::AuditStore.new( issues: issues.uniq ).
save( 'spec/support/fixtures/auditstore.afr' )
Arachni::Options.reset
end
end
end
RSpec::Core::RakeTask.new
rescue LoadError
puts 'If you want to run the tests please install rspec first:'
puts ' gem install rspec'
end
desc 'Generate docs.'
task :docs do
outdir = "../arachni-docs"
sh "rm -rf #{outdir}"
sh "mkdir -p #{outdir}"
sh "yardoc -o #{outdir}"
sh "rm -rf .yardoc"
end
desc 'Generate graphics.'
task :gfx do
outdir = 'gfx/compiled'
srcdir = 'gfx/source'
sh 'mkdir -p ~/.fonts'
sh 'cp gfx/font/Beneath_the_Surface.ttf ~/.fonts'
Dir.glob( "#{srcdir}/*.svg" ).each do |src|
sh "inkscape #{src} --export-png=#{outdir}/#{File.basename( src, '.svg' )}.png"
end
cp "#{outdir}/icon.png", "#{outdir}/favicon.ico"
sh 'rm -f ~/.fonts/Beneath_the_Surface.ttf'
end
#
# Simple profiler using perftools[1].
#
# To install perftools for Ruby:
# gem install perftools.rb
#
# [1] https://github.com/tmm1/perftools.rb
#
desc 'Profile Arachni.'
task :profile do
if !Gem::Specification.find_all_by_name( 'perftools.rb' ).empty?
sh "CPUPROFILE_FREQUENCY=500 CPUPROFILE=/tmp/profile.dat " +
"RUBYOPT=\"-r`gem which perftools | tail -1`\" " +
" ./bin/arachni http://demo.testfire.net && " +
"pprof.rb --gif /tmp/profile.dat > profile.gif"
else
puts 'If you want to run the profiler please install perftools.rb first:'
puts ' gem install perftools.rb'
end
end
desc 'Remove report and log files.'
task :clean do
files = %w(error.log *.afr *.yaml *.json *.marshal *.gem pkg/*.gem logs/*.log
spec/support/logs/*.log).map { |file| Dir.glob( file ) }.flatten
next if files.empty?
puts 'Removing:'
files.each { |file| puts " * #{file}" }
FileUtils.rm files
end
Bundler::GemHelper.install_tasks
desc 'Push a new version to RubyGems'
task :publish => [ :release ]
desc 'Build Arachni and run all the tests.'
task :default => [ :build, :spec ]