Skip to content

Bad -seeds path leaves a temporary -o file behind #212

Closed

Description

@TMHSDigital

Summary

When the -seeds file cannot be read, the run exits after the -o output file has been opened but before its cleanup is registered, so a hidden temporary file is left next to the output path and its handle is never closed.

Where

  • main_session.go:96 (runWith): if !s.loadInputs() || !s.openOutputs() || !s.loadSeeds() {
  • main_session.go:100-115: the deferred s.outFile.Close(s.anyDone) is only registered after all three succeed
  • main_session.go:401 (loadSeeds)

Details

openOutputs calls output.CreateFile, which writes to a temporary file beside the target and only renames or removes it in Close. If loadSeeds then fails, runWith returns exitFailure without calling Close, so the temporary file stays on disk.

Steps to reproduce

  1. printf 'www\n' > wl.txt
  2. subenum -simulate -w wl.txt -o out.txt -seeds missing.json example.com
  3. Exit code is 1 with Error: reading -seeds file: ..., and ls -A shows a leftover .out.txt.<random>.tmp.

Impact

Stray hidden files accumulate next to the output path on every run with a bad -seeds path (for example in scheduled jobs). On Windows the open handle also keeps the file locked until the process exits. Low frequency, low severity.

Suggested fix

Read the seeds before opening outputs (loadInputs, loadSeeds, then openOutputs), or register the deferred close right after openOutputs succeeds. Add an e2e test that runs with a missing -seeds file and -o in a temp dir and asserts the directory has no leftover files.

Acceptance criteria

  • A missing or unreadable -seeds file leaves no temporary file behind
  • Test covering it

Getting started

  • Relevant files: main_session.go, internal/output/file.go, main_e2e_test.go
  • How to run tests: go test .

Filed by repo-audit/fix-issues at b1ee267. Severity: low. Effort: S. audit-key: bug|main_session.go|loadSeeds-before-outFile-close

Activity

  1. added
    bug
    good first issue
    area: cli
    severity: low
    on Nov 10, 2026
  2. TMHSDigital commented on Nov 10, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in 989741e: runWith now reads -seeds before opening the -o file, so a failed seeds read has nothing to clean up. Verified with the new TestE2EBadSeedsLeavesNoTempFile, which failed before the change (leftover .out.txt.*.tmp, still locked on Windows) and passes after, plus the full go test ./....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: clibuggood first issueseverity: low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions