Skip to content

Commit 7d5bbc3

Browse files
committed
put each new sink in its own framework
1 parent 9598bb5 commit 7d5bbc3

File tree

46 files changed

+4579
-731
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+4579
-731
lines changed

go/ql/lib/go.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,6 @@ import semmle.go.frameworks.XPath
6464
import semmle.go.frameworks.Yaml
6565
import semmle.go.frameworks.Zap
6666
import semmle.go.security.FlowSources
67+
import semmle.go.frameworks.Afero
68+
import semmle.go.frameworks.Iris
69+
import semmle.go.frameworks.Fiber
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
11
package main
22

3-
//go:generate depstubber -vendor github.com/beego/beego/v2/server/web Controller Run,Router
4-
//go:generate depstubber -vendor github.com/beego/beego/v2/server/web/context BeegoOutput,Context
5-
//go:generate depstubber -vendor github.com/gin-gonic/gin Context Default
6-
//go:generate depstubber -vendor github.com/gofiber/fiber/v2 Ctx New
7-
//go:generate depstubber -vendor github.com/kataras/iris/v12/context Context
8-
//go:generate depstubber -vendor github.com/labstack/echo/v4 Context New
93
//go:generate depstubber -vendor github.com/spf13/afero Afero,RegexpFs,HttpFs,ReadOnlyFs,MemMapFs,OsFs,BasePathFs WriteReader,SafeWriteReader,WriteFile,ReadFile,ReadDir,NewOsFs,NewRegexpFs,NewReadOnlyFs,NewCacheOnReadFs,,NewHttpFs,NewBasePathFs,NewIOFS
104

115
import (
126
"fmt"
13-
beego "github.com/beego/beego/v2/server/web"
14-
BeegoContext "github.com/beego/beego/v2/server/web/context"
15-
"github.com/gin-gonic/gin"
16-
"github.com/gofiber/fiber/v2"
17-
"github.com/kataras/iris/v12/context"
18-
"github.com/labstack/echo/v4"
197
"github.com/spf13/afero"
208
"net/http"
219
"os"
@@ -26,13 +14,6 @@ func main() {
2614
return
2715
}
2816

29-
func BeegoController(beegoController beego.Controller) {
30-
beegoOutput := BeegoContext.BeegoOutput{}
31-
beegoOutput.Download("filepath", "license.txt") // $ FileSystemAccess="filepath"
32-
buffer := make([]byte, 10)
33-
_ = beegoController.SaveToFileWithBuffer("filenameExistsInForm", "filepath", buffer) // $ FileSystemAccess="filepath"
34-
}
35-
3617
func Afero(writer http.ResponseWriter, request *http.Request) {
3718
filepath := request.URL.Query()["filepath"][0]
3819
//osFS := afero.NewMemMapFs()
@@ -97,52 +78,3 @@ func Afero(writer http.ResponseWriter, request *http.Request) {
9778
fmt.Println(afero.ReadFile(basePathFs, filepath))
9879
afero.ReadFile(basePathFs, filepath)
9980
}
100-
101-
func Echo() {
102-
e := echo.New()
103-
e.GET("/", func(c echo.Context) error {
104-
filepath := c.QueryParam("filePath")
105-
return c.File(filepath) // $ FileSystemAccess=filepath
106-
})
107-
108-
e.GET("/attachment", func(c echo.Context) error {
109-
filepath := c.QueryParam("filePath")
110-
return c.Attachment(filepath, "file name in response") // $ FileSystemAccess=filepath
111-
})
112-
_ = e.Start(":1323")
113-
}
114-
115-
func Fiber() {
116-
app := fiber.New()
117-
app.Get("/b", func(c *fiber.Ctx) error {
118-
filepath := c.Params("filepath")
119-
header, _ := c.FormFile("f")
120-
_ = c.SaveFile(header, filepath) // $ FileSystemAccess=filepath
121-
return c.SendFile(filepath) // $ FileSystemAccess=filepath
122-
})
123-
_ = app.Listen(":3000")
124-
}
125-
126-
func IrisTest(ctx context.Context) {
127-
filepath := ctx.URLParam("filepath")
128-
_ = ctx.SendFile(filepath, "file") // $ FileSystemAccess=filepath
129-
_ = ctx.SendFileWithRate(filepath, "file", 0, 0) // $ FileSystemAccess=filepath
130-
_ = ctx.ServeFile(filepath) // $ FileSystemAccess=filepath
131-
_ = ctx.ServeFileWithRate(filepath, 0, 0) // $ FileSystemAccess=filepath
132-
_, _, _ = ctx.UploadFormFiles(filepath, nil) // $ FileSystemAccess=filepath
133-
_, fileHeader, _ := ctx.FormFile("file")
134-
_, _ = ctx.SaveFormFile(fileHeader, filepath) // $ FileSystemAccess=filepath
135-
136-
}
137-
func Gin() {
138-
router := gin.Default()
139-
router.POST("/FormUploads", func(c *gin.Context) {
140-
filepath := c.Query("filepath")
141-
c.File(filepath) // $ FileSystemAccess=filepath
142-
http.ServeFile(c.Writer, c.Request, filepath) // $ FileSystemAccess=filepath
143-
c.FileAttachment(filepath, "file name in response") // $ FileSystemAccess=filepath
144-
file, _ := c.FormFile("afile")
145-
_ = c.SaveUploadedFile(file, filepath) // $ FileSystemAccess=filepath
146-
})
147-
_ = router.Run()
148-
}

0 commit comments

Comments
 (0)