fix(security): close six open GHSA findings from security triage

Harden share-link listing, password rotation, OIDC callback binding,
org invite search, knowledge batch mutations, and connector redirects.
This commit is contained in:
wizardchen
2026-07-02 14:49:27 +08:00
committed by lyingbug
parent fc64751f4e
commit f23c674bad
12 changed files with 400 additions and 34 deletions
+50
View File
@@ -0,0 +1,50 @@
package utils
import (
"strings"
"sync"
"testing"
"time"
)
func TestSignAndVerifyOIDCState(t *testing.T) {
t.Setenv("JWT_SECRET", "test-oidc-state-secret")
oidcStateSecretOnce = sync.Once{}
oidcStateSecret = ""
state, err := SignOIDCState(&OIDCStatePayload{
Nonce: "nonce-abc",
RedirectURI: "http://localhost:5173/login",
IssuedAt: time.Now().Unix(),
})
if err != nil {
t.Fatalf("SignOIDCState: %v", err)
}
got, err := VerifyOIDCState(state)
if err != nil {
t.Fatalf("VerifyOIDCState: %v", err)
}
if got.Nonce != "nonce-abc" || got.RedirectURI != "http://localhost:5173/login" {
t.Fatalf("unexpected payload: %+v", got)
}
}
func TestVerifyOIDCStateRejectsTamperedPayload(t *testing.T) {
t.Setenv("JWT_SECRET", "test-oidc-state-secret")
oidcStateSecretOnce = sync.Once{}
oidcStateSecret = ""
state, err := SignOIDCState(&OIDCStatePayload{
Nonce: "nonce-abc",
RedirectURI: "http://localhost:5173/login",
IssuedAt: time.Now().Unix(),
})
if err != nil {
t.Fatalf("SignOIDCState: %v", err)
}
parts := strings.Split(state, ".")
tampered := parts[0] + ".AAAA"
if _, err := VerifyOIDCState(tampered); err == nil {
t.Fatal("expected tampered state to be rejected")
}
}