ax(ueps): rename tagLengthByte to tagLength — type suffix violates AX Principle 1

Variable name tagLengthByte encoded its type (byte) rather than its role
(the length field of a TLV record). AX Principle 1: names must be semantic,
not type-annotated. tagLength is unambiguous without the redundant Byte suffix.

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 13:59:57 +01:00
parent 7a121b7d18
commit 7f02b47445
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -49,12 +49,12 @@ func ReadAndVerify(reader *bufio.Reader, sharedSecret []byte) (*ParsedPacket, er
break
}
tagLengthByte, err := reader.ReadByte()
tagLength, err := reader.ReadByte()
if err != nil {
return nil, err
}
tagValue := make([]byte, int(tagLengthByte))
tagValue := make([]byte, int(tagLength))
if _, err := io.ReadFull(reader, tagValue); err != nil {
return nil, err
}
@ -63,33 +63,33 @@ func ReadAndVerify(reader *bufio.Reader, sharedSecret []byte) (*ParsedPacket, er
case TagVersion:
header.Version = tagValue[0]
hmacInputBuffer.WriteByte(tagType)
hmacInputBuffer.WriteByte(tagLengthByte)
hmacInputBuffer.WriteByte(tagLength)
hmacInputBuffer.Write(tagValue)
case TagCurrentLayer:
header.CurrentLayer = tagValue[0]
hmacInputBuffer.WriteByte(tagType)
hmacInputBuffer.WriteByte(tagLengthByte)
hmacInputBuffer.WriteByte(tagLength)
hmacInputBuffer.Write(tagValue)
case TagTargetLayer:
header.TargetLayer = tagValue[0]
hmacInputBuffer.WriteByte(tagType)
hmacInputBuffer.WriteByte(tagLengthByte)
hmacInputBuffer.WriteByte(tagLength)
hmacInputBuffer.Write(tagValue)
case TagIntent:
header.IntentID = tagValue[0]
hmacInputBuffer.WriteByte(tagType)
hmacInputBuffer.WriteByte(tagLengthByte)
hmacInputBuffer.WriteByte(tagLength)
hmacInputBuffer.Write(tagValue)
case TagThreatScore:
header.ThreatScore = binary.BigEndian.Uint16(tagValue)
hmacInputBuffer.WriteByte(tagType)
hmacInputBuffer.WriteByte(tagLengthByte)
hmacInputBuffer.WriteByte(tagLength)
hmacInputBuffer.Write(tagValue)
case TagHMAC:
hmacSignature = tagValue
default:
hmacInputBuffer.WriteByte(tagType)
hmacInputBuffer.WriteByte(tagLengthByte)
hmacInputBuffer.WriteByte(tagLength)
hmacInputBuffer.Write(tagValue)
}
}