nuclear_secrets 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2e6143ce94a195360d3b2574234b667df27c026a
4
+ data.tar.gz: ec0e4d6a79022de8341f61b10a922ae11c071307
5
+ SHA512:
6
+ metadata.gz: 95eb9e5a7034fcb774df6df36fdb281c3f7fafc640e7e5b8fd035d0c4b48eeb4d1b1d2b5b353c4f496fd997e3e3481fc060346163a6618db05ddde09dcf5c123
7
+ data.tar.gz: ecab8f9d5e067b069f1f910f42f77cc77d3524b7a52154c1fa6f34d8a4c2d83c51e10464f7bf1a6f968bf457389bd781dd5d62bb38d615b2e5717162b628b479
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2017 Nick Benoit
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # NuclearSecrets
2
+ Quell rails secret espionage by verifying what secrets exist and their types in your rails application
3
+
4
+ ## Usage
5
+ Record all application secrets and their appropriate types in Nuclear Secrets initializer.
6
+ If your application loads secrets that are not recorded, or your app does not load a
7
+ required secret, your rails app will crash and inform you of what missing or extra
8
+ secrets exist.
9
+
10
+ ## Installation
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'nuclear_secrets'
15
+ ```
16
+
17
+ And then execute:
18
+ ```bash
19
+ $ bundle
20
+ ```
21
+
22
+ Add initializer to your rails application at `config/initializers/nuclear_secrets.rb`
23
+ ```ruby
24
+ NuclearSecrets.configure do |config|
25
+ config.required_secrets = {
26
+ my_string_secret: String,
27
+ my_numeric_secret: Fixnum,
28
+ }
29
+ end
30
+ ```
31
+ Include all secrets that your application utilizes, and their types, in `required_secrets` hash
32
+
33
+ ## Contributing
34
+ Contribution directions go here.
35
+
36
+ ## License
37
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,36 @@
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 = 'NuclearSecrets'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
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
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ require 'bundler/gem_tasks'
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'test'
31
+ t.pattern = 'test/**/*_test.rb'
32
+ t.verbose = false
33
+ end
34
+
35
+
36
+ task default: :test
@@ -0,0 +1,7 @@
1
+ module NuclearSecrets
2
+ class Application < Rails::Application
3
+ config.after_initialize do
4
+ NuclearSecrets::check_secrets(Rails.application.secrets)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,61 @@
1
+ require "nuclear_secrets/engine"
2
+
3
+ module NuclearSecrets
4
+ class NuclearSecretError < StandardError
5
+ def initialize(secrets: [])
6
+ @secrets = secrets
7
+ end
8
+
9
+ def get_error_list
10
+ @secrets.reduce("") do |message, current|
11
+ message << "#{current.first} of type #{current.last} \n"
12
+ end
13
+ end
14
+ end
15
+
16
+ class RequiredSecretsListMissing < NuclearSecretError
17
+ def message
18
+ "You must include a required_secrets key in your config/secrets.yml file"
19
+ end
20
+ end
21
+
22
+ class SecretsMissingError < NuclearSecretError
23
+ def initialize(secrets)
24
+ super(secrets: secrets)
25
+ end
26
+
27
+ def message
28
+ "Missing secrets: \n#{get_error_list}"
29
+ end
30
+ end
31
+
32
+ class ExtraSecretsError < NuclearSecretError
33
+ def initialize(secrets)
34
+ super(secrets: secrets)
35
+ end
36
+
37
+ def message
38
+ "Secrets not included in required_secrets list: \n#{get_error_list}"
39
+ end
40
+ end
41
+
42
+ class << self
43
+ attr_accessor(:required_secrets)
44
+
45
+ def configure
46
+ yield self if block_given?
47
+ end
48
+
49
+ def check_secrets(secrets)
50
+ raise NuclearSecrets::RequiredSecretsListMissing if required_secrets.nil?
51
+ req_secret_pairs = required_secrets.map { |pair| [pair.first.to_sym, pair.last.to_s] }
52
+ types = secrets.map { |pair| [pair.first, pair.last.class.to_s] }
53
+
54
+ missing_secrets = req_secret_pairs - types
55
+ extra_secrets = types - req_secret_pairs
56
+
57
+ raise SecretsMissingError.new(missing_secrets) unless missing_secrets.empty?
58
+ raise ExtraSecretsError.new(extra_secrets) unless extra_secrets.empty?
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,5 @@
1
+ module NuclearSecrets
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace NuclearSecrets
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module NuclearSecrets
2
+ VERSION = "1.0.0".freeze
3
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nuclear_secrets
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Atomic Jolt
8
+ - Nick Benoit
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2017-09-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 5.0.0
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 5.0.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: sqlite3
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ description: Rails secrets checker
43
+ email:
44
+ - nick.benoit14@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - MIT-LICENSE
50
+ - README.md
51
+ - Rakefile
52
+ - config/initializers/nuclear_secrets.rb
53
+ - lib/nuclear_secrets.rb
54
+ - lib/nuclear_secrets/engine.rb
55
+ - lib/nuclear_secrets/version.rb
56
+ homepage:
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.6.13
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Quell rails secret espionage by verifying what secrets exist and their types
80
+ in your rails application
81
+ test_files: []