Skip to content

Commit

Permalink
chore: sig helper clone metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
rscampos committed Sep 20, 2024
1 parent 5cadb4a commit 9d62cbd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions signatures/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package helpers

import (
"fmt"
"maps"
"strings"

"github.com/aquasecurity/tracee/types/detect"
"github.com/aquasecurity/tracee/types/trace"
)

Expand Down Expand Up @@ -435,3 +437,13 @@ func GetProtoHTTPByName(

return trace.ProtoHTTP{}, fmt.Errorf("protocol HTTP: type error (should be trace.ProtoHTTP, is %T)", arg.Value)
}

// CloneMetadataProperties makes a shallow clone of the Metadata
// Properties map, ensuring that there is always a new reference to it.
//
// TODO: since this helper is a workaround to avoid data races,
// perhaps a better solution would be to convert Properties into
// a concrete structure.
func CloneMetadataProperties(m *detect.SignatureMetadata) {
m.Properties = maps.Clone(m.Properties)
}

0 comments on commit 9d62cbd

Please sign in to comment.