github.com/noqcks/syft@v0.0.0-20230920222752-a9e2c4e288e5/internal/redact/redact.go (about) 1 package redact 2 3 import "github.com/anchore/go-logger/adapter/redact" 4 5 var store redact.Store 6 7 func Set(s redact.Store) { 8 if store != nil { 9 // if someone is trying to set a redaction store and we already have one then something is wrong. The store 10 // that we're replacing might already have values in it, so we should never replace it. 11 panic("replace existing redaction store (probably unintentional)") 12 } 13 store = s 14 } 15 16 func Get() redact.Store { 17 return store 18 } 19 20 func Add(vs ...string) { 21 if store == nil { 22 // if someone is trying to add values that should never be output and we don't have a store then something is wrong. 23 // we should never accidentally output values that should be redacted, thus we panic here. 24 panic("cannot add redactions without a store") 25 } 26 store.Add(vs...) 27 } 28 29 func Apply(value string) string { 30 if store == nil { 31 // if someone is trying to add values that should never be output and we don't have a store then something is wrong. 32 // we should never accidentally output values that should be redacted, thus we panic here. 33 panic("cannot apply redactions without a store") 34 } 35 return store.RedactString(value) 36 }