mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Add squirrel models
This commit is contained in:
committed by
Owen Mansel-Chan
parent
6d61820c92
commit
a8c3ef9500
@@ -6,6 +6,38 @@ extensions:
|
||||
- ["squirrel", "github.com/Masterminds/squirrel"]
|
||||
- ["squirrel", "gopkg.in/Masterminds/squirrel"]
|
||||
- ["squirrel", "github.com/lann/squirrel"]
|
||||
- addsTo:
|
||||
pack: codeql/go-all
|
||||
extensible: sourceModel
|
||||
data:
|
||||
- ["group:squirrel", "", True, "QueryContextWith", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "", True, "QueryRowContextWith", "", "", "ReturnValue", "database", "manual"]
|
||||
- ["group:squirrel", "", True, "QueryRowWith", "", "", "ReturnValue", "database", "manual"]
|
||||
- ["group:squirrel", "", True, "QueryWith", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "DeleteBuilder", True, "Query", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "DeleteBuilder", True, "QueryContext", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "DeleteBuilder", True, "QueryRow", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "DeleteBuilder", True, "QueryRowContext", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "InsertBuilder", True, "Query", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "InsertBuilder", True, "QueryContext", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "InsertBuilder", True, "QueryRow", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "InsertBuilder", True, "QueryRowContext", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "QueryRower", True, "QueryRow", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "QueryRowerContext", True, "QueryRowContext", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "Queryer", True, "Query", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "QueryerContext", True, "QueryContext", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "SelectBuilder", True, "Query", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "SelectBuilder", True, "QueryContext", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "SelectBuilder", True, "QueryRow", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "SelectBuilder", True, "QueryRowContext", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "StdSql", True, "Query", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "StdSql", True, "QueryRow", "", "", "ReturnValue", "database", "manual"]
|
||||
- ["group:squirrel", "StdSqlCtx", True, "QueryContext", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "StdSqlCtx", True, "QueryRowContext", "", "", "ReturnValue", "database", "manual"]
|
||||
- ["group:squirrel", "UpdateBuilder", True, "Query", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "UpdateBuilder", True, "QueryContext", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "UpdateBuilder", True, "QueryRow", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- ["group:squirrel", "UpdateBuilder", True, "QueryRowContext", "", "", "ReturnValue[0]", "database", "manual"]
|
||||
- addsTo:
|
||||
pack: codeql/go-all
|
||||
extensible: sinkModel
|
||||
|
||||
@@ -57,6 +57,7 @@ import semmle.go.frameworks.Protobuf
|
||||
import semmle.go.frameworks.Revel
|
||||
import semmle.go.frameworks.Spew
|
||||
import semmle.go.frameworks.SQL
|
||||
import semmle.go.frameworks.Squirrel
|
||||
import semmle.go.frameworks.Stdlib
|
||||
import semmle.go.frameworks.SystemCommandExecutors
|
||||
import semmle.go.frameworks.Testing
|
||||
|
||||
85
go/ql/lib/semmle/go/frameworks/Squirrel.qll
Normal file
85
go/ql/lib/semmle/go/frameworks/Squirrel.qll
Normal file
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* Provides classes modeling security-relevant aspects of the `squirrel` ORM package.
|
||||
*/
|
||||
|
||||
import go
|
||||
|
||||
/**
|
||||
* Provides classes modeling security-relevant aspects of the `squirrel` ORM package.
|
||||
*/
|
||||
module Squirrel {
|
||||
private string packagePath() {
|
||||
result =
|
||||
package([
|
||||
"github.com/Masterminds/squirrel",
|
||||
"github.com/lann/squirrel",
|
||||
"gopkg.in/Masterminds/squirrel",
|
||||
], "")
|
||||
}
|
||||
|
||||
private class RowScan extends TaintTracking::FunctionModel, Method {
|
||||
FunctionInput inp;
|
||||
FunctionOutput outp;
|
||||
|
||||
RowScan() {
|
||||
// signature: func (rs *RowScanner) Scan(dest ...interface{}) error
|
||||
this.hasQualifiedName(packagePath(), "Row", "Scan") and
|
||||
inp.isReceiver() and
|
||||
outp.isParameter(_)
|
||||
}
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
||||
input = inp and output = outp
|
||||
}
|
||||
}
|
||||
|
||||
private class RowScannerScan extends TaintTracking::FunctionModel, Method {
|
||||
FunctionInput inp;
|
||||
FunctionOutput outp;
|
||||
|
||||
RowScannerScan() {
|
||||
// signature: func (rs *RowScanner) Scan(dest ...interface{}) error
|
||||
this.hasQualifiedName(packagePath(), "RowScanner", "Scan") and
|
||||
inp.isReceiver() and
|
||||
outp.isParameter(_)
|
||||
}
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
||||
input = inp and output = outp
|
||||
}
|
||||
}
|
||||
|
||||
private class BuilderScan extends TaintTracking::FunctionModel, Method {
|
||||
FunctionInput inp;
|
||||
FunctionOutput outp;
|
||||
|
||||
BuilderScan() {
|
||||
// signature: func (rs *InsertBuilder) Scan(dest ...interface{}) error
|
||||
this.hasQualifiedName(packagePath(),
|
||||
["DeleteBuilder", "InsertBuilder", "SelectBuilder", "UpdateBuilder"], "Scan") and
|
||||
inp.isReceiver() and
|
||||
outp.isParameter(_)
|
||||
}
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
||||
input = inp and output = outp
|
||||
}
|
||||
}
|
||||
|
||||
private class BuilderScanContext extends TaintTracking::FunctionModel, Method {
|
||||
FunctionInput inp;
|
||||
FunctionOutput outp;
|
||||
|
||||
BuilderScanContext() {
|
||||
// signature: func (rs *InsertBuilder) ScanContext(ctx context.Context, dest ...interface{}) error
|
||||
this.hasQualifiedName(packagePath(),
|
||||
["DeleteBuilder", "InsertBuilder", "SelectBuilder", "UpdateBuilder"], "ScanContext") and
|
||||
inp.isReceiver() and
|
||||
exists(int i | i > 0 | outp.isParameter(i))
|
||||
}
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
||||
input = inp and output = outp
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user