-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(misconf): Register rego rules on init
- Loading branch information
Showing
9 changed files
with
80 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package rego | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetProviderNames(t *testing.T) { | ||
assert.Equal(t, []string{"AWS", "Azure", "Cloudstack", "Digital Ocean", "Dockerfile", "GitHub", "Google", "Kubernetes", "Nifcloud", "OpenStack", "Oracle"}, GetProviderNames()) | ||
} | ||
|
||
func TestGetProviderServiceNames(t *testing.T) { | ||
testCases := []struct { | ||
provider string | ||
expectedServices []string | ||
}{ | ||
{ | ||
provider: "aws", | ||
expectedServices: []string{"apigateway", "athena", "cloudfront", "cloudtrail", "cloudwatch", "codebuild", "config", "documentdb", "dynamodb", "ec2", "ecr", "ecs", "efs", "eks", "elasticache", "elasticsearch", "elb", "emr", "iam", "kinesis", "kms", "lambda", "mq", "msk", "neptune", "rds", "redshift", "s3", "sam", "sns", "sqs", "ssm", "workspaces"}, | ||
}, | ||
{ | ||
provider: "azure", | ||
expectedServices: []string{"appservice", "authorization", "compute", "container", "database", "datafactory", "datalake", "keyvault", "monitor", "network", "security-center", "storage", "synapse"}, | ||
}, | ||
{ | ||
provider: "digital ocean", | ||
expectedServices: []string{"compute", "spaces"}, | ||
}, | ||
{ | ||
provider: "dockerfile", | ||
expectedServices: []string{"general"}, | ||
}, | ||
{ | ||
provider: "google", | ||
expectedServices: []string{"bigquery", "compute", "dns", "gke", "iam", "kms", "sql", "storage"}, | ||
}, | ||
{ | ||
provider: "kubernetes", | ||
expectedServices: []string{"general", "network"}, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.provider, func(t *testing.T) { | ||
assert.Equal(t, tc.expectedServices, GetProviderServiceNames(tc.provider)) | ||
}) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package rules | ||
package rego | ||
|
||
import ( | ||
"sync" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package rules | ||
package rego | ||
|
||
import ( | ||
"fmt" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package rego | ||
|
||
import ( | ||
trules "github.com/aquasecurity/trivy-checks/pkg/rules" | ||
) | ||
|
||
func init() { | ||
LoadAndRegister() | ||
for _, r := range trules.GetRules() { | ||
Register(r) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters