gravitational / rbac-linter Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
$ python3 role_query.py data/nodes.yaml data/roles.yaml
Traceback (most recent call last):
File "/Users/gus/saleseng/rbac-linter/role_query.py", line 82, in <module>
main()
File "/Users/gus/saleseng/rbac-linter/role_query.py", line 70, in main
node_matches_role(nodes, roles)
File "/Users/gus/saleseng/rbac-linter/role_query.py", line 12, in node_matches_role
node_labels = node['metadata']['labels']
KeyError: 'labels'
$ cat data/nodes.yaml
kind: node
metadata:
expires: "2021-12-16T15:21:25Z"
id: 1638972710140895259
name: 31e62008-012f-4b65-8997-9df524b2316b
spec:
addr: 10.10.67.28:3022
hostname: ip-10-10-67-28-us-east-2-compute-internal
rotation:
current_id: 8b81073e-b474-40ea-8646-d8a66d1ee249
grace_period: 10m0s
last_rotated: "2021-12-03T19:43:59.014196449Z"
phase: standby
schedule:
standby: "0001-01-01T00:00:00Z"
update_clients: "0001-01-01T00:00:00Z"
update_servers: "0001-01-01T00:00:00Z"
started: "0001-01-01T00:00:00Z"
state: standby
version: 7.3.2
version: v2
In Z3, it isn't enough to define what elements are in a set - you also have to define what elements are not in a set, otherwise the solver uses the trivial model of a set containing every element of the given sort. The result of this requirement is some fairly hideous quantification constraints in the role_analyzer.labels_as_z3_map
and role_analyzer.traits_as_z3_map
functions. This doesn't seem to cause any problems by itself yet, although the models it generates are basically unintelligible; it may cause tractability issues for some inputs to role_query.py
, although that seems unlikely. For simplicity an alternative representation of sets should be explored which avoids this problem. However, this direction of using specified functions instead of uninterpreted functions could lead to unforeseen issues with functionality used by role_equivalence_check.py
.
In Teleport's RBAC for allow rule to apply, all labels should match for Allow rule to apply, and Any label could match for Deny rule to apply:
Line 426 in 2e64c6e
So this above should be tweaked for allow and deny rules
I think this would be a fairly simple fix. In regexp.replace
the start/end tokens would be quite difficult to implement, but for ordinary regex constraints of the form:
'key' : '^staging|prod$'
the tokens are actually irrelevant, because the regex implicitly matches the entirety of the text - its start must be the text's start, and its end must be the text's end. It's possible someone could define a constraint like:
'key' : 'foo^bar'
but this would just be invalid and match nothing. So the fix to add support would be as follows:
^
and $
characters are at the start/end of the regex, ignore them^
and $
are not at the start/end of the regex, either raise a ValueError
exception or match nothing with Empty(ReSort(StringSort))
To make it more robust, this analysis should be done on the output of sre_parse.parse
rather than the raw regex string. There are various alternative positional markers like [\A]
, [\b]
, [\B]
, and [\Z]
that the parser will help identify with the sre_constants.AT
category.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.