-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganise into Custimizations file + add some more sinks on ActiveRe…
…cord methods
- Loading branch information
1 parent
07fd809
commit e9647c1
Showing
4 changed files
with
92 additions
and
47 deletions.
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
55 changes: 55 additions & 0 deletions
55
ruby/ql/lib/codeql/ruby/security/MassAssignmentCustomizations.qll
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,55 @@ | ||
/** | ||
* Provides default sources, sinks, sanitizers, and flow steps for | ||
* detecting insecure mass assignment, as well as extension points for adding your own. | ||
*/ | ||
|
||
private import codeql.ruby.AST | ||
private import codeql.ruby.DataFlow | ||
private import codeql.ruby.TaintTracking | ||
private import codeql.ruby.dataflow.RemoteFlowSources | ||
|
||
/** | ||
* Provides default sources, sinks, sanitizers, and flow steps for | ||
* detecting insecure mass assignment, as well as extension points for adding your own. | ||
*/ | ||
module MassAssignment { | ||
/** | ||
* A data flow source for user input used for mass assignment. | ||
*/ | ||
abstract class Source extends DataFlow::Node { } | ||
|
||
/** | ||
* A data flow sink for user input used for mass assignment. | ||
*/ | ||
abstract class Sink extends DataFlow::Node { } | ||
|
||
/** | ||
* A sanitizer for insecure mass assignment. | ||
*/ | ||
abstract class Sanitizer extends DataFlow::Node { } | ||
|
||
/** | ||
* A call that permits arbitrary parameters to be used for mass assignment. | ||
*/ | ||
abstract class MassPermit extends DataFlow::Node { | ||
/** Gets the argument for the parameters to be permitted */ | ||
abstract DataFlow::Node getParamsArgument(); | ||
|
||
/** Gets the result node of the permitted parameters. */ | ||
abstract DataFlow::Node getPermittedParamsResult(); | ||
} | ||
|
||
private class RemoteSource extends Source instanceof RemoteFlowSource { } | ||
|
||
private class PermitBangCall extends MassPermit instanceof DataFlow::CallNode { | ||
PermitBangCall() { this.asExpr().getExpr().(MethodCall).getMethodName() = "permit!" } | ||
|
||
override DataFlow::Node getParamsArgument() { result = this.(DataFlow::CallNode).getReceiver() } | ||
|
||
override DataFlow::Node getPermittedParamsResult() { | ||
result = this | ||
or | ||
result.(DataFlow::PostUpdateNode).getPreUpdateNode() = this.getParamsArgument() | ||
} | ||
} | ||
} |
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