Skip to content

fix: skip rewriting files with special mode bits#81

Open
leno23 wants to merge 1 commit into
dolph:mainfrom
leno23:fix/skip-special-mode-bits-issue-18-v2
Open

fix: skip rewriting files with special mode bits#81
leno23 wants to merge 1 commit into
dolph:mainfrom
leno23:fix/skip-special-mode-bits-issue-18-v2

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 30, 2026

Fixes #18

Made with Cursor

Refuse to rewrite content when special mode bits are set so find-replace
does not silently strip setuid/setgid/sticky permissions.

Fixes dolph#18
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b0457e73c8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread find_replace_test.go
if err := os.WriteFile(path, []byte("needle"), 0o755); err != nil {
t.Fatal(err)
}
if err := os.Chmod(path, 0o4755); err != nil {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Set the setuid bit with os.ModeSetuid

In this test, 0o4755 does not request setuid through Go's os.Chmod: on Unix, Chmod consumes mode.Perm() plus os.ModeSetuid/os.ModeSetgid/os.ModeSticky, and 0o4000 is neither a permission bit nor os.ModeSetuid. On normal Unix this leaves the file at 0755, so the later hasSpecialFileModeBits check takes the t.Skip path and the new regression test never exercises the skip behavior; use os.ModeSetuid|0o755 so the test actually covers setuid files.

Useful? React with 👍 / 👎.

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.

Setuid/setgid/sticky bits are silently stripped from rewritten files

1 participant