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
Browse files Browse the repository at this point in the history
  • Loading branch information
nikpivkin committed Jan 18, 2024
1 parent 87a2031 commit 8fb98dc
Showing 1 changed file with 16 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

0 comments on commit 8fb98dc

Please sign in to comment.