aboutsummaryrefslogtreecommitdiff
path: root/internal/manager/helpers.go
blob: a9a2158ea6f5e45e01c97824c5cbe75c357eded9 (plain)
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
package manager

import (
	"crypto/sha256"
	"encoding/base64"
	"fmt"

	ct "github.com/google/certificate-transparency-go"
	"gitlab.torproject.org/rgdd/ct/pkg/metadata"
	"rgdd.se/silent-ct/pkg/monitor"
)

func selectLogs(m metadata.Metadata) []monitor.MessageLogConfig {
	var logs []monitor.MessageLogConfig
	for _, operator := range m.Operators {
		for _, log := range operator.Logs {
			if log.State == nil {
				continue // ignore logs without a state (should not happen)
			}
			if log.State.Name == metadata.LogStatePending {
				continue // log is not yet relevant
			}
			if log.State.Name == metadata.LogStateRetired {
				continue // log is not expected to be reachable
			}
			if log.State.Name == metadata.LogStateRejected {
				continue // log is not expected to be reachable
			}

			// FIXME: remove me instead of hard coding Argon 2024
			id, _ := log.Key.ID()
			got := fmt.Sprintf("%s", base64.StdEncoding.EncodeToString(id[:]))
			want := "7s3QZNXbGs7FXLedtM0TojKHRny87N7DUUhZRnEftZs="
			if got != want {
				continue
			}

			logs = append(logs, monitor.MessageLogConfig{
				Metadata: log,
				State: monitor.MonitorState{
					LogState: monitor.LogState{ct.SignedTreeHead{
						SHA256RootHash: [sha256.Size]byte{47, 66, 110, 15, 246, 154, 8, 100, 150, 140, 206, 208, 17, 57, 112, 116, 210, 3, 19, 55, 46, 63, 209, 12, 234, 130, 225, 124, 237, 2, 64, 228},
						TreeSize:       610650601,
						Timestamp:      1702108968538,
					}},
					NextIndex: 388452203,
				},
			})
		}
	}
	return logs
}