Skip to content

Replace generated configuration logs with structural summaries - #139

Merged
hawkff merged 1 commit into
mainfrom
security/002-safe-config-diagnostics
Jul 12, 2026
Merged

Replace generated configuration logs with structural summaries#139
hawkff merged 1 commit into
mainfrom
security/002-safe-config-diagnostics

Conversation

@hawkff

@hawkff hawkff commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • remove serialized runtime configuration content from debug logs
  • emit only byte and collection counts
  • add marker-based summary tests

Validation

  • Namespace CI run 29210065434 passed
  • CodeRabbit CLI reported no findings

Greptile Summary

This PR replaces generated configuration logs with structural diagnostics. The main changes are:

  • Adds a safe diagnostics helper for byte and collection counts.
  • Replaces config and plugin content logs in proxy startup paths.
  • Replaces test-instance config logging with the same summary format.
  • Adds tests that check counts and marker redaction.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
app/src/main/java/io/nekohasekai/sagernet/bg/proto/ProxyInstance.kt Replaces generated config and plugin content logs with safe structural summaries.
app/src/main/java/io/nekohasekai/sagernet/bg/proto/SafeConfigDiagnostics.kt Adds a helper that reports config size and related collection counts.
app/src/main/java/io/nekohasekai/sagernet/bg/proto/TestInstance.kt Uses the structural diagnostics helper for debug test-instance logging.
app/src/test/java/io/nekohasekai/sagernet/bg/proto/SafeConfigDiagnosticsTest.kt Adds tests for count formatting, empty inputs, UTF-8 sizing, and marker exclusion.

Reviews (2): Last reviewed commit: "fix(logs): omit generated configurations" | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 45 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 40624c52-2c8d-4d7b-a182-e06b0e8487e1

📥 Commits

Reviewing files that changed from the base of the PR and between 48de56d and 376ca36.

📒 Files selected for processing (4)
  • app/src/main/java/io/nekohasekai/sagernet/bg/proto/ProxyInstance.kt
  • app/src/main/java/io/nekohasekai/sagernet/bg/proto/SafeConfigDiagnostics.kt
  • app/src/main/java/io/nekohasekai/sagernet/bg/proto/TestInstance.kt
  • app/src/test/java/io/nekohasekai/sagernet/bg/proto/SafeConfigDiagnosticsTest.kt

Comment @coderabbitai help to get the list of available commands.

} else {
Commandline.redactProcessOutput(content)
}
if (notTmp) Logs.d(safeConfigDiagnostics(config, pluginConfigs.size))

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 Startup Failures Lose Diagnostics

When super.init() fails while loading the generated config, this summary never runs. The old config log ran during buildConfig(), before load/startup, so a bad generated config still left debug evidence; the replacement can leave startup failures with no byte/count diagnostics.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed. The normal path now emits the structural summary immediately after configuration generation, before later initialization work can fail.

Comment thread app/src/main/java/io/nekohasekai/sagernet/bg/proto/ProxyInstance.kt Outdated
@hawkff
hawkff force-pushed the security/002-safe-config-diagnostics branch from 207b41c to 376ca36 Compare July 12, 2026 22:36
@hawkff
hawkff merged commit ff4269f into main Jul 12, 2026
9 checks passed
@hawkff
hawkff deleted the security/002-safe-config-diagnostics branch July 13, 2026 01:29
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.

1 participant