From 678e7af74ed616988e16aa916f4bf089d26e166e Mon Sep 17 00:00:00 2001 From: nikpivkin Date: Sun, 8 Dec 2024 18:23:47 +0600 Subject: [PATCH] feat: add a examples field to check metadata Signed-off-by: nikpivkin --- pkg/iac/rego/metadata.go | 3 +++ pkg/iac/scan/rule.go | 1 + 2 files changed, 4 insertions(+) diff --git a/pkg/iac/rego/metadata.go b/pkg/iac/rego/metadata.go index ac2eb84a36d2..a087e9b6ba92 100644 --- a/pkg/iac/rego/metadata.go +++ b/pkg/iac/rego/metadata.go @@ -39,6 +39,7 @@ type StaticMetadata struct { Library bool CloudFormation *scan.EngineMetadata Terraform *scan.EngineMetadata + Examples string } func NewStaticMetadata(pkgPath string, inputOpt InputOptions) *StaticMetadata { @@ -75,6 +76,7 @@ func (sm *StaticMetadata) update(meta map[string]any) error { upd(&sm.Provider, "provider") upd(&sm.RecommendedActions, "recommended_actions") upd(&sm.RecommendedActions, "recommended_action") + upd(&sm.Examples, "examples") if raw, ok := meta["deprecated"]; ok { if dep, ok := raw.(bool); ok { @@ -269,6 +271,7 @@ func (m StaticMetadata) ToRule() scan.Rule { Frameworks: m.Frameworks, CloudFormation: m.CloudFormation, Terraform: m.Terraform, + Examples: m.Examples, } } diff --git a/pkg/iac/scan/rule.go b/pkg/iac/scan/rule.go index 96db0007ffcc..0ed48d8a6145 100755 --- a/pkg/iac/scan/rule.go +++ b/pkg/iac/scan/rule.go @@ -50,6 +50,7 @@ type Rule struct { Severity severity.Severity `json:"severity"` Terraform *EngineMetadata `json:"terraform,omitempty"` CloudFormation *EngineMetadata `json:"cloud_formation,omitempty"` + Examples string `json:"-"` CustomChecks CustomChecks `json:"-"` RegoPackage string `json:"-"` Frameworks map[framework.Framework][]string `json:"frameworks"`