rails_cve 0.0.1

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 (59) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.travis.yml +7 -0
  4. data/Gemfile +3 -0
  5. data/MIT-LICENSE +21 -0
  6. data/README.md +116 -0
  7. data/Rakefile +34 -0
  8. data/app/models/concerns/rails_cve/entry/presentation.rb +12 -0
  9. data/app/models/concerns/rails_cve/entry/references.rb +22 -0
  10. data/app/models/concerns/rails_cve/entry/search.rb +14 -0
  11. data/app/models/concerns/rails_cve/entry/updater.rb +43 -0
  12. data/app/models/rails_cve/entry.rb +10 -0
  13. data/bin/rails +12 -0
  14. data/db/migrate/20140402144115_create_rails_cve_entries.rb +31 -0
  15. data/lib/rails_cve/engine.rb +13 -0
  16. data/lib/rails_cve/utils.rb +100 -0
  17. data/lib/rails_cve/version.rb +3 -0
  18. data/lib/rails_cve.rb +5 -0
  19. data/lib/tasks/rails_cve_tasks.rake +12 -0
  20. data/rails_cve.gemspec +31 -0
  21. data/test/dummy/Rakefile +6 -0
  22. data/test/dummy/app/assets/javascripts/application.js +13 -0
  23. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  24. data/test/dummy/app/controllers/application_controller.rb +5 -0
  25. data/test/dummy/app/helpers/application_helper.rb +2 -0
  26. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  27. data/test/dummy/bin/bundle +3 -0
  28. data/test/dummy/bin/rails +4 -0
  29. data/test/dummy/bin/rake +4 -0
  30. data/test/dummy/config/application.rb +28 -0
  31. data/test/dummy/config/boot.rb +5 -0
  32. data/test/dummy/config/database.yml +16 -0
  33. data/test/dummy/config/environment.rb +5 -0
  34. data/test/dummy/config/environments/development.rb +11 -0
  35. data/test/dummy/config/environments/production.rb +80 -0
  36. data/test/dummy/config/environments/test.rb +14 -0
  37. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  38. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  39. data/test/dummy/config/initializers/inflections.rb +16 -0
  40. data/test/dummy/config/initializers/mime_types.rb +5 -0
  41. data/test/dummy/config/initializers/secret_token.rb +12 -0
  42. data/test/dummy/config/initializers/session_store.rb +3 -0
  43. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  44. data/test/dummy/config/locales/en.yml +23 -0
  45. data/test/dummy/config/routes.rb +5 -0
  46. data/test/dummy/config.ru +4 -0
  47. data/test/dummy/db/schema.rb +28 -0
  48. data/test/dummy/public/404.html +58 -0
  49. data/test/dummy/public/422.html +58 -0
  50. data/test/dummy/public/500.html +57 -0
  51. data/test/dummy/public/favicon.ico +0 -0
  52. data/test/fixtures/vcr/allitems-header-first10.yml +147 -0
  53. data/test/fixtures/vcr/download-error.yml +31 -0
  54. data/test/fixtures/vcr/download-success.yml +58 -0
  55. data/test/models/rails_cve/entry_test.rb +16 -0
  56. data/test/models/rails_cve/utils_test.rb +76 -0
  57. data/test/support/vcr.rb +6 -0
  58. data/test/test_helper.rb +10 -0
  59. metadata +249 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7710d41cfcbd020a20e7e80c182d9ca3dfc1833d
4
+ data.tar.gz: c2fd962891aa4517b740ffb40976385d28e5c485
5
+ SHA512:
6
+ metadata.gz: c9a4fe45b865081da707e6c6fc582ab87fec7540e53e76b8947c18af9bd45780881a4322b9e3a23a8bb4d0fcc360c7aa2fd372f9b89e319cbbe9dd0ad89592a5
7
+ data.tar.gz: 557546b6e29aeaf568f33d434df27708b2fd4cf9b621bc61592af3dbbd6317b48dbd90c96cfdb9df90d2496761a22ceddcbffecb958b0c2b7c94b1699ff3a378
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ .bundle/
2
+ Gemfile.lock
3
+ log/*.log
4
+ pkg/
5
+ test/dummy/data/
6
+ test/dummy/db/*.sqlite3
7
+ test/dummy/db/*.sqlite3-journal
8
+ test/dummy/log/*.log
9
+ test/dummy/tmp/
10
+ test/dummy/.sass-cache
11
+ *~
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ruby:
2
+ - 2.0.0
3
+ - 2.1.1
4
+
5
+ before_script:
6
+ - psql -U postgres -c "CREATE ROLR railscve WITH LOGIN ENCRYPTED PASSWORD 'railscve';"
7
+ - psql -U postgres -c "CREATE DATABASE railscve_test WITH OWNER railscve;"
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/MIT-LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright 2014 Dominik Menke and contributors. For a full list of contributors
2
+ see https://github.com/havainto/rails-cve/graphs/contributors.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,116 @@
1
+ # Rails Common Vulnerability Engine
2
+
3
+ If you ever need a local copy of the [CVE list][1] in your Rails application,
4
+ you could consider using this engine.
5
+
6
+ RailsCVE gives you a `RailsCVE::Entry` model, on which you can perform various
7
+ tasks, notably searching the CVE descriptions:
8
+
9
+ ```ruby
10
+ # in `rails console`
11
+
12
+ list = RailsCVE::Entry.search 'ruby'
13
+ # SELECT "rails_cve_entries".* FROM "rails_cve_entries"
14
+ # WHERE (to_tsvector('english', description) @@ to_tsquery('ruby'))
15
+ # ORDER BY ts_rank(to_tsvector(description), plainto_tsquery('ruby')) DESC
16
+
17
+ list.count
18
+ #=> 165
19
+
20
+ list.last
21
+ # #<RailsCVE::Entry
22
+ # id: 29523,
23
+ # name: "CVE-2007-6183",
24
+ # descri ption: "Format string vulnerability in the mdiag_initialize...",
25
+ # references: [
26
+ # "BUGTRAQ:20071127 Ruby/Gnome2 0.16.0 Format String Vulnerability",
27
+ # "URL:http://www.securityfocus.com/archive/1/archive/1/484240/100/0/threaded",
28
+ # "MISC:http://em386.blogspot.com/2007/11/your-favorite-better-than-c-scripting.html",
29
+ # "MISC:https://bugzilla.redhat.com/show_bug.cgi?id=402871",
30
+ # …,
31
+ # "XF:rubygnome2-mdiaginitialize-format-string(38757)",
32
+ # "URL:http://xforce.iss.net/xforce/xfdb/38757"
33
+ # ]>
34
+ ```
35
+
36
+ ## Full text search capabilities
37
+
38
+ As you can see in the example above, we take advantage of PostgreSQL's text
39
+ search features. Hence, you will need to migrate to PostgreSQL unless you
40
+ haven't already.
41
+
42
+ I should mention, that it is **strongly recommended** to change your schema
43
+ format from Ruby to SQL, like so:
44
+
45
+ ```ruby
46
+ # in config/application.rb
47
+ config.active_record.schema_format = :sql
48
+ ```
49
+
50
+ While `RailsCVE::Entry.search` uses a predefined search query, you can, of
51
+ course, build your own using Postgres' [text search functions and operators][2]
52
+
53
+
54
+ ## Installation
55
+
56
+ Add `rails-cve` to your Gemfile and run `bundle install`
57
+
58
+ ```ruby
59
+ gem 'rails-cve'
60
+ ```
61
+
62
+ Then install and run the migrations via
63
+
64
+ ```
65
+ rake db:migrate
66
+ ```
67
+
68
+ and seed/import all currently knwon CVE entries (~70.000 at the time of
69
+ writing):
70
+
71
+ ```
72
+ rake rails_cve:seed
73
+ ```
74
+
75
+ ## Maintenance
76
+
77
+ You should (at least daily) import the updates. RailsCVE currently uses the
78
+ [Cassandra][3] web service. To do so, you need to call
79
+
80
+ ```ruby
81
+ RailsCVE::Entry.update_entries
82
+ ```
83
+
84
+ This does not only import new entries, but also updates existing entries.
85
+ These updates usually include updates in the references list and/or
86
+ description text, but can also mark a CVE entry as candidate (CAN) or reject
87
+ the entry. Currently, the updating method does not provide any hooks, but
88
+ patches are welcome!
89
+
90
+
91
+ ## Tests
92
+
93
+ I'm working on it. Don't use this release unless you know what you're doing!
94
+
95
+
96
+ ## Contributing
97
+
98
+ Either
99
+
100
+ 1. open an issue and ask for directions
101
+
102
+ or
103
+
104
+ 1. Fork this repository.
105
+ 2. Commit your changes (tests are very welcome).
106
+ 3. Open a pull request.
107
+
108
+
109
+ ## License
110
+
111
+ MIT. See LICENSE file.
112
+
113
+
114
+ [1]: http://cve.mitre.org/
115
+ [2]: http://www.postgresql.org/docs/9.1/static/functions-textsearch.html
116
+ [3]: https://cassandra.cerias.purdue.edu/CVE_changes/
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'RailsCVE'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,12 @@
1
+ module RailsCVE::Entry::Presentation
2
+ extend ActiveSupport::Concern
3
+
4
+ def to_s
5
+ name
6
+ end
7
+
8
+ def year
9
+ @year ||= name.gsub(/^CVE-(\d{4})/, '\1').to_i
10
+ end
11
+
12
+ end
@@ -0,0 +1,22 @@
1
+ module RailsCVE::Entry::References
2
+ extend ActiveSupport::Concern
3
+
4
+ def reference_uris
5
+ return [] unless references?
6
+ references.grep(/^URL:/).map{|r| r.gsub(/^URL:/, '') }
7
+ end
8
+
9
+ def references=(refs)
10
+ case refs
11
+ when Array
12
+ references_will_change!
13
+ super refs.flatten
14
+ when String
15
+ references_will_change!
16
+ super refs.split(' | ')
17
+ else
18
+ raise ArgumentError, 'invalid type'
19
+ end
20
+ end
21
+
22
+ end
@@ -0,0 +1,14 @@
1
+ module RailsCVE::Entry::Search
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ scope :search, ->(query){
6
+ q = sanitize(query)
7
+
8
+ rank = "ts_rank(to_tsvector(description), plainto_tsquery(%{q}))" % { q: q }
9
+ cond = "to_tsvector('english', description) @@ to_tsquery(%{q})" % { q: q }
10
+
11
+ where(cond).order("#{rank} desc")
12
+ }
13
+ end
14
+ end
@@ -0,0 +1,43 @@
1
+ module RailsCVE::Entry::Updater
2
+ extend ActiveSupport::Concern
3
+
4
+ DATA_PATH = if Rails.env.production?
5
+ Rails.root.join('data/cve-list')
6
+ else
7
+ Rails.root.join("data/cve-list-#{Rails.env}")
8
+ end
9
+
10
+ module ClassMethods
11
+
12
+ def rebuild_entries!
13
+ transaction do
14
+ RailsCVE::Utils.fetch_all_entries do |name, desc, ref|
15
+ entry = create_or_update_with_data! name, desc, ref
16
+ yield entry if block_given?
17
+ end.size
18
+ end
19
+ end
20
+
21
+ def update_entries
22
+ now = Time.current
23
+
24
+ transaction do
25
+ RailsCVE::Utils.fetch_updates(now.year, now.month) do |name, desc, ref|
26
+ create_or_update_with_data! name, desc, ref
27
+ end.size
28
+ end
29
+ end
30
+
31
+ def create_or_update_with_data!(name, description, references)
32
+ entry = where(name: name).first_or_initialize
33
+ entry.description = description
34
+ entry.references = references
35
+ entry.save!
36
+ entry
37
+ rescue ActiveRecord::RecordNotUnique
38
+ retry
39
+ end
40
+
41
+ end
42
+
43
+ end
@@ -0,0 +1,10 @@
1
+ module RailsCVE
2
+ class Entry < ActiveRecord::Base
3
+ include RailsCVE::Entry::Updater
4
+ include RailsCVE::Entry::Presentation
5
+ include RailsCVE::Entry::References
6
+ include RailsCVE::Entry::Search
7
+
8
+ validates :name, presence: true, uniqueness: true
9
+ end
10
+ end
data/bin/rails ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/rails_cve/engine', __FILE__)
6
+
7
+ # Set up gems listed in the Gemfile.
8
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
9
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
10
+
11
+ require 'rails/all'
12
+ require 'rails/engine/commands'
@@ -0,0 +1,31 @@
1
+ class CreateRailsCveEntries < ActiveRecord::Migration
2
+ def up
3
+ create_table :rails_cve_entries do |t|
4
+ t.string :name, null: false
5
+ t.text :description
6
+ t.string :references, array: true, limit: 1024
7
+ end
8
+
9
+ add_index :rails_cve_entries, :name, unique: true
10
+
11
+ # It is recommended to set
12
+ #
13
+ # config.active_record.schema_format = :sql
14
+ #
15
+ # in your config/application.rb. If you don't and you just run
16
+ # `rake db:schema:load` later on, you'll end up having REALLY SLOW search
17
+ # queries.
18
+ execute <<-SQL.squish
19
+ CREATE INDEX
20
+ cve_entry_text_search ON rails_cve_entries
21
+ USING
22
+ gin(to_tsvector('english', description))
23
+ SQL
24
+ end
25
+
26
+ def down
27
+ execute "DROP INDEX cve_entry_text_search"
28
+ remove_index :rails_cve_entries, :name
29
+ drop_table :rails_cve_entries
30
+ end
31
+ end
@@ -0,0 +1,13 @@
1
+ module RailsCVE
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace RailsCVE
4
+
5
+ initializer :append_migrations do |app|
6
+ unless app.root.to_s.match root.to_s
7
+ config.paths["db/migrate"].expanded.each do |expanded_path|
8
+ app.config.paths["db/migrate"] << expanded_path
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,100 @@
1
+ require 'csv'
2
+ require 'nokogiri'
3
+ require 'httparty'
4
+
5
+ module RailsCVE
6
+ Error = Class.new(StandardError)
7
+ UnknownTarget = Class.new(ArgumentError)
8
+
9
+ module Utils
10
+ extend self
11
+
12
+ # Source of full CVE list
13
+ def allitems_source(basename)
14
+ "http://cve.mitre.org/data/downloads/#{basename}.gz"
15
+ end
16
+
17
+ # Source for updates
18
+ def updates_source(basename)
19
+ "https://cassandra.cerias.purdue.edu/CVE_changes/#{basename}"
20
+ end
21
+
22
+ # Path for downloads, needs to be writeable
23
+ def data_path(target)
24
+ RailsCVE::Entry::DATA_PATH.join(target).tap {|path| path.dirname.mkpath }
25
+ end
26
+
27
+ # Downloads latest allitems.cvs(.gz) from cve.mitre.org and yields name,
28
+ # description and references list of every CVE entry
29
+ def fetch_all_entries(&block)
30
+ file = data_path('allitems.csv')
31
+ download allitems_source(file.basename), to: file
32
+
33
+ latch_locked = true
34
+ result = []
35
+
36
+ CSV.parse(file.read) do |row|
37
+ # there are some comments prefacing the entry list
38
+ latch_locked = false if row[0].nil?
39
+ next if latch_locked || row[0].nil?
40
+
41
+ name, _, description, references, _, _, _ = row
42
+
43
+ if block_given?
44
+ result << yield(name, description, references)
45
+ else
46
+ result << [name, description, references]
47
+ end
48
+ end
49
+
50
+ result
51
+ end
52
+
53
+ # Fetches the updates for a given year/month from Cassandra and
54
+ # yields name, desc. and refs. for each CVE change
55
+ def fetch_updates(year, month, &block)
56
+ list = data_path('CVE.%4d.%02d.html' % [year.to_i, month.to_i])
57
+ download updates_source(list.basename), to: list
58
+
59
+ # Sadly, there is only little structure in the downloaded list.
60
+ Nokogiri::HTML(list.read).css('a').map do |a|
61
+ url = URI.parse(a[:href])
62
+ next unless url.host == 'cve.mitre.org'
63
+ next unless url.query =~ /name=(\d{4})-(\d{4,})/
64
+
65
+ y,id = $1, $2
66
+ name = "CVE-#{y}-#{id}"
67
+
68
+ # max. 2 digits per dirname → max. 100 subdirs per directory
69
+ parts = id.to_s.scan(/\d\d/).join('/')
70
+
71
+ # for now, we fetch *each* embedded link, which could take a while…
72
+ file = data_path("entries/#{y}/#{parts}/#{name}.html")
73
+ download a[:href], to: file
74
+
75
+ table = Nokogiri::HTML(file.read).xpath('//div[@id="GeneratedTable"]/table')
76
+ description = table.xpath('.//tr[4]/td').text
77
+ references = table.xpath('.//tr[7]//li').map(&:text)
78
+
79
+ yield name, description, references
80
+ end
81
+ end
82
+
83
+ def download(url, to: nil)
84
+ unless to.present? && Pathname === to
85
+ raise UnknownTarget, '"to" parameter needs to be Pathname instance'
86
+ end
87
+
88
+ response = HTTParty.get(url, verify: false)
89
+ return false if response.code != 200
90
+
91
+ data = response.body.encode(Encoding::UTF_8, invalid: :replace, undef: :replace)
92
+ to.open('w') {|f| f.write data }
93
+
94
+ true
95
+ rescue HTTParty::Error, Net::HTTPError
96
+ return false
97
+ end
98
+ end
99
+
100
+ end
@@ -0,0 +1,3 @@
1
+ module RailsCVE
2
+ VERSION = "0.0.1"
3
+ end
data/lib/rails_cve.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "rails_cve/engine"
2
+ require "rails_cve/utils"
3
+
4
+ module RailsCVE
5
+ end
@@ -0,0 +1,12 @@
1
+ namespace :rails_cve do
2
+
3
+ desc "Seed the database"
4
+ task seed: :environment do
5
+ puts '(Re-) Importing CVE list. This could take a while...'
6
+ n = RailsCVE::Entry.rebuild_entries! do |entry|
7
+ puts "\t#{entry.name} imported"
8
+ end
9
+ puts "Done! Imported #{n} CVE entries."
10
+ end
11
+
12
+ end
data/rails_cve.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require 'rails_cve/version'
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = 'rails_cve'
9
+ s.version = RailsCVE::VERSION
10
+ s.authors = 'Dominik Menke'
11
+ s.email = 'dominik.menke@gmail.com'
12
+ s.homepage = 'https://havain.to'
13
+ s.summary = 'Rails Common Vulnerability Engine'
14
+
15
+
16
+ s.files = `git ls-files -z`.split("\x0")
17
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
+
19
+ #s.files = Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.rdoc']
20
+ #s.test_files = Dir['test/**/*']
21
+
22
+ s.add_dependency 'rails', '~> 4.0.4'
23
+ s.add_dependency 'nokogiri'
24
+ s.add_dependency 'httparty'
25
+ s.add_dependency 'pg'
26
+
27
+ s.add_development_dependency 'pry-byebug'
28
+ s.add_development_dependency 'pry-rails'
29
+ s.add_development_dependency 'vcr'
30
+ s.add_development_dependency 'webmock'
31
+ end
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Dummy::Application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application", media: "all" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,28 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ # Pick the frameworks you want:
4
+ require "active_record/railtie"
5
+ #require "action_controller/railtie"
6
+ #require "action_mailer/railtie"
7
+ # require "sprockets/railtie"
8
+ require "rails/test_unit/railtie"
9
+
10
+ Bundler.require(*Rails.groups)
11
+ require "rails_cve"
12
+
13
+ module Dummy
14
+ class Application < Rails::Application
15
+ # Settings in config/environments/* take precedence over those specified here.
16
+ # Application configuration should go into files in config/initializers
17
+ # -- all .rb files in that directory are automatically loaded.
18
+
19
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
20
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
21
+ # config.time_zone = 'Central Time (US & Canada)'
22
+
23
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
24
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
25
+ # config.i18n.default_locale = :de
26
+ end
27
+ end
28
+
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,16 @@
1
+ development: &local
2
+ adapter: postgresql
3
+ encoding: unicode
4
+ database: railscve_dev
5
+ pool: 5
6
+ username: railscve
7
+ password: railscve
8
+
9
+ #host: localhost
10
+ #port: 5432
11
+ min_messages: warning
12
+
13
+ test:
14
+ <<: *local
15
+ database: railscve_test
16
+ min_messages: notice