Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 58 additions & 126 deletions dashboard/app/api.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dashboard/app/coverage.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func getParam[T int | string | bool | civil.Date](r *http.Request, name string,
return extractVal(t, r.FormValue(name)).(T)
}

func extractVal(t interface{}, val string) interface{} {
func extractVal(t any, val string) any {
switch t.(type) {
case int:
res, _ := strconv.Atoi(val)
Expand Down
2 changes: 1 addition & 1 deletion dashboard/app/entities_spanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ from merge_history join files
on merge_history.session = files.session
where namespace=$1 and duration>=$2 and duration<=$3 and manager='*'
group by dateto, duration`,
Params: map[string]interface{}{
Params: map[string]any{
"p1": ns,
"p2": minDays,
"p3": maxDays,
Expand Down
2 changes: 1 addition & 1 deletion dashboard/app/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func handleAuth(fn contextHandler) contextHandler {
}
}

func serveTemplate(w http.ResponseWriter, name string, data interface{}) error {
func serveTemplate(w http.ResponseWriter, name string, data any) error {
buf := new(bytes.Buffer)
if err := templates.ExecuteTemplate(buf, name, data); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion dashboard/app/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ func pollCompletedJobs(c context.Context, typ string) ([]*dashapi.BugReport, err
return reports, nil
}

func createBugReportForJob(c context.Context, job *Job, jobKey *db.Key, config interface{}) (
func createBugReportForJob(c context.Context, job *Job, jobKey *db.Key, config any) (
*dashapi.BugReport, error) {
reportingConfig, err := json.Marshal(config)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions dashboard/app/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type subsetOf []string
type trueFalse struct{}

func makeLabelSet(c context.Context, ns string) *labelSet {
ret := map[BugLabelType]interface{}{
ret := map[BugLabelType]any{
PriorityLabel: oneOf([]string{
string(LowPrioBug),
string(NormalPrioBug),
Expand Down Expand Up @@ -74,7 +74,7 @@ func makeLabelSet(c context.Context, ns string) *labelSet {
type labelSet struct {
c context.Context
ns string
labels map[BugLabelType]interface{}
labels map[BugLabelType]any
}

func (s *labelSet) FindLabel(label BugLabelType) bool {
Expand Down
4 changes: 2 additions & 2 deletions dashboard/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ type uiCollapsible struct {
Title string
Show bool // By default it's collapsed.
Type string // Template system understands it.
Value interface{}
Value any
}

func makeCollapsibleBugJobs(title string, jobs []*uiJob) *uiCollapsible {
Expand Down Expand Up @@ -1411,7 +1411,7 @@ func handleBugSummaries(c context.Context, w http.ResponseWriter, r *http.Reques
return json.NewEncoder(w).Encode(list)
}

func writeJSONVersionOf(writer http.ResponseWriter, page interface{}) error {
func writeJSONVersionOf(writer http.ResponseWriter, page any) error {
data, err := GetJSONDescrFor(page)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions dashboard/app/public_json_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ func getExtAPIDescrForBackports(groups []*uiBackportGroup) *publicAPIBackports {
}
}

func GetJSONDescrFor(page interface{}) ([]byte, error) {
var res interface{}
func GetJSONDescrFor(page any) ([]byte, error) {
var res any
switch i := page.(type) {
case *uiBugPage:
res = getExtAPIDescrForBugPage(i)
Expand Down
35 changes: 6 additions & 29 deletions dashboard/app/reporting_external.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ package main

import (
"context"
"encoding/json"
"errors"
"fmt"
"io"

"github.com/google/syzkaller/dashboard/dashapi"
"google.golang.org/appengine/v2/log"
Expand All @@ -18,14 +15,10 @@ import (
// The external system is meant to poll for new bugs with apiReportingPoll,
// and report back bug status updates with apiReportingUpdate.

func apiReportingPollBugs(c context.Context, payload io.Reader) (interface{}, error) {
func apiReportingPollBugs(c context.Context, req *dashapi.PollBugsRequest) (any, error) {
if stop, err := emergentlyStopped(c); err != nil || stop {
return &dashapi.PollBugsResponse{}, err
}
req := new(dashapi.PollBugsRequest)
if err := json.NewDecoder(payload).Decode(req); err != nil {
return nil, fmt.Errorf("failed to unmarshal request: %w", err)
}
reports := reportingPollBugs(c, req.Type)
resp := &dashapi.PollBugsResponse{
Reports: reports,
Expand All @@ -38,30 +31,22 @@ func apiReportingPollBugs(c context.Context, payload io.Reader) (interface{}, er
return resp, nil
}

func apiReportingPollNotifications(c context.Context, payload io.Reader,
) (interface{}, error) {
func apiReportingPollNotifications(c context.Context, req *dashapi.PollNotificationsRequest) (
any, error) {
if stop, err := emergentlyStopped(c); err != nil || stop {
return &dashapi.PollNotificationsResponse{}, err
}
req := new(dashapi.PollNotificationsRequest)
if err := json.NewDecoder(payload).Decode(req); err != nil {
return nil, fmt.Errorf("failed to unmarshal request: %w", err)
}
notifs := reportingPollNotifications(c, req.Type)
resp := &dashapi.PollNotificationsResponse{
Notifications: notifs,
}
return resp, nil
}

func apiReportingPollClosed(c context.Context, payload io.Reader) (interface{}, error) {
func apiReportingPollClosed(c context.Context, req *dashapi.PollClosedRequest) (any, error) {
if stop, err := emergentlyStopped(c); err != nil || stop {
return &dashapi.PollClosedResponse{}, err
}
req := new(dashapi.PollClosedRequest)
if err := json.NewDecoder(payload).Decode(req); err != nil {
return nil, fmt.Errorf("failed to unmarshal request: %w", err)
}
ids, err := reportingPollClosed(c, req.IDs)
if err != nil {
return nil, err
Expand All @@ -72,11 +57,7 @@ func apiReportingPollClosed(c context.Context, payload io.Reader) (interface{},
return resp, nil
}

func apiReportingUpdate(c context.Context, payload io.Reader) (interface{}, error) {
req := new(dashapi.BugUpdate)
if err := json.NewDecoder(payload).Decode(req); err != nil {
return nil, fmt.Errorf("failed to unmarshal request: %w", err)
}
func apiReportingUpdate(c context.Context, req *dashapi.BugUpdate) (any, error) {
if req.JobID != "" {
resp := &dashapi.BugUpdateReply{
OK: true,
Expand All @@ -97,11 +78,7 @@ func apiReportingUpdate(c context.Context, payload io.Reader) (interface{}, erro
}, nil
}

func apiNewTestJob(c context.Context, payload io.Reader) (interface{}, error) {
req := new(dashapi.TestPatchRequest)
if err := json.NewDecoder(payload).Decode(req); err != nil {
return nil, fmt.Errorf("failed to unmarshal request: %w", err)
}
func apiNewTestJob(c context.Context, req *dashapi.TestPatchRequest) (any, error) {
resp := &dashapi.TestPatchReply{}
err := handleExternalTestRequest(c, req)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion dashboard/app/subsystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ type (
)

func updateBugSubsystems(c context.Context, bugKey *db.Key,
list []*subsystem.Subsystem, info interface{}) error {
list []*subsystem.Subsystem, info any) error {
now := timeNow(c)
return updateSingleBug(c, bugKey, func(bug *Bug) error {
switch v := info.(type) {
Expand Down
6 changes: 3 additions & 3 deletions dashboard/app/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func treeOriginJobDone(cGlobal context.Context, jobKey *db.Key, job *Job) error
return runInTransaction(cGlobal, tx, &db.TransactionOptions{XG: true})
}

type pollTreeJobResult interface{}
type pollTreeJobResult any

// pollResultPending is returned when we wait some job to finish.
type pollResultPending struct{}
Expand Down Expand Up @@ -371,15 +371,15 @@ func (ctx *bugTreeContext) groupResults(results []pollTreeJobResult) pollTreeJob
return pollResultSkip{}
}

type expectedResult interface{}
type expectedResult any

// resultFreshness subtypes.
type wantFirstOK struct{}
type wantFirstCrash struct{}
type wantFirstAny struct{}
type wantNewAny time.Time

type runReproOn interface{}
type runReproOn any

// runReproOn subtypes.
type runOnAny struct{} // attempts to find any result, if unsuccessful, runs on HEAD
Expand Down
10 changes: 5 additions & 5 deletions dashboard/app/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ func (c *Ctx) expectBadReqest(err error) {
expectFailureStatus(c.t, err, http.StatusBadRequest)
}

func (c *Ctx) expectEQ(got, want interface{}) {
func (c *Ctx) expectEQ(got, want any) {
if diff := cmp.Diff(got, want); diff != "" {
c.t.Helper()
c.t.Fatal(diff)
}
}

func (c *Ctx) expectNE(got, want interface{}) {
func (c *Ctx) expectNE(got, want any) {
if reflect.DeepEqual(got, want) {
c.t.Helper()
c.t.Fatalf("equal: %#v", got)
Expand Down Expand Up @@ -504,8 +504,8 @@ type apiClient struct {
}

func (c *Ctx) makeClient(client, key string, failOnErrors bool) *apiClient {
logger := func(msg string, args ...interface{}) {
c.t.Logf("%v: "+msg, append([]interface{}{caller(3)}, args...)...)
logger := func(msg string, args ...any) {
c.t.Logf("%v: "+msg, append([]any{caller(3)}, args...)...)
}
errorHandler := func(err error) {
if failOnErrors {
Expand Down Expand Up @@ -628,7 +628,7 @@ type (
EmailOptSender string
)

func (c *Ctx) incomingEmail(to, body string, opts ...interface{}) {
func (c *Ctx) incomingEmail(to, body string, opts ...any) {
id := 0
subject := "crash1"
from := "default@sender.com"
Expand Down
8 changes: 4 additions & 4 deletions dashboard/dashapi/dashapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func New(client, addr, key string, opts ...DashboardOpts) (*Dashboard, error) {
type (
RequestCtor func(method, url string, body io.Reader) (*http.Request, error)
RequestDoer func(req *http.Request) (*http.Response, error)
RequestLogger func(msg string, args ...interface{})
RequestLogger func(msg string, args ...any)
)

// key == "" indicates that the ambient GCE service account authority
Expand Down Expand Up @@ -407,7 +407,7 @@ type LogEntry struct {
}

// Centralized logging on dashboard.
func (dash *Dashboard) LogError(name, msg string, args ...interface{}) {
func (dash *Dashboard) LogError(name, msg string, args ...any) {
req := &LogEntry{
Name: name,
Text: fmt.Sprintf(msg, args...),
Expand Down Expand Up @@ -988,7 +988,7 @@ type JobInfo struct {
OnMergeBase bool
}

func (dash *Dashboard) Query(method string, req, reply interface{}) error {
func (dash *Dashboard) Query(method string, req, reply any) error {
if dash.logger != nil {
dash.logger("API(%v): %#v", method, req)
}
Expand All @@ -1008,7 +1008,7 @@ func (dash *Dashboard) Query(method string, req, reply interface{}) error {
return nil
}

func (dash *Dashboard) queryImpl(method string, req, reply interface{}) error {
func (dash *Dashboard) queryImpl(method string, req, reply any) error {
if reply != nil {
// json decoding behavior is somewhat surprising
// (see // https://github.com/golang/go/issues/21092).
Expand Down
8 changes: 4 additions & 4 deletions pkg/ast/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,24 @@ func TestParse(t *testing.T) {
var parseTests = []struct {
name string
input string
result []interface{}
result []any
}{
{
"empty",
``,
[]interface{}{},
[]any{},
},
{
"new-line",
`

`,
[]interface{}{},
[]any{},
},
{
"nil",
"\x00",
[]interface{}{},
[]any{},
},
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/ast/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func (s *scanner) scanIdent(pos Pos) (tok token, lit string) {
return
}

func (s *scanner) Errorf(pos Pos, msg string, args ...interface{}) {
func (s *scanner) Errorf(pos Pos, msg string, args ...any) {
s.errors++
s.errorHandler(pos, fmt.Sprintf(msg, args...))
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/bisect/bisect.go
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ func (env *env) log(msg string) {
env.logf("%v", msg)
}

func (env *env) logf(msg string, args ...interface{}) {
func (env *env) logf(msg string, args ...any) {
if false {
_ = fmt.Sprintf(msg, args...) // enable printf checker
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/bisect/minimize/slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Config[T any] struct {
// anongside the intermediate bisection result (a valid, but not fully minimized slice).
MaxChunks int
// Logf is used for sharing debugging output.
Logf func(string, ...interface{})
Logf func(string, ...any)
}

// Slice() finds a minimal subsequence of slice elements that still gives Pred() == true.
Expand All @@ -33,7 +33,7 @@ type Config[T any] struct {
// The expected number of Pred() runs is O(|result|*log2(|elements|)).
func Slice[T any](config Config[T], slice []T) ([]T, error) {
if config.Logf == nil {
config.Logf = func(string, ...interface{}) {}
config.Logf = func(string, ...any) {}
}
ctx := &sliceCtx[T]{
Config: config,
Expand Down
4 changes: 2 additions & 2 deletions pkg/compiler/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ type warn struct {
msg string
}

func (comp *compiler) error(pos ast.Pos, msg string, args ...interface{}) {
func (comp *compiler) error(pos ast.Pos, msg string, args ...any) {
comp.errors++
comp.eh(pos, fmt.Sprintf(msg, args...))
}

func (comp *compiler) warning(pos ast.Pos, msg string, args ...interface{}) {
func (comp *compiler) warning(pos ast.Pos, msg string, args ...any) {
comp.warnings = append(comp.warnings, warn{pos, fmt.Sprintf(msg, args...)})
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/compiler/const_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func DeserializeConstFile(glob string, eh ast.ErrorHandler) *ConstFile {

func (cf *ConstFile) deserializeFile(data []byte, file, arch string, eh ast.ErrorHandler) bool {
pos := ast.Pos{File: file, Line: 1}
errf := func(msg string, args ...interface{}) bool {
errf := func(msg string, args ...any) bool {
eh(pos, fmt.Sprintf(msg, args...))
return false
}
Expand Down Expand Up @@ -247,7 +247,7 @@ func (cf *ConstFile) deserializeFile(data []byte, file, arch string, eh ast.Erro
return true
}

type errft func(msg string, args ...interface{}) bool
type errft func(msg string, args ...any) bool

func (cf *ConstFile) parseConst(arches []string, name, line string, weak bool, errf errft) bool {
var dflt map[string]uint64
Expand Down
Loading
Loading