grantinee 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/README.md +1 -1
- data/lib/grantinee/engine.rb +1 -1
- data/lib/grantinee/engine/abstract_engine.rb +1 -1
- data/lib/grantinee/engine/mysql.rb +3 -2
- data/lib/grantinee/engine/postgresql.rb +2 -1
- data/lib/grantinee/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18bcce1973995afd674f4a71ac00e99faf7dfcfee9919bd7fdde72daa2e90adf
|
4
|
+
data.tar.gz: 43fea39c39305f2f413b36f15eb3e6ed23efc6f19eda2d39c23fe445e8d0cb5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 195731cbacfda40abc4e1b7aeb7b9f77c2ad51cca4b9718d93d8cc443b34628694ef2ab1f395dcab9a9778c8dbd1b9f8f00003d88e00e88e247e52bda0f1f40b
|
7
|
+
data.tar.gz: 4c562d81ad86fbb16ae5968c94c07bc50b48399a171b04e2fe58d5ba26d8e405b30d52ecd519f4e0f6dff118b2d41f9ba72cb8064eda4e029ee19e25486aba9f
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -126,4 +126,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
126
126
|
|
127
127
|
## Code of Conduct
|
128
128
|
|
129
|
-
Everyone interacting in the Grantinee project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
129
|
+
Everyone interacting in the Grantinee project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/blinkist/grantinee/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/grantinee/engine.rb
CHANGED
@@ -4,7 +4,7 @@ module Grantinee
|
|
4
4
|
module Engine
|
5
5
|
SUPPORTED_ENGINES = %w[mysql postgresql].freeze
|
6
6
|
|
7
|
-
WHITELISTED_KINDS = %w[all usage select update insert].freeze
|
7
|
+
WHITELISTED_KINDS = %w[all usage select update insert delete execute].freeze
|
8
8
|
|
9
9
|
class << self
|
10
10
|
# Get appropriate engine class for the engine name
|
@@ -33,7 +33,7 @@ module Grantinee
|
|
33
33
|
run! query, data
|
34
34
|
end
|
35
35
|
|
36
|
-
def grant_permission!(data)
|
36
|
+
def grant_permission!(data)
|
37
37
|
raise "Invalid permission kind" unless WHITELISTED_KINDS.include?(data[:kind]&.downcase)
|
38
38
|
|
39
39
|
database = sanitize_column_name(data[:database])
|
@@ -42,9 +42,10 @@ module Grantinee
|
|
42
42
|
user = sanitize_value(data[:user])
|
43
43
|
host = sanitize_value(data[:host])
|
44
44
|
fields = data[:fields].map { |v| sanitize_column_name(v.to_s) }.join(', ')
|
45
|
+
helper = (kind == "EXECUTE" ? " PROCEDURE " : "")
|
45
46
|
|
46
47
|
query = if data[:fields].empty?
|
47
|
-
"GRANT #{kind} ON #{database}.#{table} TO '#{user}'@'#{host}';"
|
48
|
+
"GRANT #{kind} ON #{helper}#{database}.#{table} TO '#{user}'@'#{host}';"
|
48
49
|
else
|
49
50
|
"GRANT #{kind}(#{fields}) ON #{database}.#{table} TO '#{user}'@'#{host}';"
|
50
51
|
end
|
@@ -37,9 +37,10 @@ module Grantinee
|
|
37
37
|
table = sanitize_table_name(data[:table])
|
38
38
|
user = sanitize_column_name(data[:user])
|
39
39
|
fields = data[:fields].map { |v| sanitize_column_name(v.to_s) }.join(', ')
|
40
|
+
helper = (kind == "EXECUTE" ? " FUNCTION " : "")
|
40
41
|
|
41
42
|
query = if data[:fields].empty?
|
42
|
-
"GRANT #{kind} ON #{table} TO #{user};"
|
43
|
+
"GRANT #{kind} ON #{helper}#{table} TO #{user};"
|
43
44
|
else
|
44
45
|
"GRANT #{kind}(#{fields}) ON TABLE #{table} TO #{user};"
|
45
46
|
end
|
data/lib/grantinee/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grantinee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paweł Komarnicki
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-06-
|
12
|
+
date: 2018-06-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|