ARTEX - AI autonomous penetration testing system (English translation; upstream: Autumn-27/ARTEX, AGPL-3.0)
Go aiai-agentsautonomous-agentsbug-bountydockergolanglinuxllmmcpnextjspenetration-testingpentestpostgresqlreareactred-teamsecuritysecurity-automationsqlitetypescript
test: clean remaining residual rows across db, agent, and server test suites
BaaRai752d0cfab4c2
diff --git a/agent/scan_ingest_tool_pg_test.go b/agent/scan_ingest_tool_pg_test.goindex 10c4a50..26b0de9 100644--- a/agent/scan_ingest_tool_pg_test.go+++ b/agent/scan_ingest_tool_pg_test.go@@ -127,7 +127,7 @@ func TestIngestScanOutputJSONPG(t *testing.T) {if err != nil {t.Fatal(err)}- const assetsWhere = `domain LIKE '%scan-ingest.example.com' OR url LIKE '%scan-ingest.example.com%'`+ const assetsWhere = `ip IN ('198.51.100.77','2001:db8::77') OR domain IN ('198.51.100.77','2001:db8::77','example.com') OR domain LIKE '%scan-ingest.example.com' OR url LIKE '%scan-ingest.example.com%'`t.Cleanup(func() {_ = d.DeleteTask(task.ID)_, _ = d.Exec(`DELETE FROM assets WHERE ` + assetsWhere)@@ -210,7 +210,7 @@ func TestIngestScanOutputUserinfoPG(t *testing.T) {if err != nil {t.Fatal(err)}- const assetsWhere = `domain LIKE '%scan-ingest.example.com' OR url LIKE '%scan-ingest.example.com%'`+ const assetsWhere = `ip IN ('198.51.100.77','2001:db8::77') OR domain IN ('198.51.100.77','2001:db8::77','example.com') OR domain LIKE '%scan-ingest.example.com' OR url LIKE '%scan-ingest.example.com%'`t.Cleanup(func() {_ = d.DeleteTask(task.ID)_, _ = d.Exec(`DELETE FROM assets WHERE ` + assetsWhere)diff --git a/db/activity_outbox_test.go b/db/activity_outbox_test.goindex 3d088d7..c7a702e 100644--- a/db/activity_outbox_test.go+++ b/db/activity_outbox_test.go@@ -22,7 +22,7 @@ func TestFlushActivityOutboxReplaysOnce(t *testing.T) {if err != nil {SkipPGUnavailable(t, err)}- defer d.Close()+ t.Cleanup(func() { _ = d.Close() })expID, err := d.CreateExploration("outbox", "replay")if err != nil {t.Fatal(err)@@ -65,7 +65,7 @@ func TestFlushActivityOutboxDropsStuckRow(t *testing.T) {if err != nil {SkipPGUnavailable(t, err)}- defer d.Close()+ t.Cleanup(func() { _ = d.Close() })const missing = int64(9_000_000_000_001)t.Cleanup(func() { _, _ = d.Exec(`DELETE FROM activity_outbox WHERE exploration_id=$1`, missing) })es := d.Exploration(missing)diff --git a/db/task_llm_spend_test.go b/db/task_llm_spend_test.goindex ec3e9e2..a47f997 100644--- a/db/task_llm_spend_test.go+++ b/db/task_llm_spend_test.go@@ -13,7 +13,7 @@ func TestTaskLLMSpendCountsJudgeNotChat(t *testing.T) {if err != nil {SkipPGUnavailable(t, err)}- defer d.Close()+ t.Cleanup(func() { _ = d.Close() })taskID := fmt.Sprintf("spend-%d", time.Now().UnixNano())t.Cleanup(func() {diff --git a/server/core_test.go b/server/core_test.goindex 8bd71d8..a4dfaf3 100644--- a/server/core_test.go+++ b/server/core_test.go@@ -73,6 +73,9 @@ func TestCoreTaskLifecyclePG(t *testing.T) {if id == "" || expID == 0 {t.Fatalf("bad task payload: %v", out)}+ defer func() {+ _, _ = m.pg.Exec(`DELETE FROM assets WHERE type = 'ip' AND ip = '127.0.0.1'`)+ }()// the exploration owns goal node(s) — goal seeding is async, poll brieflyvar goals []*db.Nodediff --git a/server/finding_traffic_test.go b/server/finding_traffic_test.goindex 001024b..c041765 100644--- a/server/finding_traffic_test.go+++ b/server/finding_traffic_test.go@@ -282,6 +282,7 @@ func TestFindingTrafficArchiveV3RoundTripAndRetry(t *testing.T) {if err != nil {t.Fatal(err)}+ defer s.m.pg.DeleteFinding(shared.FindingID)if _, err = s.m.traffic.DeleteHost("evidence.local"); err != nil {t.Fatal(err)}diff --git a/server/findings_groups_test.go b/server/findings_groups_test.goindex eefd361..f85048f 100644--- a/server/findings_groups_test.go+++ b/server/findings_groups_test.go@@ -286,15 +286,19 @@ func TestDeepenAdmissionFailureDiscardsFollowUpIntent(t *testing.T) {t.Fatal(err)}taskID, _ := strconv.ParseInt(task.ID, 10, 64)+ var findingID int64defer func() {_, _ = m.pg.Exec(`UPDATE tasks SET deleted_at=NULL WHERE id=$1`, taskID)+ if findingID > 0 {+ _, _ = m.pg.DeleteFinding(findingID)+ }_, _ = m.DeleteTask(task.ID, DeleteTaskOptions{})}()findingNodeID, err := task.Store.AddNode(db.KindFinding, map[string]any{"summary": "source"}, 5, "confirmed", "worker", nil)if err != nil {t.Fatal(err)}- findingID, err := m.pg.AddFinding(taskID, findingNodeID, "test", "source", db.SeverityHigh, "source", "", "worker", nil)+ findingID, err = m.pg.AddFinding(taskID, findingNodeID, "test", "source", db.SeverityHigh, "source", "", "worker", nil)if err != nil {t.Fatal(err)}diff --git a/server/llmrec_raw_test.go b/server/llmrec_raw_test.goindex e6dd70f..6a26b84 100644--- a/server/llmrec_raw_test.go+++ b/server/llmrec_raw_test.go@@ -74,6 +74,7 @@ func TestRecorderPersistsRawWireBodies(t *testing.T) {if _, err := pg.Exec(`DELETE FROM llm_records WHERE session_id = $1`, session); err != nil {t.Logf("cleanup: %v", err)}+ _, _ = pg.Exec(`DELETE FROM llm_usage WHERE task_id = '999999' AND profile_name = 'raw-test-profile'`)}()ctx := transcript.WithSessionID(context.Background(), session)diff --git a/server/target_gate_flag_test.go b/server/target_gate_flag_test.goindex b9af9af..5361c59 100644--- a/server/target_gate_flag_test.go+++ b/server/target_gate_flag_test.go@@ -83,6 +83,7 @@ func (g *gateServer) cleanupTask(t *testing.T, id string) {_ = g.m.pg.DeleteTask(n)_, _ = g.m.pg.Exec(`DELETE FROM target_pins WHERE task_id=$1`, n)_, _ = g.m.pg.Exec(`DELETE FROM intercept_pending WHERE task_id=$1`, id)+ _, _ = g.m.pg.Exec(`DELETE FROM assets WHERE type = 'ip' AND ip = '127.0.0.1'`)})}diff --git a/server/task_credentials_test.go b/server/task_credentials_test.goindex eacbdf9..caed522 100644--- a/server/task_credentials_test.go+++ b/server/task_credentials_test.go@@ -49,8 +49,14 @@ func TestTaskCredentialsFlow(t *testing.T) {if err != nil {t.Fatal(err)}- t.Cleanup(func() { _ = s.m.pg.DeleteTask(id) })- t.Cleanup(func() { s.m.PG().Exec(`DELETE FROM tasks WHERE id=$1`, id) })+ t.Cleanup(func() {+ _ = s.m.pg.DeleteTask(id)+ // The first POST with an invalid credential entry returns 400 after+ // creating a task/exploration row; remove any remaining fixture rows.+ _, _ = s.m.PG().Exec(`DELETE FROM tasks WHERE description = 'credential flow test'`)+ _, _ = s.m.PG().Exec(`DELETE FROM explorations WHERE description = 'credential flow test'`)+ _, _ = s.m.PG().Exec(`DELETE FROM assets WHERE type = 'ip' AND ip = '127.0.0.1'`)+ })// List: both rows, user source, order stable.resp = request("GET", fmt.Sprintf("/api/tasks/%s/credentials", created.ID), "")diff --git a/server/task_end_reason_test.go b/server/task_end_reason_test.goindex 9d2f59f..1fff2fc 100644--- a/server/task_end_reason_test.go+++ b/server/task_end_reason_test.go@@ -21,7 +21,7 @@ func TestReviveClearsBudgetEndReason(t *testing.T) {if err != nil {t.Fatal(err)}- t.Cleanup(func() { pg.Exec(`DELETE FROM tasks WHERE id=$1`, id) })+ t.Cleanup(func() { _ = pg.DeleteTask(id) })endReason := func() string {t.Helper()var r stringdiff --git a/server/task_llm_rotation_test.go b/server/task_llm_rotation_test.goindex b779d8f..20d77cc 100644--- a/server/task_llm_rotation_test.go+++ b/server/task_llm_rotation_test.go@@ -75,7 +75,10 @@ func TestRotationConcurrentProvidersAndPrecedence(t *testing.T) {if err != nil {t.Fatal(err)}- defer m.DeleteTask(task.ID, DeleteTaskOptions{})+ defer func() {+ _, _ = m.pg.Exec(`DELETE FROM llm_usage WHERE task_id = $1`, task.ID)+ _, _ = m.DeleteTask(task.ID, DeleteTaskOptions{})+ }()s := &Server{m: m, provByProfile: map[int64]*provEntry{}}runtime := &taskLLMRuntime{s: s, taskID: task.ID, agentKey: "worker"}done := make(chan error, 3)@@ -343,7 +346,10 @@ func TestRunIntentRotatesPinnedProfileWithCachedExecCtx(t *testing.T) {if err != nil {t.Fatal(err)}- defer m.DeleteTask(task.ID, DeleteTaskOptions{})+ defer func() {+ _, _ = m.pg.Exec(`DELETE FROM llm_usage WHERE task_id = $1`, task.ID)+ _, _ = m.DeleteTask(task.ID, DeleteTaskOptions{})+ }()e := NewEngine(m)// Warm the per-task cached execCtx before any worker intent runs.diff --git a/server/task_pause_deadline_test.go b/server/task_pause_deadline_test.goindex de1b056..bc583d7 100644--- a/server/task_pause_deadline_test.go+++ b/server/task_pause_deadline_test.go@@ -24,7 +24,7 @@ func TestPauseShiftsTaskDeadlineOnResume(t *testing.T) {if err != nil {t.Fatal(err)}- t.Cleanup(func() { pg.Exec(`DELETE FROM tasks WHERE id=$1`, id) })+ t.Cleanup(func() { _ = pg.DeleteTask(id) })// A running task with a stamped deadline (first_run_at + 1h budget).if _, err := m.StampTaskFirstRun(task.ID); err != nil {