From d4ba2d68f9b46c4ddafc7c6aab02ba0af985c725 Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Tue, 3 Mar 2026 14:59:12 +0000 Subject: [PATCH] Go: Inline expectation should have space after $ This was a regex-find-replace from `// \$(?! )` (using a negative lookahead) to `// $ `. --- .../dataflow/flowsources/local/file/test.go | 12 +++++----- .../dataflow/flowsources/local/stdin/test.go | 20 ++++++++-------- .../semmle/go/frameworks/Macaron/sources.go | 24 +++++++++---------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/file/test.go b/go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/file/test.go index 1a145751476..27bdff33a27 100644 --- a/go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/file/test.go +++ b/go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/file/test.go @@ -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 } diff --git a/go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/stdin/test.go b/go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/stdin/test.go index 4166dc4000b..8a2830b73e3 100644 --- a/go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/stdin/test.go +++ b/go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/stdin/test.go @@ -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" } diff --git a/go/ql/test/library-tests/semmle/go/frameworks/Macaron/sources.go b/go/ql/test/library-tests/semmle/go/frameworks/Macaron/sources.go index 9cc46d5611e..eaf3ad51f43 100644 --- a/go/ql/test/library-tests/semmle/go/frameworks/Macaron/sources.go +++ b/go/ql/test/library-tests/semmle/go/frameworks/Macaron/sources.go @@ -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 }