diff --git a/ctpolicy/loglist/loglist.go b/ctpolicy/loglist/loglist.go index a4f312e3321..be6f97bb49a 100644 --- a/ctpolicy/loglist/loglist.go +++ b/ctpolicy/loglist/loglist.go @@ -65,6 +65,12 @@ func usableForPurpose(s loglist3.LogStatus, p purpose) bool { return false } +// isTestLog returns true if the log type is test is "test" or "monitoring_only". +// The schema documents a third option, "prod", which does not currently appear in Google's lists. +func isTestLog(log Log) bool { + return log.Type == "test" || log.Type == "monitoring_only" +} + // New returns a LogList of all operators and all logs parsed from the file at // the given path. The file must conform to the JSON Schema published by Google: // https://www.gstatic.com/ct/log_list/v3/log_list_schema.json @@ -186,10 +192,13 @@ func (ll List) forPurpose(p purpose, submitToTestLogs bool) (List, error) { // interprets this as "UndefinedLogStatus", which causes usableForPurpose() // to return false. To account for this, we skip this check for test logs. for _, log := range ll { - if log.Type == "test" && !submitToTestLogs { + // Only consider test logs if we are submitting to test logs: + if isTestLog(log) && !submitToTestLogs { continue } - if log.Type != "test" && !usableForPurpose(log.State, p) { + // Check the log is usable for a purpose. + // But test logs aren't ever marked Usable. + if !isTestLog(log) && !usableForPurpose(log.State, p) { continue } res = append(res, log) diff --git a/ctpolicy/loglist/loglist_test.go b/ctpolicy/loglist/loglist_test.go index 40f928a89a0..9eb1e6fa2b4 100644 --- a/ctpolicy/loglist/loglist_test.go +++ b/ctpolicy/loglist/loglist_test.go @@ -95,6 +95,7 @@ func TestForPurpose(t *testing.T) { Log{Name: "Log A1", Operator: "A", State: loglist3.UsableLogStatus}, Log{Name: "Log B1", Operator: "B", State: loglist3.UsableLogStatus}, Log{Name: "Log T1", Operator: "T", Type: "test", State: loglist3.UndefinedLogStatus}, + Log{Name: "Log M1", Operator: "M", Type: "monitoring_only", State: loglist3.UndefinedLogStatus}, } expected = List{ Log{Name: "Log A1", Operator: "A", State: loglist3.UsableLogStatus}, @@ -108,6 +109,7 @@ func TestForPurpose(t *testing.T) { Log{Name: "Log A1", Operator: "A", State: loglist3.UsableLogStatus}, Log{Name: "Log B1", Operator: "B", State: loglist3.UsableLogStatus}, Log{Name: "Log T1", Operator: "T", Type: "test", State: loglist3.UndefinedLogStatus}, + Log{Name: "Log M1", Operator: "M", Type: "monitoring_only", State: loglist3.UndefinedLogStatus}, } actual, err = input.forPurpose(Issuance, true) test.AssertNotError(t, err, "should have two acceptable logs with submitToTestLogs=[true]")