|
| 1 | +/** |
| 2 | + * Provides classes modeling security-relevant aspects of the `net/textproto` package. |
| 3 | + */ |
| 4 | + |
| 5 | +import go |
| 6 | + |
| 7 | +/** Provides models of commonly used functions in the `net/textproto` package. */ |
| 8 | +module NetTextproto { |
| 9 | + private class FunctionModels extends TaintTracking::FunctionModel { |
| 10 | + FunctionInput inp; |
| 11 | + FunctionOutput outp; |
| 12 | + |
| 13 | + FunctionModels() { |
| 14 | + // signature: func CanonicalMIMEHeaderKey(s string) string |
| 15 | + hasQualifiedName("net/textproto", "CanonicalMIMEHeaderKey") and |
| 16 | + (inp.isParameter(0) and outp.isResult()) |
| 17 | + or |
| 18 | + // signature: func NewConn(conn io.ReadWriteCloser) *Conn |
| 19 | + hasQualifiedName("net/textproto", "NewConn") and |
| 20 | + ( |
| 21 | + inp.isParameter(0) and outp.isResult() |
| 22 | + or |
| 23 | + inp.isResult() and outp.isParameter(0) |
| 24 | + ) |
| 25 | + or |
| 26 | + // signature: func NewReader(r *bufio.Reader) *Reader |
| 27 | + hasQualifiedName("net/textproto", "NewReader") and |
| 28 | + (inp.isParameter(0) and outp.isResult()) |
| 29 | + or |
| 30 | + // signature: func NewWriter(w *bufio.Writer) *Writer |
| 31 | + hasQualifiedName("net/textproto", "NewWriter") and |
| 32 | + (inp.isResult() and outp.isParameter(0)) |
| 33 | + or |
| 34 | + // signature: func TrimBytes(b []byte) []byte |
| 35 | + hasQualifiedName("net/textproto", "TrimBytes") and |
| 36 | + (inp.isParameter(0) and outp.isResult()) |
| 37 | + or |
| 38 | + // signature: func TrimString(s string) string |
| 39 | + hasQualifiedName("net/textproto", "TrimString") and |
| 40 | + (inp.isParameter(0) and outp.isResult()) |
| 41 | + } |
| 42 | + |
| 43 | + override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) { |
| 44 | + input = inp and output = outp |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + private class MethodModels extends TaintTracking::FunctionModel, Method { |
| 49 | + FunctionInput inp; |
| 50 | + FunctionOutput outp; |
| 51 | + |
| 52 | + MethodModels() { |
| 53 | + // signature: func (MIMEHeader).Add(key string, value string) |
| 54 | + this.hasQualifiedName("net/textproto", "MIMEHeader", "Add") and |
| 55 | + (inp.isParameter(_) and outp.isReceiver()) |
| 56 | + or |
| 57 | + // signature: func (MIMEHeader).Get(key string) string |
| 58 | + this.hasQualifiedName("net/textproto", "MIMEHeader", "Get") and |
| 59 | + (inp.isReceiver() and outp.isResult()) |
| 60 | + or |
| 61 | + // signature: func (MIMEHeader).Set(key string, value string) |
| 62 | + this.hasQualifiedName("net/textproto", "MIMEHeader", "Set") and |
| 63 | + (inp.isParameter(_) and outp.isReceiver()) |
| 64 | + or |
| 65 | + // signature: func (MIMEHeader).Values(key string) []string |
| 66 | + this.hasQualifiedName("net/textproto", "MIMEHeader", "Values") and |
| 67 | + (inp.isReceiver() and outp.isResult()) |
| 68 | + or |
| 69 | + // signature: func (*Reader).DotReader() io.Reader |
| 70 | + this.hasQualifiedName("net/textproto", "Reader", "DotReader") and |
| 71 | + (inp.isReceiver() and outp.isResult()) |
| 72 | + or |
| 73 | + // signature: func (*Reader).ReadCodeLine(expectCode int) (code int, message string, err error) |
| 74 | + this.hasQualifiedName("net/textproto", "Reader", "ReadCodeLine") and |
| 75 | + (inp.isReceiver() and outp.isResult(1)) |
| 76 | + or |
| 77 | + // signature: func (*Reader).ReadContinuedLine() (string, error) |
| 78 | + this.hasQualifiedName("net/textproto", "Reader", "ReadContinuedLine") and |
| 79 | + (inp.isReceiver() and outp.isResult(0)) |
| 80 | + or |
| 81 | + // signature: func (*Reader).ReadContinuedLineBytes() ([]byte, error) |
| 82 | + this.hasQualifiedName("net/textproto", "Reader", "ReadContinuedLineBytes") and |
| 83 | + (inp.isReceiver() and outp.isResult(0)) |
| 84 | + or |
| 85 | + // signature: func (*Reader).ReadDotBytes() ([]byte, error) |
| 86 | + this.hasQualifiedName("net/textproto", "Reader", "ReadDotBytes") and |
| 87 | + (inp.isReceiver() and outp.isResult(0)) |
| 88 | + or |
| 89 | + // signature: func (*Reader).ReadDotLines() ([]string, error) |
| 90 | + this.hasQualifiedName("net/textproto", "Reader", "ReadDotLines") and |
| 91 | + (inp.isReceiver() and outp.isResult(0)) |
| 92 | + or |
| 93 | + // signature: func (*Reader).ReadLine() (string, error) |
| 94 | + this.hasQualifiedName("net/textproto", "Reader", "ReadLine") and |
| 95 | + (inp.isReceiver() and outp.isResult(0)) |
| 96 | + or |
| 97 | + // signature: func (*Reader).ReadLineBytes() ([]byte, error) |
| 98 | + this.hasQualifiedName("net/textproto", "Reader", "ReadLineBytes") and |
| 99 | + (inp.isReceiver() and outp.isResult(0)) |
| 100 | + or |
| 101 | + // signature: func (*Reader).ReadMIMEHeader() (MIMEHeader, error) |
| 102 | + this.hasQualifiedName("net/textproto", "Reader", "ReadMIMEHeader") and |
| 103 | + (inp.isReceiver() and outp.isResult(0)) |
| 104 | + or |
| 105 | + // signature: func (*Reader).ReadResponse(expectCode int) (code int, message string, err error) |
| 106 | + this.hasQualifiedName("net/textproto", "Reader", "ReadResponse") and |
| 107 | + (inp.isReceiver() and outp.isResult(1)) |
| 108 | + or |
| 109 | + // signature: func (*Writer).DotWriter() io.WriteCloser |
| 110 | + this.hasQualifiedName("net/textproto", "Writer", "DotWriter") and |
| 111 | + (inp.isResult() and outp.isReceiver()) |
| 112 | + or |
| 113 | + // signature: func (*Writer).PrintfLine(format string, args ...interface{}) error |
| 114 | + this.hasQualifiedName("net/textproto", "Writer", "PrintfLine") and |
| 115 | + (inp.isParameter(_) and outp.isReceiver()) |
| 116 | + } |
| 117 | + |
| 118 | + override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) { |
| 119 | + input = inp and output = outp |
| 120 | + } |
| 121 | + } |
| 122 | +} |
0 commit comments