@@ -151,10 +151,14 @@ private module FStream {
151
151
/**
152
152
* Gets a reference to a method in the `fstream` library.
153
153
*/
154
- private DataFlow:: SourceNode getAnFStreamProperty ( ) {
154
+ private DataFlow:: SourceNode getAnFStreamProperty ( boolean writer ) {
155
155
exists ( DataFlow:: SourceNode mod , string readOrWrite , string subMod |
156
156
mod = DataFlow:: moduleImport ( "fstream" ) and
157
- ( readOrWrite = "Reader" or readOrWrite = "Writer" ) and
157
+ (
158
+ readOrWrite = "Reader" and writer = false
159
+ or
160
+ readOrWrite = "Writer" and writer = true
161
+ ) and
158
162
( subMod = "File" or subMod = "Dir" or subMod = "Link" or subMod = "Proxy" )
159
163
|
160
164
result = mod .getAPropertyRead ( readOrWrite ) or
@@ -167,7 +171,9 @@ private module FStream {
167
171
* An invocation of a method defined in the `fstream` library.
168
172
*/
169
173
private class FStream extends FileSystemAccess , DataFlow:: InvokeNode {
170
- FStream ( ) { this = getAnFStreamProperty ( ) .getAnInvocation ( ) }
174
+ boolean writer ;
175
+
176
+ FStream ( ) { this = getAnFStreamProperty ( writer ) .getAnInvocation ( ) }
171
177
172
178
override DataFlow:: Node getAPathArgument ( ) {
173
179
result = getOptionArgument ( 0 , "path" )
@@ -176,6 +182,24 @@ private module FStream {
176
182
result = getArgument ( 0 )
177
183
}
178
184
}
185
+
186
+ /**
187
+ * An invocation of an `fstream` method that writes to a file.
188
+ */
189
+ private class FStreamWriter extends FileSystemWriteAccess , FStream {
190
+ FStreamWriter ( ) { writer = true }
191
+
192
+ override DataFlow:: Node getADataNode ( ) { none ( ) }
193
+ }
194
+
195
+ /**
196
+ * An invocation of an `fstream` method that reads a file.
197
+ */
198
+ private class FStreamReader extends FileSystemReadAccess , FStream {
199
+ FStreamReader ( ) { writer = false }
200
+
201
+ override DataFlow:: Node getADataNode ( ) { none ( ) }
202
+ }
179
203
}
180
204
181
205
/**
0 commit comments