Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
JJOptimist authored Jan 21, 2025
2 parents 99a6ff4 + 6f37334 commit 7a338dc
Show file tree
Hide file tree
Showing 110 changed files with 3,559 additions and 392 deletions.
2 changes: 1 addition & 1 deletion contribs/github-bot/internal/check/comment.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.

##### 📚 Resources:
- [Report a bug with the bot](https://github.com/gnolang/gno/issues/3238).
- [Report a bug with the bot](https://www.github.com/gnolang/gno/issues/3238).
- [View the bot’s configuration file](https://github.com/gnolang/gno/tree/master/contribs/github-bot/internal/config/config.go).

{{ if or .AutoRules .ManualRules }}<details><summary><b>Debug</b></summary><blockquote>
Expand Down
2 changes: 1 addition & 1 deletion contribs/gnodev/pkg/emitter/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
_ "embed"
"encoding/json"
"fmt"
"html/template"
"net/http"
"strings"
"sync"
"text/template"

"github.com/gnolang/gno/contribs/gnodev/pkg/events"
)
Expand Down
43 changes: 43 additions & 0 deletions contribs/gnodev/pkg/emitter/middleware_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package emitter

import (
"fmt"
"net/http"
"net/http/httptest"
"regexp"
"testing"

"github.com/stretchr/testify/require"
)

func TestMiddlewareUsesHTMLTemplate(t *testing.T) {
tests := []struct {
name string
remote string
want string
}{
{"normal remote", "localhost:9999", "const ws = new WebSocket('ws://localhost:9999');"},
{"xss'd remote", `localhost:9999');alert('pwned`, "const ws = new WebSocket('ws://localhost:9999&#39;);alert(&#39;pwned');"},
}

// As the code revolves, add more search patterns here.
reWebsocket := regexp.MustCompile("const ws = new WebSocket[^\n]+")

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
rec := httptest.NewRecorder()
mdw := NewMiddleware(tt.remote, http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
rw.Header().Set("Content-Type", "text/html")
fmt.Fprintf(rw, "<body></body>")
}))
rec.Header().Set("Content-Type", "text/html")
req := httptest.NewRequest("GET", "https://gno.land/example", nil)
mdw.ServeHTTP(rec, req)

targets := reWebsocket.FindAllString(rec.Body.String(), -1)
require.True(t, len(targets) > 0)
body := targets[0]
require.Equal(t, body, tt.want)
})
}
}
4 changes: 3 additions & 1 deletion contribs/gnodev/pkg/emitter/static/hotreload.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
(function() {
// Define the events that will trigger a page reload
const eventsReload = {{ .ReloadEvents | json }};
const eventsReload = [
{{range .ReloadEvents}}'{{.}}',{{end}}
];

// Establish the WebSocket connection to the event server
const ws = new WebSocket('ws://{{- .Remote -}}');
Expand Down
24 changes: 0 additions & 24 deletions contribs/gnohealth/health.go

This file was deleted.

2 changes: 1 addition & 1 deletion contribs/gnohealth/internal/timestamp/timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewTimestampCmd(io commands.IO) *commands.Command {
return commands.NewCommand(
commands.Metadata{
Name: "timestamp",
ShortUsage: "[flags]",
ShortUsage: "timestamp [flags]",
ShortHelp: "check if block timestamps are drifting",
LongHelp: "This command checks if block timestamps are drifting on a blockchain by connecting to a specified node via RPC.",
},
Expand Down
15 changes: 14 additions & 1 deletion contribs/gnohealth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,24 @@ import (
"context"
"os"

"github.com/gnolang/gno/contribs/gnohealth/internal/timestamp"
"github.com/gnolang/gno/tm2/pkg/commands"
)

func main() {
cmd := newHealthCmd(commands.NewDefaultIO())
cmd := commands.NewCommand(
commands.Metadata{
ShortUsage: "<subcommand> [flags]",
LongHelp: "Gno health check suite, to verify that different parts of Gno are working correctly",
},
commands.NewEmptyConfig(),
commands.HelpExec,
)

io := commands.NewDefaultIO()
cmd.AddSubCommands(
timestamp.NewTimestampCmd(io),
)

cmd.Execute(context.Background(), os.Args[1:])
}
Loading

0 comments on commit 7a338dc

Please sign in to comment.