feat(assessment): find the attempt behind a leaked task text
This commit is contained in:
1 parent
bb917bf62e
commit
5a731c25b7
26 files changed
+2500
No files matched your search
@@ -188,6 +188,35 @@ func TestAssessmentAgentAndWorkClientDigestsAreKeyedBoundToTheAttemptAndSeparate
|
||||
}
|
||||
}
|
||||
|
||||
func TestAssessmentLeakTextDigestIsKeyedAndSeparateFromTheOtherDigests(t *testing.T) {
|
||||
keyring, err := NewKeyring(bytes.Repeat([]byte{1}, MinKeySecretBytes))
|
||||
if err != nil {
|
||||
t.Fatalf("NewKeyring() error = %v", err)
|
||||
}
|
||||
other, err := NewKeyring(bytes.Repeat([]byte{2}, MinKeySecretBytes))
|
||||
if err != nil {
|
||||
t.Fatalf("NewKeyring(other secret) error = %v", err)
|
||||
}
|
||||
text := []byte("A gateway protects an endpoint with a sliding-window limiter.")
|
||||
digest := keyring.AssessmentLeakTextDigest(text)
|
||||
if digest.IsZero() || digest != keyring.AssessmentLeakTextDigest(text) {
|
||||
t.Fatal("the leak text digest is empty or not deterministic")
|
||||
}
|
||||
if digest == keyring.AssessmentLeakTextDigest(append(bytes.Clone(text), '.')) {
|
||||
t.Fatal("two texts have the same digest")
|
||||
}
|
||||
if digest == other.AssessmentLeakTextDigest(text) {
|
||||
t.Fatal("the digest does not depend on the server secret, so a guess about a text could be confirmed from the audit")
|
||||
}
|
||||
// The digest does not reuse the key of another purpose.
|
||||
attempt := uuid.New()
|
||||
if digest == domain.AssessmentDigest(keyring.AssessmentWatermarkSeed(attempt)) ||
|
||||
digest == keyring.AssessmentAgentDigest(attempt, string(text)) ||
|
||||
digest == domain.AssessmentDigest(keyring.Fingerprint(text)) {
|
||||
t.Fatal("the leak text digest shares a key with another purpose")
|
||||
}
|
||||
}
|
||||
|
||||
func TestResultHistoryCursorKeyIsSeparateFromIdempotencyAndBoundToTheCandidate(t *testing.T) {
|
||||
keyring, err := NewKeyring([]byte(strings.Repeat("k", MinKeySecretBytes)))
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user