@@ -29,6 +29,7 @@ import semmle.go.frameworks.stdlib.EncodingPem
29
29
import semmle.go.frameworks.stdlib.EncodingXml
30
30
import semmle.go.frameworks.stdlib.Html
31
31
import semmle.go.frameworks.stdlib.HtmlTemplate
32
+ import semmle.go.frameworks.stdlib.Io
32
33
import semmle.go.frameworks.stdlib.Path
33
34
import semmle.go.frameworks.stdlib.PathFilepath
34
35
import semmle.go.frameworks.stdlib.Reflect
@@ -145,226 +146,6 @@ module Fmt {
145
146
}
146
147
}
147
148
148
- /** Provides models of commonly used functions in the `io` package. */
149
- module Io {
150
- private class Copy extends TaintTracking:: FunctionModel {
151
- Copy ( ) {
152
- // func Copy(dst Writer, src Reader) (written int64, err error)
153
- // func CopyBuffer(dst Writer, src Reader, buf []byte) (written int64, err error)
154
- // func CopyN(dst Writer, src Reader, n int64) (written int64, err error)
155
- hasQualifiedName ( "io" , "Copy" ) or
156
- hasQualifiedName ( "io" , "CopyBuffer" ) or
157
- hasQualifiedName ( "io" , "CopyN" )
158
- }
159
-
160
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
161
- input .isParameter ( 1 ) and output .isParameter ( 0 )
162
- }
163
- }
164
-
165
- private class Pipe extends TaintTracking:: FunctionModel {
166
- Pipe ( ) {
167
- // func Pipe() (*PipeReader, *PipeWriter)
168
- hasQualifiedName ( "io" , "Pipe" )
169
- }
170
-
171
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
172
- input .isResult ( 0 ) and output .isResult ( 1 )
173
- }
174
- }
175
-
176
- private class ReadAtLeast extends TaintTracking:: FunctionModel {
177
- ReadAtLeast ( ) {
178
- // func ReadAtLeast(r Reader, buf []byte, min int) (n int, err error)
179
- // func ReadFull(r Reader, buf []byte) (n int, err error)
180
- hasQualifiedName ( "io" , "ReadAtLeast" ) or
181
- hasQualifiedName ( "io" , "ReadFull" )
182
- }
183
-
184
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
185
- input .isParameter ( 0 ) and output .isParameter ( 1 )
186
- }
187
- }
188
-
189
- private class WriteString extends TaintTracking:: FunctionModel {
190
- WriteString ( ) {
191
- // func WriteString(w Writer, s string) (n int, err error)
192
- this .hasQualifiedName ( "io" , "WriteString" )
193
- }
194
-
195
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
196
- input .isParameter ( 1 ) and output .isParameter ( 0 )
197
- }
198
- }
199
-
200
- private class ByteReaderReadByte extends TaintTracking:: FunctionModel , Method {
201
- ByteReaderReadByte ( ) {
202
- // func ReadByte() (byte, error)
203
- this .implements ( "io" , "ByteReader" , "ReadByte" )
204
- }
205
-
206
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
207
- input .isReceiver ( ) and output .isResult ( 0 )
208
- }
209
- }
210
-
211
- private class ByteWriterWriteByte extends TaintTracking:: FunctionModel , Method {
212
- ByteWriterWriteByte ( ) {
213
- // func WriteByte(c byte) error
214
- this .implements ( "io" , "ByteWriter" , "WriteByte" )
215
- }
216
-
217
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
218
- input .isParameter ( 0 ) and output .isReceiver ( )
219
- }
220
- }
221
-
222
- private class ReaderRead extends TaintTracking:: FunctionModel , Method {
223
- ReaderRead ( ) {
224
- // func Read(p []byte) (n int, err error)
225
- this .implements ( "io" , "Reader" , "Read" )
226
- }
227
-
228
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
229
- input .isReceiver ( ) and output .isParameter ( 0 )
230
- }
231
- }
232
-
233
- private class LimitReader extends TaintTracking:: FunctionModel {
234
- LimitReader ( ) {
235
- // func LimitReader(r Reader, n int64) Reader
236
- this .hasQualifiedName ( "io" , "LimitReader" )
237
- }
238
-
239
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
240
- input .isParameter ( 0 ) and output .isResult ( )
241
- }
242
- }
243
-
244
- private class MultiReader extends TaintTracking:: FunctionModel {
245
- MultiReader ( ) {
246
- // func MultiReader(readers ...Reader) Reader
247
- this .hasQualifiedName ( "io" , "MultiReader" )
248
- }
249
-
250
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
251
- input .isParameter ( _) and output .isResult ( )
252
- }
253
- }
254
-
255
- private class TeeReader extends TaintTracking:: FunctionModel {
256
- TeeReader ( ) {
257
- // func TeeReader(r Reader, w Writer) Reader
258
- this .hasQualifiedName ( "io" , "TeeReader" )
259
- }
260
-
261
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
262
- input .isParameter ( 0 ) and output .isResult ( )
263
- or
264
- input .isParameter ( 0 ) and output .isParameter ( 1 )
265
- }
266
- }
267
-
268
- private class ReaderAtReadAt extends TaintTracking:: FunctionModel , Method {
269
- ReaderAtReadAt ( ) {
270
- // func ReadAt(p []byte, off int64) (n int, err error)
271
- this .implements ( "io" , "ReaderAt" , "ReadAt" )
272
- }
273
-
274
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
275
- input .isReceiver ( ) and output .isParameter ( 0 )
276
- }
277
- }
278
-
279
- private class ReaderFromReadFrom extends TaintTracking:: FunctionModel , Method {
280
- ReaderFromReadFrom ( ) {
281
- // func ReadFrom(r Reader) (n int64, err error)
282
- this .implements ( "io" , "ReaderFrom" , "ReadFrom" )
283
- }
284
-
285
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
286
- input .isParameter ( 0 ) and output .isReceiver ( )
287
- }
288
- }
289
-
290
- private class RuneReaderReadRune extends TaintTracking:: FunctionModel , Method {
291
- RuneReaderReadRune ( ) {
292
- // func ReadRune() (r rune, size int, err error)
293
- this .implements ( "io" , "RuneReader" , "ReadRune" )
294
- }
295
-
296
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
297
- input .isReceiver ( ) and output .isResult ( 0 )
298
- }
299
- }
300
-
301
- private class NewSectionReader extends TaintTracking:: FunctionModel {
302
- NewSectionReader ( ) {
303
- // func NewSectionReader(r ReaderAt, off int64, n int64) *SectionReader
304
- this .hasQualifiedName ( "io" , "NewSectionReader" )
305
- }
306
-
307
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
308
- input .isParameter ( 0 ) and output .isResult ( )
309
- }
310
- }
311
-
312
- private class StringWriterWriteString extends TaintTracking:: FunctionModel , Method {
313
- StringWriterWriteString ( ) {
314
- // func WriteString(s string) (n int, err error)
315
- this .implements ( "io" , "StringWriter" , "WriteString" )
316
- }
317
-
318
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
319
- input .isParameter ( 0 ) and output .isReceiver ( )
320
- }
321
- }
322
-
323
- private class WriterWrite extends TaintTracking:: FunctionModel , Method {
324
- WriterWrite ( ) {
325
- // func Write(p []byte) (n int, err error)
326
- this .implements ( "io" , "Writer" , "Write" )
327
- }
328
-
329
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
330
- input .isParameter ( 0 ) and output .isReceiver ( )
331
- }
332
- }
333
-
334
- private class MultiWriter extends TaintTracking:: FunctionModel {
335
- MultiWriter ( ) {
336
- // func MultiWriter(writers ...Writer) Writer
337
- hasQualifiedName ( "io" , "MultiWriter" )
338
- }
339
-
340
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
341
- input .isResult ( ) and output .isParameter ( _)
342
- }
343
- }
344
-
345
- private class WriterAtWriteAt extends TaintTracking:: FunctionModel , Method {
346
- WriterAtWriteAt ( ) {
347
- // func WriteAt(p []byte, off int64) (n int, err error)
348
- this .implements ( "io" , "WriterAt" , "WriteAt" )
349
- }
350
-
351
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
352
- input .isParameter ( 0 ) and output .isReceiver ( )
353
- }
354
- }
355
-
356
- private class WriterToWriteTo extends TaintTracking:: FunctionModel , Method {
357
- WriterToWriteTo ( ) {
358
- // func WriteTo(w Writer) (n int64, err error)
359
- this .implements ( "io" , "WriterTo" , "WriteTo" )
360
- }
361
-
362
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
363
- input .isReceiver ( ) and output .isParameter ( 0 )
364
- }
365
- }
366
- }
367
-
368
149
/** Provides models of commonly used functions in the `io/ioutil` package. */
369
150
module IoUtil {
370
151
private class IoUtilFileSystemAccess extends FileSystemAccess:: Range , DataFlow:: CallNode {
0 commit comments