sanctum 0.8.5.rc5 → 0.8.6.rc1

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: dff385a40c33fc32dc3c5b57c28c1c8493cf9e01dc6e79cfbfee08269a3bd072
4
- data.tar.gz: ebdd7ba3f3a1020357301d281e4dc474195d8b765a25885f96e10e7a7e6b3573
3
+ metadata.gz: b898d2e916e8ec1febdcaaa482017484aa1d2c0d7bb407cd0f1e93fb58615622
4
+ data.tar.gz: 5f34552ae0916fdce2b8903e0548e3656a60e9f950b1e5a656a9f54d500f78f4
5
5
  SHA512:
6
- metadata.gz: 23d19761e85666eb94b7c7e25a7957be59ba422f2967a930000b1171ae1280e0417b3ad767fc35e0c5c1a19cb61962c752c06d3ae381a1b54c2ef6e8c4cf9949
7
- data.tar.gz: 8563efa095ac2a186572adcd14f999db22070e91803cc6ad89d67c29c009e4f8c6c005675b9f796744dbb76633381ad5df05cc8050366aa32e5e503aa860acb2
6
+ metadata.gz: d72a9696fc57f35c6eb1da437069ba9eb369aec6ce871095296bdd09b753528ac8eeb5ed3023a52f3ae3826df81a5dd70dda8e19a07bdbf860ebd3fd761de895
7
+ data.tar.gz: c63d24c16472a5170a54f3da4fa2ba5caf472f5cc5b25bbe3ce2d3bd8c41e087ff8efbc640289b45decdbaf74a7e32e30bbdfa5c8344fc33f4b79054808991cf
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sanctum (0.8.5.rc5)
4
+ sanctum (0.8.6.rc1)
5
5
  gli (~> 2.18)
6
6
  hashdiff (~> 0.3)
7
+ tty-editor (~> 0.5)
7
8
  vault (~> 0.12)
8
9
 
9
10
  GEM
@@ -13,13 +14,18 @@ GEM
13
14
  aws-sigv4 (1.0.3)
14
15
  coderay (1.1.2)
15
16
  diff-lcs (1.3)
17
+ equatable (0.5.0)
16
18
  gli (2.18.0)
17
19
  hashdiff (0.3.8)
18
20
  jaro_winkler (1.5.2)
19
21
  method_source (0.9.2)
22
+ necromancer (0.4.0)
20
23
  parallel (1.14.0)
21
24
  parser (2.6.0.0)
22
25
  ast (~> 2.4.0)
26
+ pastel (0.7.2)
27
+ equatable (~> 0.5.0)
28
+ tty-color (~> 0.4.0)
23
29
  powerpack (0.1.2)
24
30
  pry (0.12.2)
25
31
  coderay (~> 1.1.0)
@@ -52,9 +58,28 @@ GEM
52
58
  rubocop-rspec (1.32.0)
53
59
  rubocop (>= 0.60.0)
54
60
  ruby-progressbar (1.10.0)
61
+ timers (4.3.0)
62
+ tty-color (0.4.3)
63
+ tty-cursor (0.6.1)
64
+ tty-editor (0.5.0)
65
+ tty-prompt (~> 0.18)
66
+ tty-which (~> 0.4)
67
+ tty-prompt (0.18.1)
68
+ necromancer (~> 0.4.0)
69
+ pastel (~> 0.7.0)
70
+ timers (~> 4.0)
71
+ tty-cursor (~> 0.6.0)
72
+ tty-reader (~> 0.5.0)
73
+ tty-reader (0.5.0)
74
+ tty-cursor (~> 0.6.0)
75
+ tty-screen (~> 0.6.4)
76
+ wisper (~> 2.0.0)
77
+ tty-screen (0.6.5)
78
+ tty-which (0.4.0)
55
79
  unicode-display_width (1.4.1)
56
80
  vault (0.12.0)
57
81
  aws-sigv4
82
+ wisper (2.0.0)
58
83
 
59
84
  PLATFORMS
60
85
  ruby
@@ -41,6 +41,9 @@ module Sanctum
41
41
  default_transit_key = options.fetch(:sanctum).fetch(:transit_key, nil)
42
42
  default_secrets_version = options.fetch(:sanctum).fetch(:secrets_version)
43
43
 
44
+ # TODO: make this better
45
+ # remove_trailing_slash needs to run first, as some of the other logic in other methods
46
+ # rely on it
44
47
  targets = remove_trailing_slash(targets)
45
48
  targets = set_secrets_version(targets, default_secrets_version)
46
49
  targets = set_transit_key(targets, default_transit_key)
@@ -63,13 +66,16 @@ module Sanctum
63
66
 
64
67
  if default_secrets_version == "auto"
65
68
  mounts_hash = mounts_info
69
+ # Use the root path to determine secrets_version
70
+ prefix = "#{h[:prefix].lines('/').first}"
71
+ prefix = prefix.include?("/") ? prefix.to_sym : "#{prefix}/".to_sym
66
72
 
67
73
  # If mount options is nil default to api version 1 otherwise use version value
68
74
  # generic mounts will not have a version specified
69
- if mounts_hash.dig(:data, :secret, "#{h[:prefix]}/".to_sym, :options).nil?
75
+ if mounts_hash.dig(:data, :secret, prefix, :options).nil?
70
76
  h[:secrets_version] = "1"
71
77
  else
72
- h[:secrets_version] = mounts_hash.dig(:data, :secret, "#{h[:prefix]}/".to_sym, :options, :version).to_s
78
+ h[:secrets_version] = mounts_hash.dig(:data, :secret, prefix, :options, :version).to_s
73
79
  end
74
80
  else
75
81
  h[:secrets_version] = default_secrets_version
@@ -103,7 +109,14 @@ module Sanctum
103
109
  targets.each do |h|
104
110
  next unless h[:secrets_version] == "2"
105
111
 
106
- h[:prefix] = h[:prefix].include?("/data") ? h[:prefix] : "#{h[:prefix]}/data"
112
+ # Super gross..., split path into an array
113
+ path_array = h[:prefix].lines("/")
114
+ # Add `data/` to the right place in the path if it's not already there
115
+ if path_array.count == 1
116
+ h[:prefix] = path_array.insert(1, "/data").join
117
+ else
118
+ h[:prefix] = path_array.include?("data/") ? path_array.join : path_array.insert(1, "data/").join
119
+ end
107
120
  end
108
121
  end
109
122
 
@@ -111,6 +124,7 @@ module Sanctum
111
124
  targets.each do |h|
112
125
  h[:prefix] = h[:prefix].chomp("/")
113
126
  h[:path] = h[:path].chomp("/")
127
+ h[:transit_key] = h[:transit_key].chomp("/") if h.key?(:transit_key)
114
128
  end
115
129
  end
116
130
 
@@ -30,12 +30,7 @@ module Sanctum
30
30
  if block_given?
31
31
  yield tmp_file
32
32
  else
33
- editor = ENV.fetch('EDITOR', 'vi')
34
- #This should help in the case where people are using macvim, atom, etc
35
- command = Thread.new do
36
- raise red("Error with editor") unless system(editor, tmp_file.path)
37
- end
38
- command.join
33
+ TTY::Editor.open(tmp_file.path)
39
34
  end
40
35
 
41
36
  contents = File.read(tmp_file.path)
@@ -12,6 +12,8 @@ module Sanctum
12
12
  puts green("#{diff[0].to_s + diff[1].join(" => ").to_s} => #{diff[2]}")
13
13
  else
14
14
  puts red("#{diff[0].to_s + diff[1].join(" => ").to_s} => #{diff[2]}")
15
+ # If a secret is changed, we should show the change
16
+ puts green("+#{diff[1].join(" => ").to_s} => #{diff[3]}") if diff.fetch(3, false)
15
17
  end
16
18
  end
17
19
  differences
@@ -33,12 +33,7 @@ module Sanctum
33
33
  yield tmp_file
34
34
  else
35
35
  previous_contents = File.read(tmp_file.path)
36
- editor = ENV.fetch('EDITOR', 'vi')
37
- #This should help in the case where people are using macvim, atom, etc
38
- command = Thread.new do
39
- raise red("Error with editor") unless system(editor, tmp_file.path )
40
- end
41
- command.join
36
+ TTY::Editor.open(tmp_file.path)
42
37
  end
43
38
  contents = File.read(tmp_file.path)
44
39
 
@@ -1,6 +1,7 @@
1
+ require 'json'
1
2
  require 'securerandom'
3
+ require 'tty-editor'
2
4
  require 'yaml'
3
- require 'json'
4
5
 
5
6
  module Sanctum
6
7
  module Command
@@ -5,6 +5,7 @@ module Sanctum
5
5
  class Pull < Base
6
6
 
7
7
  def run
8
+ puts yellow("Running `pull` for the following targets: \n#{targets.map{ |h| h.dig(:name)}.to_yaml.gsub("---\n", '')}")
8
9
  targets.each do |target|
9
10
  # Use command line if force: true
10
11
  if options[:cli][:force]
@@ -6,6 +6,7 @@ module Sanctum
6
6
  class Push < Base
7
7
 
8
8
  def run
9
+ puts yellow("Running `push` for the following targets: \n#{targets.map{ |h| h.dig(:name)}.to_yaml.gsub("---\n", '')}")
9
10
  targets.each do |target|
10
11
  # Use command line if force: true
11
12
  if options[:cli][:force]
@@ -1,3 +1,3 @@
1
1
  module Sanctum
2
- VERSION = "0.8.5.rc5"
2
+ VERSION = "0.8.6.rc1"
3
3
  end
@@ -17,15 +17,17 @@ Gem::Specification.new do |spec|
17
17
  spec.required_ruby_version = '>=2.5.0'
18
18
 
19
19
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
20
- f.match(%r{^(test|spec|features)/})
20
+ exclude = [%r{^(test|spec|features|examples)/}, %r{docker.*}i, %r{\.gitlab-ci.yml}]
21
+ f.match(Regexp.union(exclude))
21
22
  end
22
23
  spec.bindir = "bin"
23
24
  spec.executables = "sanctum"
24
25
  spec.require_paths = ["lib"]
25
26
 
26
- spec.add_dependency 'vault', '~> 0.12'
27
- spec.add_dependency 'hashdiff', '~> 0.3'
28
27
  spec.add_dependency 'gli', '~> 2.18'
28
+ spec.add_dependency 'hashdiff', '~> 0.3'
29
+ spec.add_dependency 'tty-editor', '~> 0.5'
30
+ spec.add_dependency 'vault', '~> 0.12'
29
31
 
30
32
  spec.add_development_dependency 'bundler', '~> 1.0'
31
33
  spec.add_development_dependency 'pry', '~> 0.12.0'
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sanctum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5.rc5
4
+ version: 0.8.6.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corban Raun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-06 00:00:00.000000000 Z
11
+ date: 2019-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: vault
14
+ name: gli
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.12'
19
+ version: '2.18'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.12'
26
+ version: '2.18'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: hashdiff
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -39,19 +39,33 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.3'
41
41
  - !ruby/object:Gem::Dependency
42
- name: gli
42
+ name: tty-editor
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.18'
47
+ version: '0.5'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.18'
54
+ version: '0.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: vault
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.12'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.12'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -145,10 +159,8 @@ extensions: []
145
159
  extra_rdoc_files: []
146
160
  files:
147
161
  - ".gitignore"
148
- - ".gitlab-ci.yml"
149
162
  - ".rspec"
150
163
  - ".rubocop.yml"
151
- - Dockerfile
152
164
  - Gemfile
153
165
  - Gemfile.lock
154
166
  - LICENSE.txt
@@ -157,11 +169,6 @@ files:
157
169
  - bin/console
158
170
  - bin/sanctum
159
171
  - bin/setup
160
- - docker-compose.override.yml_sample
161
- - docker-compose.test.yml
162
- - docker-compose.yml
163
- - examples/single_target/example_policy.hcl
164
- - examples/single_target/sanctum.yaml
165
172
  - lib/sanctum.rb
166
173
  - lib/sanctum/cli.rb
167
174
  - lib/sanctum/colorize_string.rb
@@ -1,22 +0,0 @@
1
- ---
2
- image:
3
- name: docker/compose:1.23.2
4
- entrypoint: ["/bin/sh", "-c"]
5
-
6
- variables:
7
- COMPOSE_FILE: 'docker-compose.test.yml'
8
-
9
- stages:
10
- - test
11
-
12
- before_script:
13
- - docker version
14
- - docker info
15
- - docker-compose version
16
-
17
- testing:
18
- stage: test
19
- script:
20
- - docker-compose build
21
- - docker-compose run -T --rm sanctum ls -lart -hu
22
- - docker-compose run -T --rm sanctum bundle exec rspec
data/Dockerfile DELETED
@@ -1,31 +0,0 @@
1
- FROM ruby:2.5-alpine
2
-
3
- USER root
4
-
5
- ENV VERSION 1.0.3
6
- ADD https://releases.hashicorp.com/vault/${VERSION}/vault_${VERSION}_linux_amd64.zip /tmp/
7
- ADD https://releases.hashicorp.com/vault/${VERSION}/vault_${VERSION}_SHA256SUMS /tmp/
8
- ADD https://releases.hashicorp.com/vault/${VERSION}/vault_${VERSION}_SHA256SUMS.sig /tmp/
9
-
10
- # Install additional dependencies
11
- # As well as nice to haves locally
12
- RUN apk --no-cache add git vim busybox-extras curl gnupg build-base \
13
- && until gpg --keyserver hkp://p80.pool.sks-keyservers.net --recv-key 0x348FFC4C; do echo "Retry"; sleep 30; done \
14
- && gpg --verify /tmp/vault_${VERSION}_SHA256SUMS.sig \
15
- && cat /tmp/vault_${VERSION}_SHA256SUMS | grep linux_amd64 | sha256sum /tmp/vault_${VERSION}_linux_amd64.zip \
16
- && unzip /tmp/vault_${VERSION}_linux_amd64.zip \
17
- && mv vault /usr/local/bin/ \
18
- && rm -rf /tmp/*
19
-
20
- # Setup up app directory
21
- ENV APP_HOME /usr/src/app/
22
- WORKDIR $APP_HOME
23
-
24
- # Add app code
25
- COPY . $APP_HOME
26
-
27
- # Install gems
28
- RUN bundle install --jobs=8
29
-
30
- # Install sanctum gem
31
- RUN bundle exec rake install
@@ -1,11 +0,0 @@
1
- ---
2
- version: '3.4'
3
-
4
- services:
5
- sanctum:
6
- environment:
7
- GEM_HOST_API_KEY:
8
- GIT_AUTHOR_NAME:
9
- GIT_AUTHOR_EMAIL:
10
- GIT_COMMITTER_NAME:
11
- GIT_COMMITTER_EMAIL:
@@ -1,17 +0,0 @@
1
- ---
2
- version: '3.4'
3
-
4
- services:
5
- sanctum:
6
- build:
7
- context: "."
8
- command: /bin/true
9
- depends_on:
10
- - vault
11
- vault:
12
- image: vault:1.0.3
13
- environment:
14
- SKIP_SETCAP: "true"
15
- VAULT_DEV_ROOT_TOKEN_ID: "514c55f0-c452-99e3-55e0-8301b770b92c"
16
- VAULT_DEV_LISTEN_ADDRESS: "0.0.0.0:8200"
17
- command: ["vault", "server", "-dev"]
@@ -1,19 +0,0 @@
1
- ---
2
- version: '3.4'
3
-
4
- services:
5
- sanctum:
6
- build:
7
- context: "."
8
- command: /bin/true
9
- depends_on:
10
- - vault
11
- volumes:
12
- - ".:/usr/src/app"
13
- vault:
14
- image: vault:1.0.3
15
- environment:
16
- SKIP_SETCAP: "true"
17
- VAULT_DEV_ROOT_TOKEN_ID: "514c55f0-c452-99e3-55e0-8301b770b92c"
18
- VAULT_DEV_LISTEN_ADDRESS: "0.0.0.0:8200"
19
- command: ["vault", "server", "-dev"]
@@ -1,54 +0,0 @@
1
- # Helpful documentation can be found
2
- # https://www.vaultproject.io/guides/identity/policies
3
- # https://www.vaultproject.io/docs/concepts/policies.html
4
- # https://learn.hashicorp.com/vault/getting-started/policies
5
- #
6
- # You can make permissions more granular or limited by specifying deeper paths
7
- # Example: `path "sanctum-test/data/dev/*"`, etc.
8
- #
9
- ################# Read/Write v2 api example #################################################
10
- path "sanctum-test/data/*" { capabilities = ["list","read","create","update","delete"] }
11
- path "sanctum-test/metadata/*" { capabilities = ["list","read","create","update","delete"] }
12
- path "sanctum-test/destroy/*" { capabilities = ["update"] }
13
- path "sanctum-test/delete/*" { capabilities = ["update"] }
14
- path "sanctum-test/undelete/*" { capabilities = ["update"] }
15
- #############################################################################################
16
-
17
- ################# Read/Write v1/generic example ###################################
18
- path "sanctum-test/*" { capabilities = ["list","read","create","update","delete"] }
19
- ###################################################################################
20
-
21
- ################## Additional sys/ and sys/mount permissions ############################################
22
- # Grant access to tune existing mount
23
- # Required to upgrade from v1/generic to v2
24
- path "sys/mounts/sanctum-test/tune" { capabilities = ["read", "update"] }
25
- # Grant broader permission to specific mount
26
- path "sys/mounts/sanctum-test" { capabilities = ["create", "read", "update", "delete", "list", "sudo"] }
27
- # Read health checks
28
- path "sys/health" { capabilities = ["read", "sudo"] }
29
- # View capabilities of token
30
- path "sys/capabilities" { capabilities = ["create", "update"] }
31
- # View capabilities of token
32
- path "sys/capabilities-self" { capabilities = ["create", "update"] }
33
- # View mount info for mounts that you have permissions on
34
- path "sys/internal/ui/mounts" { capabilities = ["read"] }
35
- #########################################################################################################
36
-
37
- ################### Transit permissions###########################################################
38
- # General permission on key
39
- path "transit/keys/sanctum-test" { capabilities = ["list","read","create","update", "delete"] }
40
- # Permission to rotate keys
41
- path "transit/keys/sanctum-test/rotate" { capabilities = ["list","read","create","update"] }
42
- # Permission to modify transit key config
43
- path "transit/keys/sanctum-test/config" { capabilities = ["list","read","create","update"] }
44
- # Permission to backup key
45
- #path "transit/backup/sanctum-test" { capabilities = ["list","read"] }
46
- # Permission to restore key
47
- #path "transit/restore/sanctum-test" { capabilities = ["list","read","create","update"] }
48
- # Transit encryption endpoint
49
- path "transit/encrypt/sanctum-test" { capabilities = ["list","read","create","update"] }
50
- # Transit decrypt endpoint
51
- path "transit/decrypt/sanctum-test" { capabilities = ["list","read","create","update"] }
52
- # Transit rewrap permissions
53
- path "transit/rewrap/sanctum-test" { capabilities = ["list","read","create","update"] }
54
- ##################################################################################################