gitrob 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +47 -0
  7. data/Rakefile +2 -0
  8. data/bin/gitrob +258 -0
  9. data/gitrob.gemspec +36 -0
  10. data/lib/gitrob.rb +116 -0
  11. data/lib/gitrob/github/blob.rb +41 -0
  12. data/lib/gitrob/github/http_client.rb +127 -0
  13. data/lib/gitrob/github/organization.rb +93 -0
  14. data/lib/gitrob/github/repository.rb +72 -0
  15. data/lib/gitrob/github/user.rb +78 -0
  16. data/lib/gitrob/observers/sensitive_files.rb +82 -0
  17. data/lib/gitrob/progressbar.rb +52 -0
  18. data/lib/gitrob/util.rb +11 -0
  19. data/lib/gitrob/version.rb +3 -0
  20. data/lib/gitrob/webapp.rb +76 -0
  21. data/models/blob.rb +35 -0
  22. data/models/finding.rb +14 -0
  23. data/models/organization.rb +32 -0
  24. data/models/repo.rb +22 -0
  25. data/models/user.rb +28 -0
  26. data/patterns.json +303 -0
  27. data/public/fonts/glyphicons-halflings-regular.eot +0 -0
  28. data/public/fonts/glyphicons-halflings-regular.svg +229 -0
  29. data/public/fonts/glyphicons-halflings-regular.ttf +0 -0
  30. data/public/fonts/glyphicons-halflings-regular.woff +0 -0
  31. data/public/javascripts/bootstrap.min.js +7 -0
  32. data/public/javascripts/gitrob.js +75 -0
  33. data/public/javascripts/jquery-2.1.1.min.js +4 -0
  34. data/public/javascripts/lang-apollo.js +2 -0
  35. data/public/javascripts/lang-basic.js +3 -0
  36. data/public/javascripts/lang-clj.js +18 -0
  37. data/public/javascripts/lang-css.js +2 -0
  38. data/public/javascripts/lang-dart.js +3 -0
  39. data/public/javascripts/lang-erlang.js +2 -0
  40. data/public/javascripts/lang-go.js +1 -0
  41. data/public/javascripts/lang-hs.js +2 -0
  42. data/public/javascripts/lang-lisp.js +3 -0
  43. data/public/javascripts/lang-llvm.js +1 -0
  44. data/public/javascripts/lang-lua.js +2 -0
  45. data/public/javascripts/lang-matlab.js +6 -0
  46. data/public/javascripts/lang-ml.js +2 -0
  47. data/public/javascripts/lang-mumps.js +2 -0
  48. data/public/javascripts/lang-n.js +4 -0
  49. data/public/javascripts/lang-pascal.js +3 -0
  50. data/public/javascripts/lang-proto.js +1 -0
  51. data/public/javascripts/lang-r.js +2 -0
  52. data/public/javascripts/lang-rd.js +1 -0
  53. data/public/javascripts/lang-scala.js +2 -0
  54. data/public/javascripts/lang-sql.js +2 -0
  55. data/public/javascripts/lang-tcl.js +3 -0
  56. data/public/javascripts/lang-tex.js +1 -0
  57. data/public/javascripts/lang-vb.js +2 -0
  58. data/public/javascripts/lang-vhdl.js +3 -0
  59. data/public/javascripts/lang-wiki.js +2 -0
  60. data/public/javascripts/lang-xq.js +3 -0
  61. data/public/javascripts/lang-yaml.js +2 -0
  62. data/public/javascripts/prettify.js +30 -0
  63. data/public/javascripts/run_prettify.js +34 -0
  64. data/public/stylesheets/bootstrap.min.css +7 -0
  65. data/public/stylesheets/bootstrap.min.css.vanilla +5 -0
  66. data/public/stylesheets/gitrob.css +88 -0
  67. data/public/stylesheets/prettify.css +51 -0
  68. data/spec/lib/gitrob/observers/sensitive_files_spec.rb +558 -0
  69. data/spec/spec_helper.rb +127 -0
  70. data/views/blob.erb +22 -0
  71. data/views/index.erb +32 -0
  72. data/views/layout.erb +30 -0
  73. data/views/organization.erb +126 -0
  74. data/views/repository.erb +51 -0
  75. data/views/user.erb +51 -0
  76. metadata +317 -0
@@ -0,0 +1,127 @@
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 ADDED
@@ -0,0 +1,22 @@
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>
data/views/index.erb ADDED
@@ -0,0 +1,32 @@
1
+ <div class="page-header">
2
+ <h1>Organizations</h1>
3
+ </div>
4
+
5
+ <% if @orgs.count.zero? %>
6
+
7
+ <% else %>
8
+ <table class="table table-striped table-hover">
9
+ <thead>
10
+ <tr>
11
+ <th>Name</th>
12
+ <th>Repositories</th>
13
+ <th>Members</th>
14
+ <th>Findings</th>
15
+ <th style="text-align:right">Creation date</th>
16
+ </tr>
17
+ </thead>
18
+ <tbody>
19
+ <% @orgs.each do |org| %>
20
+ <tr>
21
+ <td>
22
+ <img src="<%=h org.avatar_url %>" alt="<%=h org.name %>" class="avatar" width="24" height="24" />
23
+ <strong><a href="/orgs/<%=h org.id%>"><%=h org.name %></a></strong></td>
24
+ <td><%=h org.repos.count %></td>
25
+ <td><%=h org.users.count %></td>
26
+ <td><%=h org.findings.count %></td>
27
+ <td style="text-align:right"><%= org.created_at.strftime("%e %b %Y %H:%M") %></td>
28
+ </tr>
29
+ <% end %>
30
+ </tbody>
31
+ </table>
32
+ <% end %>
data/views/layout.erb ADDED
@@ -0,0 +1,30 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+ <title>Gitrob</title>
8
+
9
+ <link href="/stylesheets/bootstrap.min.css" rel="stylesheet">
10
+ <link href="/stylesheets/prettify.css" rel="stylesheet">
11
+ <link href="/stylesheets/gitrob.css" rel="stylesheet">
12
+
13
+ <script type="text/javascript" src="/javascripts/jquery-2.1.1.min.js"></script>
14
+ <script type="text/javascript" src="/javascripts/bootstrap.min.js"></script>
15
+
16
+ <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
17
+ <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
18
+ <!--[if lt IE 9]>
19
+ <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
20
+ <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
21
+ <![endif]-->
22
+ </head>
23
+ <body>
24
+ <div class="container">
25
+ <%= yield %>
26
+ </div>
27
+ <script type="text/javascript" src="/javascripts/prettify.js"></script>
28
+ <script type="text/javascript" src="/javascripts/gitrob.js"></script>
29
+ </body>
30
+ </html>
@@ -0,0 +1,126 @@
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>
@@ -0,0 +1,51 @@
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 ADDED
@@ -0,0 +1,51 @@
1
+ <h1><img src="<%=h @user.avatar_url %>" alt="<%= @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 %>