Task retarget keeps the old host in task scope and adds the new host in a form that matches nothing

オープン 初心者向け
#652 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@chaitanya0305 がすでに取り組んでいます。

2026年11月28日 から。

  • #653 @chaitanya0305 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
62/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go, postgresql
領域
backend, database

調査の方向性

バグは db/retarget.go の RetargetTask にあり、147行目と154行目でホストのスコープ行を domain ではなく value 列を通じて書き込み、削除しています。まず issue の再現手順から始め、次に ListTaskScope、ListUntestedAssets、declaredScopeFilter が subdomain 行を domain でどのように照合しているかを読んでください。ARTEX_PG_DSN を設定した状態で TestRetargetTaskUpdatesGoalConstraintsScopeAndStopsStaleIntents を実行し、スコープ行に対するチェックを追加してください。1つの subdomain 行が新しいホストを domain に保持し、list_untested_assets が古いホストではなく新しいホストを返せば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug P2

POST /api/tasks/{id}/retarget (db.RetargetTask, #623) is meant to replace the old host with the new one in task_scope. It reads and writes the wrong column.

Host scope rows (root_domain, subdomain) keep the host in task_scope.domain. value is only used by icp and keyword rows. RetargetTask:

  • deletes WHERE task_id=$1 AND LOWER(value)=$2, which never matches a host row, so the old host stays in the declared scope;
  • inserts (kind='subdomain', value=newHost) with domain NULL. The coverage queries match subdomain rows on a.domain = ts.domain, and declaredScopeFilter only accepts auto rows under a declared domain. That row matches no asset.

After a retarget, the coverage figure, list_untested_assets and the task's scope view still point at the old instance. Assets of the new instance are left out, and the new host is not a declared root, so its auto scope rows are filtered out as well.

Reproduce

Against a test database (ARTEX_PG_DSN set), in package server:

task, _ := m.CreateTaskWithOptions("rt", "Capture flags on https://old-0c3f.ctf.local/docs", db.TaskCreateOptions{})
tid := mustTaskID(t, task.ID)
m.Assets().AddAgentScope(tid, "subdomain", "old-0c3f.ctf.local", "seed", "manual")
s.RetargetTask(ctx, task.ID, "old-0c3f.ctf.local", "https://new-4791.ctf.local")
m.Assets().UpsertSubdomain(db.UpsertSubdomainReq{Domain: "new-4791.ctf.local", TaskID: tid})
m.Assets().UpsertSubdomain(db.UpsertSubdomainReq{Domain: "old-0c3f.ctf.local", TaskID: tid})
rows, _ := m.Assets().ListTaskScope(tid)
untested, _, _ := m.Assets().ListUntestedAssets(tid, task.ExpID, "", 50, 0)

Output on main (b8cd251):

scope row: kind=subdomain domain="old-0c3f.ctf.local" value=""
scope row: kind=subdomain domain=""                   value="new-4791.ctf.local"
untested: old-0c3f.ctf.local

Expected: one subdomain row with domain="new-4791.ctf.local", and list_untested_assets lists the new host, not the old one.

The existing TestRetargetTaskUpdatesGoalConstraintsScopeAndStopsStaleIntents seeds a scope row but does not check it after the retarget.

Cause

db/retarget.go:147 and db/retarget.go:154 use the value column for a host.

Version: main at b8cd251.

A tested fix is ready on branch chaitanya0305:fix/retarget-task-scope.

主要言語
Go
スター
18.7k
フォーク
7k
平均マージ
10時間 41分
マージ済み PR(30日)
342

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

BaaRai/ARTEX のほかの issue

BaaRai/ARTEX の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。