mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-11-26 18:16:47 -05:00
[full-ci] chore: bump reva to 2.46.9
This commit is contained in:
5 files changed
+139
-34
No files matched your search
@@ -64,7 +64,7 @@ require (
|
||||
github.com/open-policy-agent/opa v1.15.2
|
||||
github.com/opencloud-eu/icap-client v0.0.0-20250930132611-28a2afe62d89
|
||||
github.com/opencloud-eu/libre-graph-api-go v1.0.8-0.20260310090739-853d972b282d
|
||||
github.com/opencloud-eu/reva/v2 v2.46.8
|
||||
github.com/opencloud-eu/reva/v2 v2.46.9
|
||||
github.com/opensearch-project/opensearch-go/v4 v4.6.0
|
||||
github.com/orcaman/concurrent-map v1.0.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
|
||||
@@ -948,8 +948,8 @@ github.com/opencloud-eu/icap-client v0.0.0-20250930132611-28a2afe62d89 h1:W1ms+l
|
||||
github.com/opencloud-eu/icap-client v0.0.0-20250930132611-28a2afe62d89/go.mod h1:vigJkNss1N2QEceCuNw/ullDehncuJNFB6mEnzfq9UI=
|
||||
github.com/opencloud-eu/libre-graph-api-go v1.0.8-0.20260310090739-853d972b282d h1:JcqGDiyrcaQwVyV861TUyQgO7uEmsjkhfm7aQd84dOw=
|
||||
github.com/opencloud-eu/libre-graph-api-go v1.0.8-0.20260310090739-853d972b282d/go.mod h1:pzatilMEHZFT3qV7C/X3MqOa3NlRQuYhlRhZTL+hN6Q=
|
||||
github.com/opencloud-eu/reva/v2 v2.46.8 h1:stqn5VfGiIkR7+b/BIsFAqbLbrzSARu43I/t/6G9X3Q=
|
||||
github.com/opencloud-eu/reva/v2 v2.46.8/go.mod h1:RoFQt+u7edxwzHr1IZ2Y6VaDinMiRPQupAvMBy3WVmE=
|
||||
github.com/opencloud-eu/reva/v2 v2.46.9 h1:8iqQ13BoJLpJIYM382GIzTYWKpFQ/M0yuM2m1bF3uPE=
|
||||
github.com/opencloud-eu/reva/v2 v2.46.9/go.mod h1:RoFQt+u7edxwzHr1IZ2Y6VaDinMiRPQupAvMBy3WVmE=
|
||||
github.com/opencloud-eu/secure v0.0.0-20260312082735-b6f5cb2244e4 h1:l2oB/RctH+t8r7QBj5p8thfEHCM/jF35aAY3WQ3hADI=
|
||||
github.com/opencloud-eu/secure v0.0.0-20260312082735-b6f5cb2244e4/go.mod h1:BmF5hyM6tXczk3MpQkFf1hpKSRqCyhqcbiQtiAF7+40=
|
||||
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
||||
|
||||
+70
-2
@@ -23,8 +23,10 @@ import (
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/opencloud-eu/reva/v2/internal/http/services/wellknown"
|
||||
@@ -38,11 +40,44 @@ type OCMClient struct {
|
||||
client *http.Client
|
||||
}
|
||||
|
||||
// newOCMTransport returns the HTTP transport used for outbound OCM requests.
|
||||
// It honors the standard HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment
|
||||
// variables and optionally skips TLS certificate verification.
|
||||
func newOCMTransport(insecure bool) *http.Transport {
|
||||
var tr *http.Transport
|
||||
if dt, ok := http.DefaultTransport.(*http.Transport); ok {
|
||||
tr = dt.Clone()
|
||||
} else {
|
||||
tr = &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
}
|
||||
}
|
||||
tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: insecure}
|
||||
return tr
|
||||
}
|
||||
|
||||
// NewClient returns a new OCMClient.
|
||||
func NewClient(timeout time.Duration, insecure bool) *OCMClient {
|
||||
tr := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: insecure},
|
||||
return &OCMClient{
|
||||
client: &http.Client{
|
||||
Transport: newOCMTransport(insecure),
|
||||
Timeout: timeout,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// NewPublicOnlyClient returns an OCMClient that only dials public addresses, for
|
||||
// discovery of hosts named by an untrusted caller. The check is in the dialer so
|
||||
// it also covers redirects and DNS rebinding.
|
||||
func NewPublicOnlyClient(timeout time.Duration, insecure bool) *OCMClient {
|
||||
tr := newOCMTransport(insecure)
|
||||
// with a proxy the dial goes to the proxy, so Control never sees the target
|
||||
tr.Proxy = nil
|
||||
tr.DialContext = (&net.Dialer{
|
||||
Timeout: timeout,
|
||||
KeepAlive: 30 * time.Second,
|
||||
Control: refuseNonPublicAddr,
|
||||
}).DialContext
|
||||
return &OCMClient{
|
||||
client: &http.Client{
|
||||
Transport: tr,
|
||||
@@ -51,6 +86,39 @@ func NewClient(timeout time.Duration, insecure bool) *OCMClient {
|
||||
}
|
||||
}
|
||||
|
||||
func refuseNonPublicAddr(_, address string, _ syscall.RawConn) error {
|
||||
host, _, err := net.SplitHostPort(address)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ip := net.ParseIP(host)
|
||||
if ip == nil || !isPublicIP(ip) {
|
||||
return errtypes.BadRequest("refusing to connect to non-public address " + address)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 64:ff9b::/96 embeds an IPv4 address in its low 32 bits (RFC 6052), so on a
|
||||
// NAT64 network it can still reach internal hosts.
|
||||
var nat64WellKnownPrefix = net.IPNet{IP: net.ParseIP("64:ff9b::"), Mask: net.CIDRMask(96, 128)}
|
||||
|
||||
func isPublicIP(ip net.IP) bool {
|
||||
if nat64WellKnownPrefix.Contains(ip) {
|
||||
v6 := ip.To16()
|
||||
return isPublicIP(net.IPv4(v6[12], v6[13], v6[14], v6[15]))
|
||||
}
|
||||
if ip.IsLoopback() || ip.IsPrivate() || ip.IsUnspecified() ||
|
||||
ip.IsLinkLocalUnicast() || ip.IsLinkLocalMulticast() ||
|
||||
ip.IsMulticast() || ip.IsInterfaceLocalMulticast() {
|
||||
return false
|
||||
}
|
||||
// 100.64.0.0/10 is carrier-grade NAT, which net.IP.IsPrivate does not cover
|
||||
if ip4 := ip.To4(); ip4 != nil && ip4[0] == 100 && ip4[1]&0xc0 == 64 {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Discover returns the OCM discovery information for a remote endpoint.
|
||||
// It tries /.well-known/ocm first, then falls back to /ocm-provider (legacy).
|
||||
// https://cs3org.github.io/OCM-API/docs.html?branch=develop&repo=OCM-API&user=cs3org#/paths/~1ocm-provider/get
|
||||
|
||||
Generated
Vendored
+65
-28
@@ -21,9 +21,11 @@ package sciencemesh
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -35,6 +37,8 @@ import (
|
||||
type wayfHandler struct {
|
||||
directoryServices []ocmd.DirectoryService
|
||||
ocmClient *ocmd.OCMClient
|
||||
// for /discover, where the host comes from the request body, not from config
|
||||
untrustedClient *ocmd.OCMClient
|
||||
}
|
||||
|
||||
type DiscoverRequest struct {
|
||||
@@ -45,20 +49,56 @@ type DiscoverResponse struct {
|
||||
InviteAcceptDialog string `json:"inviteAcceptDialog"`
|
||||
}
|
||||
|
||||
// makeAbsoluteURL takes a base URL and a path/URL and returns an absolute URL.
|
||||
// If dialogURL is already absolute (has scheme and host), it returns it as-is.
|
||||
// Otherwise, it joins the dialogURL with the baseURL to create an absolute URL.
|
||||
func makeAbsoluteURL(baseURL, dialogURL string) (string, error) {
|
||||
if dialogURL == "" {
|
||||
return "", nil
|
||||
var (
|
||||
errInvalidProviderURL = errors.New("invalid provider URL")
|
||||
errInvalidInviteDialog = errors.New("invalid invite accept dialog")
|
||||
)
|
||||
|
||||
// resolveInviteAcceptDialog builds the invite page on the provider origin.
|
||||
// The discovery value is a path. An absolute URL is accepted only when its
|
||||
// scheme and host, including port, match the provider; the result is rebuilt
|
||||
// from those fields and the path, never returned as received.
|
||||
func resolveInviteAcceptDialog(providerBase, dialog string) (string, error) {
|
||||
base, err := url.Parse(providerBase)
|
||||
if err != nil || (base.Scheme != "http" && base.Scheme != "https") || base.Host == "" || base.User != nil {
|
||||
return "", errInvalidProviderURL
|
||||
}
|
||||
|
||||
parsed, err := url.Parse(dialogURL)
|
||||
if err == nil && parsed.Scheme != "" && parsed.Host != "" {
|
||||
return dialogURL, nil
|
||||
dialog = strings.TrimSpace(dialog)
|
||||
if dialog == "" || strings.ContainsAny(dialog, "\\#") || containsControl(dialog) {
|
||||
return "", errInvalidInviteDialog
|
||||
}
|
||||
ref, err := url.Parse(dialog)
|
||||
if err != nil || ref.Opaque != "" || ref.User != nil {
|
||||
return "", errInvalidInviteDialog
|
||||
}
|
||||
if (ref.Scheme != "" || ref.Host != "") &&
|
||||
(ref.Scheme != base.Scheme || !strings.EqualFold(ref.Host, base.Host)) {
|
||||
return "", errInvalidInviteDialog
|
||||
}
|
||||
|
||||
return url.JoinPath(baseURL, dialogURL)
|
||||
p := ref.Path
|
||||
if ref.Scheme != "" && p == "" {
|
||||
p = "/"
|
||||
}
|
||||
if !strings.HasPrefix(p, "/") || strings.HasPrefix(p, "//") ||
|
||||
strings.ContainsAny(p, "\\?#") || containsControl(p) {
|
||||
return "", errInvalidInviteDialog
|
||||
}
|
||||
p = path.Clean(p)
|
||||
if !strings.HasPrefix(p, "/") {
|
||||
return "", errInvalidInviteDialog
|
||||
}
|
||||
return (&url.URL{Scheme: base.Scheme, Host: base.Host, Path: p}).String(), nil
|
||||
}
|
||||
|
||||
func containsControl(s string) bool {
|
||||
for _, r := range s {
|
||||
if r < 0x20 || r == 0x7f {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (h *wayfHandler) init(c *config) error {
|
||||
@@ -66,6 +106,7 @@ func (h *wayfHandler) init(c *config) error {
|
||||
|
||||
// Create OCM client for discovery from config
|
||||
h.ocmClient = ocmd.NewClient(time.Duration(c.OCMClientTimeout)*time.Second, c.OCMClientInsecure)
|
||||
h.untrustedClient = ocmd.NewPublicOnlyClient(time.Duration(c.OCMClientTimeout)*time.Second, c.OCMClientInsecure)
|
||||
log.Debug().
|
||||
Int("timeout_seconds", c.OCMClientTimeout).
|
||||
Bool("insecure", c.OCMClientInsecure).
|
||||
@@ -127,20 +168,20 @@ func (h *wayfHandler) init(c *config) error {
|
||||
inviteDialog := disco.InviteAcceptDialog
|
||||
|
||||
if inviteDialog != "" {
|
||||
absoluteURL, err := makeAbsoluteURL(srv.URL, inviteDialog)
|
||||
resolved, err := resolveInviteAcceptDialog(srv.URL, inviteDialog)
|
||||
if err != nil {
|
||||
log.Debug().Err(err).
|
||||
Str("federation", directoryService.Federation).
|
||||
Str("server", srv.DisplayName).
|
||||
Str("url", srv.URL).
|
||||
Str("inviteDialog", disco.InviteAcceptDialog).
|
||||
Msg("Failed to construct absolute URL, skipping server")
|
||||
Msg("Invalid invite accept dialog, skipping server")
|
||||
continue
|
||||
}
|
||||
if absoluteURL != inviteDialog {
|
||||
log.Debug().Str("original", inviteDialog).Str("absolute", absoluteURL).Msg("Converted to absolute URL")
|
||||
if resolved != inviteDialog {
|
||||
log.Debug().Str("original", inviteDialog).Str("resolved", resolved).Msg("Resolved invite accept dialog")
|
||||
}
|
||||
inviteDialog = absoluteURL
|
||||
inviteDialog = resolved
|
||||
}
|
||||
|
||||
validServers = append(validServers, ocmd.DirectoryServiceServer{
|
||||
@@ -216,7 +257,7 @@ func (h *wayfHandler) DiscoverProvider(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
log.Debug().Str("domain", domain).Msg("Attempting OCM discovery")
|
||||
disco, err := h.ocmClient.Discover(ctx, domain)
|
||||
disco, err := h.untrustedClient.Discover(ctx, domain)
|
||||
if err != nil {
|
||||
log.Info().Err(err).Str("domain", domain).Msg("Discovery failed")
|
||||
reqres.WriteError(w, r, reqres.APIErrorNotFound,
|
||||
@@ -224,19 +265,15 @@ func (h *wayfHandler) DiscoverProvider(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
inviteDialog := disco.InviteAcceptDialog
|
||||
|
||||
if inviteDialog == "" {
|
||||
log.Info().Str("domain", domain).Msg("Provider does not provide invite accept dialog")
|
||||
reqres.WriteError(w, r, reqres.APIErrorNotFound,
|
||||
fmt.Sprintf("Provider at '%s' does not provide an invite accept dialog", req.Domain), nil)
|
||||
return
|
||||
}
|
||||
|
||||
inviteDialog, err = makeAbsoluteURL(domain, inviteDialog)
|
||||
inviteDialog, err := resolveInviteAcceptDialog(domain, disco.InviteAcceptDialog)
|
||||
if err != nil {
|
||||
log.Info().Err(err).Str("domain", domain).Str("inviteDialog", disco.InviteAcceptDialog).Msg("Failed to construct invite accept dialog URL")
|
||||
reqres.WriteError(w, r, reqres.APIErrorServerError, "Failed to construct invite accept dialog URL", err)
|
||||
log.Info().Err(err).Str("domain", domain).Str("inviteDialog", disco.InviteAcceptDialog).Msg("Provider does not provide a usable invite accept dialog")
|
||||
if errors.Is(err, errInvalidProviderURL) {
|
||||
reqres.WriteError(w, r, reqres.APIErrorInvalidParameter, "Invalid domain format", err)
|
||||
return
|
||||
}
|
||||
reqres.WriteError(w, r, reqres.APIErrorNotFound,
|
||||
fmt.Sprintf("Provider at '%s' does not provide an invite accept dialog", req.Domain), err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1360,7 +1360,7 @@ github.com/opencloud-eu/icap-client
|
||||
# github.com/opencloud-eu/libre-graph-api-go v1.0.8-0.20260310090739-853d972b282d
|
||||
## explicit; go 1.18
|
||||
github.com/opencloud-eu/libre-graph-api-go
|
||||
# github.com/opencloud-eu/reva/v2 v2.46.8
|
||||
# github.com/opencloud-eu/reva/v2 v2.46.9
|
||||
## explicit; go 1.25.0
|
||||
github.com/opencloud-eu/reva/v2/cmd/revad/internal/grace
|
||||
github.com/opencloud-eu/reva/v2/cmd/revad/runtime
|
||||
|
||||
Reference in new issue
Block a user