Skip to content

Commit

Permalink
update anser
Browse files Browse the repository at this point in the history
  • Loading branch information
ybrill committed Nov 27, 2024
1 parent 816ec97 commit e5cf621
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
12 changes: 5 additions & 7 deletions environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/mongodb/jasper"
"github.com/pkg/errors"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsontype"
"go.mongodb.org/mongo-driver/mongo"
"go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws"
"go.opentelemetry.io/otel"
Expand Down Expand Up @@ -354,23 +353,22 @@ func getCollectionName(command bson.Raw) (string, error) {
if err != nil {
return "", errors.Wrap(err, "getting element value")
}
if v.Type != bsontype.String {
if v.Type != bson.TypeString {
return "", errors.Errorf("element value was of unexpected type '%s'", v.Type)
}
return v.StringValue(), nil
}

// redactSensitiveCollections satisfies the apm.CommandTransformer interface.
// Returns an empty string when the command is a CRUD command on a sensitive collection
// Returns nil when the command is a CRUD command on a sensitive collection
// or if we can't determine the collection the command is on.
func redactSensitiveCollections(command bson.Raw) string {
func redactSensitiveCollections(command bson.Raw) bson.Raw {
collectionName, err := getCollectionName(command)
if err != nil || utility.StringSliceContains(sensitiveCollections, collectionName) {
return ""
return nil
}

b, _ := bson.MarshalExtJSON(command, false, false)
return string(b)
return command
}

func (e *envState) initDB(ctx context.Context, settings DBSettings, tracer trace.Tracer) error {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ require (
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/mapstructure v1.5.0
github.com/mongodb/amboy v0.0.0-20240718152556-3b1827bc7168
github.com/mongodb/anser v0.0.0-20241029200935-fcf3befed0ea
github.com/mongodb/anser v0.0.0-20241127170517-ea9e8f6f8a85
github.com/mongodb/grip v0.0.0-20240213223901-f906268d82b9
github.com/pkg/errors v0.9.1
github.com/ravilushqa/otelgqlgen v0.15.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,8 @@ github.com/mongodb/amboy v0.0.0-20220408184825-b2a14e2c511d/go.mod h1:pyAwlkip3M
github.com/mongodb/amboy v0.0.0-20240718152556-3b1827bc7168 h1:7zT/+PDqVGZnn4KgJcIVdj/GWhpFOE4mD7U9nhQl36Q=
github.com/mongodb/amboy v0.0.0-20240718152556-3b1827bc7168/go.mod h1:XtYIRjheNi0/pf4NOV1qnyjdDncEpmUqAv4lRMIfBxo=
github.com/mongodb/anser v0.0.0-20220408164649-99dd61768f4a/go.mod h1:iiM0FTD1XWGSxZPdM3NkCQeZEqatn9lGqwIZy3RwtgE=
github.com/mongodb/anser v0.0.0-20241029200935-fcf3befed0ea h1:OxW95sY2iU6oD0vnDAdLqEMiJQ8abVxsfvInd6n3i1Q=
github.com/mongodb/anser v0.0.0-20241029200935-fcf3befed0ea/go.mod h1:S55HFuPbd6Fq0e6c/cRbZZlbpvaiIQ7KiS/yZFT/p1c=
github.com/mongodb/anser v0.0.0-20241127170517-ea9e8f6f8a85 h1:U46FETSU/Kwj96271zWp8eoImozOy8yzKCu+tdnZaWE=
github.com/mongodb/anser v0.0.0-20241127170517-ea9e8f6f8a85/go.mod h1:StO4IeoZVYpcnJ2rIt9A/+ulq/o39jUxO2cSbfm8sfM=
github.com/mongodb/ftdc v0.0.0-20211018154918-80dd1c22e4cf/go.mod h1:qd800FxWJIh4VUqu2d9Cmzdpv1CGXMqdwkntAKbaLlY=
github.com/mongodb/ftdc v0.0.0-20220401165013-13e4af55e809 h1:CQVEigRr2M/OFIPn+wQWerSadMioMY1cLp22yZX+Ygk=
github.com/mongodb/ftdc v0.0.0-20220401165013-13e4af55e809/go.mod h1:zz0HHFUU4/TOxl9TW4P9t3y3Ivx+sTWS2nwnhuYYRdw=
Expand Down

0 comments on commit e5cf621

Please sign in to comment.