From 813cf2d6326bbf5a13dff1a7798559df256fb116 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 2 Apr 2026 10:55:02 +0100 Subject: [PATCH] ax(ueps): rename tagByte to tagType for semantic clarity tagByte described the storage type (a byte), not the purpose. All constants in the package use Tag* naming (TagVersion, TagPayload, etc.) so the loop variable should match: tagType aligns with the domain vocabulary and satisfies AX Principle 1 (predictable names over short names). Co-Authored-By: Charon --- pkg/ueps/reader.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/ueps/reader.go b/pkg/ueps/reader.go index c04954b..ab8f5df 100644 --- a/pkg/ueps/reader.go +++ b/pkg/ueps/reader.go @@ -33,12 +33,12 @@ func ReadAndVerify(reader *bufio.Reader, sharedSecret []byte) (*ParsedPacket, er var payload []byte for { - tagByte, err := reader.ReadByte() + tagType, err := reader.ReadByte() if err != nil { return nil, err } - if tagByte == TagPayload { + if tagType == TagPayload { payload, err = io.ReadAll(reader) if err != nil { return nil, err @@ -56,37 +56,37 @@ func ReadAndVerify(reader *bufio.Reader, sharedSecret []byte) (*ParsedPacket, er return nil, err } - switch tagByte { + switch tagType { case TagVersion: header.Version = tagValue[0] - signedData.WriteByte(tagByte) + signedData.WriteByte(tagType) signedData.WriteByte(tagValueLength) signedData.Write(tagValue) case TagCurrentLayer: header.CurrentLayer = tagValue[0] - signedData.WriteByte(tagByte) + signedData.WriteByte(tagType) signedData.WriteByte(tagValueLength) signedData.Write(tagValue) case TagTargetLayer: header.TargetLayer = tagValue[0] - signedData.WriteByte(tagByte) + signedData.WriteByte(tagType) signedData.WriteByte(tagValueLength) signedData.Write(tagValue) case TagIntent: header.IntentID = tagValue[0] - signedData.WriteByte(tagByte) + signedData.WriteByte(tagType) signedData.WriteByte(tagValueLength) signedData.Write(tagValue) case TagThreatScore: header.ThreatScore = binary.BigEndian.Uint16(tagValue) - signedData.WriteByte(tagByte) + signedData.WriteByte(tagType) signedData.WriteByte(tagValueLength) signedData.Write(tagValue) case TagHMAC: hmacSignature = tagValue default: - // signedData.WriteByte(tagByte); signedData.WriteByte(tagValueLength); signedData.Write(tagValue) — unknown tags contribute to HMAC, blocking injection - signedData.WriteByte(tagByte) + // signedData.WriteByte(tagType); signedData.WriteByte(tagValueLength); signedData.Write(tagValue) — unknown tags contribute to HMAC, blocking injection + signedData.WriteByte(tagType) signedData.WriteByte(tagValueLength) signedData.Write(tagValue) }