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

Abierto Apto para principiantes
#652 1 comentario 1 reacción 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@chaitanya0305 ya está trabajando en esto.

Desde el 28/11/2026.

  • #653 de @chaitanya0305 — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
62/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
go, postgresql
Área
backend, database

Línea de trabajo

El error está en RetargetTask en db/retarget.go, donde las líneas 147 y 154 escriben y eliminan filas de alcance de host a través de la columna value en lugar de domain. Empieza con la reproducción del issue y luego lee cómo ListTaskScope, ListUntestedAssets y declaredScopeFilter emparejan filas de subdomain por domain. Ejecuta TestRetargetTaskUpdatesGoalConstraintsScopeAndStopsStaleIntents con ARTEX_PG_DSN definido y añade una comprobación sobre la fila de alcance. Está terminado cuando una fila subdomain contiene el nuevo host en domain y list_untested_assets devuelve el nuevo host y no el antiguo.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Go
Estrellas
18.7k
Forks
7k
Merge medio
10 h 41 min
PR fusionados (30 d)
342

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de BaaRai/ARTEX

Todos los issues de BaaRai/ARTEX

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.