@@ -2,11 +2,54 @@ private import codeql.ruby.AST
2
2
private import codeql.ruby.ApiGraphs
3
3
private import codeql.ruby.Concepts
4
4
private import codeql.ruby.DataFlow
5
+ private import codeql.ruby.dataflow.FlowSummary
5
6
7
+ /** Defines calls to `ActiveStorage::Filename#sanitized` as path sanitizers. */
6
8
class ActiveStorageFilenameSanitizedCall extends Path:: PathSanitization:: Range , DataFlow:: CallNode {
7
9
ActiveStorageFilenameSanitizedCall ( ) {
8
10
this .getReceiver ( ) =
9
11
API:: getTopLevelMember ( "ActiveStorage" ) .getMember ( "Filename" ) .getAnInstantiation ( ) and
10
12
this .asExpr ( ) .getExpr ( ) .( MethodCall ) .getMethodName ( ) = "sanitized"
11
13
}
12
14
}
15
+
16
+ /** Taint summary for `ActiveStorage::Filename.new`. */
17
+ class ActiveStorageFilenameNewSummary extends SummarizedCallable {
18
+ ActiveStorageFilenameNewSummary ( ) { this = "ActiveStorage::Filename.new" }
19
+
20
+ override MethodCall getACall ( ) {
21
+ result =
22
+ API:: getTopLevelMember ( "ActiveStorage" )
23
+ .getMember ( "Filename" )
24
+ .getAnInstantiation ( )
25
+ .asExpr ( )
26
+ .getExpr ( )
27
+ }
28
+
29
+ override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
30
+ input = "Argument[0]" and
31
+ output = "ReturnValue" and
32
+ preservesValue = false
33
+ }
34
+ }
35
+
36
+ /** Taint summary for `ActiveStorage::Filename#sanitized`. */
37
+ class ActiveStorageFilenameSanitizedSummary extends SummarizedCallable {
38
+ ActiveStorageFilenameSanitizedSummary ( ) { this = "ActiveStorage::Filename#sanitized" }
39
+
40
+ override MethodCall getACall ( ) {
41
+ result =
42
+ API:: getTopLevelMember ( "ActiveStorage" )
43
+ .getMember ( "Filename" )
44
+ .getInstance ( )
45
+ .getAMethodCall ( "sanitized" )
46
+ .asExpr ( )
47
+ .getExpr ( )
48
+ }
49
+
50
+ override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
51
+ input = "Argument[-1]" and
52
+ output = "ReturnValue" and
53
+ preservesValue = false
54
+ }
55
+ }
0 commit comments