Serialize patch vulnerabilities through one helper; get's selectionRequired options[] are unsorted and drop description

Abierto
#1,836 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
58/100
Tipo de issue
Refactorización
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust
Área
cli

Línea de trabajo

Start with crates/socket-patch-cli/src/commands/agent_download.rs, list.rs, get.rs, and json_envelope.rs; compare the three vulnerability serializers and inspect select_json_mode_multi_free_options_serialize_vulnerabilities in get.rs. Run that test, then update it to assert that options contain vulnerabilities sorted by id with descriptions; confirm the other JSON outputs stay unchanged except for any deliberate severity field addition.

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

Descripción

agent:triaged arch-audit priority:p3 refactor

[agent] Filed by the scheduled architecture audit (audit-cli-tests). Register: register comment.

Kind: refactor (with a small output fix). Register ID: T02.

Problem

The per-vulnerability JSON object {id, cves, severity, summary, description} is built by hand in three places, and the copies have drifted:

  • agent_download::patch_event_metadata L119-L141 includes description and sorts by id. Its comment notes that "HashMap iteration is otherwise nondeterministic and consumers diff this output".
  • list.rs L172-L192 builds the same shape from a PatchRecord, sorted and with description, but it omits the top-level severity that patch_event_metadata emits.
  • get.rs L767-L790, the selectionRequired options[], iterates p.vulnerabilities (a HashMap) unsorted and omits description.

So get --json <CVE> with several free options lists each option's vulnerabilities in a different order from run to run. The test that claims to cover this, select_json_mode_multi_free_options_serialize_vulnerabilities (get.rs L4898), only asserts Err(1), so the drift went unnoticed.

Proposed change

  • Add one #[derive(Serialize)] vulnerability view, or a single vuln_json(id, &v) helper, in json_envelope.rs. It returns the list sorted by id.
  • Use it from all three sites.
  • Decide in the PR whether list gains the top-level severity, and say so in the PR description.

Size

3 to 4 files. About −40 / +30 lines.

Acceptance criteria

  • scan/get event details and list --json are byte-identical before and after, apart from any field the PR deliberately adds.
  • get's options[].vulnerabilities is sorted by id and carries description.
  • The fake test above captures the envelope and asserts the sorted options[].vulnerabilities.
Lenguaje dominante
Rust
Estrellas
9
Forks
2
Merge medio
20 h 47 min
PR fusionados (30 d)
681

Preparar el entorno

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 SocketDev/socket-patch

Todos los issues de SocketDev/socket-patch

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.