Skip to content

Commit adb479d

Browse files
committed
Convert xss sanitizer to MaD
1 parent ffcfe40 commit adb479d

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

go/ql/lib/ext/github.com.beego.beego.server.web.model.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,8 @@ extensions:
5050
- ["group:beego", "Controller", True, "GetString", "", "", "ReturnValue[0]", "remote", "manual"]
5151
- ["group:beego", "Controller", True, "GetStrings", "", "", "ReturnValue[0]", "remote", "manual"]
5252
- ["group:beego", "Controller", True, "Input", "", "", "ReturnValue[0]", "remote", "manual"]
53+
- addsTo:
54+
pack: codeql/go-all
55+
extensible: barrierModel
56+
data:
57+
- ["group:beego", "", True, "Htmlquote", "", "", "ReturnValue", "html-injection", "manual"]

go/ql/lib/semmle/go/frameworks/Beego.qll

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,6 @@ module Beego {
165165
override string getAContentType() { none() }
166166
}
167167

168-
private class HtmlQuoteSanitizer extends SharedXss::Sanitizer {
169-
HtmlQuoteSanitizer() {
170-
exists(DataFlow::CallNode c | c.getTarget().hasQualifiedName(packagePath(), "Htmlquote") |
171-
this = c.getArgument(0)
172-
)
173-
}
174-
}
175-
176168
private class UtilsTaintPropagators extends TaintTracking::FunctionModel {
177169
UtilsTaintPropagators() { this.hasQualifiedName(utilsPackagePath(), "GetDisplayString") }
178170

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ module SharedXss {
8888
body.getAContentType().regexpMatch("(?i).*html.*")
8989
}
9090

91+
private class ExternalSanitizer extends Sanitizer {
92+
ExternalSanitizer() { barrierNode(this, ["html-injection", "js-injection"]) }
93+
}
94+
9195
/**
9296
* A JSON marshaler, acting to sanitize a possible XSS vulnerability because the
9397
* marshaled value is very unlikely to be returned as an HTML content-type.

0 commit comments

Comments
 (0)