Skip to content

Commit

Permalink
Skipped authentication when not needed to fix broken test case. Relat…
Browse files Browse the repository at this point in the history
…ed to #41.
  • Loading branch information
lextm committed Feb 4, 2024
1 parent 41ae447 commit df43b94
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions pysnmp/proto/secmod/rfc3414/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,28 +902,30 @@ def processIncomingMsg(self, snmpEngine, messageProcessingModel,
errorIndication=errind.authenticationFailure
)

hash = securityParameters.getComponentByPosition(4)
try:
authHandler.authenticateIncomingMsg(
usmUserAuthKeyLocalized,
securityParameters.getComponentByPosition(4),
hash,
wholeMsg
)

except error.StatusInformation:
usmStatsWrongDigests, = mibBuilder.importSymbols(
'__SNMP-USER-BASED-SM-MIB', 'usmStatsWrongDigests')
usmStatsWrongDigests.syntax += 1
raise error.StatusInformation(
errorIndication=errind.authenticationFailure,
oid=usmStatsWrongDigests.name,
val=usmStatsWrongDigests.syntax,
securityStateReference=securityStateReference,
securityLevel=securityLevel,
contextEngineId=contextEngineId,
contextName=contextName,
msgUserName=msgUserName,
maxSizeResponseScopedPDU=maxSizeResponseScopedPDU
)
if len(hash) != 0: # don't throw error if hash is empty (and agent returned REPORT)
usmStatsWrongDigests, = mibBuilder.importSymbols(
'__SNMP-USER-BASED-SM-MIB', 'usmStatsWrongDigests')
usmStatsWrongDigests.syntax += 1
raise error.StatusInformation(
errorIndication=errind.authenticationFailure,
oid=usmStatsWrongDigests.name,
val=usmStatsWrongDigests.syntax,
securityStateReference=securityStateReference,
securityLevel=securityLevel,
contextEngineId=contextEngineId,
contextName=contextName,
msgUserName=msgUserName,
maxSizeResponseScopedPDU=maxSizeResponseScopedPDU
)

debug.logger & debug.flagSM and debug.logger('processIncomingMsg: incoming msg authenticated')

Expand Down

0 comments on commit df43b94

Please sign in to comment.