getsops / getsops/sops

Add --no-clobber for explicit output files

Open
#2,297 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
23.1k
Forks
1.1k
Avg merge
1d 11h
Merged PRs (30d)
9

Description

DennisGaida raised accidental overwrites in Discussion #1976. I'd suggest an opt-in --no-clobber instead of changing the default or adding prompts.

With --output, the flag would fail without changing an existing destination, including symlinks, or exclusively create a new file. It would reject use without --output or with --in-place. Without the flag, behavior stays unchanged; shell redirection is outside this feature.

The explicit-output branches in cmd/sops/main.go currently use os.Create. Exclusive creation would avoid the race in a separate existence check.

I'd implement this across commands supporting --output, including legacy syntax, with tests for unchanged existing bytes and invalid combinations. Does this approach fit SOPS?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the explicit-output branches of cmd/sops/main.go, where os.Create is currently used, and trace the commands that support --output, including legacy syntax. Add coverage for unchanged existing bytes, symlink destinations, exclusive creation, and invalid use without --output or with --in-place. Done means --no-clobber works across those commands while existing behavior and shell redirection remain unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, security
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.