Code Monkey home page Code Monkey logo

rbac-linter's People

Contributors

ahelwer avatar klizhentas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rbac-linter's Issues

KeyError if node doesn't have any labels set

$ 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

Simplify set constraint logic

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.

Support start & end tokens in regexes

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:

  • if the ^ and $ characters are at the start/end of the regex, ignore them
  • if the ^ 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.