v0.1.7 removed spew usage for serializing complex raw logs
This commit is contained in:
@@ -2,12 +2,10 @@ module github.com/lixenwraith/log
|
|||||||
|
|
||||||
go 1.26.0
|
go 1.26.0
|
||||||
|
|
||||||
require (
|
require github.com/stretchr/testify v1.11.1
|
||||||
github.com/davecgh/go-spew v1.1.1
|
|
||||||
github.com/stretchr/testify v1.11.1
|
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
+2
-22
@@ -8,14 +8,11 @@
|
|||||||
package sanitizer
|
package sanitizer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"unicode"
|
"unicode"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Filter flags for character matching
|
// Filter flags for character matching
|
||||||
@@ -323,24 +320,8 @@ func (se *Serializer) WriteNil(buf *[]byte) {
|
|||||||
|
|
||||||
// WriteComplex writes complex types
|
// WriteComplex writes complex types
|
||||||
func (se *Serializer) WriteComplex(buf *[]byte, v any) {
|
func (se *Serializer) WriteComplex(buf *[]byte, v any) {
|
||||||
switch se.format {
|
str := fmt.Sprintf("%+v", v)
|
||||||
// For debugging
|
se.WriteString(buf, str)
|
||||||
case "raw":
|
|
||||||
var b bytes.Buffer
|
|
||||||
dumper := &spew.ConfigState{
|
|
||||||
Indent: " ",
|
|
||||||
MaxDepth: 10,
|
|
||||||
DisablePointerAddresses: true,
|
|
||||||
DisableCapacities: true,
|
|
||||||
SortKeys: true,
|
|
||||||
}
|
|
||||||
dumper.Fdump(&b, v)
|
|
||||||
*buf = append(*buf, bytes.TrimSpace(b.Bytes())...)
|
|
||||||
|
|
||||||
default:
|
|
||||||
str := fmt.Sprintf("%+v", v)
|
|
||||||
se.WriteString(buf, str)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NeedsQuotes determines if quoting is needed
|
// NeedsQuotes determines if quoting is needed
|
||||||
@@ -371,4 +352,3 @@ func (se *Serializer) NeedsQuotes(s string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -300,4 +300,3 @@ func TestPolicyShellExtended(t *testing.T) {
|
|||||||
assert.Equal(t, "rm-rf", s.Sanitize("rm -rf *"))
|
assert.Equal(t, "rm-rf", s.Sanitize("rm -rf *"))
|
||||||
assert.Equal(t, "ab", s.Sanitize("a\x00\x1bb")) // control stripped
|
assert.Equal(t, "ab", s.Sanitize("a\x00\x1bb")) // control stripped
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user