@@ -2,11 +2,54 @@ private import codeql.ruby.AST
22private import codeql.ruby.ApiGraphs
33private import codeql.ruby.Concepts
44private import codeql.ruby.DataFlow
5+ private import codeql.ruby.dataflow.FlowSummary
56
7+ /** Defines calls to `ActiveStorage::Filename#sanitized` as path sanitizers. */
68class ActiveStorageFilenameSanitizedCall extends Path:: PathSanitization:: Range , DataFlow:: CallNode {
79 ActiveStorageFilenameSanitizedCall ( ) {
810 this .getReceiver ( ) =
911 API:: getTopLevelMember ( "ActiveStorage" ) .getMember ( "Filename" ) .getAnInstantiation ( ) and
1012 this .asExpr ( ) .getExpr ( ) .( MethodCall ) .getMethodName ( ) = "sanitized"
1113 }
1214}
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