loglist: handle logs with no state (#6329)

While the Chrome log_list.json has a `state` stanza for every
log, the all_logs_list.json file does not. This code was originally
tested against the former file, but we are actually using the
latter file in production. Add a check for missing `state` stanzas
to avoid a nil pointer dereference.
This commit is contained in:
Aaron Gable 2022-08-31 09:10:29 -07:00 committed by GitHub
parent 73b72e8fa2
commit 4e8df49908
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -71,7 +71,9 @@ const (
)
func stateFromState(s *schema.LogListSchemaJsonOperatorsElemLogsElemState) state {
if s.Rejected != nil {
if s == nil {
return unknown
} else if s.Rejected != nil {
return rejected
} else if s.Retired != nil {
return retired

View File

@ -259,6 +259,17 @@
"start_inclusive": "1970-01-01T00:00:01Z",
"end_exclusive": "2070-01-01T00:00:01Z"
}
},
{
"description": "This Log Is Missing State To Ensure We Can Handle It",
"log_id": "SomeOtherFakeLogID=",
"key": "SomeOtherFakeKey=",
"url": "https://example.net/ct/",
"mmd": 86400,
"temporal_interval": {
"start_inclusive": "1970-01-01T00:00:01Z",
"end_exclusive": "2070-01-01T00:00:01Z"
}
}
]
}