-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Go: Add database
source models for the squirrel
package (#2)
#19090
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a8c3ef9
Add squirrel models
egregius313 4ab5d34
Add fake `Source` function and models
egregius313 c5f5427
Add test for `squirrel` package
egregius313 59ad30d
Change note
egregius313 1de15ec
Fix signatures in comments
owen-mc 09d6929
Fix package name in stub
owen-mc bbed79c
Add squirrel to go.mod
owen-mc bf82a87
Rename model file to fix typo
owen-mc 0fbeef8
Remove model for method that doesn't exist
owen-mc 8bc70be
Address review comments
owen-mc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
category: minorAnalysis | ||
--- | ||
* Added `database` source models for the `github.com/Masterminds/squirrel` ORM package. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 (r *Row) 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 (b {Insert,Delete,Select,Update}Builder) 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 (b {Insert,Delete,Select,Update}Builder) 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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a comment to the yml models pointing out there are also QL models and vice versa