1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
package loglist
import "gitlab.torproject.org/rgdd/ct/pkg/metadata"
// FIXME: helpers that should probably be in the upstream package
func metadataFindLog(md metadata.Metadata, target metadata.Log) bool {
for _, operator := range md.Operators {
if findLog(operator.Logs, target) {
return true
}
}
return false
}
func findLog(logs []metadata.Log, target metadata.Log) bool {
targetID, _ := target.Key.ID()
for _, log := range logs {
id, _ := log.Key.ID()
if id == targetID {
return true
}
}
return false
}
func findKey(keys []metadata.LogKey, target metadata.Log) bool {
targetID, _ := target.Key.ID()
for _, key := range keys {
id, _ := key.ID()
if id == targetID {
return true
}
}
return false
}
func metadataLogDiff(initial, other metadata.Metadata) (added []metadata.Log, removed []metadata.Log) {
return metadataNewLogsIn(initial, other), metadataNewLogsIn(other, initial)
}
func metadataNewLogsIn(initial, other metadata.Metadata) (added []metadata.Log) {
for _, operator := range other.Operators {
for _, log := range operator.Logs {
if !metadataFindLog(initial, log) {
added = append(added, log)
}
}
}
return
}
func checkLog(log metadata.Log) error {
return nil // FIXME: check valid key, url, mmd, state
}
func skipLog(log metadata.Log) bool {
return log.State == nil || // logs without a state are considered misconfigured
log.State.Name == metadata.LogStatePending || // log is not yet relevant
log.State.Name == metadata.LogStateRetired || // log is not expected to be reachable
log.State.Name == metadata.LogStateRejected // log is not expected to be reachable
}
|