Derive the env-var scrub lists from clap's bindings; SOCKET_NO_SOCKET_YML is missing from LOCAL_ARG_ENV_VARS

Ouverte
#1,837 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
48/100
Type d'issue
Refactorisation
Clarté
Clairement spécifiée
Activité
Active
Stack technique
rust
Domaine
cli, testing

Piste de recherche

Start with the env-var lists and clap argument definitions in crates/socket-patch-cli/src/args.rs, then trace their consumers in tests/common/hermetic.rs and the cli_parse_* test helpers. Build the binding walk from crate::cli_command() and check how subcommand args expose env and global settings. Done means every env binding is scrubbed, parse tests pass, and the socket.yml policy test passes with SOCKET_NO_SOCKET_YML=1 set.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

agent:triaged arch-audit priority:p3 refactor

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

Kind: refactor. Register ID: T03.

Problem

GLOBAL_ARG_ENV_VARS and LOCAL_ARG_ENV_VARS (args.rs L711-L761) are hand-kept copies of the env = "..." attributes on the clap structs. Three things read them:

They have drifted. scan --no-socket-yml binds SOCKET_NO_SOCKET_YML (scan/socket_yml_args.rs L17),`` but neither list names it. So a developer's ambient SOCKET_NO_SOCKET_YML=1 reaches every "hermetic" test child and silently disables socket.yml policy in `e2e_socket_yml_policy`.

The doc above the list (L739-L744) claims that "the invariant tests below parse every entry against its owning subcommand to keep this honest". But those tests iterate their own hand lists, BOOL_BINDINGS and VALUE_BINDINGS (args.rs L1697 and L1786), and global_arg_env_vars_includes_vendor_knobs (L1207) only checks that the const contains strings typed into it. More hand copies exist in tests/cli_parse_scan.rs (SCAN_ENV_VARS, L40-L55) and the other cli_parse_* files.

Proposed change

  • Replace both consts with one function that walks crate::cli_command() and every subcommand's args, collecting Arg::get_env(). The global/local split, if still needed, comes from Arg::is_global_set().
  • Point the hermetic builder, with_clean_socket_env and scrub_empty_env_vars at it.
  • Delete the tautological global_arg_env_vars_includes_vendor_knobs.
  • Generate BOOL_BINDINGS from the same walk, filtered on the parse_bool_flag value parser or kept as an explicit list asserted equal to the walk.

Size

args.rs, tests/common/hermetic.rs and the cli_parse_* helpers. About −80 / +30 lines.

Acceptance criteria

  • A new test asserts that every env binding in cli_command() is scrubbed. It fails on today's main because SOCKET_NO_SOCKET_YML is missing.
  • The existing parse tests stay green.
  • With SOCKET_NO_SOCKET_YML=1 set in the outer environment, cargo test -p socket-patch-cli --test e2e_socket_yml_policy stays green.
Langage dominant
Rust
Étoiles
9
Forks
2
Merge moyen
1 j 8 h
PR mergées (30 j)
309

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de SocketDev/socket-patch

Toutes les issues de SocketDev/socket-patch

Issues similaires

Plus d'issues Rust

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.