Skip to content

Commit

Permalink
Merge pull request #132 from github/danieljoos-backport-cve-2024-53257-…
Browse files Browse the repository at this point in the history
…fix

Backport fix for CVE-2024-53257 to `release-18.0-github`
  • Loading branch information
arthurschreiber authored Dec 13, 2024
2 parents eb53017 + 30aebea commit 1f2e2a7
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
3 changes: 2 additions & 1 deletion go/vt/vtgate/debugenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import (
"html"
"net/http"
"strconv"
"text/template"
"time"

"github.com/google/safehtml/template"

"vitess.io/vitess/go/acl"
"vitess.io/vitess/go/vt/discovery"
"vitess.io/vitess/go/vt/log"
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vtgate/querylogz.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ import (
"net/http"
"strconv"
"strings"
"text/template"
"time"

"vitess.io/vitess/go/vt/vtgate/logstats"
"github.com/google/safehtml/template"

"vitess.io/vitess/go/acl"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/logz"
"vitess.io/vitess/go/vt/sqlparser"
"vitess.io/vitess/go/vt/vtgate/logstats"
)

var (
Expand Down
8 changes: 4 additions & 4 deletions go/vt/vtgate/querylogz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (

func TestQuerylogzHandlerFormatting(t *testing.T) {
req, _ := http.NewRequest("GET", "/querylogz?timeout=10&limit=1", nil)
logStats := logstats.NewLogStats(context.Background(), "Execute", "select name from test_table limit 1000", "suuid", nil)
logStats := logstats.NewLogStats(context.Background(), "Execute", "select name, 'inject <script>alert();</script>' from test_table limit 1000", "suuid", nil)
logStats.StmtType = "select"
logStats.RowsAffected = 1000
logStats.ShardQueries = 1
Expand Down Expand Up @@ -63,7 +63,7 @@ func TestQuerylogzHandlerFormatting(t *testing.T) {
`<td>0.002</td>`,
`<td>0.003</td>`,
`<td>select</td>`,
`<td>select name from test_table limit 1000</td>`,
regexp.QuoteMeta(`<td>select name,​ &#39;inject &lt;script&gt;alert()​;&lt;/script&gt;&#39; from test_table limit 1000</td>`),
`<td>1</td>`,
`<td>1000</td>`,
`<td></td>`,
Expand Down Expand Up @@ -93,7 +93,7 @@ func TestQuerylogzHandlerFormatting(t *testing.T) {
`<td>0.002</td>`,
`<td>0.003</td>`,
`<td>select</td>`,
`<td>select name from test_table limit 1000</td>`,
regexp.QuoteMeta(`<td>select name,​ &#39;inject &lt;script&gt;alert()​;&lt;/script&gt;&#39; from test_table limit 1000</td>`),
`<td>1</td>`,
`<td>1000</td>`,
`<td></td>`,
Expand Down Expand Up @@ -123,7 +123,7 @@ func TestQuerylogzHandlerFormatting(t *testing.T) {
`<td>0.002</td>`,
`<td>0.003</td>`,
`<td>select</td>`,
`<td>select name from test_table limit 1000</td>`,
regexp.QuoteMeta(`<td>select name,​ &#39;inject &lt;script&gt;alert()​;&lt;/script&gt;&#39; from test_table limit 1000</td>`),
`<td>1</td>`,
`<td>1000</td>`,
`<td></td>`,
Expand Down
3 changes: 2 additions & 1 deletion go/vt/vttablet/tabletserver/debugenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import (
"html"
"net/http"
"strconv"
"text/template"
"time"

"github.com/google/safehtml/template"

"vitess.io/vitess/go/acl"
"vitess.io/vitess/go/vt/log"
)
Expand Down
3 changes: 2 additions & 1 deletion go/vt/vttablet/tabletserver/querylogz.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (
"net/http"
"strconv"
"strings"
"text/template"
"time"

"github.com/google/safehtml/template"

"vitess.io/vitess/go/acl"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/logz"
Expand Down
8 changes: 4 additions & 4 deletions go/vt/vttablet/tabletserver/querylogz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestQuerylogzHandler(t *testing.T) {
req, _ := http.NewRequest("GET", "/querylogz?timeout=10&limit=1", nil)
logStats := tabletenv.NewLogStats(context.Background(), "Execute")
logStats.PlanType = planbuilder.PlanSelect.String()
logStats.OriginalSQL = "select name from test_table limit 1000"
logStats.OriginalSQL = "select name, 'inject <script>alert();</script>' from test_table limit 1000"
logStats.RowsAffected = 1000
logStats.NumberOfQueries = 1
logStats.StartTime, _ = time.Parse("Jan 2 15:04:05", "Nov 29 13:33:09")
Expand All @@ -63,7 +63,7 @@ func TestQuerylogzHandler(t *testing.T) {
`<td>0.001</td>`,
`<td>1e-08</td>`,
`<td>Select</td>`,
`<td>select name from test_table limit 1000</td>`,
regexp.QuoteMeta(`<td>select name,​ &#39;inject &lt;script&gt;alert()​;&lt;/script&gt;&#39; from test_table limit 1000</td>`),
`<td>1</td>`,
`<td>none</td>`,
`<td>1000</td>`,
Expand Down Expand Up @@ -94,7 +94,7 @@ func TestQuerylogzHandler(t *testing.T) {
`<td>0.001</td>`,
`<td>1e-08</td>`,
`<td>Select</td>`,
`<td>select name from test_table limit 1000</td>`,
regexp.QuoteMeta(`<td>select name,​ &#39;inject &lt;script&gt;alert()​;&lt;/script&gt;&#39; from test_table limit 1000</td>`),
`<td>1</td>`,
`<td>none</td>`,
`<td>1000</td>`,
Expand Down Expand Up @@ -125,7 +125,7 @@ func TestQuerylogzHandler(t *testing.T) {
`<td>0.001</td>`,
`<td>1e-08</td>`,
`<td>Select</td>`,
`<td>select name from test_table limit 1000</td>`,
regexp.QuoteMeta(`<td>select name,​ &#39;inject &lt;script&gt;alert()​;&lt;/script&gt;&#39; from test_table limit 1000</td>`),
`<td>1</td>`,
`<td>none</td>`,
`<td>1000</td>`,
Expand Down

0 comments on commit 1f2e2a7

Please sign in to comment.