Attestation Verification - Buffer Fix (#9198)

* swap scanner to readline for attestations
* replace readLine with readBytes
This commit is contained in:
Forrin 2024-06-14 12:55:58 -05:00 committed by GitHub
parent 5e7ba54b56
commit c572383bda
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -73,21 +73,21 @@ func loadBundlesFromJSONLinesFile(path string) ([]*api.Attestation, error) {
attestations := []*api.Attestation{}
scanner := bufio.NewScanner(file)
for scanner.Scan() {
b := scanner.Bytes()
reader := bufio.NewReader(file)
var line []byte
line, err = reader.ReadBytes('\n')
for err == nil {
var bundle bundle.ProtobufBundle
bundle.Bundle = new(protobundle.Bundle)
err = bundle.UnmarshalJSON(b)
err = bundle.UnmarshalJSON(line)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal bundle from JSON: %v", err)
}
a := api.Attestation{Bundle: &bundle}
attestations = append(attestations, &a)
}
if err := scanner.Err(); err != nil {
return nil, err
line, err = reader.ReadBytes('\n')
}
return attestations, nil