Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

Commit

Permalink
fix(iam): pass all document metadata fields to rego (#1525)
Browse files Browse the repository at this point in the history
* fix(iam): pass all document metadata fields to rego

* chore: update schema
  • Loading branch information
nikpivkin authored Jan 19, 2024
1 parent 87a2031 commit c2d65f4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
24 changes: 16 additions & 8 deletions pkg/providers/aws/iam/iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,23 @@ type Document struct {
func (d Document) ToRego() interface{} {
m := d.Metadata
doc, _ := d.Parsed.MarshalJSON()
return map[string]interface{}{
"filepath": m.Range().GetFilename(),
"startline": m.Range().GetStartLine(),
"endline": m.Range().GetEndLine(),
"managed": m.IsManaged(),
"explicit": m.IsExplicit(),
"value": string(doc),
"fskey": defsecTypes.CreateFSKey(m.Range().GetFS()),
input := map[string]interface{}{
"filepath": m.Range().GetFilename(),
"startline": m.Range().GetStartLine(),
"endline": m.Range().GetEndLine(),
"managed": m.IsManaged(),
"explicit": m.IsExplicit(),
"value": string(doc),
"sourceprefix": m.Range().GetSourcePrefix(),
"fskey": defsecTypes.CreateFSKey(m.Range().GetFS()),
"resource": m.Reference(),
}

if m.Parent() != nil {
input["parent"] = m.Parent().ToRego()
}

return input
}

type Group struct {
Expand Down
6 changes: 6 additions & 0 deletions pkg/rego/schemas/cloud.json
Original file line number Diff line number Diff line change
Expand Up @@ -2159,6 +2159,12 @@
"managed": {
"type": "boolean"
},
"resource": {
"type": "string"
},
"sourceprefix": {
"type": "string"
},
"startline": {
"type": "integer"
},
Expand Down

0 comments on commit c2d65f4

Please sign in to comment.