feat(check): gRPC, SMTP, RADIUS and SNMP checks
gRPC asks the standard health service, optionally about one service. SMTP waits for the greeting, says EHLO and, unless disabled, requires STARTTLS or connects with implicit TLS. RADIUS sends an Access-Request signed with a Message-Authenticator and tells a rejected login from a wrong shared secret. SNMP v1/v2c reads one OID and compares its value textually or numerically, hinting at the community when the agent stays silent. All go through the network guard. Errors from dialing are no longer passed through redaction, and secrets shorter than four characters are left in messages instead of garbling them. Refs #95 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
302514dc35
commit
03f6e9137f
8 files changed
+675
-4
No files matched your search
@@ -2,6 +2,7 @@ package check
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"net"
|
||||
"strings"
|
||||
)
|
||||
@@ -20,11 +21,16 @@ func tlsFor(mode, target string) *tls.Config {
|
||||
}
|
||||
|
||||
// redact shortens err for customers and removes secrets some clients
|
||||
// repeat in their errors.
|
||||
// repeat in their errors. Secrets shorter than four characters are left:
|
||||
// replacing them would garble the message while hiding little.
|
||||
func redact(err error, secrets ...string) string {
|
||||
var op *net.OpError
|
||||
if errors.As(err, &op) && op.Op == "dial" {
|
||||
return describeNetErr(err)
|
||||
}
|
||||
msg := err.Error()
|
||||
for _, s := range secrets {
|
||||
if s != "" {
|
||||
if len(s) >= 4 {
|
||||
msg = strings.ReplaceAll(msg, s, "***")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user