Skip to content

Commit 8b5aa62

Browse files
authored
Allow monitoring_only logs as well as test logs for submitToTestLogs (#8510)
For our purpose (of testing non-production logs), these are equivalent.
1 parent 4aeb2b8 commit 8b5aa62

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

ctpolicy/loglist/loglist.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ func usableForPurpose(s loglist3.LogStatus, p purpose) bool {
6565
return false
6666
}
6767

68+
// isTestLog returns true if the log type is test is "test" or "monitoring_only".
69+
// The schema documents a third option, "prod", which does not currently appear in Google's lists.
70+
func isTestLog(log Log) bool {
71+
return log.Type == "test" || log.Type == "monitoring_only"
72+
}
73+
6874
// New returns a LogList of all operators and all logs parsed from the file at
6975
// the given path. The file must conform to the JSON Schema published by Google:
7076
// 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) {
186192
// interprets this as "UndefinedLogStatus", which causes usableForPurpose()
187193
// to return false. To account for this, we skip this check for test logs.
188194
for _, log := range ll {
189-
if log.Type == "test" && !submitToTestLogs {
195+
// Only consider test logs if we are submitting to test logs:
196+
if isTestLog(log) && !submitToTestLogs {
190197
continue
191198
}
192-
if log.Type != "test" && !usableForPurpose(log.State, p) {
199+
// Check the log is usable for a purpose.
200+
// But test logs aren't ever marked Usable.
201+
if !isTestLog(log) && !usableForPurpose(log.State, p) {
193202
continue
194203
}
195204
res = append(res, log)

ctpolicy/loglist/loglist_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func TestForPurpose(t *testing.T) {
9595
Log{Name: "Log A1", Operator: "A", State: loglist3.UsableLogStatus},
9696
Log{Name: "Log B1", Operator: "B", State: loglist3.UsableLogStatus},
9797
Log{Name: "Log T1", Operator: "T", Type: "test", State: loglist3.UndefinedLogStatus},
98+
Log{Name: "Log M1", Operator: "M", Type: "monitoring_only", State: loglist3.UndefinedLogStatus},
9899
}
99100
expected = List{
100101
Log{Name: "Log A1", Operator: "A", State: loglist3.UsableLogStatus},
@@ -108,6 +109,7 @@ func TestForPurpose(t *testing.T) {
108109
Log{Name: "Log A1", Operator: "A", State: loglist3.UsableLogStatus},
109110
Log{Name: "Log B1", Operator: "B", State: loglist3.UsableLogStatus},
110111
Log{Name: "Log T1", Operator: "T", Type: "test", State: loglist3.UndefinedLogStatus},
112+
Log{Name: "Log M1", Operator: "M", Type: "monitoring_only", State: loglist3.UndefinedLogStatus},
111113
}
112114
actual, err = input.forPurpose(Issuance, true)
113115
test.AssertNotError(t, err, "should have two acceptable logs with submitToTestLogs=[true]")

0 commit comments

Comments
 (0)