Skip to content

feat(interp): add RemediationMode() RunnerOption [PR A]#524

Merged
julesmcrt merged 3 commits into
mainfrom
jules.macret/remediation-mode-option
Jun 11, 2026
Merged

feat(interp): add RemediationMode() RunnerOption [PR A]#524
julesmcrt merged 3 commits into
mainfrom
jules.macret/remediation-mode-option

Conversation

@julesmcrt

Copy link
Copy Markdown
Collaborator

Summary

  • Adds RemediationMode() RunnerOption in interp/api.go with the corresponding remediationMode bool field on runnerConfig
  • Adds --remediation-mode boolean CLI flag (default false) in cmd/rshell/main.go
  • Documents the new mode in README.md and SHELL_FEATURES.md (one line each)

This PR is purely an API addition — no behavior changes. The option is accepted and stored on the runner but is otherwise inert.

Context (multi-PR series)

PR Description
A (this PR) RemediationMode() option — API only, inert
B Add write capability to allowedpaths/sandbox.go
C Wire remediationMode into interpreter so > / >> redirects work when set
Later truncate and logrotate builtins

End goal: a runRemediationCommand PAR action creates a Runner with RemediationMode() set; the existing runCommand action does not.

Test plan

  • go build ./... — clean
  • go test ./... — all pass
  • make fmt — no changes after formatting

… series)

Adds `RemediationMode() RunnerOption`, the `remediationMode bool` field on
`runnerConfig`, the `--remediation-mode` CLI flag, and one-line docs in
README.md / SHELL_FEATURES.md. The option is accepted without error and
stored on the runner, but is otherwise inert — no behavior changes in this
PR. Write capability and interpreter wiring follow in PRs B and C.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@julesmcrt

Copy link
Copy Markdown
Collaborator Author

@codex review

1 similar comment
@julesmcrt

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

ℹ️ 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".

@julesmcrt
julesmcrt marked this pull request as ready for review June 10, 2026 11:28
Comment thread cmd/rshell/main.go Outdated
…remediation

Per review feedback, a string enum is more extensible than a per-mode
boolean flag. The default is read-only (existing behavior); passing
--mode remediation enables remediation mode. Invalid values are rejected
with a clear error message.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Comment thread cmd/rshell/main.go Outdated
allowedCommands []string
allowAllCommands bool
procPath string
remediationMode bool

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can/shall we align also remediationMode ?

instead of remediationMode have mode: <read-only | remediation>

with struct types ModeReadOnly and ModeRemediation that can be used by datadog-agent (client)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done — added an exported Mode type with ModeReadOnly and ModeRemediation constants to the interp package. executeOpts now carries an interp.Mode field, and the CLI parses the --mode string against those constants. Agent clients can import the type directly.

…n constants

Per review feedback, align executeOpts with the --mode flag by replacing
the internal remediationMode bool with an interp.Mode field. Define the
Mode type and its constants in the interp package so datadog-agent clients
can reference them directly without stringly-typed comparisons.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@julesmcrt
julesmcrt added this pull request to the merge queue Jun 11, 2026
Merged via the queue into main with commit 41bdae4 Jun 11, 2026
40 checks passed
@julesmcrt
julesmcrt deleted the jules.macret/remediation-mode-option branch June 11, 2026 12:26
julesmcrt added a commit that referenced this pull request Jun 16, 2026
PR #524 reviewer explicitly asked for type Mode with ModeReadOnly and
ModeRemediation constants. PR #526 had renamed the type to ExecutionMode
to avoid a naming conflict with the Mode() RunnerOption function, but
that went against the prior review feedback.

Restore type Mode string (as requested in PR #524) and rename the
RunnerOption from Mode() to WithMode(), which reads naturally at the
call site (interp.WithMode(interp.ModeRemediation)) and eliminates the
awkward inversion where the setter and the type had swapped names.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
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.

2 participants