Skip to content

fix: harden entrypoint — injection shell, erreurs silencieuses, DRY#9

Open
Guimove wants to merge 1 commit into
mainfrom
fix/code-review-findings
Open

fix: harden entrypoint — injection shell, erreurs silencieuses, DRY#9
Guimove wants to merge 1 commit into
mainfrom
fix/code-review-findings

Conversation

@Guimove
Copy link
Copy Markdown

@Guimove Guimove commented May 26, 2026

Contexte

Revue de code complète du projet. Ce PR adresse 4 des 8 findings retenus.

Changements

🔴 Critique — Injection shell via GIT_TOKEN

Avant : GIT_TOKEN était interpolé directement dans la string du credential helper bash, permettant à un token contenant ", ;, $() d'injecter du code exécuté par git.

Après : Le helper est un script indépendant /tmp/git-cred-helper.sh qui lit les credentials depuis des env vars à l'invocation — aucune valeur n'est jamais embarquée dans du code shell.

🟡 Injection sed via DEV_PORT

DEV_PORT était injecté sans validation dans une commande sed -i "s|...||". Un pipe | cassait le délimiteur sed ; un & corrompait l'output HTML.

Fix : validation numérique au démarrage avec fallback + warning.

🟡 PRE_START_SCRIPT : échec invisible dans docker logs

Avec set -e, un script en échec tuait le container sans rien afficher (stdout+stderr redirigés vers un log file). docker logs ne montrait rien.

Fix : tee vers stdout + vérification de PIPESTATUS[0] + exit avec le vrai code.

🔵 DRY — Détection framework dupliquée

detect_and_start_devserver() et generate_tasks_json() détectaient le type de projet indépendamment et avaient déjà divergé (Flask/FastAPI/Rails/Go/Static HTML manquants dans generate_tasks_json, npm run preview manquant dans detect_and_start_devserver).

Fix : extraction de detect_dev_cmd(dir, port) utilisée par les deux appelants.

Points non traités (Dockerfile off-limits, ou hors scope)

🤖 Generated with Claude Code

…olations

- fix(security): replace inline GIT_TOKEN interpolation in git credential
  helper with a helper script that reads env vars at invocation time —
  prevents shell injection when TOKEN contains ", ;, $() or backticks

- fix(security): validate DEV_PORT and OPENCODE_PORT as integers on startup —
  prevents sed delimiter injection ("|" breaks command, "&" corrupts output)
  in the welcome page HTML generation

- fix(ux): pipe PRE_START_SCRIPT output through tee so failures are visible
  in docker logs; check PIPESTATUS[0] and exit with the real code instead of
  swallowing the error behind a log redirect

- refactor(dry): extract detect_dev_cmd() shared by detect_and_start_devserver
  and generate_tasks_json — eliminates duplicated framework detection logic
  that had already diverged (Flask/FastAPI/Rails/Go/Static HTML were missing
  from generate_tasks_json, npm run preview was missing from detect_and_start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant