Skip to content

Commit

Permalink
fix panic while scanning https://github.com/bridgecrewio/cfngoat (#1238)
Browse files Browse the repository at this point in the history
  • Loading branch information
patilpankaj212 committed May 5, 2022
1 parent 5be816d commit 9baa8ef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
20 changes: 11 additions & 9 deletions pkg/mapper/iac-providers/cft/config/eks-cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,21 @@ func GetEksClusterConfig(c *eks.Cluster) []AWSResourceConfig {
vpcConfig[0].EndpointPublicAccess = c.ResourcesVpcConfig.EndpointPublicAccess
}

enabledClusterLogTypes := make([]string, len(c.Logging.ClusterLogging.EnabledTypes))
for i := range c.Logging.ClusterLogging.EnabledTypes {
enabledClusterLogTypes[i] = c.Logging.ClusterLogging.EnabledTypes[i].Type
}

cf := EksClusterConfig{
Config: Config{
Name: c.Name,
},
Name: c.Name,
RoleARN: c.RoleArn,
VPCConfig: vpcConfig,
EnabledClusterLogTypes: enabledClusterLogTypes,
Name: c.Name,
RoleARN: c.RoleArn,
VPCConfig: vpcConfig,
}

if c.Logging != nil && c.Logging.ClusterLogging != nil && len(c.Logging.ClusterLogging.EnabledTypes) > 0 {
enabledClusterLogTypes := make([]string, len(c.Logging.ClusterLogging.EnabledTypes))
for i := range c.Logging.ClusterLogging.EnabledTypes {
enabledClusterLogTypes[i] = c.Logging.ClusterLogging.EnabledTypes[i].Type
}
cf.EnabledClusterLogTypes = enabledClusterLogTypes
}

return []AWSResourceConfig{{
Expand Down
16 changes: 10 additions & 6 deletions pkg/mapper/iac-providers/cft/config/iam-user.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,21 @@ func GetIamUserConfig(i *iam.User) []AWSResourceConfig {
},
})

iamLoginProfileConfig := IamUserLoginProfileConfig{
Config: Config{
Name: i.UserName,
},
}
if i.LoginProfile != nil {
iamLoginProfileConfig.PasswordResetRequired = i.LoginProfile.PasswordResetRequired
}

// add aws_iam_user_login_profile
resourceConfigs = append(resourceConfigs, AWSResourceConfig{
Type: IamUserLoginProfile,
Name: i.UserName,
Metadata: i.AWSCloudFormationMetadata,
Resource: IamUserLoginProfileConfig{
Config: Config{
Name: i.UserName,
},
PasswordResetRequired: i.LoginProfile.PasswordResetRequired,
},
Resource: iamLoginProfileConfig,
})

// add aws_iam_user_policy
Expand Down

0 comments on commit 9baa8ef

Please sign in to comment.