Skip to content

Commit b17ccf0

Browse files
authored
Remove support for the old log line checksum format (#8416)
Switch to outputting the new checksum format. Part of #8414
1 parent f173028 commit b17ccf0

File tree

4 files changed

+8
-31
lines changed

4 files changed

+8
-31
lines changed

log/log.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,6 @@ func LogLineChecksum(line string) string {
170170
return base64.RawURLEncoding.EncodeToString(buf)
171171
}
172172

173-
// OldLineChecksum was previously used, and is still accepted for validation.
174-
func OldLineChecksum(line string) string {
175-
crc := crc32.ChecksumIEEE([]byte(line))
176-
// Using the hash.Hash32 doesn't make this any easier
177-
// as it also returns a uint32 rather than []byte
178-
buf := make([]byte, binary.MaxVarintLen32)
179-
binary.PutUvarint(buf, uint64(crc))
180-
return base64.RawURLEncoding.EncodeToString(buf)
181-
}
182-
183173
func checkSummed(msg string) string {
184174
return fmt.Sprintf("%s %s", LogLineChecksum(msg), msg)
185175
}

log/log_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,6 @@ func TestLogLineChecksum(t *testing.T) {
357357
input: "Hello, World!",
358358
expected: "0MNK7A",
359359
},
360-
{
361-
name: "OldLineChecksum with Info log",
362-
function: OldLineChecksum,
363-
input: "Info log",
364-
expected: "pcbo7wk",
365-
},
366360
}
367361

368362
for _, tc := range testCases {

log/validator/validator.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,9 @@ func lineValid(text string) error {
186186
}
187187
checksum := fields[5]
188188
_, err := base64.RawURLEncoding.DecodeString(checksum)
189-
// TODO(#8414): Temporarily accept length 6 or 7 checksums
190-
if err != nil || (len(checksum) != 6 && len(checksum) != 7) {
189+
if err != nil || len(checksum) != 6 {
191190
return fmt.Errorf(
192-
"%s expected a 6 or 7 character base64 raw URL decodable string, got %q: %w",
191+
"%s expected a 6 character base64 raw URL decodable string, got %q: %w",
193192
errorPrefix,
194193
checksum,
195194
errInvalidChecksum,
@@ -205,13 +204,7 @@ func lineValid(text string) error {
205204
return nil
206205
}
207206
// Check the extracted checksum against the computed checksum
208-
// TODO(#8414): Accept both the old and new checksum format, distinguished by length
209-
var computedChecksum string
210-
if len(checksum) == 6 {
211-
computedChecksum = log.LogLineChecksum(line)
212-
} else {
213-
computedChecksum = log.OldLineChecksum(line)
214-
}
207+
computedChecksum := log.LogLineChecksum(line)
215208
if checksum != computedChecksum {
216209
return fmt.Errorf("%s invalid checksum (expected %q, got %q)", errorPrefix, computedChecksum, checksum)
217210
}

log/validator/validator_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ func TestLineValidAcceptsNew(t *testing.T) {
1111
test.AssertNotError(t, err, "errored on valid checksum")
1212
}
1313

14-
func TestLineValidAcceptsOld(t *testing.T) {
14+
func TestLineValidRejectsOld(t *testing.T) {
1515
err := lineValid("2020-07-06T18:07:43.109389+00:00 70877f679c72 datacenter 6 boulder-wfe[1595]: kKG6cwA Caught SIGTERM")
16-
test.AssertNotError(t, err, "errored on valid old checksum")
16+
test.AssertError(t, err, "didn't error on old checksum format")
1717
}
1818

1919
func TestLineValidRejects(t *testing.T) {
20-
err := lineValid("2020-07-06T18:07:43.109389+00:00 70877f679c72 datacenter 6 boulder-wfe[1595]: xxxxxxx Caught SIGTERM")
20+
err := lineValid("2020-07-06T18:07:43.109389+00:00 70877f679c72 datacenter 6 boulder-wfe[1595]: xxxxxx Caught SIGTERM")
2121
test.AssertError(t, err, "didn't error on invalid checksum")
2222
}
2323

@@ -28,10 +28,10 @@ func TestLineValidRejectsNotAChecksum(t *testing.T) {
2828
}
2929

3030
func TestLineValidNonOurobouros(t *testing.T) {
31-
err := lineValid("2020-07-06T18:07:43.109389+00:00 70877f679c72 datacenter 6 boulder-wfe[1595]: xxxxxxx Caught SIGTERM")
31+
err := lineValid("2020-07-06T18:07:43.109389+00:00 70877f679c72 datacenter 6 boulder-wfe[1595]: xxxxxx Caught SIGTERM")
3232
test.AssertError(t, err, "didn't error on invalid checksum")
3333

34-
selfOutput := "2020-07-06T18:07:43.109389+00:00 70877f679c72 datacenter 6 log-validator[1337]: xxxxxxx " + err.Error()
34+
selfOutput := "2020-07-06T18:07:43.109389+00:00 70877f679c72 datacenter 6 log-validator[1337]: xxxxxx " + err.Error()
3535
err2 := lineValid(selfOutput)
3636
test.AssertNotError(t, err2, "expected no error when feeding lineValid's error output into itself")
3737
}

0 commit comments

Comments
 (0)