Skip to content

feat: redact sensitive flags in logging middleware - #1814

Merged
aidandaly24 merged 1 commit into
refactorfrom
sensitive-logging
Jul 23, 2026
Merged

feat: redact sensitive flags in logging middleware#1814
aidandaly24 merged 1 commit into
refactorfrom
sensitive-logging

Conversation

@nborges-aws

Copy link
Copy Markdown
Contributor

Description

Added sensitive option to flag() API to prevent identity credentials from being persisted to bug logs (ref: #1811). The withLogging middleware will now redact any flag with sensitive field set to true before logging.

Changes:

  • src/router/handler.tsx — Added sensitive?: boolean to the Flag interface; changed flag() 4th param from help?: string to options?: { help?: string; sensitive?: boolean }
  • src/middleware/withLogging.tsx — Added redactSensitiveFlags() which replaces sensitive values with [REDACTED]
  • src/middleware/withLogging.test.ts — Added test verifying sensitive flags are redacted while others remain visible
  • src/handlers/harness/{create,update}/index.tsx — Migrated existing help string args to { help: ... } format
  • src/router/router.test.ts — Migrated help string to new format

I will update my identity PR to mark --api-key as { sensitive: true } after this is merged.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

Testing

How have you tested the change?

  • I ran npm run test:unit and npm run test:integ
  • I ran npm run typecheck
  • I ran npm run lint
  • If I modified src/assets/, I ran npm run test:update-snapshots and committed the updated snapshots

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.

@github-actions github-actions Bot added agentcore-harness-reviewing AgentCore Harness review in progress and removed agentcore-harness-reviewing AgentCore Harness review in progress labels Jul 23, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.93%. Comparing base (56f62e7) to head (ecf537f).

Additional details and impacted files
@@             Coverage Diff              @@
##           refactor    #1814      +/-   ##
============================================
- Coverage     93.94%   93.93%   -0.02%     
============================================
  Files           122      122              
  Lines          6462     6445      -17     
============================================
- Hits           6071     6054      -17     
  Misses          391      391              

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AlexanderRichey AlexanderRichey 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.

🚢

@aidandaly24 aidandaly24 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.

lgtm, this will be helpful

@aidandaly24
aidandaly24 merged commit ef5a9f5 into refactor Jul 23, 2026
9 of 10 checks passed
@aidandaly24
aidandaly24 deleted the sensitive-logging branch July 23, 2026 18:51
This was referenced Sep 3, 2026
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.

4 participants