diff --git a/common/tagging/tags/git_modifiers.go b/common/tagging/tags/git_modifiers.go index 7e7f4d65..87b9dcb6 100644 --- a/common/tagging/tags/git_modifiers.go +++ b/common/tagging/tags/git_modifiers.go @@ -21,10 +21,14 @@ func (t *GitModifiersTag) CalculateValue(data interface{}) error { if !ok { return fmt.Errorf("failed to convert data to *GitBlame, which is required to calculte tag value. Type of data: %s", reflect.TypeOf(data)) } + foundModifyingUsers := make(map[string]bool) var modifyingUsers []string for _, v := range gitBlame.BlamesByLine { userName := strings.Split(v.Author, "@")[0] - modifyingUsers = append(modifyingUsers, userName) + if !foundModifyingUsers[userName] { + modifyingUsers = append(modifyingUsers, userName) + foundModifyingUsers[userName] = true + } } sort.Strings(modifyingUsers) diff --git a/terraform/structure/terraform_parser.go b/terraform/structure/terraform_parser.go index 682f9836..be177b27 100644 --- a/terraform/structure/terraform_parser.go +++ b/terraform/structure/terraform_parser.go @@ -6,18 +6,19 @@ import ( "bridgecrewio/yor/common/structure" "bridgecrewio/yor/common/tagging/tags" "fmt" - "github.com/hashicorp/go-hclog" - "github.com/hashicorp/hcl/v2" - "github.com/hashicorp/hcl/v2/hclsyntax" - "github.com/hashicorp/hcl/v2/hclwrite" - "github.com/minamijoyo/tfschema/tfschema" - "github.com/zclconf/go-cty/cty" "io/ioutil" "os" "path/filepath" "reflect" "strconv" "strings" + + "github.com/hashicorp/go-hclog" + "github.com/hashicorp/hcl/v2" + "github.com/hashicorp/hcl/v2/hclsyntax" + "github.com/hashicorp/hcl/v2/hclwrite" + "github.com/minamijoyo/tfschema/tfschema" + "github.com/zclconf/go-cty/cty" ) var prefixToTagAttribute = map[string]string{"aws": "tags", "azure": "tags", "gcp": "labels"} diff --git a/tests/utils/utils.go b/tests/utils/utils.go index 24228307..c67efc4a 100644 --- a/tests/utils/utils.go +++ b/tests/utils/utils.go @@ -46,6 +46,12 @@ func SetupBlame(t *testing.T) gitservice.GitBlame { Date: secondCommitDate, Hash: plumbing.NewHash(CommitHash2), }, + 2: { + Author: "jonjozwiak@users.noreply.github.com", + Text: "Bridgecrew solution to create vulnerable infrastructure", + Date: secondCommitDate, + Hash: plumbing.NewHash(CommitHash2), + }, }, } }