Go: Inline expectation should have space after $

This was a regex-find-replace from `// \$(?! )` (using a negative lookahead) to `// $ `.
This commit is contained in:
Owen Mansel-Chan
2026-03-03 14:59:12 +00:00
parent 05a77a2005
commit d4ba2d68f9
3 changed files with 28 additions and 28 deletions

View File

@@ -16,7 +16,7 @@ func open() {
}
func openFile() {
file, err := os.OpenFile("file.txt", os.O_RDWR, 0) // $source
file, err := os.OpenFile("file.txt", os.O_RDWR, 0) // $ source
if err != nil {
return
}
@@ -25,7 +25,7 @@ func openFile() {
}
func readFile() {
data, err := os.ReadFile("file.txt") // $source
data, err := os.ReadFile("file.txt") // $ source
if err != nil {
return
}
@@ -33,7 +33,7 @@ func readFile() {
}
func readFileIoUtil() {
data, err := ioutil.ReadFile("file.txt") // $source
data, err := ioutil.ReadFile("file.txt") // $ source
if err != nil {
return
}
@@ -45,14 +45,14 @@ func getFileFS() fs.ReadFileFS {
}
func readFileFs() {
data, err := fs.ReadFile(os.DirFS("."), "file.txt") // $source
data, err := fs.ReadFile(os.DirFS("."), "file.txt") // $ source
if err != nil {
return
}
_ = data
dir := getFileFS()
data, err = dir.ReadFile("file.txt") // $source
data, err = dir.ReadFile("file.txt") // $ source
if err != nil {
return
@@ -61,7 +61,7 @@ func readFileFs() {
}
func fsOpen() {
file, err := os.DirFS(".").Open("file.txt") // $source
file, err := os.DirFS(".").Open("file.txt") // $ source
if err != nil {
return
}

View File

@@ -12,37 +12,37 @@ func sink(string) {
func readStdinBuffer() {
buf := make([]byte, 1024)
n, err := os.Stdin.Read(buf) // $source
n, err := os.Stdin.Read(buf) // $ source
if err != nil {
return
}
sink(string(buf[:n])) // $hasTaintFlow="type conversion"
sink(string(buf[:n])) // $ hasTaintFlow="type conversion"
}
func readStdinBuffReader() {
buf := make([]byte, 1024)
r := bufio.NewReader(os.Stdin) // $source
r := bufio.NewReader(os.Stdin) // $ source
n, err := r.Read(buf)
if err != nil {
return
}
sink(string(buf[:n])) // $hasTaintFlow="type conversion"
sink(string(buf[:n])) // $ hasTaintFlow="type conversion"
}
func scan() {
var username, email string
fmt.Scan(&username, &email) // $source
sink(username) // $hasTaintFlow="username"
fmt.Scan(&username, &email) // $ source
sink(username) // $ hasTaintFlow="username"
}
func scanf() {
var s string
fmt.Scanf("%s", &s) // $source
sink(s) // $hasTaintFlow="s"
fmt.Scanf("%s", &s) // $ source
sink(s) // $ hasTaintFlow="s"
}
func scanl() {
var s string
fmt.Scanln(&s) // $source
sink(s) // $hasTaintFlow="s"
fmt.Scanln(&s) // $ source
sink(s) // $ hasTaintFlow="s"
}

View File

@@ -7,16 +7,16 @@ import (
)
func sources(ctx *macaron.Context, body *macaron.RequestBody) {
_ = ctx.AllParams() // $RemoteFlowSource
_ = ctx.GetCookie("") // $RemoteFlowSource
_, _ = ctx.GetSecureCookie("") // $RemoteFlowSource
_, _ = ctx.GetSuperSecureCookie("", "") // $RemoteFlowSource
_, _, _ = ctx.GetFile("") // $RemoteFlowSource
_ = ctx.Params("") // $RemoteFlowSource
_ = ctx.ParamsEscape("") // $RemoteFlowSource
_ = ctx.Query("") // $RemoteFlowSource
_ = ctx.QueryEscape("") // $RemoteFlowSource
_ = ctx.QueryStrings("") // $RemoteFlowSource
_, _ = body.Bytes() // $RemoteFlowSource
_, _ = body.String() // $RemoteFlowSource
_ = ctx.AllParams() // $ RemoteFlowSource
_ = ctx.GetCookie("") // $ RemoteFlowSource
_, _ = ctx.GetSecureCookie("") // $ RemoteFlowSource
_, _ = ctx.GetSuperSecureCookie("", "") // $ RemoteFlowSource
_, _, _ = ctx.GetFile("") // $ RemoteFlowSource
_ = ctx.Params("") // $ RemoteFlowSource
_ = ctx.ParamsEscape("") // $ RemoteFlowSource
_ = ctx.Query("") // $ RemoteFlowSource
_ = ctx.QueryEscape("") // $ RemoteFlowSource
_ = ctx.QueryStrings("") // $ RemoteFlowSource
_, _ = body.Bytes() // $ RemoteFlowSource
_, _ = body.String() // $ RemoteFlowSource
}