mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-08 16:38:01 +08:00
### Summary Check the URL to prevent SSRF attack. --------- Signed-off-by: Jin Hai <haijin.chn@gmail.com>
20 lines
586 B
Go
20 lines
586 B
Go
package parser
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"ragflow/internal/utility"
|
|
)
|
|
|
|
// withSSRFBypass enables the test-only SSRF bypass for the duration of a test
|
|
// and restores the previous value in t.Cleanup. Parser tests exercise parsing
|
|
// logic against httptest servers bound to 127.0.0.1, which the strict SSRF
|
|
// guard rejects. SSRF enforcement has its own dedicated coverage in
|
|
// internal/utility/ssrf_test.go.
|
|
func withSSRFBypass(t *testing.T) {
|
|
t.Helper()
|
|
prev := utility.AllowAnyHostForTest
|
|
utility.AllowAnyHostForTest = true
|
|
t.Cleanup(func() { utility.AllowAnyHostForTest = prev })
|
|
}
|