Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 406ea74

Browse files
committed
Improve comment style
1 parent faf43ef commit 406ea74

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

ql/src/Security/CWE-352/ConstantOauth2State.ql

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,26 @@ class AuthCodeURL extends Method {
2121
}
2222

2323
/**
24-
* A flow of a constant string value to a call to AuthCodeURL as the
24+
* A flow of a constant string value to a call to `AuthCodeURL` as the
2525
* `state` parameter.
2626
*/
2727
class ConstantStateFlowConf extends DataFlow::Configuration {
2828
ConstantStateFlowConf() { this = "ConstantStateFlowConf" }
2929

30-
predicate isSource(DataFlow::Node source, Literal state) {
31-
state.isConst() and source.asExpr() = state and not DataFlow::isReturnedWithError(source)
32-
}
33-
3430
predicate isSink(DataFlow::Node sink, DataFlow::CallNode call) {
3531
exists(AuthCodeURL m | call = m.getACall() | sink = call.getArgument(0))
3632
}
3733

38-
override predicate isSource(DataFlow::Node source) { isSource(source, _) }
34+
override predicate isSource(DataFlow::Node source) {
35+
source.isConst() and not DataFlow::isReturnedWithError(source)
36+
}
3937

4038
override predicate isSink(DataFlow::Node sink) { isSink(sink, _) }
4139
}
4240

4341
/**
44-
* A flow of a URL indicating the OAuth redirect doesn't point to a publically
45-
* accessible address, to the receiver of an AuthCodeURL call.
42+
* A flow of a URL indicating the OAuth redirect doesn't point to a publicly
43+
* accessible address, to the receiver of an `AuthCodeURL` call.
4644
*
4745
* Note we accept localhost and 127.0.0.1 on the assumption this is probably a transient
4846
* listener; if it actually is a persistent server then that really is vulnerable to CSRF.
@@ -63,7 +61,9 @@ class PrivateUrlFlowsToAuthCodeUrlCall extends DataFlow::Configuration {
6361
}
6462

6563
/**
66-
* Propagates a URL written to a RedirectURL field to the whole Config object.
64+
* Holds if `pred` writes a URL to the `RedirectURL` field of the `succ` `Config` object.
65+
*
66+
* This propagates flow from the RedirectURL field to the whole Config object.
6767
*/
6868
predicate isUrlTaintingConfigStep(DataFlow::Node pred, DataFlow::Node succ) {
6969
exists(Write w, Field f | f.hasQualifiedName("golang.org/x/oauth2", "Config", "RedirectURL") |
@@ -94,8 +94,8 @@ class PrivateUrlFlowsToAuthCodeUrlCall extends DataFlow::Configuration {
9494
}
9595

9696
/**
97-
* Holds if a URL indicating the OAuth redirect doesn't point to a publically
98-
* accessible address, to the receiver of an AuthCodeURL call.
97+
* Holds if a URL indicating the OAuth redirect doesn't point to a publicly
98+
* accessible address, to the receiver of an `AuthCodeURL` call.
9999
*
100100
* Note we accept localhost and 127.0.0.1 on the assumption this is probably a transient
101101
* listener; if it actually is a persistent server then that really is vulnerable to CSRF.
@@ -107,7 +107,7 @@ predicate privateUrlFlowsToAuthCodeUrlCall(DataFlow::CallNode call) {
107107
)
108108
}
109109

110-
/** A flow to a printer function of the fmt package. */
110+
/** A flow from `golang.org/x/oauth2.Config.AuthCodeURL`'s result to a logging function. */
111111
class FlowToPrint extends DataFlow::Configuration {
112112
FlowToPrint() { this = "FlowToPrint" }
113113

@@ -126,22 +126,22 @@ class FlowToPrint extends DataFlow::Configuration {
126126
override predicate isSink(DataFlow::Node sink) { isSink(sink, _) }
127127
}
128128

129-
/** Holds if the provided CallNode's result flows to a Printer call as argument. */
129+
/** Holds if the provided `CallNode`'s result flows to an argument of a printer call. */
130130
predicate resultFlowsToPrinter(DataFlow::CallNode authCodeURLCall) {
131131
exists(FlowToPrint cfg, DataFlow::PathNode source, DataFlow::PathNode sink |
132132
cfg.hasFlowPath(source, sink) and
133133
cfg.isSource(source.getNode(), authCodeURLCall)
134134
)
135135
}
136136

137-
/** Gets dataflow nodes that read the value of os.Stdin */
137+
/** Get a data-flow node that reads the value of `os.Stdin`. */
138138
DataFlow::Node getAStdinNode() {
139139
result = any(ValueEntity v | v.hasQualifiedName("os", "Stdin")).getARead()
140140
}
141141

142142
/**
143-
* Gets a call to a scanner function that reads from os.Stdin, or which creates a scanner
144-
* instance wrapping os.Stdin.
143+
* Gets a call to a scanner function that reads from `os.Stdin`, or which creates a scanner
144+
* instance wrapping `os.Stdin`.
145145
*/
146146
DataFlow::CallNode getAScannerCall() {
147147
result instanceof Fmt::ScannerCall or
@@ -150,17 +150,17 @@ DataFlow::CallNode getAScannerCall() {
150150
}
151151

152152
/**
153-
* Holds if the provided CallNode is within the same root as a call
154-
* to a scanner that reads from os.Stdin.
153+
* Holds if the provided `CallNode` is within the same root as a call
154+
* to a scanner that reads from `os.Stdin`.
155155
*/
156156
predicate containsCallToStdinScanner(FuncDef funcDef) {
157157
exists(DataFlow::CallNode call | call = getAScannerCall() | call.getRoot() = funcDef)
158158
}
159159

160160
/**
161-
* Holds if the authCodeURLCall seems to be done within a terminal
162-
* because there are calls to a Printer (fmt.Println and similar),
163-
* and a call to a Scanner (fmt.Scan and similar),
161+
* Holds if the `authCodeURLCall` seems to be done within a terminal
162+
* because there are calls to a printer (`fmt.Println` and similar),
163+
* and a call to a scanner (`fmt.Scan` and similar),
164164
* all of which are typically done within a terminal session.
165165
*/
166166
predicate seemsLikeDoneWithinATerminal(DataFlow::CallNode authCodeURLCall) {

ql/src/semmle/go/frameworks/stdlib/Bufio.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ import go
77
/** Provides models of commonly used functions in the `bufio` package. */
88
module Bufio {
99
/**
10-
* The function bufio.NewScanner.
10+
* The function `bufio.NewScanner`.
1111
*/
1212
class NewScanner extends Function {
1313
NewScanner() { this.hasQualifiedName("bufio", "NewScanner") }
1414
}
1515

1616
/**
17-
* A call to bufio.NewScanner.
17+
* A call to `bufio.NewScanner`.
1818
*/
1919
class NewScannerCall extends DataFlow::CallNode {
2020
NewScannerCall() { this.getTarget() instanceof NewScanner }
2121

2222
/**
23-
* Returns the node corresponding to the io.Reader
23+
* Returns the node corresponding to the `io.Reader`
2424
* argument provided in the call.
2525
*/
2626
DataFlow::Node getReader() { result = this.getArgument(0) }

0 commit comments

Comments
 (0)