Tree shaking
Tree shaking for documents/filter/visible keeps 67 lines, deletes 0 and adds 0. It keeps 2 files and removes 0.
filter.rego: 27 lines kept, 0 deleted, 0 added
1# The documents of the library that the user can read. The document store asks for `visible` and shows only
2# these documents, so the policy filters the data and does not only answer yes or no.
3package documents.filter
4
5levels := {"public": 0, "internal": 1, "confidential": 2}
6
7visible contains {"id": document.id, "title": document.title} if {
8 some document in data.documents.library
9 readable(document)
10}
11
12# Each user can read a public document.
13readable(document) if document.classification == "public"
14
15# A user can read a document of the department of the user, up to the clearance of the user.
16readable(document) if {
17 document.department == input.user.department
18 cleared(document)
19}
20
21# An auditor can read a document of each department, up to the clearance of the auditor.
22readable(document) if {
23 input.user.role == "auditor"
24 cleared(document)
25}
26
27cleared(document) if levels[document.classification] <= levels[input.user.clearance]
Counts
| Lines kept | 67 |
| Lines deleted | 0 |
| Lines added | 0 |
| Files kept | 2 |
| Files removed | 0 |
Builtins (2)
- equal
- lte
Legend
1A kept line: the shaken bundle has it.
2A deleted line: the shaken bundle does not have it.
+An added line: only the shaken bundle has it.
- policy.rego a removed file