mirror of
https://github.com/gin-gonic/gin.git
synced 2026-06-06 12:08:20 +08:00
Compare commits
3 Commits
8d28cadce5
...
ce131ebc9e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce131ebc9e | ||
|
|
5f4f964325 | ||
|
|
ec789274b1 |
2
.github/workflows/gin.yml
vendored
2
.github/workflows/gin.yml
vendored
@ -78,6 +78,6 @@ jobs:
|
||||
run: make test
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v5
|
||||
uses: codecov/codecov-action@v6
|
||||
with:
|
||||
flags: ${{ matrix.os }},go-${{ matrix.go }},${{ matrix.test-tags }}
|
||||
|
||||
4
.github/workflows/trivy-scan.yml
vendored
4
.github/workflows/trivy-scan.yml
vendored
@ -27,7 +27,7 @@ jobs:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Run Trivy vulnerability scanner (source code)
|
||||
uses: aquasecurity/trivy-action@0.35.0
|
||||
uses: aquasecurity/trivy-action@v0.36.0
|
||||
with:
|
||||
scan-type: "fs"
|
||||
scan-ref: "."
|
||||
@ -44,7 +44,7 @@ jobs:
|
||||
sarif_file: "trivy-results.sarif"
|
||||
|
||||
- name: Run Trivy scanner (table output for logs)
|
||||
uses: aquasecurity/trivy-action@0.35.0
|
||||
uses: aquasecurity/trivy-action@v0.36.0
|
||||
if: always()
|
||||
with:
|
||||
scan-type: "fs"
|
||||
|
||||
11
gin.go
11
gin.go
@ -486,6 +486,17 @@ func (engine *Engine) validateHeader(header string) (clientIP string, valid bool
|
||||
items := strings.Split(header, ",")
|
||||
for i := len(items) - 1; i >= 0; i-- {
|
||||
ipStr := strings.TrimSpace(items[i])
|
||||
|
||||
// Handle IPv6 with brackets and/or port: [::1], [::1]:8080, 192.168.1.1:8080
|
||||
// net.SplitHostPort handles all these cases and strips brackets
|
||||
if host, _, err := net.SplitHostPort(ipStr); err == nil {
|
||||
ipStr = host
|
||||
} else {
|
||||
// No port present, just strip brackets if any (bare IPv6 like [::1])
|
||||
ipStr = strings.TrimPrefix(ipStr, "[")
|
||||
ipStr = strings.TrimSuffix(ipStr, "]")
|
||||
}
|
||||
|
||||
ip := net.ParseIP(ipStr)
|
||||
if ip == nil {
|
||||
break
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user