Skip to content

Conversation

@leoparente
Copy link
Contributor

@leoparente leoparente commented Jan 28, 2026

This pull request introduces a new redact package and refactors logging throughout the agent to ensure sensitive information (such as secrets, tokens, and passwords) is properly masked in logs. The changes replace previous ad-hoc secret masking with a consistent, reusable approach for redacting sensitive data in both structured data and command-line arguments. This improves security and maintainability.

Key changes:

Sensitive Data Redaction (core implementation):

  • Added a new agent/redact/redact.go package, providing SensitiveData and Args functions to recursively mask sensitive fields in structs, maps, and CLI arguments. The package defines patterns and suffixes for identifying sensitive data and ensures all redacted output uses a consistent mask.

Agent and Backend Logging Updates:

  • Refactored logging in agent.go and all backend Start methods (device_discovery.go, network_discovery.go, snmp_discovery.go, worker.go) to use redact.SensitiveData and redact.Args for masking secrets in configuration and CLI arguments, replacing previous manual masking and in-place value swapping. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]

Configuration Management Improvements:

  • Updated the fleetConfigManager in configmgr/fleet.go to use redact.SensitiveData for masking sensitive fields (like client_secret) in configuration logs, replacing the previous manual masking logic. [1] [2]
  • Adjusted the AuthTokenManager in configmgr/fleet/auth.go to mask sensitive data in debug logs for token requests. [1] [2]

Testing Adjustments:

  • Updated tests in fleet_test.go to expect the new masked secret value (********) in YAML output, matching the new redaction standard. [1] [2]

Code Clean-up:

  • Removed now-unnecessary maskedSecret constants from backend files, since masking is handled centrally by the new redaction package. [1] [2] [3] [4]

These changes provide a robust and consistent way to prevent sensitive information from leaking into logs, improving the overall security posture of the agent.

@leoparente
Copy link
Contributor Author

@codex review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request introduces a centralized redaction utility (agent/redact package) to mask sensitive information in logs throughout the agent codebase. The new package provides two main functions: SensitiveData for recursively redacting sensitive fields in data structures, and Args for masking sensitive command-line arguments. The implementation replaces previous ad-hoc masking logic with a consistent, reusable approach.

Changes:

  • Added new agent/redact package with comprehensive test coverage for masking sensitive data in logs
  • Updated all backend Start methods (worker, snmpdiscovery, networkdiscovery, devicediscovery) to use redact.Args instead of manual secret swapping
  • Updated configuration logging in agent.go, cmd/main.go, and fleet config manager to use redact.SensitiveData

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
agent/redact/redact.go New package implementing sensitive data redaction with reflection-based deep copying and pattern-based field detection
agent/redact/redact_test.go Comprehensive test suite covering edge cases, different data types, and real config structures
agent/agent.go Updated backend logging to use redact.SensitiveData for configuration objects
cmd/main.go Updated backend logging to use redact.SensitiveData for configuration objects
agent/configmgr/fleet.go Replaced manual ClientSecret masking with redact.SensitiveData for full config redaction
agent/configmgr/fleet/auth.go Updated authentication request logging to use redact.SensitiveData
agent/backend/worker/worker.go Removed maskedSecret constant and manual swapping; now uses redact.Args for cleaner implementation
agent/backend/snmpdiscovery/snmp_discovery.go Removed maskedSecret constant and manual swapping; now uses redact.Args for cleaner implementation
agent/backend/networkdiscovery/network_discovery.go Removed maskedSecret constant and manual swapping; now uses redact.Args for cleaner implementation
agent/backend/devicediscovery/device_discovery.go Removed maskedSecret constant and manual swapping; now uses redact.Args for cleaner implementation

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

Copy link

@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: ab088e80c2

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

@github-actions
Copy link

github-actions bot commented Jan 28, 2026

Go test coverage

STATUS ELAPSED PACKAGE COVER PASS FAIL SKIP
🟢 PASS 1.05s github.com/netboxlabs/orb-agent/agent 44.5% 6 0 0
🟢 PASS 31.88s github.com/netboxlabs/orb-agent/agent/backend 75.2% 40 0 0
🟢 PASS 6.03s github.com/netboxlabs/orb-agent/agent/backend/devicediscovery 66.5% 4 0 0
🟢 PASS 2.23s github.com/netboxlabs/orb-agent/agent/backend/mocks 0.0% 0 0 0
🟢 PASS 6.04s github.com/netboxlabs/orb-agent/agent/backend/networkdiscovery 58.3% 4 0 0
🟢 PASS 4.02s github.com/netboxlabs/orb-agent/agent/backend/opentelemetryinfinity 45.2% 2 0 0
🟢 PASS 4.03s github.com/netboxlabs/orb-agent/agent/backend/pktvisor 67.0% 2 0 0
🟢 PASS 6.03s github.com/netboxlabs/orb-agent/agent/backend/snmpdiscovery 58.3% 4 0 0
🟢 PASS 7.04s github.com/netboxlabs/orb-agent/agent/backend/worker 67.4% 5 0 0
🟢 PASS 1.01s github.com/netboxlabs/orb-agent/agent/config 100.0% 6 0 0
🟢 PASS 1.38s github.com/netboxlabs/orb-agent/agent/configmgr 49.9% 32 0 0
🟢 PASS 2.73s github.com/netboxlabs/orb-agent/agent/configmgr/fleet 65.5% 141 0 0
🟢 PASS 1.02s github.com/netboxlabs/orb-agent/agent/otlpbridge 42.2% 8 0 0
🟢 PASS 1.01s github.com/netboxlabs/orb-agent/agent/policies 98.9% 18 0 0
🟢 PASS 1.04s github.com/netboxlabs/orb-agent/agent/policymgr 71.6% 11 0 0
🟢 PASS 1.02s github.com/netboxlabs/orb-agent/agent/redact 81.6% 84 0 0
🟢 PASS 35.05s github.com/netboxlabs/orb-agent/agent/secretsmgr 48.9% 54 0 0
🟢 PASS 1.02s github.com/netboxlabs/orb-agent/agent/telemetry 81.7% 19 0 0
🟢 PASS 1.01s github.com/netboxlabs/orb-agent/agent/version 100.0% 1 0 0

Total coverage: 60.1%

@leoparente leoparente requested a review from Copilot January 28, 2026 14:09
@leoparente
Copy link
Contributor Author

@codex review

Copy link
Contributor

Copilot AI left a comment

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 11 out of 11 changed files in this pull request and generated 2 comments.


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

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. More of your lovely PRs please.

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

@leoparente leoparente requested a review from Copilot January 28, 2026 14:27
@leoparente
Copy link
Contributor Author

@codex review

Copy link
Contributor

Copilot AI left a comment

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 11 out of 11 changed files in this pull request and generated no new comments.


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

Copy link

@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: ecf5a0ca73

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

@leoparente leoparente requested a review from Copilot January 28, 2026 16:11
@leoparente
Copy link
Contributor Author

@codex review

Copy link
Contributor

Copilot AI left a comment

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 11 out of 11 changed files in this pull request and generated no new comments.


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

Copy link

@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: c71539338d

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

@leoparente leoparente marked this pull request as ready for review January 28, 2026 16:17
@leoparente leoparente merged commit b2c1370 into develop Jan 28, 2026
11 checks passed
@leoparente leoparente deleted the chore/OBS-1656-redact branch January 28, 2026 17:21
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.

3 participants