expose more marsdb calls as database accesses

This commit is contained in:
Esben Sparre Andreasen
2021-12-10 13:43:43 +01:00
parent 9df1ac7f75
commit b0f6cf1491
2 changed files with 19 additions and 2 deletions

View File

@@ -200,6 +200,7 @@ predicate isOtherModeledArgument(DataFlow::Node n, FilteringReason reason) {
or
call instanceof FileSystemAccess and reason instanceof FileSystemAccessReason
or
// TODO database accesses are less well defined than database query sinks, so this may cover unmodeled sinks
call instanceof DatabaseAccess and reason instanceof DatabaseAccessReason
or
call = DOM::domValueRef() and reason instanceof DOMReason

View File

@@ -618,14 +618,30 @@ private module Minimongo {
* Provides classes modeling the MarsDB library.
*/
private module MarsDB {
private class MarsDBAccess extends DatabaseAccess {
string method;
MarsDBAccess() {
this =
API::moduleImport("marsdb")
.getMember("Collection")
.getInstance()
.getMember(method)
.getACall()
}
string getMethod() { result = method }
override DataFlow::Node getAQueryArgument() { none() }
}
/** A call to a MarsDB query method. */
private class QueryCall extends DatabaseAccess, API::CallNode {
int queryArgIdx;
QueryCall() {
exists(string m |
this =
API::moduleImport("marsdb").getMember("Collection").getInstance().getMember(m).getACall() and
this.(MarsDBAccess).getMethod() = m and
// implements parts of the Minimongo interface
Minimongo::CollectionMethodSignatures::interpretsArgumentAsQuery(m, queryArgIdx)
)