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 +4 -4
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +1 -1
- data/README.md +12 -2
- data/lib/hypershield.rb +13 -8
- data/lib/hypershield/engine.rb +5 -0
- data/lib/hypershield/version.rb +1 -1
- data/lib/tasks/hypershield.rake +15 -0
- metadata +52 -15
- data/.gitignore +0 -9
- data/Gemfile +0 -6
- data/Rakefile +0 -10
- data/hypershield.gemspec +0 -28
- data/lib/hypershield/railtie.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1222f7f264c0a8892096edecd7b6cc71a79fb2f1a7c81f7f5be42ecc9c19291
|
4
|
+
data.tar.gz: e661dabb10c803a25a71effde3b70dab5ff26c7a4bfe470f2f8fdcba9a7fb4a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '078a50cf334a8b95d9355a2265f15f2633dacc16be8f560bbdec9dcae346d90ef308581dfe8d6fdc76e9b8975bc9f000dfd062e153a80277d3784a5c6bee6a99'
|
7
|
+
data.tar.gz: 3feac1364504a11be41725e84913d48fc418ab13fa8082feabf9091e38b658a208461519f9956f2a9728105aa89c5af9a7dd04872c45bd2b045bca2eaf790457
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
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.
|
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.
|
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
|
data/lib/hypershield.rb
CHANGED
@@ -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
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
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)
|
data/lib/hypershield/version.rb
CHANGED
@@ -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.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
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: '
|
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:
|
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: '
|
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
|
-
|
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
data/Gemfile
DELETED
data/Rakefile
DELETED
data/hypershield.gemspec
DELETED
@@ -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
|
data/lib/hypershield/railtie.rb
DELETED
@@ -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
|