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)

ci: run gofmt in the go job, and format the 11 files it flags

BaaRaifdba29f1a9b2
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index bbe5ad4..3fffced 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -29,6 +29,10 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
+ - name: gofmt
+ run: |
+ files=$(gofmt -l $(git ls-files '*.go'))
+ if [ -n "$files" ]; then echo "gofmt required:"; echo "$files"; exit 1; fi
- run: go build ./...
- run: go vet ./...
# Skipped tests, tracked in issue #9:
diff --git a/agent/tools.go b/agent/tools.go
index 7e7bf68..9901957 100644
--- a/agent/tools.go
+++ b/agent/tools.go
@@ -46,9 +46,9 @@ const stagnationMinRepeats = 3
func detectStagnation(done, findings []*db.Node) []map[string]any {
type dir struct {
- firstID int64
- repeats int
- summary string
+ firstID int64
+ repeats int
+ summary string
}
dirs := map[string]*dir{}
order := []string{}
@@ -551,7 +551,7 @@ func (t *ToolSet) graphOverviewData() map[string]any {
// with the data so no prompt-template change is needed on deployed installs.
if stale := detectStagnation(recentDone, vulnNodes); len(stale) > 0 {
out["stagnation_warning"] = map[string]any{
- "directions": stale,
+ "directions": stale,
"instruction": "these directions were dispatched repeatedly with zero findings produced since their first attempt — do NOT re-dispatch the same approach again; open a materially different direction, or judge the goal on the existing evidence instead of grinding",
}
}
diff --git a/db/asset_intercept.go b/db/asset_intercept.go
index 263767d..b9e0a34 100644
--- a/db/asset_intercept.go
+++ b/db/asset_intercept.go
@@ -7,12 +7,12 @@ import "time"
// these match the *target asset*: an exact/fuzzy domain·ip·url, or a CIDR range.
// This layer only stores rules; the matching/enforcement logic lives elsewhere.
type AssetInterceptRule struct {
- ID int64 `json:"id"`
- Enabled bool `json:"enabled"`
- Kind string `json:"kind"` // exact_domain|exact_ip|exact_url|fuzzy_domain|fuzzy_ip|fuzzy_url|cidr
- Pattern string `json:"pattern"`
- Note string `json:"note"`
- Builtin bool `json:"builtin"`
+ ID int64 `json:"id"`
+ Enabled bool `json:"enabled"`
+ Kind string `json:"kind"` // exact_domain|exact_ip|exact_url|fuzzy_domain|fuzzy_ip|fuzzy_url|cidr
+ Pattern string `json:"pattern"`
+ Note string `json:"note"`
+ Builtin bool `json:"builtin"`
// Action is only used by task-level rules: 'block'=intercept, 'allow'=allow (whitelist).
// Global rules (asset_intercept_rules) do not have this column; it is always empty and treated as intercept.
Action string `json:"action,omitempty"`
diff --git a/db/assets_test.go b/db/assets_test.go
index f59f675..7c5d853 100644
--- a/db/assets_test.go
+++ b/db/assets_test.go
@@ -1168,11 +1168,11 @@ func TestQueryDSLInScopeMembership(t *testing.T) {
}
stamp := time.Now().UnixNano()
- root := fmt.Sprintf("sc%d.invalid", stamp) // in-scope root domain (task)
- srcRoot := fmt.Sprintf("src%d.invalid", stamp) // in-scope via source task
- out := fmt.Sprintf("out%d.invalid", stamp) // out of every scope
- marker := fmt.Sprintf("mk%d", stamp) // bare-text token present in all rows
- foreignTask := stamp + 777 // asset produced by an unrelated task
+ root := fmt.Sprintf("sc%d.invalid", stamp) // in-scope root domain (task)
+ srcRoot := fmt.Sprintf("src%d.invalid", stamp) // in-scope via source task
+ out := fmt.Sprintf("out%d.invalid", stamp) // out of every scope
+ marker := fmt.Sprintf("mk%d", stamp) // bare-text token present in all rows
+ foreignTask := stamp + 777 // asset produced by an unrelated task
// Scope: task owns root; source task owns srcRoot; task owns an IP /24.
for _, sc := range []struct {
@@ -1200,7 +1200,7 @@ func TestQueryDSLInScopeMembership(t *testing.T) {
{"subdomain", "api." + root, root, "", "", "", marker}, // under task root
{"service", "www." + root, root, "https://www." + root + "/", "", "", marker}, // service under task root
{"endpoint", "www." + root, root, "https://www." + root + "/a?" + marker + "=1", "GET", "", ""},
- {"subdomain", "dev." + srcRoot, srcRoot, "", "", "", marker}, // under source-task root
+ {"subdomain", "dev." + srcRoot, srcRoot, "", "", "", marker}, // under source-task root
{"endpoint", "198.51.100.9", "198.51.100.9", "http://198.51.100.9:8080/" + marker, "GET", "", ""}, // IP-literal host, ip col empty
{"subdomain", "x." + out, out, "", "", "", marker}, // out of scope
}
diff --git a/db/task_scope_test.go b/db/task_scope_test.go
index ec74bfe..8ac7e8a 100644
--- a/db/task_scope_test.go
+++ b/db/task_scope_test.go
@@ -6,14 +6,14 @@ import "testing"
// ip/cidr scope path so a target like "10.0.188.136:3000" no longer 404s.
func TestStripHostPort(t *testing.T) {
cases := []struct{ in, want string }{
- {"10.0.188.136:3000", "10.0.188.136"}, // the reported IP case
- {"10.0.188.136", "10.0.188.136"}, // bare IPv4 unchanged
- {"[2001:db8::1]:8080", "2001:db8::1"}, // bracketed IPv6 + port
- {"2001:db8::1", "2001:db8::1"}, // bare IPv6 unchanged (has colons)
- {" 1.2.3.4:80 ", "1.2.3.4"}, // trims surrounding space
- {"example.com:443", "example.com"}, // domain + port → bare host
- {"api.example.com:8080", "api.example.com"}, // subdomain + port
- {"example.com", "example.com"}, // bare domain unchanged
+ {"10.0.188.136:3000", "10.0.188.136"}, // the reported IP case
+ {"10.0.188.136", "10.0.188.136"}, // bare IPv4 unchanged
+ {"[2001:db8::1]:8080", "2001:db8::1"}, // bracketed IPv6 + port
+ {"2001:db8::1", "2001:db8::1"}, // bare IPv6 unchanged (has colons)
+ {" 1.2.3.4:80 ", "1.2.3.4"}, // trims surrounding space
+ {"example.com:443", "example.com"}, // domain + port → bare host
+ {"api.example.com:8080", "api.example.com"}, // subdomain + port
+ {"example.com", "example.com"}, // bare domain unchanged
}
for _, c := range cases {
if got := stripHostPort(c.in); got != c.want {
diff --git a/db/tasks.go b/db/tasks.go
index e790dc7..8a05df5 100644
--- a/db/tasks.go
+++ b/db/tasks.go
@@ -28,19 +28,19 @@ type Task struct {
LLMProfileID *int64 `json:"llm_profile_id,omitempty"`
// Task-level ordered LLM chain. LLMProfileID remains the compatibility alias
// for ActiveLLMProfileID while older API clients still send one profile id.
- LLMProfileIDs []int64 `json:"llm_profile_ids,omitempty"`
- ActiveLLMProfileID *int64 `json:"active_llm_profile_id,omitempty"`
- LLMChainRevision int64 `json:"-"`
- LLMFailoverState string `json:"llm_failover_state,omitempty"`
- LLMFailoverReason string `json:"llm_failover_reason,omitempty"`
+ LLMProfileIDs []int64 `json:"llm_profile_ids,omitempty"`
+ ActiveLLMProfileID *int64 `json:"active_llm_profile_id,omitempty"`
+ LLMChainRevision int64 `json:"-"`
+ LLMFailoverState string `json:"llm_failover_state,omitempty"`
+ LLMFailoverReason string `json:"llm_failover_reason,omitempty"`
// LLMRotate: per-intent chain-head rotation switch (#85); false = classic
// ordered failover from the active head.
- LLMRotate bool `json:"llm_rotate"`
- SourceTaskIDs []int64 `json:"source_task_ids,omitempty"`
- CompanyIDs []int64 `json:"company_ids,omitempty"`
- ParentRef string `json:"parent_ref,omitempty"` // parent task id (recorded by orchestration spawn; empty=top level)
- CreatedAt time.Time `json:"created_at"`
- CompletedAt *time.Time `json:"completed_at,omitempty"` // when it entered a terminal state (done/failed/timeout); nil for non-terminal
+ LLMRotate bool `json:"llm_rotate"`
+ SourceTaskIDs []int64 `json:"source_task_ids,omitempty"`
+ CompanyIDs []int64 `json:"company_ids,omitempty"`
+ ParentRef string `json:"parent_ref,omitempty"` // parent task id (recorded by orchestration spawn; empty=top level)
+ CreatedAt time.Time `json:"created_at"`
+ CompletedAt *time.Time `json:"completed_at,omitempty"` // when it entered a terminal state (done/failed/timeout); nil for non-terminal
// Task-level timeout (see the task-level timeout and wrap-up design doc).
TimeoutSeconds int `json:"timeout_seconds"` // 0=no time limit
FirstRunAt *time.Time `json:"first_run_at,omitempty"` // when it first actually started running (not created_at); nil=not yet run
diff --git a/server/assembly_test.go b/server/assembly_test.go
index e25866c..2cb1bba 100644
--- a/server/assembly_test.go
+++ b/server/assembly_test.go
@@ -6,9 +6,9 @@ import (
"path/filepath"
"testing"
- actool "github.com/Autumn-27/norma/tool"
"github.com/Autumn-27/artex/agent"
"github.com/Autumn-27/artex/db"
+ actool "github.com/Autumn-27/norma/tool"
)
// hasSkillTool reports whether the packed tool set contains the Skill meta-tool.
diff --git a/server/goal_gate_test.go b/server/goal_gate_test.go
index 94eb2b0..0f86016 100644
--- a/server/goal_gate_test.go
+++ b/server/goal_gate_test.go
@@ -7,19 +7,19 @@ import (
func TestGoalGateCheck(t *testing.T) {
good := map[string]string{
- "url target": "Audit " + strings.Repeat("x ", 60) + " at https://example.com/app every module for injection issues and record one finding per issue with evidence.",
- "bare domain": strings.Repeat("probe ", 25) + "the api at target.example.org for unauthenticated data exposure, one record proof, then stop.",
- "ipv4": strings.Repeat("recon ", 25) + "10.0.0.5 and map every listening service before any test.",
- "localhost port": strings.Repeat("verify ", 25) + "localhost:3000 health endpoints respond identically before and after config reload.",
- "path": strings.Repeat("review ", 25) + "the module at /app/data/core for hardcoded secrets and report each hit.",
- "targetless opt-out": "[targetless] " + strings.Repeat("summarize ", 20) + "the attached material into a prioritized hypothesis list.",
+ "url target": "Audit " + strings.Repeat("x ", 60) + " at https://example.com/app every module for injection issues and record one finding per issue with evidence.",
+ "bare domain": strings.Repeat("probe ", 25) + "the api at target.example.org for unauthenticated data exposure, one record proof, then stop.",
+ "ipv4": strings.Repeat("recon ", 25) + "10.0.0.5 and map every listening service before any test.",
+ "localhost port": strings.Repeat("verify ", 25) + "localhost:3000 health endpoints respond identically before and after config reload.",
+ "path": strings.Repeat("review ", 25) + "the module at /app/data/core for hardcoded secrets and report each hit.",
+ "targetless opt-out": "[targetless] " + strings.Repeat("summarize ", 20) + "the attached material into a prioritized hypothesis list.",
}
good["targetless short but marked"] = "[targetless] analyze nothing"
bad := map[string]string{
- "no target long": strings.Repeat("do a thorough security review of everything and report anything interesting that comes up during the exploration phase of this audit, thanks. ", 2),
- "too short": "audit the site",
- "short and bare": "find bugs",
+ "no target long": strings.Repeat("do a thorough security review of everything and report anything interesting that comes up during the exploration phase of this audit, thanks. ", 2),
+ "too short": "audit the site",
+ "short and bare": "find bugs",
}
for name, g := range good {
if name == "targetless short+:url" {
diff --git a/server/manager.go b/server/manager.go
index c366d2a..4cc7924 100644
--- a/server/manager.go
+++ b/server/manager.go
@@ -55,13 +55,13 @@ type Task struct {
LLMChainRevision int64 `json:"-"`
LLMFailoverState string `json:"llm_failover_state,omitempty"`
// LLMRotate (#85): per-intent round-robin over the task's LLM chain heads.
- LLMRotate bool `json:"llm_rotate,omitempty"`
- rotateMu sync.Mutex
- rotateNext int
- LLMFailoverReason string `json:"llm_failover_reason,omitempty"`
- SourceTaskIDs []int64 `json:"source_task_ids,omitempty"`
- CompanyIDs []int64 `json:"company_ids,omitempty"`
- Status string `json:"status"` // persisted lifecycle status (done/failed/timeout are terminal; empty/other is derived from runtime state)
+ LLMRotate bool `json:"llm_rotate,omitempty"`
+ rotateMu sync.Mutex
+ rotateNext int
+ LLMFailoverReason string `json:"llm_failover_reason,omitempty"`
+ SourceTaskIDs []int64 `json:"source_task_ids,omitempty"`
+ CompanyIDs []int64 `json:"company_ids,omitempty"`
+ Status string `json:"status"` // persisted lifecycle status (done/failed/timeout are terminal; empty/other is derived from runtime state)
// Task-level timeout (see docs/task-timeout-and-settle-design.md). DeadlineAt/FirstRunAt are unix seconds, 0 = unset/not yet run.
TimeoutSeconds int `json:"timeout_seconds"`
PlanHeartbeatSeconds int `json:"plan_heartbeat_seconds"` // planner heartbeat trigger interval (seconds)
diff --git a/server/server.go b/server/server.go
index 581e3cc..56e7473 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1609,12 +1609,12 @@ type createTaskReq struct {
CategoryID *int64 `json:"category_id,omitempty"`
Description string `json:"description"`
Goal string `json:"goal"`
- LLMProfileID *int64 `json:"llm_profile_id,omitempty"` // the LLM profile to run this task on; omitted/null = use the active profile
- LLMProfileIDs []int64 `json:"llm_profile_ids,omitempty"` // ordered task-level profile chain; the first entry takes effect initially
- SourceTaskIDs []string `json:"source_task_ids,omitempty"` // direct, read-only inherited source tasks
- CompanyIDs []int64 `json:"company_ids,omitempty"` // links the company scope and snapshots its current assets; does not copy assets or force intent generation
+ LLMProfileID *int64 `json:"llm_profile_id,omitempty"` // the LLM profile to run this task on; omitted/null = use the active profile
+ LLMProfileIDs []int64 `json:"llm_profile_ids,omitempty"` // ordered task-level profile chain; the first entry takes effect initially
+ SourceTaskIDs []string `json:"source_task_ids,omitempty"` // direct, read-only inherited source tasks
+ CompanyIDs []int64 `json:"company_ids,omitempty"` // links the company scope and snapshots its current assets; does not copy assets or force intent generation
TimeoutSeconds int `json:"timeout_seconds"`
- LLMRotate *bool `json:"llm_rotate"` // task-level timeout (seconds); 0/omitted = no limit
+ LLMRotate *bool `json:"llm_rotate"` // task-level timeout (seconds); 0/omitted = no limit
PlanHeartbeatSeconds int `json:"plan_heartbeat_seconds"` // planner heartbeat interval (seconds); 0/omitted = default 600 (10min); floor = default = 600, lower values are raised to 600
PlanQuietMode *bool `json:"plan_quiet_mode,omitempty"` // planner quiet-mode switch (#86); omitted = default on; false = edge rounds always plan
TargetGate *bool `json:"target_gate,omitempty"` // approval gate for asset targets, opt-in; omitted/null = off
diff --git a/server/task_llm_escalation_test.go b/server/task_llm_escalation_test.go
index 383fb02..af61ba4 100644
--- a/server/task_llm_escalation_test.go
+++ b/server/task_llm_escalation_test.go
@@ -77,4 +77,3 @@ func TestEscalationAdvancesAfterConsecutiveFailures(t *testing.T) {
t.Fatalf("exhaust calls=%d want 2", exhaustCalls)
}
}
-
diff --git a/server/tools_wire_test.go b/server/tools_wire_test.go
index 4fa1323..15682e1 100644
--- a/server/tools_wire_test.go
+++ b/server/tools_wire_test.go
@@ -5,9 +5,9 @@ import (
"encoding/json"
"testing"
- actool "github.com/Autumn-27/norma/tool"
"github.com/Autumn-27/artex/agent"
"github.com/Autumn-27/artex/db"
+ actool "github.com/Autumn-27/norma/tool"
)
func names(tools []actool.CoreTool) map[string]actool.CoreTool {