ax(ueps): rename tagByte to tagType for semantic clarity
Some checks failed
Test / test (push) Waiting to run
Security Scan / security (push) Has been cancelled

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 <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 10:55:02 +01:00
parent 871e6dd985
commit 813cf2d632
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -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)
}