TUI saved form: 0600 mode and corrupt-file fallback have no test

Abierto Apto para principiantes
#413 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
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
82/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
go
Área
cli, testing

Línea de trabajo

Lee internal/tui/config.go y las pruebas de configuración existentes en internal/tui/config_test.go. Añade pruebas para el modo de archivo en sistemas distintos de Windows después de saveConfig y para comprobar que el JSON corrupto recurre a los valores predeterminados mediante loadSavedConfig y New(). Ejecuta go test ./internal/tui/ -run Config; el trabajo estará terminado cuando se cumplan ambos criterios de aceptación.

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

Descripción

area: tui good first issue severity: low testing

Summary

The TUI's saved form (last.json) is written with mode 0600 on purpose, and corrupt files are meant to fall back to defaults. Neither behaviour has a test.

Where

  • internal/tui/config.go:62-75 (loadSavedConfig; the json.Unmarshal failure branch has 0 hits)
  • internal/tui/config.go:91-99 (saveConfig: "so the file is 0600 whatever the umask")
  • internal/tui/config_test.go:174-176 (only the missing-file case is tested)

Details

saveConfig deliberately avoids output.WriteFile, because the saved form can name the user's files and resolvers. No TUI test checks the file mode: there is no Mode() or Perm anywhere in internal/tui/*_test.go. saveConfig is at 60% coverage.

Impact

A refactor back to output.WriteFile, which the code comment warns against, would quietly make last.json world-readable on Unix, and no test would catch it. A corrupt or half-written last.json is untested input at startup.

Suggested fix

Add the two tests below.

Acceptance criteria

  • On non-Windows, with a permissive umask set for the test, os.Stat(configPath()) after saveConfig reports 0o600
  • With {"domain": written to last.json, loadSavedConfig returns ok=false and New() starts with the default form without panicking

Getting started

  • Relevant files: internal/tui/config.go, internal/tui/config_test.go
  • How to run tests: go test ./internal/tui/ -run Config

Filed by repo-audit/full-audit at dd5b156. Severity: low. Effort: S. audit-key: testing|internal/tui/config.go|saveConfig

Lenguaje dominante
Go
Estrellas
1
Forks
1
Merge medio
7 h 18 min
PR fusionados (30 d)
23

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

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 TMHSDigital/subenum

Todos los issues de TMHSDigital/subenum

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.