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(db): mirror SetNodeState (blocked_reason, content_version) when reopening goals (#269)

BaaRai13073ce18ecb
diff --git a/db/goal_reopen_test.go b/db/goal_reopen_test.go
index 63218b8..36fe958 100644
--- a/db/goal_reopen_test.go
+++ b/db/goal_reopen_test.go
@@ -67,15 +67,28 @@ func TestFindingStatusReopensProvedGoals(t *testing.T) {
}
}
+ goalContentVersion := func(t *testing.T, goalID int64) int {
+ t.Helper()
+ var v int
+ if err := d.QueryRow(`SELECT content_version FROM exploration_nodes WHERE id=$1`, goalID).Scan(&v); err != nil {
+ t.Fatalf("SELECT content_version(%d): %v", goalID, err)
+ }
+ return v
+ }
+
t.Run("single_status_path_reopens_for_fp_duplicate_ignored", func(t *testing.T) {
for _, status := range []string{FindingFalsePositive, FindingDuplicate, FindingIgnored} {
t.Run(status, func(t *testing.T) {
_, es, fid, fnid, gid := newTaskWithProvedGoal(t, "single-"+status)
+ vBefore := goalContentVersion(t, gid)
_, found, _, err := d.SetFindingStatusWithNotify(ctx, fid, status)
if err != nil || !found {
t.Fatalf("SetFindingStatusWithNotify(%s): found=%v err=%v", status, found, err)
}
assertGoalState(t, es, gid, "open")
+ if vAfter := goalContentVersion(t, gid); vAfter != vBefore+1 {
+ t.Fatalf("goal %d content_version = %d, want %d (bumped on reopen)", gid, vAfter, vBefore+1)
+ }
assertProvesEdgeKept(t, fnid, gid)
})
}
diff --git a/db/notification.go b/db/notification.go
index 22ad592..da150b8 100644
--- a/db/notification.go
+++ b/db/notification.go
@@ -590,7 +590,9 @@ func FindingStatusInvalidatesGoal(status string) bool {
func reopenGoalsProvedByNodeTx(ctx context.Context, tx *sql.Tx, nodeID int64) error {
_, err := tx.ExecContext(ctx, `
UPDATE exploration_nodes g
- SET state = 'open'
+ SET state = 'open',
+ blocked_reason = NULL,
+ content_version = content_version + 1
FROM exploration_edges e
WHERE e.src_id = $1
AND e.rel = $2