Skip to content

Add support for preshared key configuration and redact logging output - #427

Open
p-atr wants to merge 2 commits into
netbirdio:mainfrom
p-atr:main
Open

Add support for preshared key configuration and redact logging output#427
p-atr wants to merge 2 commits into
netbirdio:mainfrom
p-atr:main

Conversation

@p-atr

@p-atr p-atr commented Aug 8, 2026

Copy link
Copy Markdown

Proposed Changes

Added optional NetBird preshared key support in the Home Assistant addon configuration.
The key is passed to netbird up, and sensitive values are redacted from startup logs.

Summary by CodeRabbit

  • New Features

    • Added support for configuring an optional WireGuard pre-shared key.
    • The key can restrict peer communication to connections using the same key.
    • Added configuration guidance, password validation, and an empty default value for the option.
  • Security

    • Sensitive setup-key and pre-shared-key values are now hidden in command-line logs while commands continue to run normally.

Copilot AI lite review requested due to automatic review settings August 8, 2026 20:05
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 34f0c5f6-8afe-4479-8cd9-06fba1134d51

📥 Commits

Reviewing files that changed from the base of the PR and between a4f01f5 and 9525aeb.

📒 Files selected for processing (3)
  • netbird/config.yaml
  • netbird/rootfs/etc/s6-overlay/s6-rc.d/netbird/run
  • netbird/translations/en.yaml
🚧 Files skipped from review as they are similar to previous changes (3)
  • netbird/translations/en.yaml
  • netbird/config.yaml
  • netbird/rootfs/etc/s6-overlay/s6-rc.d/netbird/run

📝 Walkthrough

Walkthrough

The add-on adds a validated preshared_key option, documents it in English, passes it to NetBird when configured, and redacts setup and preshared key values from command logs.

Changes

NetBird preshared key support

Layer / File(s) Summary
Preshared key configuration contract
netbird/config.yaml, netbird/translations/en.yaml
Adds the optional string setting with an empty default, validation, display name, and peer key-matching description.
Runtime injection and command redaction
netbird/rootfs/etc/s6-overlay/s6-rc.d/netbird/run
Loads the setting, adds --preshared-key when configured, and masks sensitive values in logged command options while using the original options for execution.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AddonConfiguration
  participant NetBirdRunScript
  participant CommandLog
  participant NetBird
  AddonConfiguration->>NetBirdRunScript: provide preshared_key
  NetBirdRunScript->>CommandLog: create redacted command options
  CommandLog-->>NetBirdRunScript: mask sensitive values
  NetBirdRunScript->>NetBird: execute with original options
Loading

Possibly related issues

  • #428: This change implements the requested NetBird preshared-key configuration and startup handling.

Poem

A rabbit checks the key,
NetBird starts securely.
Logs hide each secret,
Peers match when they meet.
Hop, hop—done!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the two main changes: preshared key configuration and redacted logging output.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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 extends the Home Assistant NetBird add-on to support an optional WireGuard pre-shared key (PSK) and updates startup logging to avoid leaking sensitive key material when printing the netbird up command.

Changes:

  • Added preshared_key as an optional add-on configuration value (schema + UI translation).
  • Passed --preshared-key to netbird up when configured.
  • Introduced redacted logging for secret-bearing CLI arguments (--setup-key, --preshared-key).

Reviewed changes

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

File Description
netbird/config.yaml Adds preshared_key to add-on options and schema.
netbird/rootfs/etc/s6-overlay/s6-rc.d/netbird/run Reads preshared_key, appends --preshared-key, and logs a redacted netbird up command line.
netbird/translations/en.yaml Adds UI text for the new preshared_key option.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread netbird/config.yaml Outdated
admin_url: str?
management_url: str?
setup_key: str?
preshared_key: str?
Comment thread netbird/translations/en.yaml Outdated
Comment on lines +30 to +31
Sets WireGuard PreSharedKey property.
If set, then only peers that have the same key can communicate.

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@netbird/config.yaml`:
- Line 38: Update the preshared_key schema field in the configuration to use the
optional password type instead of the optional string type, so the input remains
optional while being masked in the add-on UI.

In `@netbird/rootfs/etc/s6-overlay/s6-rc.d/netbird/run`:
- Around line 129-151: Update the netbird startup argument construction before
the redaction loop so the preshared key is removed from the netbird command-line
arguments and supplied through the supported NB_PRESHARED_KEY environment
variable or equivalent secure channel. Preserve the existing setup-key argument
handling and ensure the resulting command still receives the preshared key
without exposing it in /proc command-line data.
- Around line 71-77: Update the preshared_key handling in the run script so an
empty Home Assistant option still appends the --preshared-key argument with an
empty value, clearing the persisted PSK. Preserve the existing informational
logs and configured-key behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: df5a6658-d48b-4591-ad12-3a4d09891d5e

📥 Commits

Reviewing files that changed from the base of the PR and between 59ed475 and a4f01f5.

📒 Files selected for processing (3)
  • netbird/config.yaml
  • netbird/rootfs/etc/s6-overlay/s6-rc.d/netbird/run
  • netbird/translations/en.yaml

Comment thread netbird/config.yaml Outdated
Comment thread netbird/rootfs/etc/s6-overlay/s6-rc.d/netbird/run
Comment thread netbird/rootfs/etc/s6-overlay/s6-rc.d/netbird/run
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.

2 participants