Skip to content

Reject report output paths that alias the activity database (#191) - #405

Open
jay23606 wants to merge 1 commit into
HafidIdrissi:mainfrom
jay23606:pr-go/191-reports-reject-an-output-path-that-alias
Open

jay23606 wants to merge 1 commit into
HafidIdrissi:mainfrom
jay23606:pr-go/191-reports-reject-an-output-path-that-alias

Conversation

@jay23606

@jay23606 jay23606 commented Dec 6, 2026

Copy link
Copy Markdown

Problem

generate_report read the activity database and then wrote the HTML report to the requested output path without checking whether both paths refer to the same file. A mistaken --output pointing at the database could replace it.

Change

  • timetracker/reporting.py: generate_report now checks the output path against the database path before opening the database or writing anything. It raises ValueError when the two resolve to the same file, including hard-link aliases detected with samefile.
  • report.py: the CLI catches ValueError and exits with a concise error instead of a traceback.
  • tests/test_reporting.py: adds a regression test that an output path resolving to the database is rejected and leaves the database bytes unchanged.

Testing

  • python3 -m unittest tests.test_reporting.GenerateReportOutputAliasTests passes on the fix and fails on the base reporting module (ValueError not raised).
  • python3 -m unittest discover -v passes: 7 skipped.

CI was not run.

Regression test: fails on base twice (/ValueError not raised/), passes on fix twice (python3 -m unittest tests.test_reporting.GenerateReportOutputAliasTests)

Fixes #191

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.

Reports: reject an output path that aliases the input activity database

1 participant