@@ -81,47 +81,42 @@ module Fasthttp {
81
81
}
82
82
}
83
83
84
- private predicate responseBodyWriterResult ( DataFlow:: Node src ) {
85
- exists ( Method responseBodyWriter |
86
- responseBodyWriter .hasQualifiedName ( packagePath ( ) , "Response" , "BodyWriter" ) and
87
- src = responseBodyWriter .getACall ( ) .getResult ( 0 )
88
- )
89
- }
90
-
91
- private module ResponseBodyWriterFlow = DataFlow:: SimpleGlobal< responseBodyWriterResult / 1 > ;
92
-
93
84
private class ResponseBody extends Http:: ResponseBody:: Range {
94
85
DataFlow:: MethodCallNode call ;
95
- string methodName ;
96
86
97
87
ResponseBody ( ) {
98
88
exists ( Method m |
99
- m .hasQualifiedName ( packagePath ( ) , "Response" , methodName ) and
89
+ m .hasQualifiedName ( packagePath ( ) , "Response" ,
90
+ [
91
+ "AppendBody" , "AppendBodyString" , "SetBody" , "SetBodyRaw" , "SetBodyStream" ,
92
+ "SetBodyString" , "Success" , "SuccessString"
93
+ ] ) and
100
94
call = m .getACall ( ) and
101
95
this = call .getArgument ( 0 )
102
96
or
103
97
m .hasQualifiedName ( packagePath ( ) , "RequestCtx" , [ "Success" , "SuccessString" ] ) and
104
98
call = m .getACall ( ) and
105
99
this = call .getArgument ( 1 )
106
- ) and
107
- methodName =
108
- [
109
- "AppendBody" , "AppendBodyString" , "SetBody" , "SetBodyRaw" , "SetBodyStream" ,
110
- "SetBodyString" , "Success" , "SuccessString"
111
- ]
100
+ )
101
+ or
102
+ exists ( Method responseBodyWriter , DataFlow:: CallNode writerCall |
103
+ responseBodyWriter .hasQualifiedName ( packagePath ( ) , "Response" , "BodyWriter" ) and
104
+ call = responseBodyWriter .getACall ( ) and
105
+ writerCall = any ( Method write | write .hasQualifiedName ( "io" , "Writer" , "Write" ) ) .getACall ( ) and
106
+ this = writerCall .getArgument ( 0 ) and
107
+ DataFlow:: localFlow ( call .getResult ( 0 ) , writerCall .getReceiver ( ) )
108
+ )
112
109
or
113
- exists ( Method write , DataFlow:: CallNode writeCall |
114
- write .hasQualifiedName ( "io" , "Writer " , "Write " ) and
115
- writeCall = write .getACall ( ) and
116
- ResponseBodyWriterFlow :: flowsTo ( writeCall . getReceiver ( ) ) and
117
- this = writeCall . getArgument ( 0 )
118
- ) and
119
- methodName = "BodyWriter"
110
+ exists ( Method responseBodyWriter , DataFlow:: CallNode writerCall |
111
+ responseBodyWriter .hasQualifiedName ( packagePath ( ) , "Response " , "BodyWriter " ) and
112
+ call = responseBodyWriter .getACall ( ) and
113
+ writerCall = any ( Function fprintf | fprintf . hasQualifiedName ( "fmt" , "Fprintf" ) ) . getACall ( ) and
114
+ this = writerCall . getSyntacticArgument ( any ( int i | i > 1 ) ) and
115
+ DataFlow :: localFlow ( call . getResult ( 0 ) , writerCall . getArgument ( 0 ) )
116
+ )
120
117
}
121
118
122
119
override Http:: ResponseWriter getResponseWriter ( ) { result .getANode ( ) = call .getReceiver ( ) }
123
-
124
- override string getAContentType ( ) { result = super .getAContentType ( ) }
125
120
}
126
121
127
122
/**
0 commit comments