Skip to content

Commit 1287f1b

Browse files
committed
Address feedback
1 parent d195273 commit 1287f1b

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

go/ql/lib/semmle/go/security/TaintedPathCustomizations.qll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,26 @@ module TaintedPath {
9393
}
9494
}
9595

96-
// /**
97-
// * A call to `mux.Vars(path)`, considered to sanitize `path` against path traversal.
98-
// * Only enabled when `SkipClean` is not set true.
99-
// */
96+
/**
97+
* A call to `mux.Vars(path)`, considered to sanitize `path` against path traversal.
98+
* Only enabled when `SkipClean` is not set true.
99+
*/
100100
class MuxVarsSanitizer extends Sanitizer {
101101
MuxVarsSanitizer() {
102102
exists(Function m |
103-
m.hasQualifiedName("github.com/gorilla/mux", "Vars") and
103+
m.hasQualifiedName(package("github.com/gorilla/mux", ""), "Vars") and
104104
this = m.getACall().getResult()
105105
) and
106106
not exists(CallExpr f |
107-
f.getTarget().hasQualifiedName("github.com/gorilla/mux", "SkipClean") and
108-
f.getArgument(0).toString().toLowerCase() = "true"
107+
f.getTarget().hasQualifiedName(package("github.com/gorilla/mux", ""), "SkipClean") and
108+
f.getArgument(0).getBoolValue() = true
109109
)
110110
}
111111
}
112112

113-
// /**
114-
// * A read from `net/url` which is sanitized
115-
// */
113+
/**
114+
* A read from the field `Path` of the type `net/url.URL`, which is sanitized.
115+
*/
116116
class UrlPathSanitizer extends Sanitizer {
117117
UrlPathSanitizer() {
118118
exists(DataFlow::Field fld |

go/ql/test/query-tests/Security/CWE-022/TaintedPath.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
9999

100100
// GOOD: Sanitized by Gorilla's cleaner
101101
func GorillaHandler(w http.ResponseWriter, r *http.Request) {
102-
not_tainted_path := mux.Vars(r)
102+
not_tainted_path := mux.Vars(r)["id"]
103103
data, _ := ioutil.ReadFile(filepath.Join("/home/user/", not_tainted_path))
104104
w.Write(data)
105105
}

0 commit comments

Comments
 (0)