Skip to content

Revert "Revert "feat(par): add default restricted shell paths with co…#48482

Closed
AlexandreYang wants to merge 1 commit into7.78.xfrom
alex/backport-48462-to-7.78.x
Closed

Revert "Revert "feat(par): add default restricted shell paths with co…#48482
AlexandreYang wants to merge 1 commit into7.78.xfrom
alex/backport-48462-to-7.78.x

Conversation

@AlexandreYang
Copy link
Copy Markdown
Member

…ntainer-aware prefixing"" (#48462)

Reverts #48460

Revert + this test fix:

All tests pass. Here's a summary of the fix:

Root cause: Both filepath.Join calls used OS path separators. On Windows, filepath.Join("/host", "/var/log") produces \host\var\log, breaking tests that expected Linux-style paths. Similarly,
filepath.Join("/host", "/proc") produced \host\proc which didn't match the mock key /host/proc, causing resolveProcPath to fall back to /proc.

Fix: Replaced filepath.Join with path.Join (POSIX package) in three files:

  • pkg/config/setup/privateactionrunner.go — container path prefix joining
  • pkg/config/setup/privateactionrunner_test.go — test assertion using same join
  • pkg/privateactionrunner/bundles/remoteaction/rshell/run_command.go — resolveProcPath

These are Linux container paths (/host/...) that must always use forward slashes regardless of the host OS.

What does this PR do?

Motivation

Describe how you validated your changes

Additional Notes

…ntainer-aware prefixing"" (#48462)

Reverts #48460

Revert + this test fix:

All tests pass. Here's a summary of the fix:

  Root cause: Both filepath.Join calls used OS path separators. On Windows, filepath.Join("/host", "/var/log") produces \host\var\log, breaking tests that expected Linux-style paths. Similarly,
  filepath.Join("/host", "/proc") produced \host\proc which didn't match the mock key /host/proc, causing resolveProcPath to fall back to /proc.

  Fix: Replaced filepath.Join with path.Join (POSIX package) in three files:
  - pkg/config/setup/privateactionrunner.go — container path prefix joining
  - pkg/config/setup/privateactionrunner_test.go — test assertion using same join
  - pkg/privateactionrunner/bundles/remoteaction/rshell/run_command.go — resolveProcPath

  These are Linux container paths (/host/...) that must always use forward slashes regardless of the host OS.

Co-authored-by: alexandre.yang <alexandre.yang@datadoghq.com>
@AlexandreYang AlexandreYang added changelog/no-changelog No changelog entry needed qa/done QA done before merge and regressions are covered by tests labels Mar 27, 2026
@AlexandreYang AlexandreYang added this to the 7.78.0 milestone Mar 27, 2026
@dd-octo-sts dd-octo-sts Bot added the internal Identify a non-fork PR label Mar 27, 2026
@AlexandreYang AlexandreYang marked this pull request as ready for review March 27, 2026 11:48
@AlexandreYang AlexandreYang requested a review from a team as a code owner March 27, 2026 11:48
@AlexandreYang AlexandreYang requested review from dd-gplassard and removed request for a team March 27, 2026 11:48
@github-actions github-actions Bot added the medium review PR review might take time label Mar 27, 2026
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: 9d3380c13e

ℹ️ 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 on lines +86 to +90
if env.IsContainerized() {
for i, v := range defaultPaths {
hostPath := path.Join(containerizedPathPrefix, v)
defaultPaths[i] = hostPath
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve fallback allowed path when host mount is absent

In containerized mode this always rewrites the default rshell allowlist entry from /var/log to /host/var/log. In the no-host-mount case (the scenario covered by TestPrivateActionRunnerAllowedPathsContainerizedWithoutHostMounts), RunCommand still forwards that path to interp.AllowedPaths, and rshell sandbox creation fails for missing directories, so runCommand can fail with failed to create runner for every task. Please keep a usable fallback (e.g., /var/log) or drop non-existent paths before constructing the runner.

Useful? React with 👍 / 👎.

Comment on lines +76 to +77
log.Debugf("rshell runCommand: command=%q allowedCommands=%v allowedPaths=%v",
inputs.Command, inputs.AllowedCommands, h.allowedPaths)
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 Remove raw command text from debug logs

This now logs inputs.Command verbatim, which can include secrets (for example API tokens passed in command arguments). When debug logging is enabled, sensitive task payload data will be written to agent logs and potentially forwarded downstream. Redact/scrub the command contents (or log only metadata like command name) to avoid leaking credentials.

Useful? React with 👍 / 👎.

@AlexandreYang AlexandreYang deleted the alex/backport-48462-to-7.78.x branch March 27, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog No changelog entry needed internal Identify a non-fork PR medium review PR review might take time qa/done QA done before merge and regressions are covered by tests team/action-platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant