mirror of
https://github.com/github/codeql.git
synced 2026-02-19 08:23:45 +01:00
Ruby: Model ActiveRecord::Relation#touch_all
This commit is contained in:
@@ -359,7 +359,7 @@ private module Persistence {
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `call` has a keyword argument of with value `value`.
|
||||
* Holds if `call` has a keyword argument with value `value`.
|
||||
*/
|
||||
private predicate keywordArgumentWithValue(DataFlow::CallNode call, DataFlow::ExprNode value) {
|
||||
exists(ExprNodes::PairCfgNode pair | pair = call.getArgument(_).asExpr() |
|
||||
@@ -412,6 +412,28 @@ private module Persistence {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A call to `ActiveRecord::Relation#touch_all`, which updates the `updated_at`
|
||||
* attribute on all records in the relation, setting it to the current time or
|
||||
* the time specified. If passed additional attribute names, they will also be
|
||||
* updated with the time.
|
||||
* Examples:
|
||||
* ```rb
|
||||
* Person.all.touch_all
|
||||
* Person.where(name: "David").touch_all
|
||||
* Person.all.touch_all(:created_at)
|
||||
* Person.all.touch_all(time: Time.new(2020, 5, 16, 0, 0, 0))
|
||||
* ```
|
||||
*/
|
||||
private class TouchAllCall extends DataFlow::CallNode, PersistentWriteAccess::Range {
|
||||
TouchAllCall() {
|
||||
exists(this.asExpr().getExpr().(ActiveRecordModelClassMethodCall).getReceiverClass()) and
|
||||
this.getMethodName() = "touch_all"
|
||||
}
|
||||
|
||||
override DataFlow::Node getValue() { result = this.getKeywordArgument("time") }
|
||||
}
|
||||
|
||||
/** A call to e.g. `User.insert_all([{name: "foo"}, {name: "bar"}])` */
|
||||
private class InsertAllLikeCall extends DataFlow::CallNode, PersistentWriteAccess::Range {
|
||||
private ExprNodes::ArrayLiteralCfgNode arr;
|
||||
|
||||
Reference in New Issue
Block a user