conjur-asset-dsl2 0.4.2 → 0.4.3
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 +4 -4
- data/CHANGELOG +10 -5
- data/lib/conjur/command/dsl2.rb +0 -10
- data/lib/conjur/dsl2/executor/base.rb +2 -0
- data/lib/conjur/dsl2/logger.rb +12 -0
- data/lib/conjur/dsl2/planner/base.rb +11 -15
- data/lib/conjur/dsl2/planner/grants.rb +0 -1
- data/lib/conjur/dsl2/planner/permissions.rb +1 -1
- data/lib/conjur/dsl2/planner/record.rb +5 -2
- data/lib/conjur/dsl2/planner.rb +5 -2
- data/lib/conjur/dsl2/types/permit.rb +1 -1
- data/lib/conjur/dsl2/yaml/handler.rb +2 -8
- data/lib/conjur/dsl2/yaml/loader.rb +1 -1
- data/lib/conjur-asset-dsl2-version.rb +1 -1
- data/lib/conjur-asset-dsl2.rb +6 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 964f33500185235bd65a6b64faefc618ccb71994
|
4
|
+
data.tar.gz: ee1a68a365e3bc9ea036e873bacf7da1ad31844f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0e879f8446c5d68520b1e38ec75f73cc0596949a475fdba8081705ed11f303f08522790e6bd2bac09b98add69ee5dd15b0d260a394503b19e6611f21058d9ee
|
7
|
+
data.tar.gz: bc5511cb4931c99a23bf1e15f8d9e7e22e272e68b116464854aceb31e65e6ae5f72dad44434a71ad88035759b102fd1091570cb5a7b7f903f483c52c93f3a6b8
|
data/CHANGELOG
CHANGED
@@ -1,14 +1,19 @@
|
|
1
|
-
# 0.4.
|
1
|
+
# 0.4.3
|
2
2
|
|
3
|
-
|
3
|
+
* Fix a load error which can occur when using YAML lists inside of policies
|
4
|
+
|
5
|
+
# 0.4.2
|
6
|
+
|
7
|
+
* Support `--context` flag to save API keys to a file.
|
4
8
|
|
5
9
|
# 0.3.2
|
6
10
|
|
7
|
-
|
11
|
+
* Fix issue where webservices were being treated as core assets by the executor.
|
8
12
|
|
9
13
|
# 0.3.1
|
10
14
|
|
11
|
-
|
15
|
+
* Fix bug in executor for permissions
|
12
16
|
|
13
17
|
# 0.3.0
|
14
|
-
|
18
|
+
|
19
|
+
* Initial stable version
|
data/lib/conjur/command/dsl2.rb
CHANGED
@@ -131,16 +131,6 @@ command. Therefore, a policy can be loaded in three steps, if desired:
|
|
131
131
|
DESC
|
132
132
|
policy.arg_name "(policy-file | STDIN)"
|
133
133
|
policy.command :load do |c|
|
134
|
-
|
135
|
-
# Undefine options which are declared in the base (default) implementation.
|
136
|
-
# TODO: This code can be removed if and when dsl2 becomes the default.
|
137
|
-
%w(as-group as-role collection context c).each do |switch|
|
138
|
-
c.switches.delete switch.to_sym
|
139
|
-
c.flags.delete switch.to_sym
|
140
|
-
c.switches_declaration_order.delete_if{|s| s.name == switch.to_sym}
|
141
|
-
c.flags_declaration_order.delete_if{|s| s.name == switch.to_sym}
|
142
|
-
end
|
143
|
-
|
144
134
|
acting_as_option(c)
|
145
135
|
|
146
136
|
c.desc "Policy namespace (optional)"
|
@@ -4,6 +4,8 @@ module Conjur::DSL2
|
|
4
4
|
# is an object from Conjur::DSL2::Types. Each execution action is
|
5
5
|
# an HTTP method, a request path, and request parameters.
|
6
6
|
class Base
|
7
|
+
include Conjur::DSL2::Logger
|
8
|
+
|
7
9
|
attr_reader :statement, :actions, :default_account
|
8
10
|
|
9
11
|
def initialize statement, actions, default_account
|
@@ -2,11 +2,11 @@ module Conjur
|
|
2
2
|
module DSL2
|
3
3
|
module Planner
|
4
4
|
class Base
|
5
|
+
include Conjur::DSL2::Logger
|
5
6
|
|
6
7
|
attr_reader :record, :api
|
7
8
|
attr_accessor :plan
|
8
9
|
|
9
|
-
|
10
10
|
def initialize record, api
|
11
11
|
@record = record
|
12
12
|
@api = api
|
@@ -80,7 +80,7 @@ module Conjur
|
|
80
80
|
# Sort in canonical order -- basically, a `Record` or `Create` comes before everything
|
81
81
|
# else. So the base class's sort just places those before us, and anything else gets 0.
|
82
82
|
def <=> other
|
83
|
-
other.kind_of?(Conjur::DSL2::Planner::ActsAsRecord) ? 1 : 0
|
83
|
+
(other.kind_of?(Conjur::DSL2::Planner::ActsAsRecord) or other.kind_of?(Conjur::DSL2::Planner::Array)) ? 1 : 0
|
84
84
|
end
|
85
85
|
|
86
86
|
def resource_exists? resource
|
@@ -101,21 +101,12 @@ module Conjur
|
|
101
101
|
raise message
|
102
102
|
end
|
103
103
|
|
104
|
-
def
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
end
|
109
|
-
|
110
|
-
def trace_enabled?
|
111
|
-
ENV["DSL_PLANNER_TRACE"] || !!@trace_enabled
|
112
|
-
end
|
113
|
-
|
114
|
-
def trace_enabled= enabled
|
115
|
-
@trace_enabled = enabled
|
104
|
+
def log &block
|
105
|
+
logger.debug('conjur/dsl2/planner') {
|
106
|
+
yield
|
107
|
+
}
|
116
108
|
end
|
117
109
|
|
118
|
-
|
119
110
|
def update_record
|
120
111
|
update = Conjur::DSL2::Types::Update.new
|
121
112
|
update.record = record
|
@@ -198,8 +189,13 @@ module Conjur
|
|
198
189
|
end
|
199
190
|
|
200
191
|
class Array < Base
|
192
|
+
# Array sorts before everything because sanity.
|
193
|
+
def <=> other
|
194
|
+
-1
|
195
|
+
end
|
201
196
|
|
202
197
|
def do_plan
|
198
|
+
|
203
199
|
planners = record.map do |item|
|
204
200
|
Planner.planner_for(item, api)
|
205
201
|
end.sort
|
@@ -10,7 +10,6 @@ module Conjur
|
|
10
10
|
# be granted every role. If the +replace+ option is set, then any existing
|
11
11
|
# grant on a role that is *not* given should be revoked, except for role admins.
|
12
12
|
def do_plan
|
13
|
-
|
14
13
|
roles = Array(record.roles)
|
15
14
|
members = Array(record.members)
|
16
15
|
given_grants = Hash.new { |hash, key| hash[key] = [] }
|
@@ -51,7 +51,7 @@ module Conjur
|
|
51
51
|
(Set.new(requested) - Set.new(given)).each do |p|
|
52
52
|
role, admin = p
|
53
53
|
|
54
|
-
error("role not found
|
54
|
+
error(%Q(Role "#{role}" not found")) unless role_exists?(role)
|
55
55
|
|
56
56
|
permit = Conjur::DSL2::Types::Permit.new
|
57
57
|
permit.resource = resource_record target
|
@@ -72,7 +72,10 @@ module Conjur
|
|
72
72
|
Planner.planner_for(record, api)
|
73
73
|
end.sort
|
74
74
|
|
75
|
+
log{ "Planing policy with body #{planners.map{|p| p.class.name}}" }
|
76
|
+
|
75
77
|
planners.each do |planner|
|
78
|
+
planner.log{ "Planning #{planner}"}
|
76
79
|
ownerid = plan.ownerid
|
77
80
|
begin
|
78
81
|
plan.policy = self.record
|
@@ -87,9 +90,9 @@ module Conjur
|
|
87
90
|
plan.ownerid = ownerid
|
88
91
|
|
89
92
|
planner.plan = plan
|
90
|
-
planner.
|
93
|
+
planner.log { "Planning policy record #{record}" }
|
91
94
|
planner.do_plan
|
92
|
-
planner.
|
95
|
+
planner.log { "Done" }
|
93
96
|
ensure
|
94
97
|
plan.policy = nil
|
95
98
|
plan.ownerid = ownerid
|
data/lib/conjur/dsl2/planner.rb
CHANGED
@@ -10,13 +10,16 @@ module Conjur
|
|
10
10
|
def plan records, api, options = {}
|
11
11
|
namespace = options[:namespace]
|
12
12
|
ownerid = options[:ownerid]
|
13
|
-
Plan.new
|
13
|
+
plan = options[:plan] || Plan.new
|
14
|
+
plan.tap do |plan|
|
14
15
|
plan.namespace = namespace if namespace
|
15
16
|
plan.ownerid = ownerid if ownerid
|
16
|
-
records.map{ |record| planner_for(record, api) }.sort.each do |planner|
|
17
|
+
Array(records).map{ |record| planner_for(record, api) }.sort.each do |planner|
|
17
18
|
planner.plan = plan
|
19
|
+
planner.log { %Q(Planning "#{planner.record} using #{planner.class}") }
|
18
20
|
begin
|
19
21
|
planner.do_plan
|
22
|
+
planner.log { "\tFinished \"#{planner.record}\"" }
|
20
23
|
ensure
|
21
24
|
planner.plan = nil
|
22
25
|
end
|
@@ -14,7 +14,7 @@ module Conjur
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def to_s
|
17
|
-
"Permit #{role.role} to
|
17
|
+
"Permit #{role.role} to [#{Array(privilege).join(', ')}] on #{Array(resource).join(', ')}#{role.admin ? ' with grant option' : ''}"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -2,16 +2,10 @@ module Conjur
|
|
2
2
|
module DSL2
|
3
3
|
module YAML
|
4
4
|
class Handler < Psych::Handler
|
5
|
+
include Conjur::DSL2::Logger
|
6
|
+
|
5
7
|
attr_accessor :parser, :filename, :result
|
6
8
|
|
7
|
-
# Override the logger with this method.
|
8
|
-
cattr_accessor :logger
|
9
|
-
|
10
|
-
require 'logger'
|
11
|
-
|
12
|
-
self.logger = Logger.new(STDERR)
|
13
|
-
self.logger.level = Logger::INFO
|
14
|
-
|
15
9
|
# An abstract Base handler. The handler will receive each document message within
|
16
10
|
# its particular context (sequence, mapping, etc).
|
17
11
|
#
|
data/lib/conjur-asset-dsl2.rb
CHANGED
@@ -6,7 +6,13 @@ require 'active_support/core_ext'
|
|
6
6
|
SafeYAML::OPTIONS[:default_mode] = :safe
|
7
7
|
SafeYAML::OPTIONS[:deserialize_symbols] = false
|
8
8
|
|
9
|
+
module Conjur
|
10
|
+
module DSL2
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
9
14
|
require 'rest-client'
|
15
|
+
require 'conjur/dsl2/logger'
|
10
16
|
require 'conjur/dsl2/invalid'
|
11
17
|
require 'conjur/dsl2/types/base'
|
12
18
|
require 'conjur/dsl2/types/records'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conjur-asset-dsl2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Gilpin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: safe_yaml
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- lib/conjur/dsl2/executor/revoke.rb
|
202
202
|
- lib/conjur/dsl2/executor/update.rb
|
203
203
|
- lib/conjur/dsl2/invalid.rb
|
204
|
+
- lib/conjur/dsl2/logger.rb
|
204
205
|
- lib/conjur/dsl2/plan.rb
|
205
206
|
- lib/conjur/dsl2/planner.rb
|
206
207
|
- lib/conjur/dsl2/planner/base.rb
|