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
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1
|
||||
github.com/stretchr/testify v1.11.1
|
||||
)
|
||||
require github.com/stretchr/testify v1.11.1
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
@@ -8,14 +8,11 @@
|
||||
package sanitizer
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
)
|
||||
|
||||
// Filter flags for character matching
|
||||
@@ -323,24 +320,8 @@ func (se *Serializer) WriteNil(buf *[]byte) {
|
||||
|
||||
// WriteComplex writes complex types
|
||||
func (se *Serializer) WriteComplex(buf *[]byte, v any) {
|
||||
switch se.format {
|
||||
// For debugging
|
||||
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
|
||||
@@ -371,4 +352,3 @@ func (se *Serializer) NeedsQuotes(s string) bool {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -300,4 +300,3 @@ func TestPolicyShellExtended(t *testing.T) {
|
||||
assert.Equal(t, "rm-rf", s.Sanitize("rm -rf *"))
|
||||
assert.Equal(t, "ab", s.Sanitize("a\x00\x1bb")) // control stripped
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user