Skip to content

Avoid collecting unsanitized process arguments#1993

Merged
bobstrecansky merged 1 commit into
open-telemetry:mainfrom
PuvaanRaaj:avoid-collecting-process-arguments
Jul 14, 2026
Merged

Avoid collecting unsanitized process arguments#1993
bobstrecansky merged 1 commit into
open-telemetry:mainfrom
PuvaanRaaj:avoid-collecting-process-arguments

Conversation

@PuvaanRaaj

Copy link
Copy Markdown
Contributor

Summary

  • stop collecting raw process.command_args by default because arguments may contain sensitive data
  • retain process.command and report process.args_count as the non-sensitive fallback
  • verify process.command_args and process.command_line remain unset

Closes #1604.

Validation

  • targeted PHPUnit tests: 156 tests, 309 assertions
  • unit suite: 1,756 tests, 2 skipped
  • integration suite: 115 tests, 392 assertions
  • PHP CS Fixer
  • Deptrac
  • package Composer validation
  • Phan
  • Psalm
  • PHPStan
  • SPI dependency check

make all-checks does not currently complete on a clean main checkout because the unpinned local Rector installation reports 22 pre-existing dry-run suggestions. The checks above were run individually; Rector is not part of the upstream CI workflow.

Raw command arguments can contain credentials or other sensitive data. Keep process.command, expose only process.args_count, and verify command_args and command_line remain unset.

Closes open-telemetry#1604

Risk-Level: low
AI-Agent: codex
@PuvaanRaaj
PuvaanRaaj requested a review from a team as a code owner June 28, 2026 06:12
@welcome

welcome Bot commented Jun 28, 2026

Copy link
Copy Markdown

Thanks for opening your first pull request! If you haven't yet signed our Contributor License Agreement (CLA), then please do so that we can accept your contribution. A link should appear shortly in this PR if you have not already signed one.

@PuvaanRaaj

Copy link
Copy Markdown
Contributor Author

Hi @brettmc, this replaces #1992 after correcting the fork branch name. The code and validation are unchanged, and this PR is ready for review. The GitHub Actions workflows may require maintainer authorization for this first-time fork contribution. Thank you.

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

Copy link
Copy Markdown

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: bbb83fa4d1

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

if (is_array($argv)) {
$command = $argv[0] ?? null;
if (is_string($command)) {
$attributes[ProcessIncubatingAttributes::PROCESS_COMMAND] = $command;

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 Restrict argv-derived command to CLI SAPIs

When this detector runs under CGI/FastCGI with register_argc_argv enabled, PHP populates $_SERVER['argv'] from the request query string rather than the OS process command. Keeping process.command sourced from $argv[0] means the default resource can still export user-supplied query data such as ?token=secret as the supposedly safe fallback after process.command_args was removed; gate this on CLI (or use a real process command source) before setting command-derived attributes.

Useful? React with 👍 / 👎.

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.04%. Comparing base (6cb4156) to head (bbb83fa).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1993      +/-   ##
============================================
+ Coverage     68.02%   68.04%   +0.02%     
- Complexity     3075     3076       +1     
============================================
  Files           459      459              
  Lines          9017     9020       +3     
============================================
+ Hits           6134     6138       +4     
+ Misses         2883     2882       -1     
Flag Coverage Δ
8.1 67.79% <100.00%> (+0.06%) ⬆️
8.2 67.91% <100.00%> (+<0.01%) ⬆️
8.3 67.98% <100.00%> (+0.06%) ⬆️
8.4 67.92% <100.00%> (-0.06%) ⬇️
8.5 68.00% <100.00%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/SDK/Resource/Detectors/Process.php 100.00% <100.00%> (ø)

... and 4 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6cb4156...bbb83fa. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@PuvaanRaaj

Copy link
Copy Markdown
Contributor Author

@ChrisLightfootWild , can help me to review this PR?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the process resource detector to avoid collecting potentially sensitive raw process arguments by default, aligning with updated semantic convention guidance. Instead, it retains a non-sensitive fallback (process.command and process.args_count) and adds/updates tests to ensure process.command_args and process.command_line remain unset.

Changes:

  • Stop emitting process.command_args from the Process resource detector by default.
  • Add process.args_count as a non-sensitive replacement signal alongside process.command.
  • Update unit/integration/config tests to assert the new behavior and attribute set.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/SDK/Resource/Detectors/Process.php Update detector to emit process.command + process.args_count and omit process.command_args.
tests/Unit/SDK/Resource/Detectors/ProcessTest.php Add a targeted argv scenario and assert args are not collected while count is reported.
tests/Integration/SDK/Resource/ResourceInfoFactoryTest.php Update integration assertions to require process.args_count and ensure command args/line are unset.
tests/Integration/Config/ConfigurationTest.php Update expected resource keys to include process.args_count and verify process.command_args is not present.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@bobstrecansky
bobstrecansky merged commit 69e2963 into open-telemetry:main Jul 14, 2026
12 checks passed
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.

[semconv 1.34.0] Require sensitive data sanitization for process.command_args and process.command_line

3 participants