Skip to content

Commit

Permalink
fix(snmp3): when using SNMPv3, userName always needs to be set. (#68)
Browse files Browse the repository at this point in the history
* When using SNMPv3, userName always needs to be set.

See https://tools.ietf.org/html/rfc3414#section-3.1, point 7: userName is set into the trap even when securityLevel = NoAuthNoPriv
Dependency "github.com/k-sone/snmpgo" is returning an error when username is not set

* feat(snmp3): Configure userName even when authentication is disabled.
  • Loading branch information
Guillaume Scott authored May 13, 2021
1 parent f7c908b commit 7a80841
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func ParseConfiguration(args []string) (*SNMPNotifierConfiguration, error) {
}

if !isV2c {
trapSenderConfiguration.SNMPAuthenticationUsername = *snmpAuthenticationUsername
trapSenderConfiguration.SNMPSecurityEngineID = *snmpSecurityEngineID
trapSenderConfiguration.SNMPContextEngineID = *snmpContextEngineID
trapSenderConfiguration.SNMPContextName = *snmpContextName
Expand All @@ -141,7 +142,6 @@ func ParseConfiguration(args []string) (*SNMPNotifierConfiguration, error) {
if *snmpAuthenticationEnabled {
trapSenderConfiguration.SNMPAuthenticationEnabled = *snmpAuthenticationEnabled
trapSenderConfiguration.SNMPAuthenticationProtocol = *snmpAuthenticationProtocol
trapSenderConfiguration.SNMPAuthenticationUsername = *snmpAuthenticationUsername
trapSenderConfiguration.SNMPAuthenticationPassword = *snmpAuthenticationPassword
}
if *snmpPrivateEnabled {
Expand Down
9 changes: 5 additions & 4 deletions configuration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,11 @@ var tests = []Test{
Severities: []string{"critical", "error", "warning", "info"},
},
trapsender.Configuration{
SNMPVersion: "V3",
SNMPDestination: "127.0.0.2:163",
SNMPRetries: 4,
ExtraFieldTemplates: make(map[string]template.Template),
SNMPVersion: "V3",
SNMPDestination: "127.0.0.2:163",
SNMPRetries: 4,
SNMPAuthenticationUsername: "username_v3",
ExtraFieldTemplates: make(map[string]template.Template),
},
httpserver.Configuration{
WebListenAddress: ":1234",
Expand Down

0 comments on commit 7a80841

Please sign in to comment.