politree 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +47 -0
- data/LICENSE.txt +21 -0
- data/README.md +122 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/politree +36 -0
- data/bin/setup +8 -0
- data/examples/default.hcl +72 -0
- data/examples/default.hcl.dot +187 -0
- data/examples/default.hcl.jpg +0 -0
- data/lib/politree/version.rb +3 -0
- data/lib/politree.rb +4 -0
- data/main.rb +44 -0
- data/politree.gemspec +41 -0
- data/tmp/.git-keep +0 -0
- metadata +154 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e0ad528d3eb963a735dab9a685cf74d38e93713dc63c0213d8a35e1f08664904
|
4
|
+
data.tar.gz: 943b0c06d14ca7031e6aeb785d4ded3e2dd63c91d87a7986998d9d7a7fb38917
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 21016eb63db1d35a8744e45499a224586865194f04af3742cf1cd0eb799b5e4a5113dbdc04d987800c3447f83b96c9ed90e8c6b058ddcf58cda6f478c0121b16
|
7
|
+
data.tar.gz: bb2e53482440af3f537027ce914040e39bdd4330f1eddb496b44caab3e1153a51e70133382442f8760436a138a43a999bd98368a08394a216d97ac26d3a3536e
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at chussenota@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
politree (0.4.0)
|
5
|
+
rgl (~> 0.5)
|
6
|
+
rhcl (~> 0.1)
|
7
|
+
thor (~> 0.20)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
deep_merge (1.2.1)
|
13
|
+
diff-lcs (1.3)
|
14
|
+
lazy_priority_queue (0.1.1)
|
15
|
+
rake (10.5.0)
|
16
|
+
rgl (0.5.3)
|
17
|
+
lazy_priority_queue (~> 0.1.0)
|
18
|
+
stream (~> 0.5.0)
|
19
|
+
rhcl (0.1.0)
|
20
|
+
deep_merge
|
21
|
+
rspec (3.7.0)
|
22
|
+
rspec-core (~> 3.7.0)
|
23
|
+
rspec-expectations (~> 3.7.0)
|
24
|
+
rspec-mocks (~> 3.7.0)
|
25
|
+
rspec-core (3.7.1)
|
26
|
+
rspec-support (~> 3.7.0)
|
27
|
+
rspec-expectations (3.7.0)
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
+
rspec-support (~> 3.7.0)
|
30
|
+
rspec-mocks (3.7.0)
|
31
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
+
rspec-support (~> 3.7.0)
|
33
|
+
rspec-support (3.7.1)
|
34
|
+
stream (0.5)
|
35
|
+
thor (0.20.0)
|
36
|
+
|
37
|
+
PLATFORMS
|
38
|
+
ruby
|
39
|
+
|
40
|
+
DEPENDENCIES
|
41
|
+
bundler (~> 1.16)
|
42
|
+
politree!
|
43
|
+
rake (~> 10.0)
|
44
|
+
rspec (~> 3.0)
|
45
|
+
|
46
|
+
BUNDLED WITH
|
47
|
+
1.16.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Clement Hussenot
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
# Politree
|
2
|
+
|
3
|
+
A Ruby gem to generate a tree view of your **HCL** Vault policies files.
|
4
|
+
|
5
|
+
> This project is really in an earlier development phase, please feel free to
|
6
|
+
> contribute, share or submit your ideas!
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'politree'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install politree
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
```
|
27
|
+
# Create a exemple file
|
28
|
+
$ cat > exemple.hcl << EOL
|
29
|
+
# Allow tokens to look up their own properties
|
30
|
+
path "auth/token/lookup-self" {
|
31
|
+
capabilities = ["read"]
|
32
|
+
}
|
33
|
+
|
34
|
+
# Allow tokens to renew themselves
|
35
|
+
path "auth/token/renew-self" {
|
36
|
+
capabilities = ["update"]
|
37
|
+
}
|
38
|
+
|
39
|
+
# Allow tokens to revoke themselves
|
40
|
+
path "auth/token/revoke-self" {
|
41
|
+
capabilities = ["update"]
|
42
|
+
}
|
43
|
+
|
44
|
+
# Allow a token to look up its own capabilities on a path
|
45
|
+
path "sys/capabilities-self" {
|
46
|
+
capabilities = ["update"]
|
47
|
+
}
|
48
|
+
|
49
|
+
# Allow a token to renew a lease via lease_id in the request body; old path for
|
50
|
+
# old clients, new path for newer
|
51
|
+
path "sys/renew" {
|
52
|
+
capabilities = ["update"]
|
53
|
+
}
|
54
|
+
path "sys/leases/renew" {
|
55
|
+
capabilities = ["update"]
|
56
|
+
}
|
57
|
+
|
58
|
+
# Allow looking up lease properties. This requires knowing the lease ID ahead
|
59
|
+
# of time and does not divulge any sensitive information.
|
60
|
+
path "sys/leases/lookup" {
|
61
|
+
capabilities = ["update"]
|
62
|
+
}
|
63
|
+
|
64
|
+
# Allow a token to manage its own cubbyhole
|
65
|
+
path "cubbyhole/*" {
|
66
|
+
capabilities = ["create", "read", "update", "delete", "list"]
|
67
|
+
}
|
68
|
+
|
69
|
+
# Allow a token to wrap arbitrary values in a response-wrapping token
|
70
|
+
path "sys/wrapping/wrap" {
|
71
|
+
capabilities = ["update"]
|
72
|
+
}
|
73
|
+
|
74
|
+
# Allow a token to look up the creation time and TTL of a given
|
75
|
+
# response-wrapping token
|
76
|
+
path "sys/wrapping/lookup" {
|
77
|
+
capabilities = ["update"]
|
78
|
+
}
|
79
|
+
|
80
|
+
# Allow a token to unwrap a response-wrapping token. This is a convenience to
|
81
|
+
# avoid client token swapping since this is also part of the response wrapping
|
82
|
+
# policy.
|
83
|
+
path "sys/wrapping/unwrap" {
|
84
|
+
capabilities = ["update"]
|
85
|
+
}
|
86
|
+
|
87
|
+
# Allow general purpose tools
|
88
|
+
path "sys/tools/hash" {
|
89
|
+
capabilities = ["update"]
|
90
|
+
}
|
91
|
+
path "sys/tools/hash/*" {
|
92
|
+
capabilities = ["update"]
|
93
|
+
}
|
94
|
+
path "sys/tools/random" {
|
95
|
+
capabilities = ["update"]
|
96
|
+
}
|
97
|
+
path "sys/tools/random/*" {
|
98
|
+
capabilities = ["update"]
|
99
|
+
}
|
100
|
+
EOL
|
101
|
+
|
102
|
+
# Run the generate command
|
103
|
+
$ politree generate example.hcl
|
104
|
+
```
|
105
|
+
|
106
|
+
## Development
|
107
|
+
|
108
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
109
|
+
|
110
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
111
|
+
|
112
|
+
## Contributing
|
113
|
+
|
114
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/anouvel/vault_tree_generator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
115
|
+
|
116
|
+
## License
|
117
|
+
|
118
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
119
|
+
|
120
|
+
## Code of Conduct
|
121
|
+
|
122
|
+
Everyone interacting in the Politree project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/anouvel/vault_tree_generator/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'politree'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/politree
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require 'rgl/adjacency'
|
5
|
+
require 'rgl/dot'
|
6
|
+
require 'rhcl'
|
7
|
+
|
8
|
+
module PoliTree
|
9
|
+
class CLI < Thor
|
10
|
+
desc 'generate FILE', 'This will generate a tree view'
|
11
|
+
long_desc <<-DESC
|
12
|
+
`generate FILE` will generate a tree view of your HCL vault policies.
|
13
|
+
https://github.com/anouvel/vault_tree_generator
|
14
|
+
DESC
|
15
|
+
option :filename
|
16
|
+
def generate(filename)
|
17
|
+
result = RGL::DirectedAdjacencyGraph.new
|
18
|
+
src_hcl = Rhcl.parse(open(filename).read)
|
19
|
+
for policy in src_hcl do
|
20
|
+
all_path = policy[1]
|
21
|
+
for path in all_path do
|
22
|
+
tmp_path = ''
|
23
|
+
s_path = path[0].split('/')
|
24
|
+
s_path.each_with_index do |_item, index|
|
25
|
+
tmp_path = tmp_path + '/' + s_path[index]
|
26
|
+
result.add_vertex tmp_path
|
27
|
+
result.add_edge tmp_path.rpartition('/')[0], tmp_path if index > 0
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
result.write_to_graphic_file(fmt = 'jpg', dotfile = filename)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
PoliTree::CLI.start(ARGV)
|
data/bin/setup
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
|
2
|
+
# Allow tokens to look up their own properties
|
3
|
+
path "auth/token/lookup-self" {
|
4
|
+
capabilities = ["read"]
|
5
|
+
}
|
6
|
+
|
7
|
+
# Allow tokens to renew themselves
|
8
|
+
path "auth/token/renew-self" {
|
9
|
+
capabilities = ["update"]
|
10
|
+
}
|
11
|
+
|
12
|
+
# Allow tokens to revoke themselves
|
13
|
+
path "auth/token/revoke-self" {
|
14
|
+
capabilities = ["update"]
|
15
|
+
}
|
16
|
+
|
17
|
+
# Allow a token to look up its own capabilities on a path
|
18
|
+
path "sys/capabilities-self" {
|
19
|
+
capabilities = ["update"]
|
20
|
+
}
|
21
|
+
|
22
|
+
# Allow a token to renew a lease via lease_id in the request body; old path for
|
23
|
+
# old clients, new path for newer
|
24
|
+
path "sys/renew" {
|
25
|
+
capabilities = ["update"]
|
26
|
+
}
|
27
|
+
path "sys/leases/renew" {
|
28
|
+
capabilities = ["update"]
|
29
|
+
}
|
30
|
+
|
31
|
+
# Allow looking up lease properties. This requires knowing the lease ID ahead
|
32
|
+
# of time and does not divulge any sensitive information.
|
33
|
+
path "sys/leases/lookup" {
|
34
|
+
capabilities = ["update"]
|
35
|
+
}
|
36
|
+
|
37
|
+
# Allow a token to manage its own cubbyhole
|
38
|
+
path "cubbyhole/*" {
|
39
|
+
capabilities = ["create", "read", "update", "delete", "list"]
|
40
|
+
}
|
41
|
+
|
42
|
+
# Allow a token to wrap arbitrary values in a response-wrapping token
|
43
|
+
path "sys/wrapping/wrap" {
|
44
|
+
capabilities = ["update"]
|
45
|
+
}
|
46
|
+
|
47
|
+
# Allow a token to look up the creation time and TTL of a given
|
48
|
+
# response-wrapping token
|
49
|
+
path "sys/wrapping/lookup" {
|
50
|
+
capabilities = ["update"]
|
51
|
+
}
|
52
|
+
|
53
|
+
# Allow a token to unwrap a response-wrapping token. This is a convenience to
|
54
|
+
# avoid client token swapping since this is also part of the response wrapping
|
55
|
+
# policy.
|
56
|
+
path "sys/wrapping/unwrap" {
|
57
|
+
capabilities = ["update"]
|
58
|
+
}
|
59
|
+
|
60
|
+
# Allow general purpose tools
|
61
|
+
path "sys/tools/hash" {
|
62
|
+
capabilities = ["update"]
|
63
|
+
}
|
64
|
+
path "sys/tools/hash/*" {
|
65
|
+
capabilities = ["update"]
|
66
|
+
}
|
67
|
+
path "sys/tools/random" {
|
68
|
+
capabilities = ["update"]
|
69
|
+
}
|
70
|
+
path "sys/tools/random/*" {
|
71
|
+
capabilities = ["update"]
|
72
|
+
}
|
@@ -0,0 +1,187 @@
|
|
1
|
+
digraph RGL__DirectedAdjacencyGraph {
|
2
|
+
"/auth" [
|
3
|
+
fontsize = 8,
|
4
|
+
label = "/auth"
|
5
|
+
]
|
6
|
+
|
7
|
+
"/auth/token" [
|
8
|
+
fontsize = 8,
|
9
|
+
label = "/auth/token"
|
10
|
+
]
|
11
|
+
|
12
|
+
"/auth/token/lookup-self" [
|
13
|
+
fontsize = 8,
|
14
|
+
label = "/auth/token/lookup-self"
|
15
|
+
]
|
16
|
+
|
17
|
+
"/auth/token/renew-self" [
|
18
|
+
fontsize = 8,
|
19
|
+
label = "/auth/token/renew-self"
|
20
|
+
]
|
21
|
+
|
22
|
+
"/auth/token/revoke-self" [
|
23
|
+
fontsize = 8,
|
24
|
+
label = "/auth/token/revoke-self"
|
25
|
+
]
|
26
|
+
|
27
|
+
"/sys" [
|
28
|
+
fontsize = 8,
|
29
|
+
label = "/sys"
|
30
|
+
]
|
31
|
+
|
32
|
+
"/sys/capabilities-self" [
|
33
|
+
fontsize = 8,
|
34
|
+
label = "/sys/capabilities-self"
|
35
|
+
]
|
36
|
+
|
37
|
+
"/sys/renew" [
|
38
|
+
fontsize = 8,
|
39
|
+
label = "/sys/renew"
|
40
|
+
]
|
41
|
+
|
42
|
+
"/sys/leases" [
|
43
|
+
fontsize = 8,
|
44
|
+
label = "/sys/leases"
|
45
|
+
]
|
46
|
+
|
47
|
+
"/sys/leases/renew" [
|
48
|
+
fontsize = 8,
|
49
|
+
label = "/sys/leases/renew"
|
50
|
+
]
|
51
|
+
|
52
|
+
"/sys/leases/lookup" [
|
53
|
+
fontsize = 8,
|
54
|
+
label = "/sys/leases/lookup"
|
55
|
+
]
|
56
|
+
|
57
|
+
"/cubbyhole" [
|
58
|
+
fontsize = 8,
|
59
|
+
label = "/cubbyhole"
|
60
|
+
]
|
61
|
+
|
62
|
+
"/cubbyhole/*" [
|
63
|
+
fontsize = 8,
|
64
|
+
label = "/cubbyhole/*"
|
65
|
+
]
|
66
|
+
|
67
|
+
"/sys/wrapping" [
|
68
|
+
fontsize = 8,
|
69
|
+
label = "/sys/wrapping"
|
70
|
+
]
|
71
|
+
|
72
|
+
"/sys/wrapping/wrap" [
|
73
|
+
fontsize = 8,
|
74
|
+
label = "/sys/wrapping/wrap"
|
75
|
+
]
|
76
|
+
|
77
|
+
"/sys/wrapping/lookup" [
|
78
|
+
fontsize = 8,
|
79
|
+
label = "/sys/wrapping/lookup"
|
80
|
+
]
|
81
|
+
|
82
|
+
"/sys/wrapping/unwrap" [
|
83
|
+
fontsize = 8,
|
84
|
+
label = "/sys/wrapping/unwrap"
|
85
|
+
]
|
86
|
+
|
87
|
+
"/sys/tools" [
|
88
|
+
fontsize = 8,
|
89
|
+
label = "/sys/tools"
|
90
|
+
]
|
91
|
+
|
92
|
+
"/sys/tools/hash" [
|
93
|
+
fontsize = 8,
|
94
|
+
label = "/sys/tools/hash"
|
95
|
+
]
|
96
|
+
|
97
|
+
"/sys/tools/hash/*" [
|
98
|
+
fontsize = 8,
|
99
|
+
label = "/sys/tools/hash/*"
|
100
|
+
]
|
101
|
+
|
102
|
+
"/sys/tools/random" [
|
103
|
+
fontsize = 8,
|
104
|
+
label = "/sys/tools/random"
|
105
|
+
]
|
106
|
+
|
107
|
+
"/sys/tools/random/*" [
|
108
|
+
fontsize = 8,
|
109
|
+
label = "/sys/tools/random/*"
|
110
|
+
]
|
111
|
+
|
112
|
+
"/auth" -> "/auth/token" [
|
113
|
+
fontsize = 8
|
114
|
+
]
|
115
|
+
|
116
|
+
"/auth/token" -> "/auth/token/lookup-self" [
|
117
|
+
fontsize = 8
|
118
|
+
]
|
119
|
+
|
120
|
+
"/auth/token" -> "/auth/token/renew-self" [
|
121
|
+
fontsize = 8
|
122
|
+
]
|
123
|
+
|
124
|
+
"/auth/token" -> "/auth/token/revoke-self" [
|
125
|
+
fontsize = 8
|
126
|
+
]
|
127
|
+
|
128
|
+
"/sys" -> "/sys/capabilities-self" [
|
129
|
+
fontsize = 8
|
130
|
+
]
|
131
|
+
|
132
|
+
"/sys" -> "/sys/renew" [
|
133
|
+
fontsize = 8
|
134
|
+
]
|
135
|
+
|
136
|
+
"/sys" -> "/sys/leases" [
|
137
|
+
fontsize = 8
|
138
|
+
]
|
139
|
+
|
140
|
+
"/sys" -> "/sys/wrapping" [
|
141
|
+
fontsize = 8
|
142
|
+
]
|
143
|
+
|
144
|
+
"/sys" -> "/sys/tools" [
|
145
|
+
fontsize = 8
|
146
|
+
]
|
147
|
+
|
148
|
+
"/sys/leases" -> "/sys/leases/renew" [
|
149
|
+
fontsize = 8
|
150
|
+
]
|
151
|
+
|
152
|
+
"/sys/leases" -> "/sys/leases/lookup" [
|
153
|
+
fontsize = 8
|
154
|
+
]
|
155
|
+
|
156
|
+
"/cubbyhole" -> "/cubbyhole/*" [
|
157
|
+
fontsize = 8
|
158
|
+
]
|
159
|
+
|
160
|
+
"/sys/wrapping" -> "/sys/wrapping/wrap" [
|
161
|
+
fontsize = 8
|
162
|
+
]
|
163
|
+
|
164
|
+
"/sys/wrapping" -> "/sys/wrapping/lookup" [
|
165
|
+
fontsize = 8
|
166
|
+
]
|
167
|
+
|
168
|
+
"/sys/wrapping" -> "/sys/wrapping/unwrap" [
|
169
|
+
fontsize = 8
|
170
|
+
]
|
171
|
+
|
172
|
+
"/sys/tools" -> "/sys/tools/hash" [
|
173
|
+
fontsize = 8
|
174
|
+
]
|
175
|
+
|
176
|
+
"/sys/tools" -> "/sys/tools/random" [
|
177
|
+
fontsize = 8
|
178
|
+
]
|
179
|
+
|
180
|
+
"/sys/tools/hash" -> "/sys/tools/hash/*" [
|
181
|
+
fontsize = 8
|
182
|
+
]
|
183
|
+
|
184
|
+
"/sys/tools/random" -> "/sys/tools/random/*" [
|
185
|
+
fontsize = 8
|
186
|
+
]
|
187
|
+
}
|
Binary file
|
data/lib/politree.rb
ADDED
data/main.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/inline'
|
4
|
+
|
5
|
+
gemfile true do
|
6
|
+
source 'https://rubygems.org'
|
7
|
+
gem 'pry', require: true
|
8
|
+
gem 'pry-nav', require: true
|
9
|
+
gem 'rhcl', require: true
|
10
|
+
gem 'rgl', require: false
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'rgl/adjacency'
|
14
|
+
require 'rgl/dot'
|
15
|
+
|
16
|
+
def build_graph(filename)
|
17
|
+
result = RGL::DirectedAdjacencyGraph.new
|
18
|
+
src_hcl = Rhcl.parse(open(filename).read)
|
19
|
+
for policy in src_hcl do
|
20
|
+
all_path = policy[1]
|
21
|
+
for path in all_path do
|
22
|
+
tmp_path = ''
|
23
|
+
s_path = path[0].split('/')
|
24
|
+
s_path.each_with_index do |_item, index|
|
25
|
+
tmp_path = tmp_path + '/' + s_path[index]
|
26
|
+
result.add_vertex tmp_path
|
27
|
+
result.add_edge tmp_path.rpartition('/')[0], tmp_path if index > 0
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
result.write_to_graphic_file(fmt = 'jpeg', dotfile = filename)
|
32
|
+
end
|
33
|
+
|
34
|
+
def main
|
35
|
+
src = ARGV[0]
|
36
|
+
if src.nil?
|
37
|
+
puts 'Please provide a filename with policies.'
|
38
|
+
exit 1
|
39
|
+
else
|
40
|
+
build_graph(src)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
main
|
data/politree.gemspec
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path('lib', __dir__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'politree/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'politree'
|
8
|
+
spec.version = Politree::VERSION
|
9
|
+
spec.authors = ['Clement Hussenot', 'Adrien Nouvel']
|
10
|
+
spec.email = ['chussenota@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'A Ruby gem to generate a tree view of your HCL Vault policies files.'
|
13
|
+
spec.description = 'A Ruby gem to generate a tree view of your HCL Vault policies files.'
|
14
|
+
spec.homepage = 'https://github.com/anouvel/vault_tree_generator'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org/'
|
21
|
+
else
|
22
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
23
|
+
'public gem pushes.'
|
24
|
+
end
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
30
|
+
end
|
31
|
+
spec.bindir = 'bin'
|
32
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ['lib']
|
34
|
+
|
35
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
36
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
37
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
38
|
+
spec.add_dependency 'rgl', '~> 0.5'
|
39
|
+
spec.add_dependency 'rhcl', '~> 0.1'
|
40
|
+
spec.add_dependency 'thor', '~> 0.20'
|
41
|
+
end
|
data/tmp/.git-keep
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: politree
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Clement Hussenot
|
8
|
+
- Adrien Nouvel
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2018-06-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.16'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.16'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '10.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '10.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '3.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '3.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rgl
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.5'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.5'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rhcl
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.1'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0.1'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: thor
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0.20'
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0.20'
|
98
|
+
description: A Ruby gem to generate a tree view of your HCL Vault policies files.
|
99
|
+
email:
|
100
|
+
- chussenota@gmail.com
|
101
|
+
executables:
|
102
|
+
- console
|
103
|
+
- politree
|
104
|
+
- setup
|
105
|
+
extensions: []
|
106
|
+
extra_rdoc_files: []
|
107
|
+
files:
|
108
|
+
- ".gitignore"
|
109
|
+
- ".rspec"
|
110
|
+
- ".travis.yml"
|
111
|
+
- CHANGELOG.md
|
112
|
+
- CODE_OF_CONDUCT.md
|
113
|
+
- Gemfile
|
114
|
+
- Gemfile.lock
|
115
|
+
- LICENSE.txt
|
116
|
+
- README.md
|
117
|
+
- Rakefile
|
118
|
+
- bin/console
|
119
|
+
- bin/politree
|
120
|
+
- bin/setup
|
121
|
+
- examples/default.hcl
|
122
|
+
- examples/default.hcl.dot
|
123
|
+
- examples/default.hcl.jpg
|
124
|
+
- lib/politree.rb
|
125
|
+
- lib/politree/version.rb
|
126
|
+
- main.rb
|
127
|
+
- politree.gemspec
|
128
|
+
- tmp/.git-keep
|
129
|
+
homepage: https://github.com/anouvel/vault_tree_generator
|
130
|
+
licenses:
|
131
|
+
- MIT
|
132
|
+
metadata:
|
133
|
+
allowed_push_host: https://rubygems.org/
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 2.7.6
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: A Ruby gem to generate a tree view of your HCL Vault policies files.
|
154
|
+
test_files: []
|