Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(misconf): export unresolvable field of IaC types to Rego #7765

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat(misconf): export unresolvable field of IaC types to Rego
Signed-off-by: nikpivkin <nikita.pivkin@smartforce.io>
nikpivkin committed Oct 18, 2024
commit 3dfbc099dd731116cc9d419a72ccb581a3631c87
2 changes: 2 additions & 0 deletions pkg/iac/rego/convert/slice_test.go
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@ func Test_SliceTypesConversion(t *testing.T) {
"endline": 123,
"sourceprefix": "",
"managed": true,
"unresolvable": false,
"explicit": false,
"fskey": "",
"resource": "",
@@ -49,6 +50,7 @@ func Test_SliceTypesConversion(t *testing.T) {
"endline": 123,
"sourceprefix": "",
"managed": true,
"unresolvable": false,
"explicit": false,
"fskey": "",
"resource": "",
21 changes: 21 additions & 0 deletions pkg/iac/rego/schemas/cloud.json
Original file line number Diff line number Diff line change
@@ -7884,6 +7884,9 @@
"startline": {
"type": "integer"
},
"unresolvable": {
"type": "boolean"
},
"value": {
"type": "boolean"
}
@@ -7916,6 +7919,9 @@
"startline": {
"type": "integer"
},
"unresolvable": {
"type": "boolean"
},
"value": {
"type": "string"
}
@@ -7948,6 +7954,9 @@
"startline": {
"type": "integer"
},
"unresolvable": {
"type": "boolean"
},
"value": {
"type": "integer"
}
@@ -7980,6 +7989,9 @@
"startline": {
"type": "integer"
},
"unresolvable": {
"type": "boolean"
},
"value": {
"type": "object"
}
@@ -8011,6 +8023,9 @@
},
"startline": {
"type": "integer"
},
"unresolvable": {
"type": "boolean"
}
}
},
@@ -8041,6 +8056,9 @@
"startline": {
"type": "integer"
},
"unresolvable": {
"type": "boolean"
},
"value": {
"type": "string"
}
@@ -8073,6 +8091,9 @@
"startline": {
"type": "integer"
},
"unresolvable": {
"type": "boolean"
},
"value": {
"type": "string"
}
2 changes: 2 additions & 0 deletions pkg/iac/state/state_test.go
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@ func Test_RegoConversion(t *testing.T) {
"startline": 2,
"endline": 4,
"managed": true,
"unresolvable": false,
"explicit": false,
"fskey": "",
},
@@ -55,6 +56,7 @@ func Test_RegoConversion(t *testing.T) {
"endline": 3,
"value": "my-bucket",
"managed": true,
"unresolvable": false,
"explicit": false,
"fskey": "",
},
1 change: 1 addition & 0 deletions pkg/iac/types/metadata.go
Original file line number Diff line number Diff line change
@@ -84,6 +84,7 @@ func (m *Metadata) ToRego() any {
"sourceprefix": m.Range().GetSourcePrefix(),
"managed": m.isManaged,
"explicit": m.isExplicit,
"unresolvable": m.isUnresolvable,
"fskey": CreateFSKey(m.Range().GetFS()),
"resource": m.Reference(),
}
3 changes: 3 additions & 0 deletions pkg/iac/types/metadata_test.go
Original file line number Diff line number Diff line change
@@ -8,12 +8,14 @@ import (

func Test_MetadataToRego(t *testing.T) {
m1 := NewTestMetadata()
m1.isUnresolvable = true
expected := map[string]any{
"endline": 123,
"explicit": false,
"filepath": "test.test",
"fskey": "",
"managed": true,
"unresolvable": true,
"resource": "",
"sourceprefix": "",
"startline": 123,
@@ -27,6 +29,7 @@ func Test_MetadataToRego(t *testing.T) {
"filepath": "test.test",
"fskey": "",
"managed": true,
"unresolvable": false,
"resource": "",
"sourceprefix": "",
"startline": 123,