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: test isolation for the escalation streak + compliant goal fixtures

BaaRai6894c391dd09
diff --git a/server/core_test.go b/server/core_test.go
index ac759ff..a8cb1b5 100644
--- a/server/core_test.go
+++ b/server/core_test.go
@@ -62,7 +62,7 @@ func TestCoreTaskLifecyclePG(t *testing.T) {
}
// create a task → 201, returns PG task (string id + exploration_id)
- code, out := doRetry("POST", "/api/tasks", map[string]string{"description": "smoke", "goal": "test SQLi/XSS"})
+ code, out := doRetry("POST", "/api/tasks", map[string]string{"description": "smoke", "goal": "Probe the lab target at http://127.0.0.1:9/v1 for unauthenticated data exposure; record one record as evidence and stop."})
if code != 201 {
t.Fatalf("create task: %d (%v)", code, out)
}
diff --git a/server/task_credentials_test.go b/server/task_credentials_test.go
index d53005b..215b3af 100644
--- a/server/task_credentials_test.go
+++ b/server/task_credentials_test.go
@@ -20,7 +20,7 @@ func TestTaskCredentialsFlow(t *testing.T) {
}
resp := request("POST", "/api/tasks", `{
"description": "credential flow test",
- "goal": "verify task credentials",
+ "goal": "Verify credential handling against the lab target at http://127.0.0.1:9/v1 and record the outcome.",
"credentials": [
{"domain": "target.example.com", "username": "alias@test", "password": "s3cret!", "note": "program alias account"},
{"domain": "target.example.com", "username": "", "password": ""}
@@ -32,7 +32,7 @@ func TestTaskCredentialsFlow(t *testing.T) {
resp = request("POST", "/api/tasks", `{
"description": "credential flow test",
- "goal": "verify task credentials",
+ "goal": "Verify credential handling against the lab target at http://127.0.0.1:9/v1 and record the outcome.",
"credentials": [
{"domain": "target.example.com", "username": "alias@test", "password": "s3cret!", "note": "program alias account"},
{"domain": "app.target.example.com", "username": "agent-account", "password": ""}
diff --git a/server/task_llm.go b/server/task_llm.go
index a00b24d..4b4d078 100644
--- a/server/task_llm.go
+++ b/server/task_llm.go
@@ -120,6 +120,14 @@ func noteLLMCallFailure(taskID string, profileID int64) bool {
return false
}
+// resetLLMFailStreaksForTest clears every streak; test isolation only (the
+// escalation counter is package-global in-memory state).
+func resetLLMFailStreaksForTest() {
+ llmFailStreaks.Lock()
+ llmFailStreaks.m = map[string]int{}
+ llmFailStreaks.Unlock()
+}
+
func resetLLMFailStreak(taskID string, profileID int64) {
llmFailStreaks.Lock()
defer llmFailStreaks.Unlock()
diff --git a/server/task_llm_escalation_test.go b/server/task_llm_escalation_test.go
index 725b24d..e394e14 100644
--- a/server/task_llm_escalation_test.go
+++ b/server/task_llm_escalation_test.go
@@ -21,7 +21,7 @@ func (f *failingProvider) Complete(ctx context.Context, req llm.CompletionReques
}
func TestEscalationAdvancesAfterConsecutiveFailures(t *testing.T) {
- resetAllLLMFailStreaksForTest()
+ resetLLMFailStreaksForTest()
prov := &failingProvider{err: errors.New("boom: upstream 500")}
profile := int64(7)
nextProfile := int64(8)
@@ -78,8 +78,3 @@ func TestEscalationAdvancesAfterConsecutiveFailures(t *testing.T) {
}
}
-func resetAllLLMFailStreaksForTest() {
- llmFailStreaks.Lock()
- llmFailStreaks.m = map[string]int{}
- llmFailStreaks.Unlock()
-}
diff --git a/server/task_llm_test.go b/server/task_llm_test.go
index be6fdd0..63ecd96 100644
--- a/server/task_llm_test.go
+++ b/server/task_llm_test.go
@@ -350,6 +350,7 @@ func TestTaskLLMStreamDoesNotSwitchForOrdinaryErrors(t *testing.T) {
}
for _, message := range tests {
t.Run(message, func(t *testing.T) {
+ resetLLMFailStreaksForTest() // package-global streaks must not leak across subtests
provider := &scriptedLLMProvider{err: errors.New(message)}
exhausted := 0
hooks := taskLLMStreamHooks{