Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

Commit

Permalink
Revert "added in adapters of codebuild (#1184)"
Browse files Browse the repository at this point in the history
This reverts commit ff5de60.
  • Loading branch information
simar7 committed May 3, 2023
1 parent d90254d commit 0ab1543
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 87 deletions.
22 changes: 1 addition & 21 deletions internal/adapters/cloud/aws/codebuild/adapt.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,32 +95,12 @@ func (a *adapter) adaptProject(name string) (*codebuild.Project, error) {
})
}

var encryptionkey, sourcetype string
if project.EncryptionKey != nil {
encryptionkey = *project.EncryptionKey
}

if project.Source != nil {
sourcetype = string(project.Source.Type)
}

var secondrysources []codebuild.SecondarySources
for _, s := range project.SecondarySources {
secondrysources = append(secondrysources, codebuild.SecondarySources{
Metadata: metadata,
Type: defsecTypes.String(string(s.Type), metadata),
})
}

return &codebuild.Project{
Metadata: metadata,
SourceType: defsecTypes.String(sourcetype, metadata),
EncryptionKey: defsecTypes.String(encryptionkey, metadata),
Metadata: metadata,
ArtifactSettings: codebuild.ArtifactSettings{
Metadata: metadata,
EncryptionEnabled: defsecTypes.Bool(encryptionEnabled, metadata),
},
SecondaryArtifactSettings: secondaryArtifactSettings,
SecondarySources: secondrysources,
}, nil
}
18 changes: 0 additions & 18 deletions internal/adapters/cloudformation/aws/codebuild/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@ func getProjects(ctx parser.FileContext) (projects []codebuild.Project) {
for _, r := range projectResources {
project := codebuild.Project{
Metadata: r.Metadata(),
EncryptionKey: r.GetStringProperty("EncryptionKey"),
SourceType: r.GetStringProperty("Source.Type"),
ArtifactSettings: getArtifactSettings(r),
SecondaryArtifactSettings: getSecondaryArtifactSettings(r),
SecondarySources: getSecondarySources(r),
}

projects = append(projects, project)
Expand Down Expand Up @@ -64,18 +61,3 @@ func getArtifactSettings(r *parser.Resource) codebuild.ArtifactSettings {

return settings
}

func getSecondarySources(r *parser.Resource) (secondarySources []codebuild.SecondarySources) {
secondarySourcesList := r.GetProperty("SecondarySources")
if secondarySourcesList.IsNil() || !secondarySourcesList.IsList() {
return
}

for _, s := range secondarySourcesList.AsList() {
secondarySources = append(secondarySources, codebuild.SecondarySources{
Metadata: s.Metadata(),
Type: s.GetStringProperty("Type"),
})
}
return secondarySources
}
17 changes: 1 addition & 16 deletions internal/adapters/terraform/aws/codebuild/adapt.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,12 @@ func adaptProjects(modules terraform.Modules) []codebuild.Project {
func adaptProject(resource *terraform.Block) codebuild.Project {

project := codebuild.Project{
Metadata: resource.GetMetadata(),
SourceType: types.StringDefault("", resource.GetMetadata()),
EncryptionKey: resource.GetAttribute("encryption_key").AsStringValueOrDefault("", resource),
Metadata: resource.GetMetadata(),
ArtifactSettings: codebuild.ArtifactSettings{
Metadata: resource.GetMetadata(),
EncryptionEnabled: types.BoolDefault(true, resource.GetMetadata()),
},
SecondaryArtifactSettings: nil,
SecondarySources: nil,
}

if sourceblock := resource.GetBlock("source"); sourceblock.IsNotNil() {
project.SourceType = sourceblock.GetAttribute("type").AsStringValueOrDefault("CODECOMMIT", sourceblock)
}

var hasArtifacts bool
Expand Down Expand Up @@ -69,13 +62,5 @@ func adaptProject(resource *terraform.Block) codebuild.Project {
})
}

secondrysources := resource.GetBlocks("secondary_sources")
for _, ss := range secondrysources {
project.SecondarySources = append(project.SecondarySources, codebuild.SecondarySources{
Metadata: ss.GetMetadata(),
Type: ss.GetAttribute("type").AsStringValueOrDefault("CODECOMMIT", ss),
})
}

return project
}
8 changes: 0 additions & 8 deletions pkg/providers/aws/codebuild/codebuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ type CodeBuild struct {

type Project struct {
Metadata defsecTypes.Metadata
SourceType defsecTypes.StringValue
EncryptionKey defsecTypes.StringValue
SecondarySources []SecondarySources
ArtifactSettings ArtifactSettings
SecondaryArtifactSettings []ArtifactSettings
}
Expand All @@ -21,8 +18,3 @@ type ArtifactSettings struct {
Metadata defsecTypes.Metadata
EncryptionEnabled defsecTypes.BoolValue
}

type SecondarySources struct {
Metadata defsecTypes.Metadata
Type defsecTypes.StringValue
}
24 changes: 0 additions & 24 deletions pkg/rego/schemas/cloud.json
Original file line number Diff line number Diff line change
Expand Up @@ -794,36 +794,12 @@
"type": "object",
"$ref": "#/definitions/github.aaakk.us.kg.aquasecurity.defsec.pkg.providers.aws.codebuild.ArtifactSettings"
},
"encryptionkey": {
"type": "object",
"$ref": "#/definitions/github.aaakk.us.kg.aquasecurity.defsec.pkg.types.StringValue"
},
"secondaryartifactsettings": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/github.aaakk.us.kg.aquasecurity.defsec.pkg.providers.aws.codebuild.ArtifactSettings"
}
},
"secondarysources": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/github.aaakk.us.kg.aquasecurity.defsec.pkg.providers.aws.codebuild.SecondarySources"
}
},
"sourcetype": {
"type": "object",
"$ref": "#/definitions/github.aaakk.us.kg.aquasecurity.defsec.pkg.types.StringValue"
}
}
},
"github.aaakk.us.kg.aquasecurity.defsec.pkg.providers.aws.codebuild.SecondarySources": {
"type": "object",
"properties": {
"type": {
"type": "object",
"$ref": "#/definitions/github.aaakk.us.kg.aquasecurity.defsec.pkg.types.StringValue"
}
}
},
Expand Down

0 comments on commit 0ab1543

Please sign in to comment.