-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathStdlib.qll
More file actions
105 lines (96 loc) · 3.84 KB
/
Stdlib.qll
File metadata and controls
105 lines (96 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/**
* Provides classes modeling security-relevant aspects of the standard libraries.
*/
overlay[local?]
module;
import go
import semmle.go.frameworks.stdlib.ArchiveTar
import semmle.go.frameworks.stdlib.ArchiveZip
import semmle.go.frameworks.stdlib.Bufio
import semmle.go.frameworks.stdlib.CompressFlate
import semmle.go.frameworks.stdlib.CompressGzip
import semmle.go.frameworks.stdlib.CompressLzw
import semmle.go.frameworks.stdlib.CompressZlib
import semmle.go.frameworks.stdlib.CryptoTls
import semmle.go.frameworks.stdlib.DatabaseSql
import semmle.go.frameworks.stdlib.EncodingAsn1
import semmle.go.frameworks.stdlib.EncodingCsv
import semmle.go.frameworks.stdlib.EncodingGob
import semmle.go.frameworks.stdlib.EncodingJson
import semmle.go.frameworks.stdlib.EncodingPem
import semmle.go.frameworks.stdlib.EncodingXml
import semmle.go.frameworks.stdlib.Errors
import semmle.go.frameworks.stdlib.Fmt
import semmle.go.frameworks.stdlib.Html
import semmle.go.frameworks.stdlib.HtmlTemplate
import semmle.go.frameworks.stdlib.Io
import semmle.go.frameworks.stdlib.IoFs
import semmle.go.frameworks.stdlib.Log
import semmle.go.frameworks.stdlib.MimeMultipart
import semmle.go.frameworks.stdlib.MimeQuotedprintable
import semmle.go.frameworks.stdlib.Net
import semmle.go.frameworks.stdlib.NetHttp
import semmle.go.frameworks.stdlib.NetHttpHttputil
import semmle.go.frameworks.stdlib.NetTextproto
import semmle.go.frameworks.stdlib.Os
import semmle.go.frameworks.stdlib.Path
import semmle.go.frameworks.stdlib.PathFilepath
import semmle.go.frameworks.stdlib.Reflect
import semmle.go.frameworks.stdlib.Regexp
import semmle.go.frameworks.stdlib.Strconv
import semmle.go.frameworks.stdlib.Strings
import semmle.go.frameworks.stdlib.Syscall
import semmle.go.frameworks.stdlib.TextTabwriter
import semmle.go.frameworks.stdlib.TextTemplate
import semmle.go.frameworks.stdlib.Unsafe
/** Provides a class for modeling functions which convert strings into integers. */
module IntegerParser {
/**
* A function that converts strings into integers.
*
* Extend this class to model new APIs. If you want to refine existing API models,
* extend `IntegerParser` instead.
*/
abstract class Range extends Function {
/**
* Gets the maximum bit size of the return value, if this makes
* sense, where 0 represents the bit size of `int` and `uint`.
*/
int getTargetBitSize() { none() }
/**
* Gets the `FunctionInput` containing the maximum bit size of the
* return value, if this makes sense. Note that if the value of the
* input is 0 then it means the bit size of `int` and `uint`.
*/
FunctionInput getTargetBitSizeInput() { none() }
/** Gets whether the function is for parsing signed or unsigned integers. */
boolean isSigned() { none() }
}
}
/** Provides models of commonly used functions in the `net/url` package. */
module Url {
// These are expressed using TaintTracking::FunctionModel because varargs functions don't work with Models-as-Data sumamries yet.
/** The `JoinPath` function. */
class JoinPath extends TaintTracking::FunctionModel {
JoinPath() { this.hasQualifiedName("net/url", "JoinPath") }
override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) {
inp.isParameter(_) and outp.isResult(0)
}
}
/** The method `URL.JoinPath`. */
class JoinPathMethod extends TaintTracking::FunctionModel, Method {
JoinPathMethod() { this.hasQualifiedName("net/url", "URL", "JoinPath") }
override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) {
(inp.isReceiver() or inp.isParameter(_)) and
outp.isResult(0)
}
}
/** A method that returns a part of a URL. */
class UrlGetter extends Method {
UrlGetter() {
exists(string m | this.hasQualifiedName("net/url", "URL", m) |
m = ["EscapedPath", "Hostname", "Port", "Query", "RequestURI"]
)
}
}
}