diff --git a/modules/analyze/export-graph.go b/modules/analyze/export-graph.go index b1e69b6..320ae8c 100644 --- a/modules/analyze/export-graph.go +++ b/modules/analyze/export-graph.go @@ -35,7 +35,7 @@ func ExportGraphViz(pg engine.Graph, filename string) error { type MethodMap map[string]bool -type MapStringInterface map[string]interface{} +type MapStringInterface map[string]any type CytoGraph struct { FormatVersion string `json:"format_version"` @@ -88,7 +88,7 @@ func GenerateCytoscapeJS(pg engine.Graph, alldetails bool) (CytoGraph, error) { newnode := CytoFlatElement{ Group: "nodes", - Data: map[string]interface{}{ + Data: map[string]any{ "id": fmt.Sprintf("n%v", object.ID()), "label": object.Label(), "type": object.Type().String(), diff --git a/modules/analyze/preferences.go b/modules/analyze/preferences.go index ac05f25..2f0b5ed 100644 --- a/modules/analyze/preferences.go +++ b/modules/analyze/preferences.go @@ -9,7 +9,7 @@ import ( ) type Prefs struct { - data map[string]interface{} + data map[string]any } var prefmutex sync.Mutex @@ -17,7 +17,7 @@ var prefmutex sync.Mutex func (p *Prefs) Load() error { prefmutex.Lock() defer prefmutex.Unlock() - p.data = make(map[string]interface{}) + p.data = make(map[string]any) rawprefs, err := ioutil.ReadFile("preferences.json") if errors.Is(err, os.ErrNotExist) { @@ -41,13 +41,13 @@ func (p *Prefs) Save() error { return err } -func (p *Prefs) Set(key string, val interface{}) { +func (p *Prefs) Set(key string, val any) { prefmutex.Lock() defer prefmutex.Unlock() p.data[key] = val } -func (p *Prefs) Get(key string) interface{} { +func (p *Prefs) Get(key string) any { prefmutex.Lock() defer prefmutex.Unlock() return p.data[key] diff --git a/modules/analyze/webservicefuncs.go b/modules/analyze/webservicefuncs.go index e42e0d2..67db4d3 100644 --- a/modules/analyze/webservicefuncs.go +++ b/modules/analyze/webservicefuncs.go @@ -921,7 +921,7 @@ func analysisfuncs(ws *webservice) { case "GET": json.NewEncoder(w).Encode(prefs.data) case "POST": - newprefs := make(map[string]interface{}) + newprefs := make(map[string]any) err := json.NewDecoder(r.Body).Decode(&newprefs) if err != nil { w.WriteHeader(500) diff --git a/modules/engine/attributevalue.go b/modules/engine/attributevalue.go index 607a7b1..7cc29a9 100644 --- a/modules/engine/attributevalue.go +++ b/modules/engine/attributevalue.go @@ -147,7 +147,7 @@ func (avo AttributeValueOne) StringSlice() []string { type AttributeValue interface { String() string - Raw() interface{} + Raw() any IsZero() bool } @@ -164,7 +164,7 @@ func (avo AttributeValueObject) String() string { return (*Object)(avo.Object).Label() + " (object)" } -func (avo AttributeValueObject) Raw() interface{} { +func (avo AttributeValueObject) Raw() any { return (*Object)(avo.Object) } @@ -181,7 +181,7 @@ func (as AttributeValueString) String() string { return string(as) } -func (as AttributeValueString) Raw() interface{} { +func (as AttributeValueString) Raw() any { return string(as) } @@ -195,7 +195,7 @@ func (ab AttributeValueBlob) String() string { return fmt.Sprintf("% x", []byte(ab)) } -func (ab AttributeValueBlob) Raw() interface{} { +func (ab AttributeValueBlob) Raw() any { return []byte(ab) } @@ -212,7 +212,7 @@ func (ab AttributeValueBool) String() string { return "false" } -func (ab AttributeValueBool) Raw() interface{} { +func (ab AttributeValueBool) Raw() any { return bool(ab) } @@ -226,7 +226,7 @@ func (as AttributeValueInt) String() string { return strconv.FormatInt(int64(as), 10) } -func (as AttributeValueInt) Raw() interface{} { +func (as AttributeValueInt) Raw() any { return int64(as) } @@ -240,7 +240,7 @@ func (as AttributeValueTime) String() string { return time.Time(as).Format("20060102150405") } -func (as AttributeValueTime) Raw() interface{} { +func (as AttributeValueTime) Raw() any { return time.Time(as) } @@ -254,7 +254,7 @@ func (as AttributeValueSID) String() string { return windowssecurity.SID(as).String() } -func (as AttributeValueSID) Raw() interface{} { +func (as AttributeValueSID) Raw() any { return windowssecurity.SID(as) } @@ -268,7 +268,7 @@ func (as AttributeValueGUID) String() string { return (uuid.UUID)(as).String() } -func (as AttributeValueGUID) Raw() interface{} { +func (as AttributeValueGUID) Raw() any { return uuid.UUID(as) } diff --git a/modules/engine/graph.go b/modules/engine/graph.go index 279cd3f..446017d 100644 --- a/modules/engine/graph.go +++ b/modules/engine/graph.go @@ -2,7 +2,7 @@ package engine import "github.com/lkarlslund/adalanche/modules/ui" -type DynamicFields map[string]interface{} +type DynamicFields map[string]any type Graph struct { Nodes []GraphNode @@ -142,14 +142,14 @@ type GraphNode struct { Target bool } -func (n *GraphNode) Set(key string, value interface{}) { +func (n *GraphNode) Set(key string, value any) { if n.DynamicFields == nil { n.DynamicFields = make(DynamicFields) } n.DynamicFields[key] = value } -func (n *GraphNode) Get(key string) interface{} { +func (n *GraphNode) Get(key string) any { if n.DynamicFields == nil { return nil } @@ -162,14 +162,14 @@ type GraphEdge struct { EdgeBitmap } -func (e *GraphEdge) Set(key string, value interface{}) { +func (e *GraphEdge) Set(key string, value any) { if e.DynamicFields == nil { e.DynamicFields = make(DynamicFields) } e.DynamicFields[key] = value } -func (e *GraphEdge) Get(key string) interface{} { +func (e *GraphEdge) Get(key string) any { if e.DynamicFields == nil { return nil } diff --git a/modules/engine/object.go b/modules/engine/object.go index 5236b10..b228969 100644 --- a/modules/engine/object.go +++ b/modules/engine/object.go @@ -52,7 +52,7 @@ type Object struct { var IgnoreBlanks = "_IGNOREBLANKS_" -func NewObject(flexinit ...interface{}) *Object { +func NewObject(flexinit ...any) *Object { var result Object result.init(0) result.setFlex(flexinit...) @@ -526,7 +526,7 @@ func (o *Object) OneAttrString(attr Attribute) string { return a.First().String() } -func (o *Object) OneAttrRaw(attr Attribute) interface{} { +func (o *Object) OneAttrRaw(attr Attribute) any { a := o.Attr(attr) if a == nil { return nil @@ -614,18 +614,18 @@ func (o *Object) SetValues(a Attribute, values ...AttributeValue) { } } -func (o *Object) SetFlex(flexinit ...interface{}) { +func (o *Object) SetFlex(flexinit ...any) { o.setFlex(flexinit...) } var avsPool = sync.Pool{ - New: func() interface{} { + New: func() any { avs := make(AttributeValueSlice, 0, 16) return &avs }, } -func (o *Object) setFlex(flexinit ...interface{}) { +func (o *Object) setFlex(flexinit ...any) { var ignoreblanks bool attribute := NonExistingAttribute diff --git a/modules/engine/objects.go b/modules/engine/objects.go index 43a6f8b..e278bfc 100644 --- a/modules/engine/objects.go +++ b/modules/engine/objects.go @@ -21,7 +21,7 @@ type typestatistics [256]int type Objects struct { root *Object - DefaultValues []interface{} + DefaultValues []any objects gsync.MapOf[ObjectID, *Object] multiindexes map[AttributePair]*MultiIndex // Uses a map for storage considerations @@ -42,7 +42,7 @@ func NewObjects() *Objects { return &os } -func (os *Objects) AddDefaultFlex(data ...interface{}) { +func (os *Objects) AddDefaultFlex(data ...any) { os.DefaultValues = append(os.DefaultValues, data...) } @@ -272,7 +272,7 @@ func (os *Objects) Filter(evaluate func(o *Object) bool) *Objects { return result } -func (os *Objects) AddNew(flexinit ...interface{}) *Object { +func (os *Objects) AddNew(flexinit ...any) *Object { o := NewObject(flexinit...) if os.DefaultValues != nil { o.setFlex(os.DefaultValues...) @@ -504,7 +504,7 @@ func (os *Objects) IterateParallel(each func(o *Object) bool, parallelFuncs int) wg.Wait() } -func (os *Objects) MergeOrAdd(attribute Attribute, value AttributeValue, flexinit ...interface{}) (*Object, bool) { +func (os *Objects) MergeOrAdd(attribute Attribute, value AttributeValue, flexinit ...any) (*Object, bool) { results, found := os.FindMultiOrAdd(attribute, value, func() *Object { // Add this is not found return NewObject(append(flexinit, attribute, value)...) @@ -530,7 +530,7 @@ func (os *Objects) FindOrAddObject(o *Object) bool { return found } -func (os *Objects) FindOrAdd(attribute Attribute, value AttributeValue, flexinit ...interface{}) (*Object, bool) { +func (os *Objects) FindOrAdd(attribute Attribute, value AttributeValue, flexinit ...any) (*Object, bool) { o, found := os.FindMultiOrAdd(attribute, value, func() *Object { return NewObject(append(flexinit, attribute, value)...) }) @@ -553,7 +553,7 @@ func (os *Objects) FindTwo(attribute Attribute, value AttributeValue, attribute2 return results.First(), results.Len() == 1 } -func (os *Objects) FindTwoOrAdd(attribute Attribute, value AttributeValue, attribute2 Attribute, value2 AttributeValue, flexinit ...interface{}) (o *Object, found bool) { +func (os *Objects) FindTwoOrAdd(attribute Attribute, value AttributeValue, attribute2 Attribute, value2 AttributeValue, flexinit ...any) (o *Object, found bool) { results, found := os.FindTwoMultiOrAdd(attribute, value, attribute2, value2, func() *Object { return NewObject(append(flexinit, attribute, value, attribute2, value2)...) }) diff --git a/modules/integrations/activedirectory/collect/ldap_multiplatform.go b/modules/integrations/activedirectory/collect/ldap_multiplatform.go index 9a5dcbd..c17d046 100644 --- a/modules/integrations/activedirectory/collect/ldap_multiplatform.go +++ b/modules/integrations/activedirectory/collect/ldap_multiplatform.go @@ -305,8 +305,8 @@ func (c *ControlInteger) String() string { return fmt.Sprintf("Control Type: %v Critiality: %t Control Value: %v", c.ControlType, c.Criticality, c.ControlValue) } -func LDAPtoMaptringInterface(e *ldap.Entry) map[string]interface{} { - result := make(map[string]interface{}) +func LDAPtoMaptringInterface(e *ldap.Entry) map[string]any { + result := make(map[string]any) for _, attribute := range e.Attributes { if len(attribute.Values) == 1 { result[attribute.Name] = attribute.Values[0] diff --git a/modules/integrations/activedirectory/rawobject.go b/modules/integrations/activedirectory/rawobject.go index 88adf11..4512122 100644 --- a/modules/integrations/activedirectory/rawobject.go +++ b/modules/integrations/activedirectory/rawobject.go @@ -76,7 +76,7 @@ func (item *RawObject) IngestLDAP(source *ldap.Entry) error { // Performance hack var avsPool = sync.Pool{ - New: func() interface{} { + New: func() any { return make(engine.AttributeValueSlice, 0, 16) }, } diff --git a/modules/ui/log.go b/modules/ui/log.go index ba17e95..7e0cf37 100644 --- a/modules/ui/log.go +++ b/modules/ui/log.go @@ -68,7 +68,7 @@ type Logger struct { pterm pterm.PrefixPrinter } -func (t Logger) Msgf(format string, args ...interface{}) Logger { +func (t Logger) Msgf(format string, args ...any) Logger { outputMutex.Lock() var timetext string