fix: anonymize the x-amz-id-2 value from hostname (#16478)

This commit is contained in:
Harshavardhana 2023-01-25 23:55:36 +05:30 committed by GitHub
parent 65c104a589
commit 54b561898f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View File

@ -552,7 +552,7 @@ func addCustomHeaders(h http.Handler) http.Handler {
// Set custom headers such as x-amz-request-id for each request. // Set custom headers such as x-amz-request-id for each request.
w.Header().Set(xhttp.AmzRequestID, mustGetRequestID(UTCNow())) w.Header().Set(xhttp.AmzRequestID, mustGetRequestID(UTCNow()))
if globalLocalNodeName != "" { if globalLocalNodeName != "" {
w.Header().Set(xhttp.AmzRequestNodeID, globalLocalNodeName) w.Header().Set(xhttp.AmzRequestNodeID, globalLocalNodeNameHex)
} }
h.ServeHTTP(xhttp.NewResponseRecorder(w), r) h.ServeHTTP(xhttp.NewResponseRecorder(w), r)
}) })

View File

@ -234,6 +234,7 @@ var (
// The name of this local node, fetched from arguments // The name of this local node, fetched from arguments
globalLocalNodeName string globalLocalNodeName string
globalLocalNodeNameHex string
// The global subnet config // The global subnet config
globalSubnetConfig subnet.Config globalSubnetConfig subnet.Config

View File

@ -19,6 +19,7 @@ package cmd
import ( import (
"context" "context"
"encoding/hex"
"errors" "errors"
"fmt" "fmt"
"io" "io"
@ -42,6 +43,7 @@ import (
"github.com/minio/minio/internal/bucket/bandwidth" "github.com/minio/minio/internal/bucket/bandwidth"
"github.com/minio/minio/internal/color" "github.com/minio/minio/internal/color"
"github.com/minio/minio/internal/config" "github.com/minio/minio/internal/config"
"github.com/minio/minio/internal/hash/sha256"
xhttp "github.com/minio/minio/internal/http" xhttp "github.com/minio/minio/internal/http"
"github.com/minio/minio/internal/logger" "github.com/minio/minio/internal/logger"
"github.com/minio/pkg/certs" "github.com/minio/pkg/certs"
@ -221,6 +223,8 @@ func serverHandleCmdArgs(ctx *cli.Context) {
logger.FatalIf(err, "Invalid command line arguments") logger.FatalIf(err, "Invalid command line arguments")
globalLocalNodeName = GetLocalPeer(globalEndpoints, globalMinioHost, globalMinioPort) globalLocalNodeName = GetLocalPeer(globalEndpoints, globalMinioHost, globalMinioPort)
nodeNameSum := sha256.Sum256([]byte(globalLocalNodeNameHex))
globalLocalNodeNameHex = hex.EncodeToString(nodeNameSum[:])
globalRemoteEndpoints = make(map[string]Endpoint) globalRemoteEndpoints = make(map[string]Endpoint)
for _, z := range globalEndpoints { for _, z := range globalEndpoints {