Skip to content

Commit 135923c

Browse files
committed
Change XNetHtmltest
1 parent e6e87a4 commit 135923c

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

go/ql/test/library-tests/semmle/go/frameworks/XNetHtml/ReflectedXss.expected

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
edges
2-
| test.go:11:2:11:42 | ... := ...[0] | test.go:14:42:14:53 | selection of Value |
3-
| test.go:14:22:14:54 | call to UnescapeString | test.go:14:15:14:55 | type conversion |
4-
| test.go:14:42:14:53 | selection of Value | test.go:14:22:14:54 | call to UnescapeString |
2+
| test.go:11:12:11:22 | selection of URL | test.go:11:12:11:30 | call to Query |
3+
| test.go:11:12:11:30 | call to Query | test.go:11:12:11:44 | call to Get |
4+
| test.go:11:12:11:44 | call to Get | test.go:14:42:14:47 | param1 |
5+
| test.go:14:22:14:48 | call to UnescapeString | test.go:14:15:14:49 | type conversion |
6+
| test.go:14:42:14:47 | param1 | test.go:14:22:14:48 | call to UnescapeString |
57
| test.go:16:2:16:36 | ... := ...[0] | test.go:17:15:17:31 | type conversion |
68
| test.go:16:2:16:36 | ... := ...[0] | test.go:28:22:28:25 | node |
79
| test.go:16:24:16:35 | selection of Body | test.go:16:2:16:36 | ... := ...[0] |
@@ -54,10 +56,12 @@ edges
5456
| test.go:49:22:49:32 | &... [pointer] | test.go:49:23:49:32 | cleanNode2 |
5557
| test.go:49:23:49:32 | cleanNode2 | test.go:49:22:49:32 | &... [pointer] |
5658
nodes
57-
| test.go:11:2:11:42 | ... := ...[0] | semmle.label | ... := ...[0] |
58-
| test.go:14:15:14:55 | type conversion | semmle.label | type conversion |
59-
| test.go:14:22:14:54 | call to UnescapeString | semmle.label | call to UnescapeString |
60-
| test.go:14:42:14:53 | selection of Value | semmle.label | selection of Value |
59+
| test.go:11:12:11:22 | selection of URL | semmle.label | selection of URL |
60+
| test.go:11:12:11:30 | call to Query | semmle.label | call to Query |
61+
| test.go:11:12:11:44 | call to Get | semmle.label | call to Get |
62+
| test.go:14:15:14:49 | type conversion | semmle.label | type conversion |
63+
| test.go:14:22:14:48 | call to UnescapeString | semmle.label | call to UnescapeString |
64+
| test.go:14:42:14:47 | param1 | semmle.label | param1 |
6165
| test.go:16:2:16:36 | ... := ...[0] | semmle.label | ... := ...[0] |
6266
| test.go:16:24:16:35 | selection of Body | semmle.label | selection of Body |
6367
| test.go:17:15:17:31 | type conversion | semmle.label | type conversion |
@@ -107,7 +111,7 @@ nodes
107111
| test.go:49:23:49:32 | cleanNode2 | semmle.label | cleanNode2 |
108112
subpaths
109113
#select
110-
| test.go:14:15:14:55 | type conversion | test.go:11:2:11:42 | ... := ...[0] | test.go:14:15:14:55 | type conversion | Cross-site scripting vulnerability due to $@. | test.go:11:2:11:42 | ... := ...[0] | user-provided value | test.go:0:0:0:0 | test.go | |
114+
| test.go:14:15:14:49 | type conversion | test.go:11:12:11:22 | selection of URL | test.go:14:15:14:49 | type conversion | Cross-site scripting vulnerability due to $@. | test.go:11:12:11:22 | selection of URL | user-provided value | test.go:0:0:0:0 | test.go | |
111115
| test.go:17:15:17:31 | type conversion | test.go:16:24:16:35 | selection of Body | test.go:17:15:17:31 | type conversion | Cross-site scripting vulnerability due to $@. | test.go:16:24:16:35 | selection of Body | user-provided value | test.go:0:0:0:0 | test.go | |
112116
| test.go:20:15:20:32 | type conversion | test.go:19:36:19:47 | selection of Body | test.go:20:15:20:32 | type conversion | Cross-site scripting vulnerability due to $@. | test.go:19:36:19:47 | selection of Body | user-provided value | test.go:0:0:0:0 | test.go | |
113117
| test.go:23:15:23:35 | type conversion | test.go:22:33:22:44 | selection of Body | test.go:23:15:23:35 | type conversion | Cross-site scripting vulnerability due to $@. | test.go:22:33:22:44 | selection of Body | user-provided value | test.go:0:0:0:0 | test.go | |

go/ql/test/library-tests/semmle/go/frameworks/XNetHtml/test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ package test
22

33
import (
44
"database/sql"
5-
"golang.org/x/net/html"
65
"net/http"
6+
"golang.org/x/net/html"
77
)
88

99
func test(request *http.Request, writer http.ResponseWriter) {
1010

11-
cookie, _ := request.Cookie("SomeCookie")
12-
writer.Write([]byte(html.EscapeString(cookie.Value))) // GOOD: escaped.
11+
param1 := request.URL.Query().Get("param1")
12+
writer.Write([]byte(html.EscapeString(param1))) // GOOD: escaped.
1313

14-
writer.Write([]byte(html.UnescapeString(cookie.Value))) // BAD: unescaped.
14+
writer.Write([]byte(html.UnescapeString(param1))) // BAD: unescaped.
1515

1616
node, _ := html.Parse(request.Body)
1717
writer.Write([]byte(node.Data)) // BAD: writing unescaped HTML data

0 commit comments

Comments
 (0)