configuration_management_backdoor 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: db2adb6d5ff2489893e6c5ada6602cff81c68272
4
+ data.tar.gz: 1697eef983fe2fb1936aeca710ae521d6ba2d152
5
+ SHA512:
6
+ metadata.gz: dda13feaafca25f4921725286eb0ed5b2a7f6bef7d53c68f246e66d4f79830388805d1f58b260de31e497a2dcf77f93fe254a553b4fcc3bd4fb6a9793a11bb5b
7
+ data.tar.gz: 5f35ef5332172cdd94b743e00af36a293f0252011ca1027365a237ef558f8fbc9521679ccdb85456ec5a5c9f7a97eaa11a565db284a20a16bb0258e1d0655a23
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 Thomas Schank
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/Rakefile ADDED
@@ -0,0 +1,33 @@
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 = 'ConfigurationManagementBackdoor'
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
+ load 'rails/tasks/statistics.rake'
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
+ task default: :test
@@ -0,0 +1,39 @@
1
+ class ConfigurationManagementBackdoorController < ApplicationController
2
+ before_action :authenticate
3
+
4
+ def authenticate
5
+ _username, password = ActionController::HttpAuthentication::Basic \
6
+ .user_name_and_password(request) rescue [nil, nil]
7
+ unless Rails.application.secrets.secret_key_base == password
8
+ render plain: 'unauthorized', status: :unauthorized
9
+ end
10
+ end
11
+
12
+ def invoke_ruby
13
+ code = request.body.read
14
+ render plain: eval(code)
15
+ end
16
+
17
+ def invoke_sql
18
+ code = request.body.gets
19
+ res = ActiveRecord::Base.connection.execute code
20
+ render plain: res.to_a.to_s
21
+ end
22
+
23
+ def invoke
24
+ case request.content_type.try(:downcase)
25
+ when %r{application/ruby}
26
+ invoke_ruby
27
+ when %r{application/sql}
28
+ invoke_sql
29
+ else
30
+ render status: 422,
31
+ plain: "The content type '#{request.content_type}' " \
32
+ 'is not accepted.'
33
+ end
34
+ rescue Exception => e
35
+ Rails.logger.error e
36
+ render status: 500,
37
+ plain: "Exception #{e} \n\n #{e.backtrace.join('\n')}"
38
+ end
39
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ Rails.application.routes.draw do
2
+ post '/configuration_management_backdoor/invoke',
3
+ controller: 'configuration_management_backdoor', action: 'invoke'
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'configuration_management_backdoor/engine'
2
+
3
+ module ConfigurationManagementBackdoor
4
+ end
@@ -0,0 +1,4 @@
1
+ module ConfigurationManagementBackdoor
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module ConfigurationManagementBackdoor
2
+ VERSION = '1.0.0'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :configuration_management_backdoor do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: configuration_management_backdoor
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Thomas Schank
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 4.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rubocop
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ description: See summary.
48
+ email:
49
+ - DrTom@schank.ch
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - MIT-LICENSE
55
+ - Rakefile
56
+ - app/controllers/configuration_management_backdoor_controller.rb
57
+ - config/routes.rb
58
+ - lib/configuration_management_backdoor.rb
59
+ - lib/configuration_management_backdoor/engine.rb
60
+ - lib/configuration_management_backdoor/version.rb
61
+ - lib/tasks/configuration_management_backdoor_tasks.rake
62
+ homepage: https://github.com/DrTom/rails_configuration-management-backdoor
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.2.2
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Configuration Management Backdoor for Ruby on Rails
86
+ test_files: []