-
Notifications
You must be signed in to change notification settings - Fork 3
feat(rm): implement rm builtin for remediation mode #556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
julesmcrt
wants to merge
10
commits into
main
Choose a base branch
from
jules.macret/rm-remediation-mode
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a6c806b
feat(rm): implement rm builtin for remediation mode
julesmcrt 14c08bc
fix(rm): apply pentest fix and docs that were dropped from the initia…
julesmcrt 45b9fa8
fix(allowedpaths): close TOCTOU window in Sandbox.Remove, fix rm docs
julesmcrt 92ff7ef
fix(rm): pre-parse constructed script in FuzzRmFilename to avoid fals…
julesmcrt c74163e
fix(rm): close Windows Unlink TOCTOU between directory check and delete
julesmcrt 4af5dd9
fix(rm): reject trailing-slash/dot operands instead of silently clean…
julesmcrt e60e35d
fix(rm): don't reject directory-symlink removal on Windows
julesmcrt b63dc79
fix(rm): enforce trailing-dir-syntax at the sandbox primitive, fix Un…
julesmcrt 011c815
fix(rm): reject no-argument flag values, validate symlink targets bef…
julesmcrt 1803ac4
fix(rm): preserve trailing-slash rm errors when LstatFile itself fails
julesmcrt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // Unless explicitly stated otherwise all files in this repository are licensed | ||
| // under the Apache License Version 2.0. | ||
| // This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| // Copyright 2026-present Datadog, Inc. | ||
|
|
||
| package writeopen | ||
|
|
||
| import "path/filepath" | ||
|
|
||
| // HasTrailingDirSyntax reports whether relPath, as literally passed to | ||
| // Unlink, syntactically requires its target to resolve as a directory: it | ||
| // ends in a path separator, or its final component is "." or "..". POSIX/GNU | ||
| // tools reject such operands (e.g. "file/", "file/.") with ENOTDIR when the | ||
| // target — after following any symlink, since a trailing separator forces | ||
| // dereference — is not a directory, rather than silently operating on | ||
| // whatever remains once path cleaning drops the trailing syntax. "/" is | ||
| // always checked since it is the shell's own path-separator syntax; "\" is | ||
| // only a separator on Windows — on Unix it is a valid filename character. | ||
| // | ||
| // Exported so Sandbox.Remove can detect this syntax on the caller's raw path | ||
| // before toAbs's filepath.Join cleans the trailing separator away, and | ||
| // re-encode the requirement onto relPath before calling Unlink. | ||
| func HasTrailingDirSyntax(relPath string) bool { | ||
| if relPath == "" { | ||
| return false | ||
| } | ||
| last := relPath[len(relPath)-1] | ||
| if last == '/' || (filepath.Separator == '\\' && last == '\\') { | ||
| return true | ||
| } | ||
| base := filepath.Base(relPath) | ||
| return base == "." || base == ".." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.