Skip to content

docs: document the package, its known bugs, the README and the examples - #57

Merged
ilyam8 merged 9 commits into
engine-apifrom
docs
Oct 13, 2026
Merged

ilyam8 merged 9 commits into
engine-apifrom
docs

Conversation

@ilyam8

@ilyam8 ilyam8 commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Summary

Phase 6 (guardrails), documentation. No behavior change, no exported API change.

  • Package documentation. The package had none. doc.go covers the client's lifecycle, concurrency, request
    attempts 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).
  • Exported docs. Every exported identifier of the root package is documented, and the docs that had drifted from
    the code are corrected: the GoSNMP fields (a per-attempt Timeout without a default, Retries, AppOpts by key
    presence, Control, LocalAddr; unexported fields moved to the end), the request methods and their limits,
    Handler pointing at the GoSNMP methods instead of drifting copies, NewHandler, SnmpPDU, Asn1BER, PDUType,
    SnmpPacket, UsmSecurityParameters, UnmarshalTrap, MarshalMsg, SnmpEncodePacket, SnmpDecodePacket,
    PasswordCaching, the security parameters table, Check and the error group. SnmpVersion.String moves to
    packet.go, the Asn* constants to value.go.
  • Known bugs. Each pinned bug now has a "Known bug" note where it happens: the trap digest checks (another security
    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/ConnectIPv6 appending their suffix on every call, Connect reseeding the IDs, the HMAC-96
    long-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.String of an unknown version, Partition with a partition size
    of 0, ToBigInt of a large uint, the empty-key signing of SnmpEncodePacket, the keys an empty passphrase
    derives 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).
  • Stale comments, among them the discovery note (every authenticated level fails for want of a key, not only
    authPriv), the request ID "uses all 32 bits", At "returns false", the BER package "decodes", and authenticate
    after its rename to sign.
  • README and examples. Correct example paths and an exact copy of examples/example, every example listed, no
    g.MAX_OIDS (it does not exist), no upstream first-person text or alouca/gosnmp migration notes, the types Set
    takes, 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 new pins pass on the code before these changes.
  • Two independent reviews checked every changed statement against the code; their findings (five false statements,
    the keys-only trap acceptance among the gaps) are corrected, and a focused follow-up review checked the
    corrections.
  • Apart from comments, the only changes are the two moves, the field order and a typo in an example's message
    (comment-free declarations of both trees compared); go generate leaves the generated files unchanged.
  • Engine, FIPS 140-only, codec and USM goldens unchanged.
  • go test -race, FIPS 140-only, golangci-lint, cross-builds, govulncheck: pass locally.

…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
ilyam8 added this pull request to stack #53 October 13, 2026 13:14
@ilyam8 ilyam8 changed the title docs docs: document the package, its known bugs, the README and the examples Oct 13, 2026
@ilyam8
ilyam8 marked this pull request as ready for review October 13, 2026 13:15
@ilyam8
ilyam8 merged commit b8c4a4a into master Oct 13, 2026
20 checks passed
@ilyam8
ilyam8 deleted the docs branch October 13, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants