ARTEX - AI autonomous penetration testing system (English translation; upstream: Autumn-27/ARTEX, AGPL-3.0)
Go aiai-agentsautonomous-agentsbug-bountydockergolanglinuxllmmcpnextjspenetration-testingpentestpostgresqlreareactred-teamsecuritysecurity-automationsqlitetypescript
fix(ui): 任务总览的测试范围显示企业名称而非 ID
Autumn-27e104d48ae3c9
diff --git a/db/task_assets_context.go b/db/task_assets_context.goindex 722cb36..2c5b1f2 100644--- a/db/task_assets_context.go+++ b/db/task_assets_context.go@@ -52,10 +52,11 @@ tested AS (// scopes of its direct source tasks. TaskScope.TaskID preserves provenance.func (s *AssetStore) ListTaskScopeWithSources(taskID int64) ([]TaskScope, error) {rows, err := s.db.Query(`WITH `+directTaskContextCTE+`-SELECT ts.id, ts.task_id, ts.kind, COALESCE(ts.company_id,0), COALESCE(ts.domain,''),+SELECT ts.id, ts.task_id, ts.kind, COALESCE(ts.company_id,0), COALESCE(c.name,''), COALESCE(ts.domain,''),COALESCE(ts.net::text,''), ts.source, COALESCE(ts.reason,'')FROM task_scope tsJOIN context_tasks ctx ON ctx.task_id=ts.task_id+LEFT JOIN companies c ON c.id=ts.company_idORDER BY CASE WHEN ts.task_id=$1 THEN 0 ELSE 1 END, ts.id`, taskID)if err != nil {return nil, err@@ -65,7 +66,7 @@ ORDER BY CASE WHEN ts.task_id=$1 THEN 0 ELSE 1 END, ts.id`, taskID)for rows.Next() {var scope TaskScopevar companyID int64- if err := rows.Scan(&scope.ID, &scope.TaskID, &scope.Kind, &companyID, &scope.Domain, &scope.Net, &scope.Source, &scope.Reason); err != nil {+ if err := rows.Scan(&scope.ID, &scope.TaskID, &scope.Kind, &companyID, &scope.CompanyName, &scope.Domain, &scope.Net, &scope.Source, &scope.Reason); err != nil {return nil, err}if companyID > 0 {diff --git a/db/task_scope.go b/db/task_scope.goindex af1fc4a..d3cf02e 100644--- a/db/task_scope.go+++ b/db/task_scope.go@@ -16,10 +16,13 @@ type TaskScope struct {TaskID int64 `json:"task_id"`Kind string `json:"kind"` // company|root_domain|subdomain|ip|cidrCompanyID *int64 `json:"company_id,omitempty"`- Domain string `json:"domain,omitempty"`- Net string `json:"net,omitempty"`- Source string `json:"source"`- Reason string `json:"reason,omitempty"`+ // CompanyName is resolved for kind=company so callers can label a scope row+ // without a second lookup. Empty when the row is not a company reference.+ CompanyName string `json:"company_name,omitempty"`+ Domain string `json:"domain,omitempty"`+ Net string `json:"net,omitempty"`+ Source string `json:"source"`+ Reason string `json:"reason,omitempty"`}// stripHostPort drops a trailing :port from a host:port / ip:port / [ipv6]:port@@ -202,8 +205,11 @@ func (s *AssetStore) DeleteTaskScope(taskID, scopeID int64) (bool, error) {// ListTaskScope returns all scope rows for a task.func (s *AssetStore) ListTaskScope(taskID int64) ([]TaskScope, error) {rows, err := s.db.Query(`-SELECT id, kind, COALESCE(company_id,0), COALESCE(domain,''), COALESCE(net::text,''), source, COALESCE(reason,'')-FROM task_scope WHERE task_id=$1 ORDER BY id`, taskID)+SELECT ts.id, ts.kind, COALESCE(ts.company_id,0), COALESCE(c.name,''), COALESCE(ts.domain,''),+ COALESCE(ts.net::text,''), ts.source, COALESCE(ts.reason,'')+FROM task_scope ts+LEFT JOIN companies c ON c.id=ts.company_id+WHERE ts.task_id=$1 ORDER BY ts.id`, taskID)if err != nil {return nil, err}@@ -212,7 +218,7 @@ FROM task_scope WHERE task_id=$1 ORDER BY id`, taskID)for rows.Next() {var t TaskScopevar cid int64- if err := rows.Scan(&t.ID, &t.Kind, &cid, &t.Domain, &t.Net, &t.Source, &t.Reason); err != nil {+ if err := rows.Scan(&t.ID, &t.Kind, &cid, &t.CompanyName, &t.Domain, &t.Net, &t.Source, &t.Reason); err != nil {return nil, err}t.TaskID = taskIDdiff --git a/web/src/app/(main)/function/tasks/detail/_tabs/overview-tab.tsx b/web/src/app/(main)/function/tasks/detail/_tabs/overview-tab.tsxindex 3c06a2b..fe9ed26 100644--- a/web/src/app/(main)/function/tasks/detail/_tabs/overview-tab.tsx+++ b/web/src/app/(main)/function/tasks/detail/_tabs/overview-tab.tsx@@ -41,7 +41,7 @@ function cacheHitRate(cacheRead: number, input: number): string {function scopeValue(row: TaskScopeRow): string {if (row.domain) return row.domain;if (row.net) return row.net;- if (row.company_id) return `company #${row.company_id}`;+ if (row.company_id) return row.company_name || `企业 #${row.company_id}`;return "—";}diff --git a/web/src/lib/types.ts b/web/src/lib/types.tsindex 93a64e7..d8d7eb0 100644--- a/web/src/lib/types.ts+++ b/web/src/lib/types.ts@@ -241,6 +241,7 @@ export interface TaskScopeRow {task_id: number;kind: "company" | "root_domain" | "subdomain" | "ip" | "cidr";company_id?: number;+ company_name?: string; // 后端 JOIN companies 解析,仅 kind=company 有值domain?: string;net?: string;source: "auto" | "agent" | "manual";