mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2025-12-06 15:22:47 +01:00
Replace interface{} with any (#538)
Co-authored-by: Jonas Plum <git@jonasplum.de>
This commit is contained in:
@@ -693,9 +693,9 @@ func (s *aqlInterpreter) function(ctx *parser.Function_callContext) {
|
||||
}
|
||||
}
|
||||
|
||||
func unique(array []interface{}) []interface{} {
|
||||
seen := map[interface{}]bool{}
|
||||
var filtered []interface{}
|
||||
func unique(array []any) []any {
|
||||
seen := map[any]bool{}
|
||||
var filtered []any
|
||||
for _, e := range array {
|
||||
_, ok := seen[e]
|
||||
if !ok {
|
||||
@@ -707,7 +707,7 @@ func unique(array []interface{}) []interface{} {
|
||||
return filtered
|
||||
}
|
||||
|
||||
func contains(values []interface{}, e interface{}) bool {
|
||||
func contains(values []any, e any) bool {
|
||||
for _, v := range values {
|
||||
if e == v {
|
||||
return true
|
||||
|
||||
@@ -33,8 +33,7 @@ rm -rf generated/models/old
|
||||
rm -rf generated/.openapi-generator generated/.openapi-generator-ignore generated/README.md
|
||||
rm -rf ui/src/client/.openapi-generator ui/src/client/git_push.sh ui/src/client/.gitignore ui/src/client/.openapi-generator-ignore
|
||||
|
||||
gofmt -w -r 'interface{} -> any' .
|
||||
go mod tidy
|
||||
gci write --Section Standard --Section Default --Section "Prefix(github.com/SecurityBrewery/catalyst)" .
|
||||
cd internal/maut
|
||||
gci write --Section Standard --Section Default --Section "Prefix(github.com/jonas-plum/maut)" .
|
||||
cd ../..
|
||||
|
||||
@@ -118,7 +118,7 @@ func parseQueryOptionalBoolArray(r *http.Request, key string) ([]bool, error) {
|
||||
return parseQueryBoolArray(r, key)
|
||||
}
|
||||
|
||||
func parseBody(b []byte, i interface{}) error {
|
||||
func parseBody(b []byte, i any) error {
|
||||
dec := json.NewDecoder(bytes.NewBuffer(b))
|
||||
err := dec.Decode(i)
|
||||
if err != nil {
|
||||
@@ -137,7 +137,7 @@ func JSONErrorStatus(w http.ResponseWriter, status int, err error) {
|
||||
w.Write(b)
|
||||
}
|
||||
|
||||
func response(w http.ResponseWriter, v interface{}, err error) {
|
||||
func response(w http.ResponseWriter, v any, err error) {
|
||||
if err != nil {
|
||||
var httpError *HTTPError
|
||||
if errors.As(err, &httpError) {
|
||||
@@ -172,7 +172,7 @@ func validateSchema(body []byte, schema *gojsonschema.Schema, w http.ResponseWri
|
||||
validationErrors = append(validationErrors, valdiationError.String())
|
||||
}
|
||||
|
||||
b, _ := json.Marshal(map[string]interface{}{"error": "wrong input", "errors": validationErrors})
|
||||
b, _ := json.Marshal(map[string]any{"error": "wrong input", "errors": validationErrors})
|
||||
w.Write(b)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ type Service interface {
|
||||
CurrentUser(context.Context) (*model.UserResponse, error)
|
||||
CurrentUserData(context.Context) (*model.UserDataResponse, error)
|
||||
UpdateCurrentUserData(context.Context, *model.UserData) (*model.UserDataResponse, error)
|
||||
DashboardData(context.Context, string, *string) (map[string]interface{}, error)
|
||||
DashboardData(context.Context, string, *string) (map[string]any, error)
|
||||
ListDashboards(context.Context) ([]*model.DashboardResponse, error)
|
||||
CreateDashboard(context.Context, *model.Dashboard) (*model.DashboardResponse, error)
|
||||
GetDashboard(context.Context, string) (*model.DashboardResponse, error)
|
||||
@@ -60,8 +60,8 @@ type Service interface {
|
||||
RemoveComment(context.Context, int64, int) (*model.TicketWithTickets, error)
|
||||
AddTicketPlaybook(context.Context, int64, *model.PlaybookTemplateForm) (*model.TicketWithTickets, error)
|
||||
RemoveTicketPlaybook(context.Context, int64, string) (*model.TicketWithTickets, error)
|
||||
SetTaskData(context.Context, int64, string, string, map[string]interface{}) (*model.TicketWithTickets, error)
|
||||
CompleteTask(context.Context, int64, string, string, map[string]interface{}) (*model.TicketWithTickets, error)
|
||||
SetTaskData(context.Context, int64, string, string, map[string]any) (*model.TicketWithTickets, error)
|
||||
CompleteTask(context.Context, int64, string, string, map[string]any) (*model.TicketWithTickets, error)
|
||||
SetTaskOwner(context.Context, int64, string, string, string) (*model.TicketWithTickets, error)
|
||||
RunTask(context.Context, int64, string, string) error
|
||||
SetReferences(context.Context, int64, *model.ReferenceArray) (*model.TicketWithTickets, error)
|
||||
@@ -901,7 +901,7 @@ func (s *server) setTaskDataHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var dataP map[string]interface{}
|
||||
var dataP map[string]any
|
||||
if err := parseBody(body, &dataP); err != nil {
|
||||
JSONError(w, err)
|
||||
return
|
||||
@@ -928,7 +928,7 @@ func (s *server) completeTaskHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var dataP map[string]interface{}
|
||||
var dataP map[string]any
|
||||
if err := parseBody(body, &dataP); err != nil {
|
||||
JSONError(w, err)
|
||||
return
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -251,14 +251,14 @@ type DashboardResponse struct {
|
||||
}
|
||||
|
||||
type Enrichment struct {
|
||||
Created time.Time `json:"created"`
|
||||
Data map[string]interface{} `json:"data"`
|
||||
Name string `json:"name"`
|
||||
Created time.Time `json:"created"`
|
||||
Data map[string]any `json:"data"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type EnrichmentForm struct {
|
||||
Data map[string]interface{} `json:"data"`
|
||||
Name string `json:"name"`
|
||||
Data map[string]any `json:"data"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type File struct {
|
||||
@@ -267,39 +267,39 @@ type File struct {
|
||||
}
|
||||
|
||||
type Job struct {
|
||||
Automation string `json:"automation"`
|
||||
Container *string `json:"container,omitempty"`
|
||||
Log *string `json:"log,omitempty"`
|
||||
Origin *Origin `json:"origin,omitempty"`
|
||||
Output map[string]interface{} `json:"output,omitempty"`
|
||||
Payload interface{} `json:"payload,omitempty"`
|
||||
Running bool `json:"running"`
|
||||
Status string `json:"status"`
|
||||
Automation string `json:"automation"`
|
||||
Container *string `json:"container,omitempty"`
|
||||
Log *string `json:"log,omitempty"`
|
||||
Origin *Origin `json:"origin,omitempty"`
|
||||
Output map[string]any `json:"output,omitempty"`
|
||||
Payload any `json:"payload,omitempty"`
|
||||
Running bool `json:"running"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type JobForm struct {
|
||||
Automation string `json:"automation"`
|
||||
Origin *Origin `json:"origin,omitempty"`
|
||||
Payload interface{} `json:"payload,omitempty"`
|
||||
Automation string `json:"automation"`
|
||||
Origin *Origin `json:"origin,omitempty"`
|
||||
Payload any `json:"payload,omitempty"`
|
||||
}
|
||||
|
||||
type JobResponse struct {
|
||||
Automation string `json:"automation"`
|
||||
Container *string `json:"container,omitempty"`
|
||||
ID string `json:"id"`
|
||||
Log *string `json:"log,omitempty"`
|
||||
Origin *Origin `json:"origin,omitempty"`
|
||||
Output map[string]interface{} `json:"output,omitempty"`
|
||||
Payload interface{} `json:"payload,omitempty"`
|
||||
Status string `json:"status"`
|
||||
Automation string `json:"automation"`
|
||||
Container *string `json:"container,omitempty"`
|
||||
ID string `json:"id"`
|
||||
Log *string `json:"log,omitempty"`
|
||||
Origin *Origin `json:"origin,omitempty"`
|
||||
Output map[string]any `json:"output,omitempty"`
|
||||
Payload any `json:"payload,omitempty"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type JobUpdate struct {
|
||||
Container *string `json:"container,omitempty"`
|
||||
Log *string `json:"log,omitempty"`
|
||||
Output map[string]interface{} `json:"output,omitempty"`
|
||||
Running bool `json:"running"`
|
||||
Status string `json:"status"`
|
||||
Container *string `json:"container,omitempty"`
|
||||
Log *string `json:"log,omitempty"`
|
||||
Output map[string]any `json:"output,omitempty"`
|
||||
Running bool `json:"running"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type LogEntry struct {
|
||||
@@ -312,7 +312,7 @@ type LogEntry struct {
|
||||
|
||||
type Message struct {
|
||||
Context *Context `json:"context,omitempty"`
|
||||
Payload interface{} `json:"payload,omitempty"`
|
||||
Payload any `json:"payload,omitempty"`
|
||||
Secrets map[string]string `json:"secrets,omitempty"`
|
||||
}
|
||||
|
||||
@@ -385,18 +385,18 @@ type Statistics struct {
|
||||
}
|
||||
|
||||
type Task struct {
|
||||
Automation *string `json:"automation,omitempty"`
|
||||
Closed *time.Time `json:"closed,omitempty"`
|
||||
Created time.Time `json:"created"`
|
||||
Data map[string]interface{} `json:"data,omitempty"`
|
||||
Done bool `json:"done"`
|
||||
Join *bool `json:"join,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Next map[string]string `json:"next,omitempty"`
|
||||
Owner *string `json:"owner,omitempty"`
|
||||
Payload map[string]string `json:"payload,omitempty"`
|
||||
Schema map[string]interface{} `json:"schema,omitempty"`
|
||||
Type string `json:"type"`
|
||||
Automation *string `json:"automation,omitempty"`
|
||||
Closed *time.Time `json:"closed,omitempty"`
|
||||
Created time.Time `json:"created"`
|
||||
Data map[string]any `json:"data,omitempty"`
|
||||
Done bool `json:"done"`
|
||||
Join *bool `json:"join,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Next map[string]string `json:"next,omitempty"`
|
||||
Owner *string `json:"owner,omitempty"`
|
||||
Payload map[string]string `json:"payload,omitempty"`
|
||||
Schema map[string]any `json:"schema,omitempty"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
type TaskOrigin struct {
|
||||
@@ -406,20 +406,20 @@ type TaskOrigin struct {
|
||||
}
|
||||
|
||||
type TaskResponse struct {
|
||||
Active bool `json:"active"`
|
||||
Automation *string `json:"automation,omitempty"`
|
||||
Closed *time.Time `json:"closed,omitempty"`
|
||||
Created time.Time `json:"created"`
|
||||
Data map[string]interface{} `json:"data,omitempty"`
|
||||
Done bool `json:"done"`
|
||||
Join *bool `json:"join,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Next map[string]string `json:"next,omitempty"`
|
||||
Order int64 `json:"order"`
|
||||
Owner *string `json:"owner,omitempty"`
|
||||
Payload map[string]string `json:"payload,omitempty"`
|
||||
Schema map[string]interface{} `json:"schema,omitempty"`
|
||||
Type string `json:"type"`
|
||||
Active bool `json:"active"`
|
||||
Automation *string `json:"automation,omitempty"`
|
||||
Closed *time.Time `json:"closed,omitempty"`
|
||||
Created time.Time `json:"created"`
|
||||
Data map[string]any `json:"data,omitempty"`
|
||||
Done bool `json:"done"`
|
||||
Join *bool `json:"join,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Next map[string]string `json:"next,omitempty"`
|
||||
Order int64 `json:"order"`
|
||||
Owner *string `json:"owner,omitempty"`
|
||||
Payload map[string]string `json:"payload,omitempty"`
|
||||
Schema map[string]any `json:"schema,omitempty"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
type TaskWithContext struct {
|
||||
@@ -432,28 +432,28 @@ type TaskWithContext struct {
|
||||
}
|
||||
|
||||
type Ticket struct {
|
||||
Artifacts []*Artifact `json:"artifacts,omitempty"`
|
||||
Comments []*Comment `json:"comments,omitempty"`
|
||||
Created time.Time `json:"created"`
|
||||
Details map[string]interface{} `json:"details,omitempty"`
|
||||
Files []*File `json:"files,omitempty"`
|
||||
Modified time.Time `json:"modified"`
|
||||
Name string `json:"name"`
|
||||
Owner *string `json:"owner,omitempty"`
|
||||
Playbooks map[string]*Playbook `json:"playbooks,omitempty"`
|
||||
Read []string `json:"read,omitempty"`
|
||||
References []*Reference `json:"references,omitempty"`
|
||||
Schema string `json:"schema"`
|
||||
Status string `json:"status"`
|
||||
Type string `json:"type"`
|
||||
Write []string `json:"write,omitempty"`
|
||||
Artifacts []*Artifact `json:"artifacts,omitempty"`
|
||||
Comments []*Comment `json:"comments,omitempty"`
|
||||
Created time.Time `json:"created"`
|
||||
Details map[string]any `json:"details,omitempty"`
|
||||
Files []*File `json:"files,omitempty"`
|
||||
Modified time.Time `json:"modified"`
|
||||
Name string `json:"name"`
|
||||
Owner *string `json:"owner,omitempty"`
|
||||
Playbooks map[string]*Playbook `json:"playbooks,omitempty"`
|
||||
Read []string `json:"read,omitempty"`
|
||||
References []*Reference `json:"references,omitempty"`
|
||||
Schema string `json:"schema"`
|
||||
Status string `json:"status"`
|
||||
Type string `json:"type"`
|
||||
Write []string `json:"write,omitempty"`
|
||||
}
|
||||
|
||||
type TicketForm struct {
|
||||
Artifacts []*Artifact `json:"artifacts,omitempty"`
|
||||
Comments []*Comment `json:"comments,omitempty"`
|
||||
Created *time.Time `json:"created,omitempty"`
|
||||
Details map[string]interface{} `json:"details,omitempty"`
|
||||
Details map[string]any `json:"details,omitempty"`
|
||||
Files []*File `json:"files,omitempty"`
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
Modified *time.Time `json:"modified,omitempty"`
|
||||
@@ -479,7 +479,7 @@ type TicketResponse struct {
|
||||
Artifacts []*Artifact `json:"artifacts,omitempty"`
|
||||
Comments []*Comment `json:"comments,omitempty"`
|
||||
Created time.Time `json:"created"`
|
||||
Details map[string]interface{} `json:"details,omitempty"`
|
||||
Details map[string]any `json:"details,omitempty"`
|
||||
Files []*File `json:"files,omitempty"`
|
||||
ID int64 `json:"id"`
|
||||
Modified time.Time `json:"modified"`
|
||||
@@ -495,22 +495,22 @@ type TicketResponse struct {
|
||||
}
|
||||
|
||||
type TicketSimpleResponse struct {
|
||||
Artifacts []*Artifact `json:"artifacts,omitempty"`
|
||||
Comments []*Comment `json:"comments,omitempty"`
|
||||
Created time.Time `json:"created"`
|
||||
Details map[string]interface{} `json:"details,omitempty"`
|
||||
Files []*File `json:"files,omitempty"`
|
||||
ID int64 `json:"id"`
|
||||
Modified time.Time `json:"modified"`
|
||||
Name string `json:"name"`
|
||||
Owner *string `json:"owner,omitempty"`
|
||||
Playbooks map[string]*Playbook `json:"playbooks,omitempty"`
|
||||
Read []string `json:"read,omitempty"`
|
||||
References []*Reference `json:"references,omitempty"`
|
||||
Schema string `json:"schema"`
|
||||
Status string `json:"status"`
|
||||
Type string `json:"type"`
|
||||
Write []string `json:"write,omitempty"`
|
||||
Artifacts []*Artifact `json:"artifacts,omitempty"`
|
||||
Comments []*Comment `json:"comments,omitempty"`
|
||||
Created time.Time `json:"created"`
|
||||
Details map[string]any `json:"details,omitempty"`
|
||||
Files []*File `json:"files,omitempty"`
|
||||
ID int64 `json:"id"`
|
||||
Modified time.Time `json:"modified"`
|
||||
Name string `json:"name"`
|
||||
Owner *string `json:"owner,omitempty"`
|
||||
Playbooks map[string]*Playbook `json:"playbooks,omitempty"`
|
||||
Read []string `json:"read,omitempty"`
|
||||
References []*Reference `json:"references,omitempty"`
|
||||
Schema string `json:"schema"`
|
||||
Status string `json:"status"`
|
||||
Type string `json:"type"`
|
||||
Write []string `json:"write,omitempty"`
|
||||
}
|
||||
|
||||
type TicketTemplate struct {
|
||||
@@ -560,7 +560,7 @@ type TicketWithTickets struct {
|
||||
Artifacts []*Artifact `json:"artifacts,omitempty"`
|
||||
Comments []*Comment `json:"comments,omitempty"`
|
||||
Created time.Time `json:"created"`
|
||||
Details map[string]interface{} `json:"details,omitempty"`
|
||||
Details map[string]any `json:"details,omitempty"`
|
||||
Files []*File `json:"files,omitempty"`
|
||||
ID int64 `json:"id"`
|
||||
Logs []*LogEntry `json:"logs,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user