Skip to content

Conversation

jmacd
Copy link
Contributor

@jmacd jmacd commented Aug 20, 2025

Description

See #12369, #11775.

Fixes #13278.

cc/ @VihasMakwana

This refines the print-config command with two modes, "redacted" and "unredacted", with an optional "--validate" or no, with optional --format=yaml or json.

Link to tracking issue

Fixes #11775.

Testing

✔️

Documentation

✔️

@jmacd jmacd requested review from a team and dmitryax as code owners August 20, 2025 21:03
Copy link

codecov bot commented Aug 20, 2025

Codecov Report

❌ Patch coverage is 83.07692% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.46%. Comparing base (1a001d9) to head (7f553c9).

Files with missing lines Patch % Lines
otelcol/command_print.go 82.94% 15 Missing and 7 partials ⚠️

❌ Your patch check has failed because the patch coverage (83.07%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13679      +/-   ##
==========================================
- Coverage   91.52%   91.46%   -0.06%     
==========================================
  Files         639      639              
  Lines       41662    41767     +105     
==========================================
+ Hits        38131    38204      +73     
- Misses       2709     2732      +23     
- Partials      822      831       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

// printUnredactedConfig prints resolved configuration before interpreting
// with the intended types for each component, thus it shows the full
// configuration without considering configuopaque. Use with caution.
func (pctx *printContext) printUnredactedConfig() error {
Copy link
Member

Choose a reason for hiding this comment

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

Can this be a CVE? I am thinking of a scenario where via the otelcol someone gets access to some credentials (VoltDB, etc.)?

I have not spent too much time thinking of all possible scenarios but I am worried a bit to offer this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a fair question. I came to this PR from a tough debugging session, #13273, where I was hit by a bug in the underlying mapstructure library and couldn't see the configuration that was invalid (fixed upstream, unreleased). This led me to #13278.

I looked at the existing print-initial-config command, and found:

  • it had been written by a similarly frustrated user wanting to see "initial" meaning unredacted configuration
  • however, it was broken because it didn't fully resolve, so you couldn't see default settings.
  • there is a feature flag covering the existing print-initial-config command (broken it may be), because of your concern about the CVE

This was discussed in a Collector SIG once or twice. The synopsis was that if a user has the power to run the collector and resolve the configuration, we're not really securing anything by hiding this detail, but we are sometimes making the operator's life difficult.

My idea was to embrace the operator need and build in protections so that by default we apply the configopaque mechanism, which is meant as a solution to exactly this problem. So, I think no, this is not a CVE, this is secure-by-default and good for users. 👍

Copy link
Contributor

@VihasMakwana VihasMakwana left a comment

Choose a reason for hiding this comment

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

LGTM Joshua! Thanks for working on this.

Copy link
Contributor

@evan-bradley evan-bradley left a comment

Choose a reason for hiding this comment

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

Looks good to me, most of my comments are just around copy.

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
subtext:
subtext: This replaces the `print-initial-config` command. See the `service` package README for more details.

I think we should make sure users who might be using the previous command are aware it's replaced. Also would be nice to point users to where to find more.

# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
change_type: enhancement
change_type: breaking

I doubt it will break many people, but this is still realistically a breaking change (even behind a feature gate) since we're renaming the command.


Validation is enabled by default, as a safety measure.

All modes are experimental requiring otelcol.printInitialConfig feature gate.`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
All modes are experimental requiring otelcol.printInitialConfig feature gate.`,
All modes are experimental, requiring the otelcol.printInitialConfig feature gate.`,

Comment on lines +172 to +175
valid. To print a potentially invalid configuration, use
`--validate=false`.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Note that by default the configuration will only print when it is
valid. To print a potentially invalid configuration, use
`--validate=false`.

Could we either remove this instance of this paragraph, or look at moving it elsewhere? I understand putting it in both sections, but having it repeated not long after the previous one makes it feel like an editing mishap.

We could also try to put it in a "caution" box if you think it's important enough to repeat.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this got committed by accident, we should delete it.

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.

5 participants