TT-14891 - adds client ip from XFF by depth #7063
Merged
probelabs / Visor: architecture
failed
Nov 3, 2025 in 3m 54s
🚨 Check Failed
architecture check failed because fail_if condition was met.
Details
📊 Summary
- Total Issues: 3
- Error Issues: 2
- Warning Issues: 1
🔍 Failure Condition Results
❌ Failed Conditions
- global_fail_if: Global failure condition met
⚠️ Severity: Error
🐛 Issues by Category
🏗️ Architecture (1)
- ❌ request/real_ip.go:12 - The use of a global function variable
request.Globalto access configuration introduces a hidden dependency and tight coupling between therequestandgatewaypackages. Therequestpackage's functionality now implicitly depends on thegatewaypackage for initialization, which reduces modularity, reusability, and makes the code harder to test and reason about.
🧠 Logic (2)
⚠️ request/real_ip.go:56 - The function is expected to return a bare IP address. However, when an invalid IP is found in theX-Forwarded-Forheader, the logic falls through to returnr.RemoteAddr, which includes the port (e.g., "192.168.1.1:8080"). This creates an inconsistency in the function's return value, as other paths return only the IP address.- ❌ system:0 - Global failure condition met
Powered by Visor from Probelabs
💡 TIP: You can chat with Visor using /visor ask <your question>
Annotations
Check failure on line 12 in request/real_ip.go
probelabs / Visor: architecture
architecture Issue
The use of a global function variable `request.Global` to access configuration introduces a hidden dependency and tight coupling between the `request` and `gateway` packages. The `request` package's functionality now implicitly depends on the `gateway` package for initialization, which reduces modularity, reusability, and makes the code harder to test and reason about.
Raw output
Refactor to use dependency injection. Pass the required configuration values (like `xffDepth`) as explicit parameters to the `RealIP` function. This makes dependencies clear, improves testability, and decouples the packages.
Check warning on line 56 in request/real_ip.go
probelabs / Visor: architecture
logic Issue
The function is expected to return a bare IP address. However, when an invalid IP is found in the `X-Forwarded-For` header, the logic falls through to return `r.RemoteAddr`, which includes the port (e.g., "192.168.1.1:8080"). This creates an inconsistency in the function's return value, as other paths return only the IP address.
Raw output
Ensure the fallback logic consistently returns only the IP address. Use `net.SplitHostPort` to parse `r.RemoteAddr` and extract the host part before returning it.
Loading