gitrob 0.0.6 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
data/spec/spec_helper.rb DELETED
@@ -1,127 +0,0 @@
1
- require 'json'
2
- require 'cgi'
3
-
4
- require 'methadone'
5
- require 'highline/import'
6
- require 'thread/pool'
7
- require 'httparty'
8
- require 'ruby-progressbar'
9
- require 'paint'
10
- require 'sinatra/base'
11
- require 'data_mapper'
12
- require 'webmock/rspec'
13
-
14
- $LOAD_PATH.unshift(File.dirname(__FILE__))
15
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
16
-
17
- $LOAD_PATH.unshift(File.dirname(__FILE__))
18
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'models'))
19
-
20
- require 'gitrob/observers/sensitive_files'
21
- require 'gitrob/github/http_client'
22
- require 'gitrob/github/organization'
23
- require 'gitrob/github/user'
24
- require 'gitrob/github/repository'
25
- require 'gitrob/github/blob'
26
-
27
- require 'organization'
28
- require 'user'
29
- require 'repo'
30
- require 'blob'
31
- require 'finding'
32
-
33
- DataMapper::Model.raise_on_save_failure = true
34
- DataMapper::Property.auto_validation(false)
35
- DataMapper.setup(:default, "postgres://development:development@localhost/gitrob_testing")
36
- DataMapper.finalize
37
- DataMapper.auto_migrate!
38
-
39
- # This file was generated by the `rspec --init` command. Conventionally, all
40
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
41
- # The generated `.rspec` file contains `--require spec_helper` which will cause this
42
- # file to always be loaded, without a need to explicitly require it in any files.
43
- #
44
- # Given that it is always loaded, you are encouraged to keep this file as
45
- # light-weight as possible. Requiring heavyweight dependencies from this file
46
- # will add to the boot time of your test suite on EVERY test run, even for an
47
- # individual file that may not need all of that loaded. Instead, consider making
48
- # a separate helper file that requires the additional dependencies and performs
49
- # the additional setup, and require it from the spec files that actually need it.
50
- #
51
- # The `.rspec` file also contains a few flags that are not defaults but that
52
- # users commonly want.
53
- #
54
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
55
- RSpec.configure do |config|
56
- # rspec-expectations config goes here. You can use an alternate
57
- # assertion/expectation library such as wrong or the stdlib/minitest
58
- # assertions if you prefer.
59
- config.expect_with :rspec do |expectations|
60
- # This option will default to `true` in RSpec 4. It makes the `description`
61
- # and `failure_message` of custom matchers include text for helper methods
62
- # defined using `chain`, e.g.:
63
- # be_bigger_than(2).and_smaller_than(4).description
64
- # # => "be bigger than 2 and smaller than 4"
65
- # ...rather than:
66
- # # => "be bigger than 2"
67
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
68
- end
69
-
70
- # rspec-mocks config goes here. You can use an alternate test double
71
- # library (such as bogus or mocha) by changing the `mock_with` option here.
72
- config.mock_with :rspec do |mocks|
73
- # Prevents you from mocking or stubbing a method that does not exist on
74
- # a real object. This is generally recommended, and will default to
75
- # `true` in RSpec 4.
76
- mocks.verify_partial_doubles = true
77
- end
78
-
79
- # The settings below are suggested to provide a good initial experience
80
- # with RSpec, but feel free to customize to your heart's content.
81
- =begin
82
- # These two settings work together to allow you to limit a spec run
83
- # to individual examples or groups you care about by tagging them with
84
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
85
- # get run.
86
- config.filter_run :focus
87
- config.run_all_when_everything_filtered = true
88
-
89
- # Limits the available syntax to the non-monkey patched syntax that is recommended.
90
- # For more details, see:
91
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
92
- # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
93
- # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
94
- config.disable_monkey_patching!
95
-
96
- # This setting enables warnings. It's recommended, but in some cases may
97
- # be too noisy due to issues in dependencies.
98
- config.warnings = true
99
-
100
- # Many RSpec users commonly either run the entire suite or an individual
101
- # file, and it's useful to allow more verbose output when running an
102
- # individual spec file.
103
- if config.files_to_run.one?
104
- # Use the documentation formatter for detailed output,
105
- # unless a formatter has already been configured
106
- # (e.g. via a command-line flag).
107
- config.default_formatter = 'doc'
108
- end
109
-
110
- # Print the 10 slowest examples and example groups at the
111
- # end of the spec run, to help surface which specs are running
112
- # particularly slow.
113
- config.profile_examples = 10
114
-
115
- # Run specs in random order to surface order dependencies. If you find an
116
- # order dependency and want to debug it, you can fix the order by providing
117
- # the seed, which is printed after each run.
118
- # --seed 1234
119
- config.order = :random
120
-
121
- # Seed global randomization in this process using the `--seed` CLI option.
122
- # Setting this allows you to use `--seed` to deterministically reproduce
123
- # test failures related to randomization by passing the same `--seed` value
124
- # as the one that triggered the failure.
125
- Kernel.srand config.seed
126
- =end
127
- end
data/views/blob.erb DELETED
@@ -1,22 +0,0 @@
1
- <div id="blob">
2
- <% if @blob.findings.count.zero? %>
3
- <div class="alert alert-info" role="alert">
4
- <strong>No findings</strong>
5
- </div>
6
- <% else %>
7
- <% @blob.findings.each do |finding| %>
8
- <div class="alert alert-warning" role="alert">
9
- <strong><%=h finding.caption %></strong>
10
- <% if finding.description %>
11
- <p><%=h finding.description %></p>
12
- <% end %>
13
- </div>
14
- <% end %>
15
- <% end %>
16
- </div>
17
-
18
- <pre class="prettyprint">
19
- <%=h @blob.content %>
20
- </pre>
21
-
22
- <p class="pull-right"><a href="<%=h @blob.url %>" target="_blank">View file on GitHub</a></p>
@@ -1,126 +0,0 @@
1
- <div class="page-header">
2
- <h1>
3
- <a href="/">Organizations</a> &rang; <%=h @org.name %>
4
- </h1>
5
- </div>
6
-
7
- <div role="tabpanel">
8
- <ul class="nav nav-tabs" role="tablist">
9
- <li role="presentation" class="active"><a href="#findings" aria-controls="findings" role="tab" data-toggle="tab">Findings</a></li>
10
- <li role="presentation"><a href="#members" aria-controls="members" role="tab" data-toggle="tab">Members</a></li>
11
- <li role="presentation"><a href="#repos" aria-controls="repos" role="tab" data-toggle="tab">Repositories</a></li>
12
- </ul>
13
-
14
- <div class="tab-content">
15
- <div role="tabpanel" class="tab-pane active" id="findings">
16
- <table id="blob_table" class="table table-condensed table-hover">
17
- <thead>
18
- <tr>
19
- <th colspan="3" style="text-align:right">
20
- <form class="form-inline" role="quick-filter">
21
- <div class="form-group">
22
- <div class="input-group">
23
- <div class="input-group-addon input-sm"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></div>
24
- <input type="search" class="form-control input-sm" id="quick_filter" placeholder="Quick filter...">
25
- </div>
26
- </div>
27
- </form>
28
- </th>
29
- </tr>
30
- <tr>
31
- <th>Path</th>
32
- <th>Repository</th>
33
- <th style="width:100px;text-align:right">Size</th>
34
- </tr>
35
- </thead>
36
- <tbody>
37
- <% @blobs_with_findings.each do |blob| %>
38
- <tr data-blob-id="<%=h blob.id %>">
39
- <td><%=format_path(blob.path) %></td>
40
- <td><a href="/repos/<%=h blob.repo.id %>"><%=h blob.repo.full_name %></a></td>
41
- <td style="text-align:right"><%=h number_to_human_size(blob.size) %></td>
42
- </tr>
43
- <% end %>
44
- </tbody>
45
- </table>
46
- </div>
47
-
48
- <div role="tabpanel" class="tab-pane" id="members">
49
- <div class="row">
50
- <div class="col-md-2">
51
- <div class="thumbnail user-thumbnail" data-username="<%=h @org.name %>" data-type="org">
52
- <img src="<%=h @org.avatar_url %>" alt="<%=h @org.name %>" class="avatar" />
53
- <div class="caption" style="text-align:center">
54
- <small><%=h @org.name %></small>
55
- </div>
56
- <% if @org.repos.findings.all(:user => nil).count.zero? %>
57
- <div class="findings-batch positive">0 findings</div>
58
- <% else %>
59
- <div class="findings-batch negative"><%=h Gitrob::Util.pluralize(@org.repos.all(:user => nil).findings.count, 'finding', 'findings') %></div>
60
- <% end %>
61
- </div>
62
- </div>
63
-
64
- <% @org.users.each do |user| %>
65
- <div class="col-md-2">
66
- <div class="thumbnail user-thumbnail" data-username="<%=h user.username %>" data-type="user">
67
- <img src="<%=h user.avatar_url %>" alt="<%=h user.name %>" class="avatar" />
68
- <div class="caption" style="text-align:center">
69
- <small><%=h user.name %></small>
70
- </div>
71
- <% if user.findings.count.zero? %>
72
- <div class="findings-batch positive">0 findings</div>
73
- <% else %>
74
- <div class="findings-batch negative"><%=h Gitrob::Util.pluralize(user.findings.count, 'finding', 'findings') %></div>
75
- <% end %>
76
- </div>
77
- </div>
78
- <% end %>
79
- </div>
80
- </div>
81
-
82
- <div role="tabpanel" class="tab-pane" id="repos">
83
- <table class="table table-striped table-hover table-condensed">
84
- <thead>
85
- <tr>
86
- <th>Name</th>
87
- <th>Description</th>
88
- <th>Website</th>
89
- <th style="width:50px;text-align:right">Findings</th>
90
- </tr>
91
- </thead>
92
- <tbody>
93
- <% @repos.each do |repository| %>
94
- <% if repository.findings.count.zero? %>
95
- <tr>
96
- <% else %>
97
- <tr class="warning">
98
- <% end %>
99
- <td><strong><a href="/repos/<%=h repository.id %>"><%=h repository.full_name %></a></strong></td>
100
- <td><%=h repository.description %></td>
101
- <td><%=h repository.website %></td>
102
- <td style="text-align:center"><strong><%=h repository.findings.count %></strong></td>
103
- </tr>
104
- <% end %>
105
- </tbody>
106
- </table>
107
- </div>
108
- </div>
109
- </div>
110
-
111
- <div id="blob_modal" class="modal fade" role="dialog" aria-hidden="true">
112
- <div class="modal-dialog modal-lg">
113
- <div class="modal-content">
114
- <div class="modal-body"></div>
115
- </div>
116
- </div>
117
- </div>
118
-
119
- <div id="user_modal" class="modal fade" role="dialog" aria-hidden="true">
120
- <div class="modal-dialog modal-lg">
121
- <div class="modal-content">
122
- <div class="modal-body"></div>
123
- </div>
124
-
125
- </div>
126
- </div>
data/views/repository.erb DELETED
@@ -1,51 +0,0 @@
1
- <div class="page-header">
2
- <h1><a href="/">Organizations</a> &rang; <a href="/orgs/<%=h @repo.organization.id %>"><%=h @repo.organization.name %></a> &rang; <%=h @repo.full_name %></h1>
3
- </div>
4
-
5
- <div class="pull-right"><a href="<%=h @repo.url %>" target="_blank">View repository on GitHub</a></div>
6
- <table id="blob_table" class="table table-condensed table-hover">
7
- <thead>
8
- <tr>
9
- <th colspan="2">
10
- <form class="form-inline" role="quick-filter">
11
- <div class="checkbox">
12
- <label>
13
- <input type="checkbox" checked="checked" id="only_with_findings"> Show only files with findings
14
- </label>
15
- </div>
16
- <div class="form-group" style="display:block;float:right">
17
- <div class="input-group">
18
- <div class="input-group-addon input-sm"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></div>
19
- <input type="search" class="form-control input-sm" id="quick_filter" placeholder="Quick filter...">
20
- </div>
21
- </div>
22
- </form>
23
- </th>
24
- </tr>
25
- <tr>
26
- <th>Path</th>
27
- <th style="width:100px;text-align:right">Size</th>
28
- </tr>
29
- </thead>
30
- <tbody>
31
- <% @repo.blobs.all.each do |blob| %>
32
- <% if blob.findings.count.zero? %>
33
- <tr data-blob-id="<%=h blob.id %>">
34
- <% else %>
35
- <tr class="warning" data-blob-id="<%=h blob.id %>">
36
- <% end %>
37
- <td><%=format_path(blob.path) %></td>
38
- <td style="text-align:right"><%=h number_to_human_size(blob.size) %></td>
39
- </tr>
40
- <% end %>
41
- </tbody>
42
- </table>
43
-
44
- <div id="blob_modal" class="modal fade" role="dialog" aria-hidden="true">
45
- <div class="modal-dialog modal-lg">
46
- <div class="modal-content">
47
- <div class="modal-body"></div>
48
- </div>
49
- </div>
50
- </div>
51
-
data/views/user.erb DELETED
@@ -1,51 +0,0 @@
1
- <h1><img src="<%=h @user.avatar_url %>" alt="<%=h @user.name %>" width="64" height="64" /> <strong><%=h @user.name %></strong></h1>
2
-
3
- <h2>Basic Information</h2>
4
- <table class="table user-details">
5
- <tr>
6
- <th>Name:</th>
7
- <td><%=h @user.name %></td>
8
- <th>Username:</th>
9
- <td><%=h @user.username %> (<a href="http://www.namechecklist.com/#!<%=h @user.username %>" target="_blank" title="Find other sites where this username is taken">elsewhere</a>)</td>
10
- <th>E-mail:</th>
11
- <td><%=h @user.email || "None" %></td>
12
- </tr>
13
- <tr>
14
- <th>Location:</th>
15
- <td><%=h @user.location || "Unknown" %></td>
16
- <th>Website:</th>
17
- <td><%=h @user.website || "None" %></td>
18
- <th>Bio:</th>
19
- <td><%=h @user.bio %></td>
20
- </tr>
21
- </table>
22
-
23
- <% if @user.repos.count.zero? %>
24
- <div class="alert alert-info" role="alert">
25
- <strong><%=h @user.name %> has no public repositories.</strong>
26
- </div>
27
- <% else %>
28
- <h2>Repositories</h2>
29
- <table class="table table-striped table-hover table-condensed user-repositories">
30
- <thead>
31
- <tr>
32
- <th>Name</th>
33
- <th>Description</th>
34
- <th style="width:50px;text-align:right">Findings</th>
35
- </tr>
36
- </thead>
37
- <tbody>
38
- <% @repos.each do |repository| %>
39
- <% if repository.findings.count.zero? %>
40
- <tr>
41
- <% else %>
42
- <tr class="warning">
43
- <% end %>
44
- <td><strong><a href="/repos/<%=h repository.id %>"><%=h repository.name %></a></strong></td>
45
- <td><%=h repository.description %></td>
46
- <td style="text-align:center"><strong><%=h repository.findings.count %></strong></td>
47
- </tr>
48
- <% end %>
49
- </tbody>
50
- </table>
51
- <% end %>