|
| 1 | +import go |
| 2 | +import StringOps |
| 3 | + |
| 4 | +module WebCacheDeception { |
| 5 | + abstract class Sink extends DataFlow::Node { } |
| 6 | + |
| 7 | + private class GoNetHttp extends Sink { |
| 8 | + GoNetHttp() { |
| 9 | + exists( |
| 10 | + DataFlow::CallNode m, DataFlow::ReadNode rn, Http::HeaderWrite::Range hw, DeclaredFunction f |
| 11 | + | |
| 12 | + m.getTarget().hasQualifiedName("net/http", "HandleFunc") and |
| 13 | + m.getArgument(0).getStringValue().matches("%/") and |
| 14 | + m.getArgument(1) = rn and |
| 15 | + rn.reads(f) and |
| 16 | + f.getParameter(0) = hw.getResponseWriter() and |
| 17 | + hw.getHeaderName() = "cache-control" and |
| 18 | + this = m.getArgument(0) |
| 19 | + ) |
| 20 | + } |
| 21 | + } |
| 22 | + |
| 23 | + private class GoFiber extends Sink { |
| 24 | + GoFiber() { |
| 25 | + exists(ImportSpec i | |
| 26 | + i.getPath() = "github.com/gofiber/fiber" or |
| 27 | + i.getPath() = "github.com/gofiber/fiber/v2" |
| 28 | + | |
| 29 | + exists(DataFlow::CallNode m | |
| 30 | + m.getCall().getArgument(0).toString().matches("%/*%") and |
| 31 | + this = m.getArgument(0) |
| 32 | + ) |
| 33 | + ) |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + private class GoChi extends Sink { |
| 38 | + GoChi() { |
| 39 | + exists(ImportSpec i | |
| 40 | + i.getPath() = "github.com/go-chi/chi/v5" or |
| 41 | + i.getPath() = "github.com/go-chi/chi/v5/middleware" |
| 42 | + | |
| 43 | + exists(DataFlow::CallNode m | |
| 44 | + m.getCall().getArgument(0).toString().matches("%/*%") and |
| 45 | + this = m.getArgument(0) |
| 46 | + ) |
| 47 | + ) |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + private class GoHttpRouter extends Sink { |
| 52 | + GoHttpRouter() { |
| 53 | + exists(string pkg | pkg = "github.com/julienschmidt/httprouter" | |
| 54 | + exists(DataFlow::CallNode m | |
| 55 | + m.getCall().getArgument(0).toString().matches("%/*%") and |
| 56 | + this = m.getArgument(0) |
| 57 | + ) |
| 58 | + ) |
| 59 | + } |
| 60 | + } |
| 61 | +} |
0 commit comments