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

chore(deps): Update trivy pkg to latest #157

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
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
54 changes: 13 additions & 41 deletions checks/cloud/google/iam/no_default_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,10 @@ func TestCheckNoDefaultNetwork(t *testing.T) {
{
name: "Project automatic network creation enabled",
input: iam.IAM{
Organizations: []iam.Organization{
Projects: []iam.Project{
{
Metadata: trivyTypes.NewTestMetadata(),
Projects: []iam.Project{
{
Metadata: trivyTypes.NewTestMetadata(),
AutoCreateNetwork: trivyTypes.Bool(true, trivyTypes.NewTestMetadata()),
},
},
Metadata: trivyTypes.NewTestMetadata(),
AutoCreateNetwork: trivyTypes.Bool(true, trivyTypes.NewTestMetadata()),
},
},
},
Expand All @@ -39,32 +34,14 @@ func TestCheckNoDefaultNetwork(t *testing.T) {
{
name: "Project automatic network creation enabled #2",
input: iam.IAM{
Organizations: []iam.Organization{
Projects: []iam.Project{
{
Metadata: trivyTypes.NewTestMetadata(),

Folders: []iam.Folder{
{
Metadata: trivyTypes.NewTestMetadata(),
Projects: []iam.Project{
{
Metadata: trivyTypes.NewTestMetadata(),
AutoCreateNetwork: trivyTypes.Bool(false, trivyTypes.NewTestMetadata()),
},
},
Folders: []iam.Folder{
{
Metadata: trivyTypes.NewTestMetadata(),
Projects: []iam.Project{
{
Metadata: trivyTypes.NewTestMetadata(),
AutoCreateNetwork: trivyTypes.Bool(true, trivyTypes.NewTestMetadata()),
},
},
},
},
},
},
Metadata: trivyTypes.NewTestMetadata(),
AutoCreateNetwork: trivyTypes.Bool(false, trivyTypes.NewTestMetadata()),
},
{
Metadata: trivyTypes.NewTestMetadata(),
AutoCreateNetwork: trivyTypes.Bool(true, trivyTypes.NewTestMetadata()),
},
},
},
Expand All @@ -73,15 +50,10 @@ func TestCheckNoDefaultNetwork(t *testing.T) {
{
name: "Project automatic network creation disabled",
input: iam.IAM{
Organizations: []iam.Organization{
Projects: []iam.Project{
{
Metadata: trivyTypes.NewTestMetadata(),
Projects: []iam.Project{
{
Metadata: trivyTypes.NewTestMetadata(),
AutoCreateNetwork: trivyTypes.Bool(false, trivyTypes.NewTestMetadata()),
},
},
Metadata: trivyTypes.NewTestMetadata(),
AutoCreateNetwork: trivyTypes.Bool(false, trivyTypes.NewTestMetadata()),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,14 @@ func TestCheckNoFolderLevelDefaultServiceAccountAssignment(t *testing.T) {
{
name: "Default service account enabled",
input: iam.IAM{
Organizations: []iam.Organization{
Folders: []iam.Folder{
{
Metadata: trivyTypes.NewTestMetadata(),

Folders: []iam.Folder{
Members: []iam.Member{
{
Metadata: trivyTypes.NewTestMetadata(),
Members: []iam.Member{
{
Metadata: trivyTypes.NewTestMetadata(),
DefaultServiceAccount: trivyTypes.Bool(true, trivyTypes.NewTestMetadata()),
Member: trivyTypes.String("[email protected]", trivyTypes.NewTestMetadata()),
},
},
Metadata: trivyTypes.NewTestMetadata(),
DefaultServiceAccount: trivyTypes.Bool(true, trivyTypes.NewTestMetadata()),
Member: trivyTypes.String("[email protected]", trivyTypes.NewTestMetadata()),
},
},
},
Expand All @@ -46,19 +40,14 @@ func TestCheckNoFolderLevelDefaultServiceAccountAssignment(t *testing.T) {
{
name: "Default service account disabled but default account data provided",
input: iam.IAM{
Organizations: []iam.Organization{
Folders: []iam.Folder{
{
Metadata: trivyTypes.NewTestMetadata(),
Folders: []iam.Folder{
Members: []iam.Member{
{
Metadata: trivyTypes.NewTestMetadata(),
Members: []iam.Member{
{
Metadata: trivyTypes.NewTestMetadata(),
DefaultServiceAccount: trivyTypes.Bool(false, trivyTypes.NewTestMetadata()),
Member: trivyTypes.String("[email protected]", trivyTypes.NewTestMetadata()),
},
},
Metadata: trivyTypes.NewTestMetadata(),
DefaultServiceAccount: trivyTypes.Bool(false, trivyTypes.NewTestMetadata()),
Member: trivyTypes.String("[email protected]", trivyTypes.NewTestMetadata()),
},
},
},
Expand All @@ -69,21 +58,15 @@ func TestCheckNoFolderLevelDefaultServiceAccountAssignment(t *testing.T) {
{
name: "Default service account disabled but default account data provided #2",
input: iam.IAM{
Organizations: []iam.Organization{
Folders: []iam.Folder{
{
Metadata: trivyTypes.NewTestMetadata(),

Folders: []iam.Folder{
Bindings: []iam.Binding{
{
Metadata: trivyTypes.NewTestMetadata(),
Bindings: []iam.Binding{
{
Metadata: trivyTypes.NewTestMetadata(),
IncludesDefaultServiceAccount: trivyTypes.Bool(false, trivyTypes.NewTestMetadata()),
Members: []trivyTypes.StringValue{
trivyTypes.String("[email protected]", trivyTypes.NewTestMetadata())},
},
},
Metadata: trivyTypes.NewTestMetadata(),
IncludesDefaultServiceAccount: trivyTypes.Bool(false, trivyTypes.NewTestMetadata()),
Members: []trivyTypes.StringValue{
trivyTypes.String("[email protected]", trivyTypes.NewTestMetadata())},
},
},
},
Expand All @@ -94,28 +77,22 @@ func TestCheckNoFolderLevelDefaultServiceAccountAssignment(t *testing.T) {
{
name: "Default service account disabled and proper account data provided",
input: iam.IAM{
Organizations: []iam.Organization{
Folders: []iam.Folder{
{
Metadata: trivyTypes.NewTestMetadata(),

Folders: []iam.Folder{
Members: []iam.Member{
{
Metadata: trivyTypes.NewTestMetadata(),
Members: []iam.Member{
{
Metadata: trivyTypes.NewTestMetadata(),
DefaultServiceAccount: trivyTypes.Bool(false, trivyTypes.NewTestMetadata()),
Member: trivyTypes.String("[email protected]", trivyTypes.NewTestMetadata()),
},
},
Bindings: []iam.Binding{
{
Metadata: trivyTypes.NewTestMetadata(),
IncludesDefaultServiceAccount: trivyTypes.Bool(false, trivyTypes.NewTestMetadata()),
Members: []trivyTypes.StringValue{
trivyTypes.String("[email protected]", trivyTypes.NewTestMetadata()),
},
},
Metadata: trivyTypes.NewTestMetadata(),
DefaultServiceAccount: trivyTypes.Bool(false, trivyTypes.NewTestMetadata()),
Member: trivyTypes.String("[email protected]", trivyTypes.NewTestMetadata()),
},
},
Bindings: []iam.Binding{
{
Metadata: trivyTypes.NewTestMetadata(),
IncludesDefaultServiceAccount: trivyTypes.Bool(false, trivyTypes.NewTestMetadata()),
Members: []trivyTypes.StringValue{
trivyTypes.String("[email protected]", trivyTypes.NewTestMetadata()),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,13 @@ func TestCheckNoFolderLevelServiceAccountImpersonation(t *testing.T) {
{
name: "Member role set to service account user",
input: iam.IAM{
Organizations: []iam.Organization{
Folders: []iam.Folder{
{
Metadata: trivyTypes.NewTestMetadata(),
Folders: []iam.Folder{
Members: []iam.Member{
{
Metadata: trivyTypes.NewTestMetadata(),
Members: []iam.Member{
{
Metadata: trivyTypes.NewTestMetadata(),
Role: trivyTypes.String("roles/iam.serviceAccountUser", trivyTypes.NewTestMetadata()),
},
},
Role: trivyTypes.String("roles/iam.serviceAccountUser", trivyTypes.NewTestMetadata()),
},
},
},
Expand All @@ -42,21 +37,16 @@ func TestCheckNoFolderLevelServiceAccountImpersonation(t *testing.T) {
expected: true,
},
{
name: "Member role set to service account token creator",
name: "Binding role set to service account token creator",
input: iam.IAM{
Organizations: []iam.Organization{
Folders: []iam.Folder{
{
Metadata: trivyTypes.NewTestMetadata(),
Folders: []iam.Folder{
Bindings: []iam.Binding{
{
Metadata: trivyTypes.NewTestMetadata(),
Bindings: []iam.Binding{
{
Metadata: trivyTypes.NewTestMetadata(),
IncludesDefaultServiceAccount: trivyTypes.Bool(false, trivyTypes.NewTestMetadata()),
Role: trivyTypes.String("roles/iam.serviceAccountTokenCreator", trivyTypes.NewTestMetadata()),
},
},
Metadata: trivyTypes.NewTestMetadata(),
IncludesDefaultServiceAccount: trivyTypes.Bool(false, trivyTypes.NewTestMetadata()),
Role: trivyTypes.String("roles/iam.serviceAccountTokenCreator", trivyTypes.NewTestMetadata()),
},
},
},
Expand All @@ -67,25 +57,20 @@ func TestCheckNoFolderLevelServiceAccountImpersonation(t *testing.T) {
{
name: "Member role set to something particular",
input: iam.IAM{
Organizations: []iam.Organization{
Folders: []iam.Folder{
{
Metadata: trivyTypes.NewTestMetadata(),
Folders: []iam.Folder{
Members: []iam.Member{
{
Metadata: trivyTypes.NewTestMetadata(),
Members: []iam.Member{
{
Metadata: trivyTypes.NewTestMetadata(),
Role: trivyTypes.String("roles/nothingInParticular", trivyTypes.NewTestMetadata()),
},
},
Bindings: []iam.Binding{
{
Metadata: trivyTypes.NewTestMetadata(),
IncludesDefaultServiceAccount: trivyTypes.Bool(false, trivyTypes.NewTestMetadata()),
Role: trivyTypes.String("roles/nothingInParticular", trivyTypes.NewTestMetadata()),
},
},
Role: trivyTypes.String("roles/nothingInParticular", trivyTypes.NewTestMetadata()),
},
},
Bindings: []iam.Binding{
{
Metadata: trivyTypes.NewTestMetadata(),
IncludesDefaultServiceAccount: trivyTypes.Bool(false, trivyTypes.NewTestMetadata()),
Role: trivyTypes.String("roles/nothingInParticular", trivyTypes.NewTestMetadata()),
},
},
},
Expand Down
54 changes: 17 additions & 37 deletions checks/cloud/google/iam/no_privileged_service_accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,15 @@ func TestCheckNoPrivilegedServiceAccounts(t *testing.T) {
{
name: "Service account granted editor role",
input: iam.IAM{
Organizations: []iam.Organization{
Projects: []iam.Project{
{
Metadata: trivyTypes.NewTestMetadata(),
Folders: []iam.Folder{
Bindings: []iam.Binding{
{
Metadata: trivyTypes.NewTestMetadata(),
Projects: []iam.Project{
{
Metadata: trivyTypes.NewTestMetadata(),
Bindings: []iam.Binding{
{
Metadata: trivyTypes.NewTestMetadata(),
Role: trivyTypes.String("roles/editor", trivyTypes.NewTestMetadata()),
Members: []trivyTypes.StringValue{
trivyTypes.String("serviceAccount:${google_service_account.test.email}", trivyTypes.NewTestMetadata()),
},
},
},
},
Role: trivyTypes.String("roles/editor", trivyTypes.NewTestMetadata()),
Members: []trivyTypes.StringValue{
trivyTypes.String("serviceAccount:${google_service_account.test.email}", trivyTypes.NewTestMetadata()),
},
},
},
Expand All @@ -70,32 +60,22 @@ func TestCheckNoPrivilegedServiceAccounts(t *testing.T) {
{
name: "No service account with excessive privileges",
input: iam.IAM{
Organizations: []iam.Organization{
Projects: []iam.Project{
{
Metadata: trivyTypes.NewTestMetadata(),
Folders: []iam.Folder{
Members: []iam.Member{
{
Metadata: trivyTypes.NewTestMetadata(),
Role: trivyTypes.String("roles/owner", trivyTypes.NewTestMetadata()),
Member: trivyTypes.String("[email protected]", trivyTypes.NewTestMetadata()),
},
},
Bindings: []iam.Binding{
{
Metadata: trivyTypes.NewTestMetadata(),
Projects: []iam.Project{
{
Metadata: trivyTypes.NewTestMetadata(),
Members: []iam.Member{
{
Metadata: trivyTypes.NewTestMetadata(),
Role: trivyTypes.String("roles/owner", trivyTypes.NewTestMetadata()),
Member: trivyTypes.String("[email protected]", trivyTypes.NewTestMetadata()),
},
},
Bindings: []iam.Binding{
{
Metadata: trivyTypes.NewTestMetadata(),
Role: trivyTypes.String("roles/logging.logWriter", trivyTypes.NewTestMetadata()),
Members: []trivyTypes.StringValue{
trivyTypes.String("serviceAccount:${google_service_account.test.email}", trivyTypes.NewTestMetadata()),
},
},
},
},
Role: trivyTypes.String("roles/logging.logWriter", trivyTypes.NewTestMetadata()),
Members: []trivyTypes.StringValue{
trivyTypes.String("serviceAccount:${google_service_account.test.email}", trivyTypes.NewTestMetadata()),
},
},
},
Expand Down
Loading