Skip to content

armgit / ARTEX

Public Imported from GitHub
0

ARTEX - AI autonomous penetration testing system (English translation; upstream: Autumn-27/ARTEX, AGPL-3.0)

fix: ignore evidence quotes shorter than 8 runes

BaaRai0a740f0894a8
diff --git a/server/finding_verification.go b/server/finding_verification.go
index 31a41f0..a1e8de3 100644
--- a/server/finding_verification.go
+++ b/server/finding_verification.go
@@ -20,9 +20,10 @@ import (
// bodies. Anything else is unverified, blocked or not_assessed, with a note.
const (
- verificationMinPOE = 3
- verificationReadCap = 4 << 20 // bytes read per bound body; a quote beyond this cannot be confirmed
- verificationNoteQuoteLen = 60
+ verificationMinPOE = 3
+ verificationMinQuoteRunes = 8 // shorter normalized quotes are ignored: "x7" proves nothing
+ verificationReadCap = 4 << 20 // bytes read per bound body; a quote beyond this cannot be confirmed
+ verificationNoteQuoteLen = 60
)
// boundBody is one bound response body, read through the evidence store and
@@ -91,6 +92,15 @@ func (s *Server) assessFindingVerification(ctx context.Context, findingID int64,
if len(quotes) == 0 {
return db.VerificationUnverified, "no evidence quotes provided"
}
+ var checked []string
+ for _, q := range quotes {
+ if utf8.RuneCountInString(normalizeEvidenceText(q)) >= verificationMinQuoteRunes {
+ checked = append(checked, q)
+ }
+ }
+ if len(checked) == 0 {
+ return db.VerificationUnverified, "evidence quote too short"
+ }
store := s.evidenceStore()
bodies := make([]boundBody, 0, len(proofs))
for _, b := range proofs {
@@ -101,7 +111,7 @@ func (s *Server) assessFindingVerification(ctx context.Context, findingID int64,
}
bodies = append(bodies, bb)
}
- for _, q := range quotes {
+ for _, q := range checked {
nq := normalizeEvidenceText(q)
if nq != "" && quoteInBodies(nq, bodies) {
continue
diff --git a/server/finding_verification_test.go b/server/finding_verification_test.go
index 7780b87..1df3793 100644
--- a/server/finding_verification_test.go
+++ b/server/finding_verification_test.go
@@ -109,6 +109,19 @@ func TestVerificationProofPOE3ExactQuoteVerified(t *testing.T) {
}
}
+func TestVerificationShortQuoteUnverified(t *testing.T) {
+ s, f, _ := verificationFixture(t, "proof")
+ // "x7" is present in the body but below verificationMinQuoteRunes: it must not count.
+ msg, isErr := updateReport(t, s, f.NodeID, `,"poe_level":3,"evidence_quotes":["x7"]`)
+ if isErr || !strings.Contains(msg, "verification: unverified - evidence quote too short") {
+ t.Fatalf("unexpected result: err=%v %q", isErr, msg)
+ }
+ status, _, note, _ := storedVerification(t, s, f.FindingID)
+ if status != db.VerificationUnverified || note != "evidence quote too short" {
+ t.Fatalf("stored: status=%s note=%q", status, note)
+ }
+}
+
func TestVerificationOldStyleCallUnverifiedWithoutError(t *testing.T) {
s, f, _ := verificationFixture(t, "proof")
msg, isErr := updateReport(t, s, f.NodeID, "")