Skip to content

Commit 84131dd

Browse files
committed
Add Client::Watch
1 parent 91b6b3f commit 84131dd

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

go/ql/lib/ext/go.mongodb.org.mongo-driver.mongo.model.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ extensions:
33
pack: codeql/go-all
44
extensible: sourceModel
55
data:
6+
- ["go.mongodb.org/mongo-driver/mongo", "Client", True, "Watch", "", "", "ReturnValue[0]", "database", "manual"]
67
- ["go.mongodb.org/mongo-driver/mongo", "Collection", True, "Aggregate", "", "", "ReturnValue[0]", "database", "manual"]
78
- ["go.mongodb.org/mongo-driver/mongo", "Collection", True, "Distinct", "", "", "ReturnValue[0]", "database", "manual"]
89
- ["go.mongodb.org/mongo-driver/mongo", "Collection", True, "Find", "", "", "ReturnValue[0]", "database", "manual"]

go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/database/test_mongo_driver_mongo.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,16 @@ func test_mongo_driver_mongo_database(db *mongo.Database, ctx context.Context, p
104104
sink(userCs) // $ hasTaintFlow="userCs"
105105
}
106106
}
107+
108+
func test_mongo_driver_mongo_Client(client *mongo.Client, ctx context.Context) {
109+
changestream, err := client.Watch(ctx, nil) // $ source
110+
if err != nil {
111+
return
112+
}
113+
114+
for changestream.Next(ctx) {
115+
var user User
116+
changestream.Decode(&user)
117+
sink(user) // $ hasTaintFlow="user"
118+
}
119+
}

0 commit comments

Comments
 (0)