Skip to content

Commit f1f4065

Browse files
committed
Go: Inline expectation should have space after $
This was a regex-find-replace from `// \$(?! )` (using a negative lookahead) to `// $ `.
1 parent 2f84d25 commit f1f4065

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/file/test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func open() {
1616
}
1717

1818
func openFile() {
19-
file, err := os.OpenFile("file.txt", os.O_RDWR, 0) // $source
19+
file, err := os.OpenFile("file.txt", os.O_RDWR, 0) // $ source
2020
if err != nil {
2121
return
2222
}
@@ -25,15 +25,15 @@ func openFile() {
2525
}
2626

2727
func readFile() {
28-
data, err := os.ReadFile("file.txt") // $source
28+
data, err := os.ReadFile("file.txt") // $ source
2929
if err != nil {
3030
return
3131
}
3232
_ = data
3333
}
3434

3535
func readFileIoUtil() {
36-
data, err := ioutil.ReadFile("file.txt") // $source
36+
data, err := ioutil.ReadFile("file.txt") // $ source
3737
if err != nil {
3838
return
3939
}
@@ -45,14 +45,14 @@ func getFileFS() fs.ReadFileFS {
4545
}
4646

4747
func readFileFs() {
48-
data, err := fs.ReadFile(os.DirFS("."), "file.txt") // $source
48+
data, err := fs.ReadFile(os.DirFS("."), "file.txt") // $ source
4949
if err != nil {
5050
return
5151
}
5252
_ = data
5353

5454
dir := getFileFS()
55-
data, err = dir.ReadFile("file.txt") // $source
55+
data, err = dir.ReadFile("file.txt") // $ source
5656

5757
if err != nil {
5858
return
@@ -61,7 +61,7 @@ func readFileFs() {
6161
}
6262

6363
func fsOpen() {
64-
file, err := os.DirFS(".").Open("file.txt") // $source
64+
file, err := os.DirFS(".").Open("file.txt") // $ source
6565
if err != nil {
6666
return
6767
}

go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/stdin/test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,37 @@ func sink(string) {
1212

1313
func readStdinBuffer() {
1414
buf := make([]byte, 1024)
15-
n, err := os.Stdin.Read(buf) // $source
15+
n, err := os.Stdin.Read(buf) // $ source
1616
if err != nil {
1717
return
1818
}
19-
sink(string(buf[:n])) // $hasTaintFlow="type conversion"
19+
sink(string(buf[:n])) // $ hasTaintFlow="type conversion"
2020
}
2121

2222
func readStdinBuffReader() {
2323
buf := make([]byte, 1024)
24-
r := bufio.NewReader(os.Stdin) // $source
24+
r := bufio.NewReader(os.Stdin) // $ source
2525
n, err := r.Read(buf)
2626
if err != nil {
2727
return
2828
}
29-
sink(string(buf[:n])) // $hasTaintFlow="type conversion"
29+
sink(string(buf[:n])) // $ hasTaintFlow="type conversion"
3030
}
3131

3232
func scan() {
3333
var username, email string
34-
fmt.Scan(&username, &email) // $source
35-
sink(username) // $hasTaintFlow="username"
34+
fmt.Scan(&username, &email) // $ source
35+
sink(username) // $ hasTaintFlow="username"
3636
}
3737

3838
func scanf() {
3939
var s string
40-
fmt.Scanf("%s", &s) // $source
41-
sink(s) // $hasTaintFlow="s"
40+
fmt.Scanf("%s", &s) // $ source
41+
sink(s) // $ hasTaintFlow="s"
4242
}
4343

4444
func scanl() {
4545
var s string
46-
fmt.Scanln(&s) // $source
47-
sink(s) // $hasTaintFlow="s"
46+
fmt.Scanln(&s) // $ source
47+
sink(s) // $ hasTaintFlow="s"
4848
}

go/ql/test/library-tests/semmle/go/frameworks/Macaron/sources.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ import (
77
)
88

99
func sources(ctx *macaron.Context, body *macaron.RequestBody) {
10-
_ = ctx.AllParams() // $RemoteFlowSource
11-
_ = ctx.GetCookie("") // $RemoteFlowSource
12-
_, _ = ctx.GetSecureCookie("") // $RemoteFlowSource
13-
_, _ = ctx.GetSuperSecureCookie("", "") // $RemoteFlowSource
14-
_, _, _ = ctx.GetFile("") // $RemoteFlowSource
15-
_ = ctx.Params("") // $RemoteFlowSource
16-
_ = ctx.ParamsEscape("") // $RemoteFlowSource
17-
_ = ctx.Query("") // $RemoteFlowSource
18-
_ = ctx.QueryEscape("") // $RemoteFlowSource
19-
_ = ctx.QueryStrings("") // $RemoteFlowSource
20-
_, _ = body.Bytes() // $RemoteFlowSource
21-
_, _ = body.String() // $RemoteFlowSource
10+
_ = ctx.AllParams() // $ RemoteFlowSource
11+
_ = ctx.GetCookie("") // $ RemoteFlowSource
12+
_, _ = ctx.GetSecureCookie("") // $ RemoteFlowSource
13+
_, _ = ctx.GetSuperSecureCookie("", "") // $ RemoteFlowSource
14+
_, _, _ = ctx.GetFile("") // $ RemoteFlowSource
15+
_ = ctx.Params("") // $ RemoteFlowSource
16+
_ = ctx.ParamsEscape("") // $ RemoteFlowSource
17+
_ = ctx.Query("") // $ RemoteFlowSource
18+
_ = ctx.QueryEscape("") // $ RemoteFlowSource
19+
_ = ctx.QueryStrings("") // $ RemoteFlowSource
20+
_, _ = body.Bytes() // $ RemoteFlowSource
21+
_, _ = body.String() // $ RemoteFlowSource
2222
}

0 commit comments

Comments
 (0)