@@ -11,49 +11,59 @@ has_key(obj, key) := true if _ = obj[key]
1111
1212# Root Component Rules Logic
1313root_policy_types := [key | key := object.keys (root_policies)[_]]
14- get_root_type := x if {
14+ get_root_type := rt if {
1515 comp_type = root_policy_types[_]
1616 startswith (nifi_inp.inherit_resource_id, comp_type)
17- x = comp_type
17+ rt = comp_type
1818}
1919comp_is_root_type := get_root_type in root_policy_types
2020
2121component_exists_in_root (comp_type, res_name) := true if {
2222 has_key (root_policies, comp_type)
2323 has_key (root_policies[comp_type], res_name)
2424}
25+
2526root_policy_user_has_permissions (comp_type, res_name, user_name, action) := true if {
2627 component_exists_in_root (comp_type, res_name)
2728 user_name in root_policies[comp_type][res_name][action][" users" ]
29+ }
30+ root_policy_group_has_permissions (comp_type, res_name, user_groups, action) := true if {
31+ component_exists_in_root (comp_type, res_name)
32+ x := { trim (k, " " ) | k = root_policies[comp_type][res_name][action][" groups" ][_] }
33+ y := { trim (k, " " ) | k = user_groups[_] }
34+ count (x & y) > 0
2835}
2936
3037
31-
3238# node Component Rules Logic
3339node_policy_types := [key | key := object.keys (node_policies)[_]]
34- get_node_type := x if {
40+ get_node_type := nt if {
3541 comp_type = node_policy_types[_]
3642 startswith (nifi_inp.inherit_resource_id, comp_type)
37- x = comp_type
43+ nt = comp_type
3844}
3945comp_is_node_type := get_node_type in node_policy_types
4046compID := array.reverse (split (nifi_inp.resource_id, " /" ))[0 ]
4147inheritCompID := array.reverse (split (nifi_inp.inherit_resource_id, " /" ))[0 ]
4248
43- component_exists_in_node (comp_type, comp_ID ) := true if {
49+ component_exists_in_node (comp_type, res_ID ) := true if {
4450 has_key (node_policies, comp_type)
45- has_key (node_policies[comp_type], comp_ID )
51+ has_key (node_policies[comp_type], res_ID )
4652}
4753
48- node_policy_user_has_permissions (comp_type, comp_ID, user_name, action) := true if {
49- component_exists_in_node (comp_type, comp_ID)
50- user_name in node_policies[comp_type][comp_ID][action][" users" ]
54+ node_policy_user_has_permissions (comp_type, res_ID, user_name, action) := true if {
55+ component_exists_in_node (comp_type, res_ID)
56+ user_name in node_policies[comp_type][res_ID][action][" users" ]
57+ }
58+ node_policy_group_has_permissions (comp_type, res_ID, user_groups, action) := true if {
59+ component_exists_in_node (comp_type, res_ID)
60+ x := { trim (k, " " ) | k = node_policies[comp_type][res_ID][action][" groups" ][_] }
61+ y := { trim (k, " " ) | k = user_groups[_] }
62+ count (x & y) > 0
5163}
5264
5365
54-
55-
56- # # Flow Access
66+ # ## "NiFi Flow" - Access
5767flow_allowed:= true if {
5868 root_policy_user_has_permissions (
5969 get_root_type,
@@ -69,36 +79,71 @@ flow_denied:= true if { # macht nur Sinn für Unter-Res zu denyn
6979 " deny" )
7080}
7181
82+ # ## Root component access
83+
7284root_comp_allowed := true if {
7385 root_policy_user_has_permissions (
7486 get_root_type,
7587 nifi_inp.resource_name,
7688 nifi_inp.user_name,
7789 nifi_inp.action)
7890}
91+ root_comp_allowed := true if {
92+ root_policy_group_has_permissions (
93+ get_root_type,
94+ nifi_inp.resource_name,
95+ nifi_inp.user_groups,
96+ nifi_inp.action)
97+ }
98+
7999root_comp_denied := true if {
80100 root_policy_user_has_permissions (
81101 get_root_type,
82102 nifi_inp.resource_name,
83103 nifi_inp.user_name,
84104 " deny" )
85105}
106+ root_comp_denied := true if {
107+ root_policy_group_has_permissions (
108+ get_root_type,
109+ nifi_inp.resource_name,
110+ nifi_inp.user_groups,
111+ " deny" )
112+ }
113+
86114root_inherit_comp_allowed := true if {
87115 root_policy_user_has_permissions (
88116 get_root_type,
89117 nifi_inp.inherit_resource_name,
90118 nifi_inp.user_name,
91119 nifi_inp.action)
92120}
121+ root_inherit_comp_allowed := true if {
122+ root_policy_group_has_permissions (
123+ get_root_type,
124+ nifi_inp.inherit_resource_name,
125+ nifi_inp.user_groups,
126+ nifi_inp.action)
127+ }
128+
93129root_inherit_comp_denied := true if {
94130 root_policy_user_has_permissions (
95131 get_root_type,
96132 nifi_inp.inherit_resource_name,
97133 nifi_inp.user_name,
98134 " deny" )
99135}
136+ root_inherit_comp_denied := true if {
137+ root_policy_group_has_permissions (
138+ get_root_type,
139+ nifi_inp.inherit_resource_name,
140+ nifi_inp.user_groups,
141+ " deny" )
142+ }
143+
100144
101145
146+ # ## Node component access
102147
103148node_comp_allowed := true if {
104149 node_policy_user_has_permissions (
@@ -107,27 +152,58 @@ node_comp_allowed := true if {
107152 nifi_inp.user_name,
108153 nifi_inp.action)
109154}
155+ node_comp_allowed := true if {
156+ node_policy_group_has_permissions (
157+ get_node_type,
158+ compID,
159+ nifi_inp.user_groups,
160+ nifi_inp.action)
161+ }
162+
110163node_comp_denied := true if {
111164 node_policy_user_has_permissions (
112165 get_node_type,
113166 compID,
114167 nifi_inp.user_name,
115168 " deny" )
116169}
170+ node_comp_denied := true if {
171+ node_policy_group_has_permissions (
172+ get_node_type,
173+ compID,
174+ nifi_inp.user_groups,
175+ " deny" )
176+ }
177+
117178node_inherit_comp_allowed := true if {
118179 node_policy_user_has_permissions (
119180 get_node_type,
120181 inheritCompID,
121182 nifi_inp.user_name,
122183 nifi_inp.action)
123184}
185+ node_inherit_comp_allowed := true if {
186+ node_policy_group_has_permissions (
187+ get_node_type,
188+ inheritCompID,
189+ nifi_inp.user_groups,
190+ nifi_inp.action)
191+ }
192+
124193node_inherit_comp_denied := true if {
125194 node_policy_user_has_permissions (
126195 get_node_type,
127196 inheritCompID,
128197 nifi_inp.user_name,
129198 " deny" )
130199}
200+ node_inherit_comp_denied := true if {
201+ node_policy_group_has_permissions (
202+ get_node_type,
203+ inheritCompID,
204+ nifi_inp.user_groups,
205+ " deny" )
206+ }
131207
132208node_comp_has_action := true if {
133209 component_exists_in_node (get_node_type, inheritCompID)
0 commit comments