gitrob 0.0.6 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +30 -7
  3. data/.rspec +0 -1
  4. data/.rubocop.yml +55 -0
  5. data/.travis.yml +4 -0
  6. data/CHANGELOG.md +42 -0
  7. data/CONTRIBUTING.md +137 -9
  8. data/Gemfile +11 -1
  9. data/Guardfile +42 -0
  10. data/LICENSE.txt +17 -18
  11. data/README.md +79 -29
  12. data/Rakefile +6 -0
  13. data/bin/console +34 -0
  14. data/bin/setup +7 -0
  15. data/db/migrations/001_create_assessments.rb +19 -0
  16. data/db/migrations/002_create_github_access_tokens.rb +11 -0
  17. data/db/migrations/003_create_owners.rb +24 -0
  18. data/db/migrations/004_create_repositories.rb +23 -0
  19. data/db/migrations/005_create_blobs.rb +16 -0
  20. data/db/migrations/006_create_flags.rb +13 -0
  21. data/db/migrations/007_create_comparisons.rb +17 -0
  22. data/db/migrations/008_create_blobs_comparisons.rb +8 -0
  23. data/db/migrations/009_create_comparisons_repositories.rb +8 -0
  24. data/db/migrations/010_create_comparisons_owners.rb +8 -0
  25. data/exe/gitrob +6 -0
  26. data/gitrob.gemspec +25 -18
  27. data/lib/gitrob/blob_observer.rb +103 -0
  28. data/lib/gitrob/cli/command.rb +58 -0
  29. data/lib/gitrob/cli/commands/accept_terms_of_use.rb +61 -0
  30. data/lib/gitrob/cli/commands/analyze/analysis.rb +75 -0
  31. data/lib/gitrob/cli/commands/analyze/gathering.rb +101 -0
  32. data/lib/gitrob/cli/commands/analyze.rb +63 -0
  33. data/lib/gitrob/cli/commands/banner.rb +25 -0
  34. data/lib/gitrob/cli/commands/configure.rb +123 -0
  35. data/lib/gitrob/cli/commands/server.rb +21 -0
  36. data/lib/gitrob/cli/progress_bar.rb +47 -0
  37. data/lib/gitrob/cli.rb +213 -0
  38. data/lib/gitrob/github/client_manager.rb +46 -0
  39. data/lib/gitrob/github/data_manager.rb +121 -0
  40. data/lib/gitrob/jobs/assessment.rb +12 -0
  41. data/lib/gitrob/jobs/comparison.rb +55 -0
  42. data/lib/gitrob/models/assessment.rb +96 -0
  43. data/lib/gitrob/models/blob.rb +50 -0
  44. data/lib/gitrob/models/comparison.rb +15 -0
  45. data/lib/gitrob/models/flag.rb +15 -0
  46. data/lib/gitrob/models/github_access_token.rb +17 -0
  47. data/lib/gitrob/models/owner.rb +23 -0
  48. data/lib/gitrob/models/repository.rb +20 -0
  49. data/lib/gitrob/utils.rb +19 -0
  50. data/lib/gitrob/version.rb +1 -1
  51. data/lib/gitrob/web_app.rb +292 -0
  52. data/lib/gitrob.rb +30 -113
  53. data/public/css/bootstrap.min.css +11 -0
  54. data/public/css/main.css +130 -0
  55. data/public/css/tomorrow-night.css +75 -0
  56. data/public/fonts/glyphicons-halflings-regular.eot +0 -0
  57. data/public/fonts/glyphicons-halflings-regular.svg +273 -214
  58. data/public/fonts/glyphicons-halflings-regular.ttf +0 -0
  59. data/public/fonts/glyphicons-halflings-regular.woff +0 -0
  60. data/public/fonts/glyphicons-halflings-regular.woff2 +0 -0
  61. data/public/images/blob_spinner.gif +0 -0
  62. data/public/images/gear_spinner.gif +0 -0
  63. data/public/js/bootstrap.min.js +7 -0
  64. data/public/js/highlight.pack.js +2 -0
  65. data/public/js/highlight.worker.js +13 -0
  66. data/public/js/jquery-2.1.4.min.js +4 -0
  67. data/public/js/main.js +239 -0
  68. data/public/robots.txt +2 -0
  69. data/signatures.json +541 -0
  70. data/views/assessments/_assessments.erb +57 -0
  71. data/views/assessments/_comparable_assessments.erb +38 -0
  72. data/views/assessments/_comparisons.erb +111 -0
  73. data/views/assessments/compare.erb +22 -0
  74. data/views/assessments/findings.erb +55 -0
  75. data/views/assessments/repositories.erb +35 -0
  76. data/views/assessments/show.erb +1 -0
  77. data/views/assessments/users.erb +46 -0
  78. data/views/blobs/show.erb +37 -0
  79. data/views/comparisons/show.erb +125 -0
  80. data/views/errors/internal_server_error.erb +9 -0
  81. data/views/errors/not_found.erb +5 -0
  82. data/views/index.erb +43 -28
  83. data/views/layout.erb +38 -12
  84. data/views/repositories/show.erb +49 -0
  85. data/views/users/show.erb +54 -0
  86. metadata +217 -106
  87. data/bin/gitrob +0 -260
  88. data/lib/gitrob/github/blob.rb +0 -41
  89. data/lib/gitrob/github/http_client.rb +0 -127
  90. data/lib/gitrob/github/organization.rb +0 -99
  91. data/lib/gitrob/github/repository.rb +0 -72
  92. data/lib/gitrob/github/user.rb +0 -84
  93. data/lib/gitrob/observers/sensitive_files.rb +0 -83
  94. data/lib/gitrob/progressbar.rb +0 -52
  95. data/lib/gitrob/util.rb +0 -11
  96. data/lib/gitrob/webapp.rb +0 -76
  97. data/models/blob.rb +0 -35
  98. data/models/finding.rb +0 -14
  99. data/models/organization.rb +0 -32
  100. data/models/repo.rb +0 -22
  101. data/models/user.rb +0 -28
  102. data/patterns.json +0 -394
  103. data/public/javascripts/bootstrap.min.js +0 -7
  104. data/public/javascripts/gitrob.js +0 -75
  105. data/public/javascripts/jquery-2.1.1.min.js +0 -4
  106. data/public/javascripts/lang-apollo.js +0 -2
  107. data/public/javascripts/lang-basic.js +0 -3
  108. data/public/javascripts/lang-clj.js +0 -18
  109. data/public/javascripts/lang-css.js +0 -2
  110. data/public/javascripts/lang-dart.js +0 -3
  111. data/public/javascripts/lang-erlang.js +0 -2
  112. data/public/javascripts/lang-go.js +0 -1
  113. data/public/javascripts/lang-hs.js +0 -2
  114. data/public/javascripts/lang-lisp.js +0 -3
  115. data/public/javascripts/lang-llvm.js +0 -1
  116. data/public/javascripts/lang-lua.js +0 -2
  117. data/public/javascripts/lang-matlab.js +0 -6
  118. data/public/javascripts/lang-ml.js +0 -2
  119. data/public/javascripts/lang-mumps.js +0 -2
  120. data/public/javascripts/lang-n.js +0 -4
  121. data/public/javascripts/lang-pascal.js +0 -3
  122. data/public/javascripts/lang-proto.js +0 -1
  123. data/public/javascripts/lang-r.js +0 -2
  124. data/public/javascripts/lang-rd.js +0 -1
  125. data/public/javascripts/lang-scala.js +0 -2
  126. data/public/javascripts/lang-sql.js +0 -2
  127. data/public/javascripts/lang-tcl.js +0 -3
  128. data/public/javascripts/lang-tex.js +0 -1
  129. data/public/javascripts/lang-vb.js +0 -2
  130. data/public/javascripts/lang-vhdl.js +0 -3
  131. data/public/javascripts/lang-wiki.js +0 -2
  132. data/public/javascripts/lang-xq.js +0 -3
  133. data/public/javascripts/lang-yaml.js +0 -2
  134. data/public/javascripts/prettify.js +0 -30
  135. data/public/javascripts/run_prettify.js +0 -34
  136. data/public/stylesheets/bootstrap.min.css +0 -7
  137. data/public/stylesheets/bootstrap.min.css.vanilla +0 -5
  138. data/public/stylesheets/gitrob.css +0 -88
  139. data/public/stylesheets/prettify.css +0 -51
  140. data/spec/lib/gitrob/observers/sensitive_files_spec.rb +0 -691
  141. data/spec/spec_helper.rb +0 -127
  142. data/views/blob.erb +0 -22
  143. data/views/organization.erb +0 -126
  144. data/views/repository.erb +0 -51
  145. data/views/user.erb +0 -51
@@ -1,691 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe Gitrob::Observers::SensitiveFiles do
4
- let(:patterns) { File.read("#{File.dirname(__FILE__)}/../../../../patterns.json") }
5
-
6
- describe '.load_patterns!' do
7
- it 'reads pattern file' do
8
- expect(File).to receive(:read).with(/gitrob\/lib\/gitrob\/observers\/\.\.\/\.\.\/\.\.\/patterns.json\z/)
9
- .and_return(patterns)
10
-
11
- described_class.load_patterns!
12
- end
13
-
14
- it 'parses JSON document' do
15
- expect(JSON).to receive(:parse).with(patterns).and_return(JSON.parse(patterns))
16
-
17
- described_class.load_patterns!
18
- end
19
-
20
- context 'when JSON document is invalid' do
21
- before do
22
- allow(File).to receive(:read).and_return('oops!')
23
- end
24
-
25
- it 'raises InvalidPatternFileError exception' do
26
- expect do
27
- described_class.load_patterns!
28
- end.to raise_error(Gitrob::Observers::SensitiveFiles::InvalidPatternFileError)
29
- end
30
- end
31
- end
32
-
33
- describe '.observe' do
34
- before do
35
- allow(described_class).to receive(:patterns).and_return(JSON.parse(patterns))
36
- stub_request(:get, "https://api.github.com/orgs/org").
37
- to_return(:status => 200, :body => JSON.dump({
38
- "login" => "org",
39
- "name" => "Org",
40
- "website" => "http://www.org.com",
41
- "location" => "The Internet",
42
- "email" => "contact@org.com",
43
- "avatar_url" => "https://github.com/avatar.png",
44
- "html_url" => "https://github.com/org"
45
- }))
46
- stub_request(:get, "https://api.github.com/repos/user/repo").
47
- to_return(:status => 200, :body => JSON.dump({
48
- "html_url" => "https://github.com/user/repo",
49
- "description" => "My Dotfiles",
50
- "homepage" => "http://localhost"
51
- }))
52
- end
53
-
54
- let(:http_client) { Gitrob::Github::HttpClient.new(:access_tokens => ['deadbeefdeadbeefdeadbeefdeadbeef']) }
55
- let(:owner) { Gitrob::Github::User.new('user', http_client) }
56
- let(:repo) { Gitrob::Github::Repository.new(owner.username, 'repo', http_client) }
57
- let(:org) { Gitrob::Github::Organization.new('org', http_client).to_model }
58
-
59
- it 'detects private keys' do
60
- ['id_rsa',
61
- 'production_rsa',
62
- '.ssh/id_rsa',
63
- 'ssh/id_rsa',
64
- 'privatekeys/id_rsa',
65
- 'id_dsa',
66
- 'key_dsa',
67
- '.ssh/id_dsa',
68
- 'privatekeys/id_dsa',
69
- 'id_ed25519',
70
- 'user_ed25519',
71
- '.ssh/id_ed25519',
72
- 'privatekeys/id_ed25519',
73
- '.ssh/id_ecdsa',
74
- 'id_ecdsa',
75
- 'jenkins_ecdsa',
76
- 'ssh/id_ecdsa',
77
- 'privatekeys/id_ecdsa'
78
- ].each do |path|
79
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
80
- described_class.observe(blob)
81
- expect(blob.findings.first.caption).to eq("Private SSH key")
82
- end
83
- end
84
-
85
- it 'detects files with .pem extension' do
86
- ['privatekey.pem',
87
- 'keys/privatekey.pem',
88
- '.secret.pem',
89
- ].each do |path|
90
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
91
- described_class.observe(blob)
92
- expect(blob.findings.first.caption).to eq("Potential cryptographic private key")
93
- end
94
- end
95
-
96
- it 'detects files with .key(pair) extension' do
97
- ['privatekey.key',
98
- 'keys/privatekey.key',
99
- '.secret.key',
100
- 'production.keypair',
101
- 'keys/privatekey.keypair'
102
- ].each do |path|
103
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
104
- described_class.observe(blob)
105
- expect(blob.findings.first.caption).to eq("Potential cryptographic private key")
106
- end
107
- end
108
-
109
- it 'detects files with .pkcs12 extension' do
110
- ['privatekey.pkcs12',
111
- 'keys/privatekey.pkcs12',
112
- '.secret.pkcs12',
113
- ].each do |path|
114
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
115
- described_class.observe(blob)
116
- expect(blob.findings.first.caption).to eq("Potential cryptographic key bundle")
117
- end
118
- end
119
-
120
- it 'detects files with .pfx extension' do
121
- ['privatekey.pfx',
122
- 'keys/privatekey.pfx',
123
- '.secret.pfx',
124
- ].each do |path|
125
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
126
- described_class.observe(blob)
127
- expect(blob.findings.first.caption).to eq("Potential cryptographic key bundle")
128
- end
129
- end
130
-
131
- it 'detects files with .p12 extension' do
132
- ['privatekey.p12',
133
- 'keys/privatekey.p12',
134
- '.secret.p12',
135
- ].each do |path|
136
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
137
- described_class.observe(blob)
138
- expect(blob.findings.first.caption).to eq("Potential cryptographic key bundle")
139
- end
140
- end
141
-
142
- it 'detects files with .asc extension' do
143
- ['privatekey.asc',
144
- 'keys/privatekey.asc',
145
- '.secret.asc',
146
- ].each do |path|
147
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
148
- described_class.observe(blob)
149
- expect(blob.findings.first.caption).to eq("Potential cryptographic key bundle")
150
- end
151
- end
152
-
153
- it 'detects Pidgin private OTR keys' do
154
- ['otr.private_key',
155
- '.purple/otr.private_key',
156
- 'pidgin/otr.private_key',
157
- ].each do |path|
158
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
159
- described_class.observe(blob)
160
- expect(blob.findings.first.caption).to eq("Pidgin OTR private key")
161
- end
162
- end
163
-
164
- it 'detects shell command history files' do
165
- ['.bash_history',
166
- 'bash_history',
167
- 'bash/bash_history',
168
- '.zsh_history',
169
- 'zsh_history',
170
- 'zsh/zsh_history',
171
- '.zhistory',
172
- 'zhistory',
173
- 'zsh/zhistory',
174
- '.history',
175
- 'history',
176
- 'shell/history'
177
- ].each do |path|
178
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
179
- described_class.observe(blob)
180
- expect(blob.findings.first.caption).to eq("Shell command history file")
181
- end
182
- end
183
-
184
- it 'detects MySQL client command history files' do
185
- ['.mysql_history',
186
- 'mysql_history',
187
- 'history/.mysql_history',
188
- ].each do |path|
189
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
190
- described_class.observe(blob)
191
- expect(blob.findings.first.caption).to eq("MySQL client command history file")
192
- end
193
- end
194
-
195
- it 'detects PostgreSQL client command history files' do
196
- ['.psql_history',
197
- 'psql_history',
198
- 'history/.psql_history',
199
- ].each do |path|
200
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
201
- described_class.observe(blob)
202
- expect(blob.findings.first.caption).to eq("PostgreSQL client command history file")
203
- end
204
- end
205
-
206
- it 'detects IRB console history files' do
207
- ['.irb_history',
208
- 'irb_history',
209
- 'history/.irb_history',
210
- ].each do |path|
211
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
212
- described_class.observe(blob)
213
- expect(blob.findings.first.caption).to eq("Ruby IRB console history file")
214
- end
215
- end
216
-
217
- it 'detects Pidgin chat client account configuration files' do
218
- ['.purple/accounts.xml',
219
- 'purple/accounts.xml',
220
- 'config/purple/accounts.xml',
221
- ].each do |path|
222
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
223
- described_class.observe(blob)
224
- expect(blob.findings.first.caption).to eq("Pidgin chat client account configuration file")
225
- end
226
- end
227
-
228
- it 'detects XChat client server list configuration files' do
229
- ['.xchat2/servlist_.conf',
230
- '.xchat2/servlist.conf',
231
- 'xchat2/servlist_.conf',
232
- 'xchat2/servlist.conf',
233
- 'xchat/servlist_.conf',
234
- 'xchat/servlist.conf',
235
- '.xchat/servlist_.conf',
236
- '.xchat/servlist.conf',
237
- 'config/.xchat/servlist.conf'
238
- ].each do |path|
239
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
240
- described_class.observe(blob)
241
- expect(blob.findings.first.caption).to eq("Hexchat/XChat IRC client server list configuration file")
242
- end
243
- end
244
-
245
- it 'detects Hexchat client server list configuration files' do
246
- ['.hexchat/servlist.conf',
247
- 'hexchat/servlist.conf',
248
- 'config/.hexchat/servlist.conf'
249
- ].each do |path|
250
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
251
- described_class.observe(blob)
252
- expect(blob.findings.first.caption).to eq("Hexchat/XChat IRC client server list configuration file")
253
- end
254
- end
255
-
256
- it 'detects irrsi IRC client configuration files' do
257
- ['.irssi/config',
258
- 'irssi/config',
259
- 'config/.irssi/config'
260
- ].each do |path|
261
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
262
- described_class.observe(blob)
263
- expect(blob.findings.first.caption).to eq("Irssi IRC client configuration file")
264
- end
265
- end
266
-
267
- it 'detects Recon-ng API key databases' do
268
- ['.recon-ng/keys.db',
269
- 'recon-ng/keys.db',
270
- 'config/.recon-ng/keys.db'
271
- ].each do |path|
272
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
273
- described_class.observe(blob)
274
- expect(blob.findings.first.caption).to eq("Recon-ng web reconnaissance framework API key database")
275
- end
276
- end
277
-
278
- it 'detects DBeaver configuration files' do
279
- ['.dbeaver-data-sources.xml',
280
- 'dbeaver-data-sources.xml',
281
- 'config/.dbeaver-data-sources.xml'
282
- ].each do |path|
283
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
284
- described_class.observe(blob)
285
- expect(blob.findings.first.caption).to eq("DBeaver SQL database manager configuration file")
286
- end
287
- end
288
-
289
- it 'detects Mutt configuration files' do
290
- ['.muttrc',
291
- 'muttrc',
292
- 'config/.muttrc'
293
- ].each do |path|
294
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
295
- described_class.observe(blob)
296
- expect(blob.findings.first.caption).to eq("Mutt e-mail client configuration file")
297
- end
298
- end
299
-
300
- it 'detects S3cmd configuration files' do
301
- ['.s3cfg',
302
- 's3cfg',
303
- 'config/.s3cfg'
304
- ].each do |path|
305
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
306
- described_class.observe(blob)
307
- expect(blob.findings.first.caption).to eq("S3cmd configuration file")
308
- end
309
- end
310
-
311
- it 'detects T Twitter client configuration files' do
312
- ['.trc',
313
- 'trc',
314
- 'config/.trc'
315
- ].each do |path|
316
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
317
- described_class.observe(blob)
318
- expect(blob.findings.first.caption).to eq("T command-line Twitter client configuration file")
319
- end
320
- end
321
-
322
- it 'detects OpenVPN configuration files' do
323
- ['vpn.ovpn',
324
- '.cryptostorm.ovpn',
325
- 'config/work.ovpn'
326
- ].each do |path|
327
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
328
- described_class.observe(blob)
329
- expect(blob.findings.first.caption).to eq("OpenVPN client configuration file")
330
- end
331
- end
332
-
333
- it 'detects Gitrob configuration files' do
334
- ['.gitrobrc',
335
- 'gitrobrc',
336
- 'config/.gitrobrc'
337
- ].each do |path|
338
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
339
- described_class.observe(blob)
340
- expect(blob.findings.first.caption).to eq("Well, this is awkward... Gitrob configuration file")
341
- end
342
- end
343
-
344
- it 'detects shell configuration files' do
345
- ['.bashrc',
346
- 'bashrc',
347
- 'bash/.bashrc',
348
- '.zshrc',
349
- 'zshrc',
350
- 'zsh/.zshrc'
351
- ].each do |path|
352
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
353
- described_class.observe(blob)
354
- expect(blob.findings.first.caption).to eq("Shell configuration file")
355
- expect(blob.findings.first.description).to eq("Shell configuration files might contain information such as server hostnames, passwords and API keys.")
356
- end
357
- end
358
-
359
- it 'detects shell profile files' do
360
- ['.bash_profile',
361
- 'bash_profile',
362
- 'bash/.bash_profile',
363
- '.zsh_profile',
364
- 'zsh_profile',
365
- 'zsh/.zsh_profile',
366
- '.profile',
367
- 'profile',
368
- 'sh/.profile'
369
- ].each do |path|
370
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
371
- described_class.observe(blob)
372
- expect(blob.findings.first.caption).to eq("Shell profile configuration file")
373
- expect(blob.findings.first.description).to eq("Shell configuration files might contain information such as server hostnames, passwords and API keys.")
374
- end
375
- end
376
-
377
- it 'detects shell alias files' do
378
- ['.bash_aliases',
379
- 'bash_aliases',
380
- 'bash/.bash_aliases',
381
- '.zsh_aliases',
382
- 'zsh_aliases',
383
- 'zsh/.zsh_aliases',
384
- '.aliases',
385
- 'aliases',
386
- 'sh/.aliases'
387
- ].each do |path|
388
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
389
- described_class.observe(blob)
390
- expect(blob.findings.first.caption).to eq("Shell command alias configuration file")
391
- expect(blob.findings.first.description).to eq("Shell configuration files might contain information such as server hostnames, passwords and API keys.")
392
- end
393
- end
394
-
395
- it 'detects Rails secret token configuration files' do
396
- ['secret_token.rb',
397
- 'config/initializers/secret_token.rb'
398
- ].each do |path|
399
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
400
- described_class.observe(blob)
401
- expect(blob.findings.first.caption).to eq("Ruby On Rails secret token configuration file")
402
- expect(blob.findings.first.description).to eq("If the Rails secret token is known, it can allow for remote code execution. (http://www.exploit-db.com/exploits/27527/)")
403
- end
404
- end
405
-
406
- it 'detects Omniauth configuration files' do
407
- ['omniauth.rb',
408
- 'config/initializers/omniauth.rb'
409
- ].each do |path|
410
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
411
- described_class.observe(blob)
412
- expect(blob.findings.first.caption).to eq("OmniAuth configuration file")
413
- expect(blob.findings.first.description).to eq("The OmniAuth configuration file might contain client application secrets.")
414
- end
415
- end
416
-
417
- it 'detects Carrierwave configuration files' do
418
- ['carrierwave.rb',
419
- 'config/initializers/carrierwave.rb'
420
- ].each do |path|
421
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
422
- described_class.observe(blob)
423
- expect(blob.findings.first.caption).to eq("Carrierwave configuration file")
424
- expect(blob.findings.first.description).to eq("Can contain credentials for online storage systems such as Amazon S3 and Google Storage.")
425
- end
426
- end
427
-
428
- it 'detects Rails schema files' do
429
- ['schema.rb',
430
- 'db/schema.rb'
431
- ].each do |path|
432
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
433
- described_class.observe(blob)
434
- expect(blob.findings.first.caption).to eq("Ruby On Rails database schema file")
435
- expect(blob.findings.first.description).to eq("Contains information on the database schema of a Ruby On Rails application.")
436
- end
437
- end
438
-
439
- it 'detects Rails database configuration files' do
440
- ['database.yml',
441
- 'config/database.yml'
442
- ].each do |path|
443
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
444
- described_class.observe(blob)
445
- expect(blob.findings.first.caption).to eq("Potential Ruby On Rails database configuration file")
446
- expect(blob.findings.first.description).to eq("Might contain database credentials.")
447
- end
448
- end
449
-
450
- it 'detects Django settings files' do
451
- ['settings.py',
452
- ].each do |path|
453
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
454
- described_class.observe(blob)
455
- expect(blob.findings.first.caption).to eq("Django configuration file")
456
- expect(blob.findings.first.description).to eq("Might contain database credentials, online storage system credentials, secret keys, etc.")
457
- end
458
- end
459
-
460
- it 'detects PHP configuration files' do
461
- ['config.php',
462
- 'config/config.inc.php',
463
- 'db_config.php',
464
- 'secret_config.inc.php'
465
- ].each do |path|
466
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
467
- described_class.observe(blob)
468
- expect(blob.findings.first.caption).to eq("PHP configuration file")
469
- expect(blob.findings.first.description).to eq("Might contain credentials and keys.")
470
- end
471
- end
472
-
473
- it 'detects KeePass database files' do
474
- ['keepass.kdb',
475
- 'secret/pwd.kdb'
476
- ].each do |path|
477
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
478
- described_class.observe(blob)
479
- expect(blob.findings.first.caption).to eq("KeePass password manager database file")
480
- end
481
- end
482
-
483
- it 'detects 1Password database files' do
484
- ['passwords.agilekeychain',
485
- 'secret/pwd.agilekeychain'
486
- ].each do |path|
487
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
488
- described_class.observe(blob)
489
- expect(blob.findings.first.caption).to eq("1Password password manager database file")
490
- end
491
- end
492
-
493
- it 'detects Apple keychain database files' do
494
- ['passwords.keychain',
495
- 'secret/pwd.keychain'
496
- ].each do |path|
497
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
498
- described_class.observe(blob)
499
- expect(blob.findings.first.caption).to eq("Apple Keychain database file")
500
- end
501
- end
502
-
503
- it 'detects GNOME keyring database files' do
504
- ['passwords.keystore',
505
- 'passwords.keyring',
506
- 'secret/pwd.keystore',
507
- 'secret/pwd.keyring'
508
- ].each do |path|
509
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
510
- described_class.observe(blob)
511
- expect(blob.findings.first.caption).to eq("GNOME Keyring database file")
512
- end
513
- end
514
-
515
- it 'detects log files' do
516
- ['log.log',
517
- 'logs/production.log',
518
- '.secret.log'
519
- ].each do |path|
520
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
521
- described_class.observe(blob)
522
- expect(blob.findings.first.caption).to eq("Log file")
523
- expect(blob.findings.first.description).to eq("Log files might contain information such as references to secret HTTP endpoints, session IDs, user information, passwords and API keys.")
524
- end
525
- end
526
-
527
- it 'detects PCAP files' do
528
- ['capture.pcap',
529
- 'debug/production.pcap'
530
- ].each do |path|
531
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
532
- described_class.observe(blob)
533
- expect(blob.findings.first.caption).to eq("Network traffic capture file")
534
- end
535
- end
536
-
537
- it 'detects SQL files' do
538
- ['db.sql',
539
- 'db.sqldump',
540
- 'setup/database.sql',
541
- 'backup/production.sqldump'
542
- ].each do |path|
543
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
544
- described_class.observe(blob)
545
- expect(blob.findings.first.caption).to eq("SQL dump file")
546
- end
547
- end
548
-
549
- it 'detects GnuCash database files' do
550
- ['budget.gnucash',
551
- '.budget.gnucash',
552
- 'finance/budget.gnucash'
553
- ].each do |path|
554
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
555
- described_class.observe(blob)
556
- expect(blob.findings.first.caption).to eq("GnuCash database file")
557
- end
558
- end
559
-
560
- it 'detects files containing word: backup' do
561
- ['backup.tar.gz',
562
- 'backups/dbbackup.zip'
563
- ].each do |path|
564
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
565
- described_class.observe(blob)
566
- expect(blob.findings.first.caption).to eq("Contains word: backup")
567
- end
568
- end
569
-
570
- it 'detects files containing word: dump' do
571
- ['dump.bin',
572
- 'debug/memdump.txt'
573
- ].each do |path|
574
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
575
- described_class.observe(blob)
576
- expect(blob.findings.first.caption).to eq("Contains word: dump")
577
- end
578
- end
579
-
580
- it 'detects files containing word: password' do
581
- ['passwords.xls',
582
- 'private/password-reminders.txt'
583
- ].each do |path|
584
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
585
- described_class.observe(blob)
586
- expect(blob.findings.first.caption).to eq("Contains word: password")
587
- end
588
- end
589
-
590
- it 'detects files containing wordis: private, key' do
591
- ['privatekey.asc',
592
- 'super_private_key.asc',
593
- 'private/private_keys.tar.gz'
594
- ].each do |path|
595
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
596
- described_class.observe(blob)
597
- expect(blob.findings.last.caption).to eq("Contains words: private, key")
598
- end
599
- end
600
-
601
- it 'detects Jenkins publish over ssh plugin configuration files' do
602
- ['jenkins.plugins.publish_over_ssh.BapSshPublisherPlugin.xml',
603
- 'jenkins/jenkins.plugins.publish_over_ssh.BapSshPublisherPlugin.xml'
604
- ].each do |path|
605
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
606
- described_class.observe(blob)
607
- expect(blob.findings.first.caption).to eq("Jenkins publish over SSH plugin file")
608
- end
609
- end
610
-
611
- it 'detects Jenkins credentials files' do
612
- ['credentials.xml',
613
- 'jenkins/credentials.xml'
614
- ].each do |path|
615
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
616
- described_class.observe(blob)
617
- expect(blob.findings.first.caption).to eq("Potential Jenkins credentials file")
618
- end
619
- end
620
-
621
- it 'detects Apache htpasswd files' do
622
- ['.htpasswd',
623
- 'htpasswd',
624
- 'public/htpasswd',
625
- 'admin/.htpasswd'
626
- ].each do |path|
627
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
628
- described_class.observe(blob)
629
- expect(blob.findings.first.caption).to eq("Apache htpasswd file")
630
- end
631
- end
632
-
633
- it 'detects netrc files' do
634
- ['.netrc',
635
- 'netrc',
636
- 'dotfiles/.netrc',
637
- 'homefolder/netrc'
638
- ].each do |path|
639
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
640
- described_class.observe(blob)
641
- expect(blob.findings.first.caption).to eq("Configuration file for auto-login process")
642
- expect(blob.findings.first.description).to eq("Might contain username and password.")
643
- end
644
- end
645
-
646
- it 'detects KDE Wallet Manager files' do
647
- ['wallet.kwallet',
648
- '.wallet.kwallet',
649
- 'dotfiles/secret.kwallet',
650
- 'homefolder/creds.kwallet'
651
- ].each do |path|
652
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
653
- described_class.observe(blob)
654
- expect(blob.findings.first.caption).to eq("KDE Wallet Manager database file")
655
- end
656
- end
657
-
658
- it 'detects MediaWiki configuration files' do
659
- ['LocalSettings.php',
660
- 'mediawiki/LocalSettings.php',
661
- 'configs/LocalSettings.php'
662
- ].each do |path|
663
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
664
- described_class.observe(blob)
665
- expect(blob.findings.first.caption).to eq("Potential MediaWiki configuration file")
666
- end
667
- end
668
-
669
- it 'detects Tunnelblick VPN configuration files' do
670
- ['vpn.tblk',
671
- 'secret/tunnel.tblk',
672
- 'configs/.tunnelblick.tblk'
673
- ].each do |path|
674
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
675
- described_class.observe(blob)
676
- expect(blob.findings.first.caption).to eq("Tunnelblick VPN configuration file")
677
- end
678
- end
679
-
680
- it 'detects Rubygems credentials files' do
681
- ['.gem/credentials',
682
- 'gem/credentials',
683
- ].each do |path|
684
- blob = Gitrob::Github::Blob.new(path, 1, repo).to_model(org, repo.to_model(org))
685
- described_class.observe(blob)
686
- expect(blob.findings.first.caption).to eq("Rubygems credentials file")
687
- expect(blob.findings.first.description).to eq("Might contain API key for a rubygems.org account.")
688
- end
689
- end
690
- end
691
- end