Repository navigation
docs: document the package, its known bugs, the README and the examples - #57
Merged
Merged
Conversation
…igning SnmpVersion.String prints an unknown version as "3"; Partition with a partition size of 0 panics; ToBigInt of a uint above math.MaxInt64 comes out negative on 64-bit platforms; SnmpEncodePacket signs an authenticated SNMPv3 message with an empty key when the client has none. The documentation of these functions will name them as known bugs.
The package had no doc. doc.go covers the lifecycle, concurrency, request attempts and timeouts, hook order, SNMPv3 discovery and Reports, walks, the Go types of varbind values, decode leniencies, in-place decoding, the key cache and the two trap paths.
Document every exported identifier of the client, packets and values: the GoSNMP fields (Timeout is per attempt, Retries, AppOpts by presence, Control, LocalAddr; unexported fields last), the request methods and their limits, Handler pointing at GoSNMP's methods, NewHandler, SnmpPDU, Asn1BER, PDUType, SnmpPacket, SnmpTrap, MarshalMsg, SnmpEncodePacket, SnmpDecodePacket, Partition, ToBigInt, Check and the error group. Name the known bugs of SnmpVersion.String, Partition, ToBigInt, the empty-key signing, ConnectIPv4/ConnectIPv6 and the ID reseeding. SnmpVersion.String moves to packet.go, the Asn* constants to value.go.
Document UsmSecurityParameters and its fields, InitSecurityKeys, PasswordCaching, the security parameters table, UnmarshalTrap and the unexported helpers that lacked docs. Mark the pinned bugs where they happen: the trap digest checks, the table path's nil-parameters panic, keys-only users on a new engine ID, encode's msgID by the client's version, the PDU type error text and the FIPS 140-only panics. Correct the discovery known-bug note (every authenticated level fails for want of a key) and the stale comments.
Fix the example paths and the README's copy of examples/example, list every example, drop the identifier g.MAX_OIDS that does not exist (MaxOids), the upstream first-person text and the alouca/gosnmp migration notes, list the types Set takes, point at the package documentation for value types instead of a BER list that named types the decoder does not decode, use documentation addresses, and give coverage commands that work with current Go.
InitSecurityKeys derives an empty authentication key, an empty DES key and, for Blumenthal AES-256 with an HMAC-SHA-256 user, a key extended from the empty localized key, all without an error.
A user configured with keys instead of passphrases loses them when a trap names another engine ID: the key derived from the empty passphrase is empty, and the digest it verifies is one anyone can compute. Pinned for the table and the single-user paths, with a passphrase user rejecting the same trap.
Set sends a later varbind of another type the encoder takes; discovery accepts a usmStatsUnknownUserNames Report that carries an engine ID; a decoded packet's security parameters are a copy of the client's; only header fields of the five field types are skipped; varbind names may be text; the Traps section and UnmarshalTrap say whose flags check a trap, that it decodes any PDU without comparing the community, that a keys-only user accepts a trap signed with the empty key, and that malformed messages can panic; the package doc lists the known bugs a client meets; walk endings, OnRetry, a zero Timeout's dial, the error group, SafeString's community, the README's Hex-String line and logging, and the unused IPv4 test variables are corrected. Known-bug markers at isAuthentic, hmacRFC3414 and the 32-bit Uinteger32 decode.
adoptEngineID's note now matches InitSecurityKeys (a Blumenthal AES key derived from nothing is usable by anyone); a decoded packet's security parameters are a copy of those it was decoded with, and the Logger claim is dropped; the 150 s note concerns authenticated requests; the walk docs say that NoSuchName ends a walk without an error, as it should.
ilyam8
added this pull request to stack #53
October 13, 2026 13:14
ilyam8
marked this pull request as ready for review
October 13, 2026 13:15
stelfrag
approved these changes
Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 6 (guardrails), documentation. No behavior change, no exported API change.
doc.gocovers the client's lifecycle, concurrency, requestattempts and timeouts, the order of the hooks, SNMPv3 engine discovery and the Reports that resend or end a request,
walks, the Go type of each value type when decoded and encoded, the malformed messages the decoder accepts, in-place
decoding and value aliasing, the password-to-key cache, and the two trap paths, with the known bugs a caller meets
in each (among them the malformed messages that make the decoders panic).
the code are corrected: the
GoSNMPfields (a per-attemptTimeoutwithout a default,Retries,AppOptsby keypresence,
Control,LocalAddr; unexported fields moved to the end), the request methods and their limits,Handlerpointing at theGoSNMPmethods instead of drifting copies,NewHandler,SnmpPDU,Asn1BER,PDUType,SnmpPacket,UsmSecurityParameters,UnmarshalTrap,MarshalMsg,SnmpEncodePacket,SnmpDecodePacket,PasswordCaching, the security parameters table,Checkand the error group.SnmpVersion.Stringmoves topacket.go, theAsn*constants tovalue.go.model, the table path's level taken from the message, privacy not required), the table path's panic on a header
that fails early, keys-only users on a new engine ID, the msgID drawn by the client's version, the PDU type error
text,
ConnectIPv4/ConnectIPv6appending their suffix on every call,Connectreseeding the IDs, the HMAC-96long-key cut, the 32-bit Uinteger32 decode, and the FIPS 140-only panics. Unpinned bugs in functions whose docs
changed are pinned first and named:
SnmpVersion.Stringof an unknown version,Partitionwith a partition sizeof 0,
ToBigIntof a largeuint, the empty-key signing ofSnmpEncodePacket, the keys an empty passphrasederives without an error, and a user configured with keys instead of passphrases accepting a trap from another
engine ID signed with the empty key, which anyone can compute (the Netdata Agent's trap receiver requires
passphrases, so it is not exposed).
authPriv), the request ID "uses all 32 bits",
At"returns false", the BER package "decodes", andauthenticateafter its rename to
sign.examples/example, every example listed, nog.MAX_OIDS(it does not exist), no upstream first-person text or alouca/gosnmp migration notes, the typesSettakes, a pointer to the package documentation instead of a BER list that named types the decoder does not decode,
documentation addresses, and coverage commands that work with current Go.
Validation
the keys-only trap acceptance among the gaps) are corrected, and a focused follow-up review checked the
corrections.
(comment-free declarations of both trees compared);
go generateleaves the generated files unchanged.go test -race, FIPS 140-only, golangci-lint, cross-builds, govulncheck: pass locally.