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

Đang mở Phù hợp với người mới
#413 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
cli, testing

Hướng nghiên cứu

Đọc internal/tui/config.go và các bài kiểm thử cấu hình hiện có trong internal/tui/config_test.go. Thêm bài kiểm thử cho chế độ tệp trên hệ điều hành không phải Windows sau saveConfig và cho trường hợp JSON bị hỏng khiến chương trình dùng các giá trị mặc định thông qua loadSavedConfig và New(). Chạy go test ./internal/tui/ -run Config; hoàn tất khi cả hai tiêu chí chấp nhận đều đạt.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Go
Star
1
Fork
1
Merge trung bình
7 giờ 18 phút
Pull request đã merge (30 ngày)
23

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TMHSDigital/subenum

Tất cả issue của TMHSDigital/subenum

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.