|
| 1 | +/** |
| 2 | + * Provides classes modeling security-relevant aspects of the `compress/zlib` package. |
| 3 | + */ |
| 4 | + |
| 5 | +import go |
| 6 | + |
| 7 | +/** Provides models of commonly used functions in the `compress/zlib` package. */ |
| 8 | +module CompressZlib { |
| 9 | + private class FunctionModels extends TaintTracking::FunctionModel { |
| 10 | + FunctionInput inp; |
| 11 | + FunctionOutput outp; |
| 12 | + |
| 13 | + FunctionModels() { |
| 14 | + // signature: func NewReader(r io.Reader) (io.ReadCloser, error) |
| 15 | + hasQualifiedName("compress/zlib", "NewReader") and |
| 16 | + (inp.isParameter(0) and outp.isResult(0)) |
| 17 | + or |
| 18 | + // signature: func NewReaderDict(r io.Reader, dict []byte) (io.ReadCloser, error) |
| 19 | + hasQualifiedName("compress/zlib", "NewReaderDict") and |
| 20 | + (inp.isParameter(0) and outp.isResult(0)) |
| 21 | + or |
| 22 | + // signature: func NewWriter(w io.Writer) *Writer |
| 23 | + hasQualifiedName("compress/zlib", "NewWriter") and |
| 24 | + (inp.isResult() and outp.isParameter(0)) |
| 25 | + or |
| 26 | + // signature: func NewWriterLevel(w io.Writer, level int) (*Writer, error) |
| 27 | + hasQualifiedName("compress/zlib", "NewWriterLevel") and |
| 28 | + (inp.isResult(0) and outp.isParameter(0)) |
| 29 | + or |
| 30 | + // signature: func NewWriterLevelDict(w io.Writer, level int, dict []byte) (*Writer, error) |
| 31 | + hasQualifiedName("compress/zlib", "NewWriterLevelDict") and |
| 32 | + (inp.isResult(0) and outp.isParameter(0)) |
| 33 | + } |
| 34 | + |
| 35 | + override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) { |
| 36 | + input = inp and output = outp |
| 37 | + } |
| 38 | + } |
| 39 | + |
| 40 | + private class MethodModels extends TaintTracking::FunctionModel, Method { |
| 41 | + FunctionInput inp; |
| 42 | + FunctionOutput outp; |
| 43 | + |
| 44 | + MethodModels() { |
| 45 | + // signature: func (*Writer).Reset(w io.Writer) |
| 46 | + this.hasQualifiedName("compress/zlib", "Writer", "Reset") and |
| 47 | + (inp.isReceiver() and outp.isParameter(0)) |
| 48 | + or |
| 49 | + // signature: func (*Writer).Write(p []byte) (n int, err error) |
| 50 | + this.hasQualifiedName("compress/zlib", "Writer", "Write") and |
| 51 | + (inp.isParameter(0) and outp.isReceiver()) |
| 52 | + or |
| 53 | + // signature: func (Resetter).Reset(r io.Reader, dict []byte) error |
| 54 | + this.implements("compress/zlib", "Resetter", "Reset") and |
| 55 | + (inp.isParameter(0) and outp.isReceiver()) |
| 56 | + } |
| 57 | + |
| 58 | + override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) { |
| 59 | + input = inp and output = outp |
| 60 | + } |
| 61 | + } |
| 62 | +} |
0 commit comments