hypershield 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b167b3edd07f94a46e64afb6bca7f78f84af7cf722335ce5a518a78e8fa5258
4
- data.tar.gz: dbc93219926d4d02b719fae8592ad5ffba3240240b7db58562f1a05f1d6427f2
3
+ metadata.gz: e1222f7f264c0a8892096edecd7b6cc71a79fb2f1a7c81f7f5be42ecc9c19291
4
+ data.tar.gz: e661dabb10c803a25a71effde3b70dab5ff26c7a4bfe470f2f8fdcba9a7fb4a5
5
5
  SHA512:
6
- metadata.gz: 0c92349ce9da647caec2ee487d815136340c25f1b42190b2589c0173b610ed7865648421db72a5a950aee9b87dbd421fcc02d0d248d945db9b9202507b425cdc
7
- data.tar.gz: 3da557fabb3e16e852f8a1762d82de60078e10a6863b340fdef76c3708f3e979555aff123623fc3c566088a8d9de8d7addd1c7ce4ebb21446cb548050ce39246
6
+ metadata.gz: '078a50cf334a8b95d9355a2265f15f2633dacc16be8f560bbdec9dcae346d90ef308581dfe8d6fdc76e9b8975bc9f000dfd062e153a80277d3784a5c6bee6a99'
7
+ data.tar.gz: 3feac1364504a11be41725e84913d48fc418ab13fa8082feabf9091e38b658a208461519f9956f2a9728105aa89c5af9a7dd04872c45bd2b045bca2eaf790457
@@ -1,3 +1,8 @@
1
+ ## 0.1.1
2
+
3
+ - Fixed error with MySQL 8
4
+ - Added `log_sql` option
5
+
1
6
  ## 0.1.0
2
7
 
3
8
  - First release
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 Andrew
3
+ Copyright (c) 2018-2019 Andrew Kane
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -4,16 +4,20 @@
4
4
 
5
5
  Great for business intelligence tools like [Blazer](https://github.com/ankane/blazer)
6
6
 
7
+ [![Build Status](https://travis-ci.org/ankane/hypershield.svg?branch=master)](https://travis-ci.org/ankane/hypershield)
8
+
7
9
  ## How It Works
8
10
 
9
- Hypershield creates *shielded views* (in the `hypershield` schema by default) that hide sensitive tables and columns. By default, it hides columns with:
11
+ Hypershield creates *shielded views* (in the `hypershield` schema by default) that hide sensitive tables and columns. The advantage of this approach over column-level privileges is you can use `SELECT *`.
12
+
13
+ By default, it hides columns with:
10
14
 
11
15
  - `encrypted`
12
16
  - `password`
13
17
  - `token`
14
18
  - `secret`
15
19
 
16
- Give database users access to these views instead of the original tables. You can set the `search_path` so queries don’t need to be schema-qualified. The advantage of this approach over column-level privileges is you can use `SELECT *`.
20
+ Give database users access to these views instead of the original tables.
17
21
 
18
22
  ## Database Setup
19
23
 
@@ -100,6 +104,12 @@ Hypershield.schemas = {
100
104
  }
101
105
  ```
102
106
 
107
+ Log Hypershield SQL statements [master]
108
+
109
+ ```ruby
110
+ Hypershield.log_sql = true
111
+ ```
112
+
103
113
  ## TODO
104
114
 
105
115
  - Create CLI
@@ -1,12 +1,16 @@
1
+ # dependencies
1
2
  require "active_support"
2
3
 
4
+ # modules
3
5
  require "hypershield/migration"
4
- require "hypershield/railtie" if defined?(Rails)
5
6
  require "hypershield/version"
6
7
 
8
+ # integrations
9
+ require "hypershield/engine" if defined?(Rails)
10
+
7
11
  module Hypershield
8
12
  class << self
9
- attr_accessor :schemas
13
+ attr_accessor :schemas, :log_sql
10
14
  end
11
15
  self.schemas = {
12
16
  hypershield: {
@@ -14,6 +18,7 @@ module Hypershield
14
18
  show: []
15
19
  }
16
20
  }
21
+ self.log_sql = false
17
22
 
18
23
  class << self
19
24
  def drop_view(view)
@@ -67,7 +72,7 @@ module Hypershield
67
72
  private
68
73
 
69
74
  def quiet_logging
70
- if ActiveRecord::Base.logger
75
+ if ActiveRecord::Base.logger && !log_sql
71
76
  previous_level = ActiveRecord::Base.logger.level
72
77
  begin
73
78
  ActiveRecord::Base.logger.level = Logger::INFO
@@ -113,11 +118,11 @@ module Hypershield
113
118
  table_schema = #{schema}
114
119
  SQL
115
120
 
116
- Hash[
117
- select_all(query)
118
- .group_by { |c| c["table_name"] }
119
- .map { |t, cs| [t, cs.sort_by { |c| c["ordinal_position"].to_i }.map { |c| c["column_name"] }] }
120
- ]
121
+ select_all(query.squish)
122
+ .map { |c| c.transform_keys(&:downcase) }
123
+ .group_by { |c| c["table_name"] }
124
+ .map { |t, cs| [t, cs.sort_by { |c| c["ordinal_position"].to_i }.map { |c| c["column_name"] }] }
125
+ .to_h
121
126
  end
122
127
 
123
128
  def select_all(sql)
@@ -0,0 +1,5 @@
1
+ module Hypershield
2
+ class Engine < Rails::Engine
3
+ # for rake tasks
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Hypershield
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,15 @@
1
+ namespace :hypershield do
2
+ task refresh: :environment do
3
+ $stderr.puts "[hypershield] Refreshing schemas"
4
+ Hypershield.refresh
5
+ $stderr.puts "[hypershield] Success!"
6
+ end
7
+ end
8
+
9
+ Rake::Task["db:migrate"].enhance do
10
+ Rake::Task["hypershield:refresh"].invoke
11
+ end
12
+
13
+ Rake::Task["db:rollback"].enhance do
14
+ Rake::Task["hypershield:refresh"].invoke
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hypershield
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-02 00:00:00.000000000 Z
11
+ date: 2019-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,9 +16,23 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '5'
20
20
  type: :runtime
21
21
  prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: benchmark-ips
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - ">="
@@ -38,6 +52,20 @@ dependencies:
38
52
  - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: minitest
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -53,7 +81,21 @@ dependencies:
53
81
  - !ruby/object:Gem::Version
54
82
  version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
- name: rake
84
+ name: pg
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: mysql2
57
99
  requirement: !ruby/object:Gem::Requirement
58
100
  requirements:
59
101
  - - ">="
@@ -67,23 +109,19 @@ dependencies:
67
109
  - !ruby/object:Gem::Version
68
110
  version: '0'
69
111
  description:
70
- email:
71
- - andrew@chartkick.com
112
+ email: andrew@chartkick.com
72
113
  executables: []
73
114
  extensions: []
74
115
  extra_rdoc_files: []
75
116
  files:
76
- - ".gitignore"
77
117
  - CHANGELOG.md
78
- - Gemfile
79
118
  - LICENSE.txt
80
119
  - README.md
81
- - Rakefile
82
- - hypershield.gemspec
83
120
  - lib/hypershield.rb
121
+ - lib/hypershield/engine.rb
84
122
  - lib/hypershield/migration.rb
85
- - lib/hypershield/railtie.rb
86
123
  - lib/hypershield/version.rb
124
+ - lib/tasks/hypershield.rake
87
125
  homepage: https://github.com/ankane/hypershield
88
126
  licenses:
89
127
  - MIT
@@ -96,15 +134,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
96
134
  requirements:
97
135
  - - ">="
98
136
  - !ruby/object:Gem::Version
99
- version: '0'
137
+ version: '2.4'
100
138
  required_rubygems_version: !ruby/object:Gem::Requirement
101
139
  requirements:
102
140
  - - ">="
103
141
  - !ruby/object:Gem::Version
104
142
  version: '0'
105
143
  requirements: []
106
- rubyforge_project:
107
- rubygems_version: 2.7.6
144
+ rubygems_version: 3.0.3
108
145
  signing_key:
109
146
  specification_version: 4
110
147
  summary: Shield sensitive data in Postgres and MySQL
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- Gemfile.lock
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in hypershield.gemspec
6
- gemspec
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
8
- end
9
-
10
- task default: :test
@@ -1,28 +0,0 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "hypershield/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "hypershield"
8
- spec.version = Hypershield::VERSION
9
- spec.authors = ["Andrew Kane"]
10
- spec.email = ["andrew@chartkick.com"]
11
-
12
- spec.summary = "Shield sensitive data in Postgres and MySQL"
13
- spec.homepage = "https://github.com/ankane/hypershield"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
- f.match(%r{^(test|spec|features)/})
18
- end
19
- spec.bindir = "exe"
20
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
- spec.require_paths = ["lib"]
22
-
23
- spec.add_dependency "activerecord"
24
-
25
- spec.add_development_dependency "bundler"
26
- spec.add_development_dependency "minitest"
27
- spec.add_development_dependency "rake"
28
- end
@@ -1,21 +0,0 @@
1
- module Hypershield
2
- class Railtie < Rails::Railtie
3
- rake_tasks do
4
- namespace :hypershield do
5
- task refresh: :environment do
6
- $stderr.puts "[hypershield] Refreshing schemas"
7
- Hypershield.refresh
8
- $stderr.puts "[hypershield] Success!"
9
- end
10
- end
11
-
12
- Rake::Task["db:migrate"].enhance do
13
- Rake::Task["hypershield:refresh"].invoke
14
- end
15
-
16
- Rake::Task["db:rollback"].enhance do
17
- Rake::Task["hypershield:refresh"].invoke
18
- end
19
- end
20
- end
21
- end