Skip to content

Commit 5e5aa9b

Browse files
authored
Make the loginfo command a bit more future/backwards proof. (sigstore#718)
The logid field comes back as nil (which is expected), but we break trying to dereference that for formatting. Signed-off-by: Dan Lorenc <lorenc.d@gmail.com>
1 parent db61de9 commit 5e5aa9b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

cmd/rekor-cli/app/log_info.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ type logInfoCmdOutput struct {
4949
func (l *logInfoCmdOutput) String() string {
5050
// Verification is always successful if we return an object.
5151
ts := time.Unix(0, int64(l.TimestampNanos)).UTC().Format(time.RFC3339)
52+
5253
return fmt.Sprintf(`Verification Successful!
5354
Tree Size: %v
5455
Root Hash: %s
@@ -112,11 +113,18 @@ var logInfoCmd = &cobra.Command{
112113
return nil, errors.New("signature on tree head did not verify")
113114
}
114115

116+
pToInt := func(p *int64) int64 {
117+
if p == nil {
118+
return 0
119+
}
120+
return *p
121+
}
122+
115123
cmdOutput := &logInfoCmdOutput{
116-
TreeSize: *logInfo.TreeSize,
124+
TreeSize: pToInt(logInfo.TreeSize),
117125
RootHash: *logInfo.RootHash,
118126
TimestampNanos: sth.GetTimestamp(),
119-
TreeID: *logInfo.TreeID,
127+
TreeID: pToInt(logInfo.TreeID),
120128
}
121129

122130
oldState := state.Load(serverURL)

0 commit comments

Comments
 (0)