Skip to content

fix: tolerate quotes and host bits in HP_TRUSTED_PROXY_IPS and keep valid entries - #112

Merged
oleksandr-nc merged 1 commit into
mainfrom
fix/trusted-proxy-ips-parsing
Jul 29, 2026
Merged

fix: tolerate quotes and host bits in HP_TRUSTED_PROXY_IPS and keep valid entries#112
oleksandr-nc merged 1 commit into
mainfrom
fix/trusted-proxy-ips-parsing

Conversation

@oleksandr-nc

Copy link
Copy Markdown
Contributor

Values for HP_TRUSTED_PROXY_IPS often arrive with literal quotes (env files, compose list syntax, systemd units) and are then rejected, which silently disables client IP detection and lets bruteforce protection ban the reverse proxy for everyone behind it. Quotes are now stripped, ranges with host bits set are masked to their network the same way Nextcloud handles trusted_proxies, and invalid entries are skipped individually instead of discarding the whole list. Fixes #108.

@oleksandr-nc
oleksandr-nc requested a review from kyteinsky as a code owner July 28, 2026 13:26
@coderabbitai

coderabbitai Bot commented Jul 28, 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: f61ef98c-8bf3-474e-a7e3-9f7ae5196659

📥 Commits

Reviewing files that changed from the base of the PR and between 44eeb38 and 46bf45e.

📒 Files selected for processing (2)
  • README.md
  • haproxy_agent.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • README.md
  • haproxy_agent.py

📝 Walkthrough

Walkthrough

Trusted proxy parsing now tokenizes comma-separated environment values, strips surrounding quotes and whitespace, normalizes network entries with host bits, and logs ignored invalid entries. TRUSTED_PROXIES is initialized from the new parser, with header-based client IP detection disabled when no valid networks are found. The README documents these behaviors.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main fix: handling quotes and host bits in HP_TRUSTED_PROXY_IPS while preserving valid entries.
Description check ✅ Passed The description matches the changeset and explains the parsing fixes and their motivation.
Linked Issues check ✅ Passed The PR addresses #108 by handling quoted HP_TRUSTED_PROXY_IPS values in code instead of rejecting them.
Out of Scope Changes check ✅ Passed The added host-bit normalization and per-entry validation are aligned with the stated PR objectives, not unrelated scope.

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.

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

🧹 Nitpick comments (1)
haproxy_agent.py (1)

78-114: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add regression tests for the trusted-proxy parser.

This security-sensitive path should cover quoted comma-separated values, host-bit normalization, mixed valid/invalid entries, and the no-valid-entry fallback that disables forwarded-header trust.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 66481226-e3a5-44b0-9292-a9c91ef104f7

📥 Commits

Reviewing files that changed from the base of the PR and between e0cb449 and 44eeb38.

📒 Files selected for processing (2)
  • README.md
  • haproxy_agent.py

@oleksandr-nc
oleksandr-nc force-pushed the fix/trusted-proxy-ips-parsing branch from 44eeb38 to cd65ab7 Compare July 28, 2026 13:38
…alid entries

Signed-off-by: Oleksander Piskun <oleksandr2088@icloud.com>
@oleksandr-nc
oleksandr-nc force-pushed the fix/trusted-proxy-ips-parsing branch from cd65ab7 to 46bf45e Compare July 29, 2026 10:28

@julien-nc julien-nc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lgtm

@oleksandr-nc
oleksandr-nc merged commit 090268b into main Jul 29, 2026
19 of 21 checks passed
@oleksandr-nc
oleksandr-nc deleted the fix/trusted-proxy-ips-parsing branch July 29, 2026 11:25
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.

Docs for HP_TRUSTED_PROXY_IPS should remove double quotes or handle them in the bash script

2 participants