File tree 2 files changed +17
-1
lines changed
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -10,9 +10,18 @@ import rego.v1
10
10
obj_by_path (obj, path) := res if {
11
11
occurrences := {obj_path: child_object |
12
12
walk (obj, [obj_path, child_object])
13
- child_object.__defsec_metadata
13
+ has_metadata ( child_object)
14
14
object.subset (path, obj_path)
15
15
}
16
16
17
17
res := occurrences[max (object.keys (occurrences))]
18
18
} else := obj
19
+
20
+ has_metadata (obj) if obj.__defsec_metadata
21
+
22
+ has_metadata (obj) if {
23
+ obj.fskey
24
+ has_key (obj, " value" )
25
+ }
26
+
27
+ has_key (x, k) if _ = x[k]
Original file line number Diff line number Diff line change @@ -31,4 +31,11 @@ test_obj_by_path_skip_without_metadata if {
31
31
metadata.obj_by_path (obj, [" foo" , " baz" ]) == obj
32
32
}
33
33
34
+ test_obj_by_path_happy_iac_type if {
35
+ bar := {" value" : 1 , " fskey" : " somekey" }
36
+ obj := with_meta ({" foo" : with_meta ({" bar" : bar})})
37
+
38
+ metadata.obj_by_path (obj, [" foo" , " bar" ]) == bar
39
+ }
40
+
34
41
with_meta (obj) := object.union (obj, {" __defsec_metadata" : {}})
You can’t perform that action at this time.
0 commit comments