this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

implement future rev check

+10 -1
+10 -1
cmd/relay/relay/verify.go
··· 75 75 func (r *Relay) VerifyCommitObject(ctx context.Context, commit *repo.Commit, ident *identity.Identity, hostname string) error { 76 76 logger := r.Logger.With("host", hostname, "did", commit.DID, "rev", commit.Rev) 77 77 78 - // TODO: what parts does this actually do? 78 + // `VerifyStructure` checks that commit object field syntax is correct 79 79 if err := commit.VerifyStructure(); err != nil { 80 80 return err 81 + } 82 + 83 + // this re-parse is technically duplicate work 84 + rev, err := syntax.ParseTID(commit.Rev) 85 + if err != nil { 86 + return fmt.Errorf("commit rev syntax: %w", err) 87 + } 88 + if rev.Time().Compare(time.Now().Add(futureRevTolerance)) > 0 { 89 + return fmt.Errorf("%w: %s: %s", ErrFutureRev, rev, rev.Time().String()) 81 90 } 82 91 83 92 // if identity is available, verify the signature