-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathRakefile
122 lines (104 loc) · 3.36 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
#
# Copyright (c) 2015-2017 Brendan Coles <bcoles@gmail.com>
# SSRF Proxy - https://github.com/bcoles/ssrf_proxy
# See the file 'LICENSE.md' for copying permission
#
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'rubocop/rake_task'
require 'yard'
task default: :all
task test: :all
Rake::TestTask.new(:all) do |t|
t.description = 'Run unit and integration tests'
t.test_files = FileList['test/unit/**/test_*.rb', 'test/integration/**/test_*.rb']
end
Rake::TestTask.new(:unit) do |t|
t.description = 'Run unit tests'
t.test_files = FileList['test/unit/**/test_*.rb']
end
Rake::TestTask.new(:integration) do |t|
t.description = 'Run integration tests'
t.test_files = FileList['test/integration/**/test_*.rb']
end
namespace :integration do
Rake::TestTask.new(:http) do |t|
t.description = 'Run SSRFProxy::HTTP tests'
t.test_files = FileList['test/integration/test_http.rb', 'test/integration/http/test_*.rb']
end
Rake::TestTask.new(:server) do |t|
t.description = 'Run SSRFProxy::Server tests'
t.test_files = FileList['test/integration/test_server.rb', 'test/integration/server/test_*.rb']
end
Rake::TestTask.new(:executable) do |t|
t.description = 'Run bin/ssrf-proxy tests'
t.test_files = FileList['test/integration/test_executable.rb']
end
end
Rake::TestTask.new(:stress) do |t|
t.description = 'Run stress tests'
t.test_files = FileList['test/stress/test_server.rb']
end
desc 'Generate API documentation to doc/rdocs/index.html'
task :rdoc do
Rake::Task['rdoc:rerdoc'].invoke
end
desc 'Open an irb session preloaded with ssrf_proxy'
task :console do
sh 'irb -rubygems -I lib -r ssrf_proxy.rb'
end
RuboCop::RakeTask.new(:rubocop) do |t|
t.options = ['--display-cop-names']
end
YARD::Rake::YardocTask.new
############################################################
# rdoc
############################################################
namespace :rdoc do
require 'rdoc/task'
desc 'Generate documentation to doc/rdocs/index.html'
Rake::RDocTask.new do |rd|
rd.title = 'SSRF Proxy'
rd.rdoc_dir = 'doc/rdocs'
rd.main = 'README.md'
rd.rdoc_files.include(
'lib/*\.rb',
'lib/ssrf_proxy/*\.rb'
)
rd.options << '--line-numbers'
rd.options << '--all'
end
end
############################################################
# fuzz
############################################################
namespace :fuzz do
Rake::TestTask.new(:hamms) do |t|
t.description = 'Fuzz proxy with Hamms'
t.test_files = FileList['test/fuzz/hamms.rb']
end
end
############################################################
# help2man
############################################################
namespace :help2man do
desc 'Generate man page to doc/ssrf-proxy.1'
task :generate do
if File.file?('/usr/local/bin/help2man')
path = '/usr/local/bin/help2man'
elsif File.file?('/usr/bin/help2man')
path = '/usr/bin/help2man'
else
puts '[-] Error: could not find help2man'
exit 1
end
Dir.mkdir('doc') unless File.directory?('doc')
IO.popen([path, './bin/ssrf-proxy', '--output', 'doc/ssrf-proxy.1'], 'r+').read.to_s
end
desc 'Generate and install man page'
task :install do
Rake::Task['help2man:generate'].invoke
IO.popen(['/bin/mv', 'doc/ssrf-proxy.1', '/usr/local/share/man/man1/ssrf-proxy.1'], 'r+').read.to_s
IO.popen(['/usr/bin/mandb'], 'r+').read.to_s
end
end