Only replace secret text if it is longer than 2 characters
This is inline with what Travis does. Otherwise, for very short
secrets our regex based approach will throw `[secret]` all over the
place.
@@ -114,17 +114,24 @@ func makeEventEmitter(events chan<- Event, update Update) eventEmitter {
if !v.Secure() {
continue
}
+ secret, err := v.Value(target.Decrypter)
+ contract.AssertNoError(err)
+
+ // For short secrets, don't actually add them to the filter, this is a trade-off we make to prevent
+ // displaying `[secret]`. Travis does a similar thing, for example.
+ if len(secret) < 3 {
+ continue
+ }
if b.Len() > 0 {
b.WriteRune('|')
}
- secret, err := v.Value(target.Decrypter)
- contract.AssertNoError(err)
b.WriteString(regexp.QuoteMeta(secret))
}
-
+ if b.Len() > 0 {
f = &regexFilter{re: regexp.MustCompile(b.String())}
}
+ }
return eventEmitter{
Chan: events,
