diff --git a/api/src/logtape.ts b/api/src/logtape.ts index eaaa818b..2966e5ea 100644 --- a/api/src/logtape.ts +++ b/api/src/logtape.ts @@ -23,7 +23,7 @@ export async function setupLogging() { const minLevel = aliasMap[minLevelRaw] ?? minLevelRaw; return withFilter( redactByField(getConsoleSink(), { - fieldPatterns: [/password/i, /secret/i, /apikey/i], + fieldPatterns: [/password/i, /secret/i, /apikey/i, /ca/i, /cert/i], action: () => "[REDACTED]", }), getLevelFilter(parseLogLevel(minLevel)), @@ -38,7 +38,7 @@ export async function setupLogging() { const minLevel = aliasMap[minLevelRaw] ?? minLevelRaw; return withFilter( redactByField(getOpenTelemetrySink({ loggerProvider }), { - fieldPatterns: [/password/i, /secret/i, /apikey/i], + fieldPatterns: [/password/i, /secret/i, /apikey/i, /ca/i, /cert/i], action: () => "[REDACTED]", }), getLevelFilter(parseLogLevel(minLevel)), diff --git a/auth/main.go b/auth/main.go index 16299045..fbb6ccaa 100644 --- a/auth/main.go +++ b/auth/main.go @@ -3,12 +3,10 @@ package main import ( "context" "encoding/base64" - "errors" "fmt" "log/slog" "net/http" "os" - "os/user" "slices" "sort" "strings" @@ -103,10 +101,10 @@ func GetenvOr(env string, def string) string { } func OpenDatabase(ctx context.Context) (*pgxpool.Pool, error) { - connectionString := GetenvOr("POSTGRES_URL", "") + connectionString := os.Getenv("POSTGRES_URL") config, err := pgxpool.ParseConfig(connectionString) if err != nil { - return nil, errors.New("failed to create postgres config from environment variables") + return nil, fmt.Errorf("failed to create postgres config from environment variables: %v", err) } // Set default values @@ -116,22 +114,6 @@ func OpenDatabase(ctx context.Context) (*pgxpool.Pool, error) { if config.ConnConfig.Database == "" { config.ConnConfig.Database = "kyoo" } - // The pgx library will set the username to the name of the current user if not provided via - // environment variable or connection string. Make a best-effort attempt to see if the user - // was explicitly specified, without implementing full connection string parsing. If not, set - // the username to the default value of "kyoo". - if os.Getenv("PGUSER") == "" { - currentUserName, _ := user.Current() - // If the username matches the current user and it's not in the connection string, then it was set - // by the pgx library. This doesn't cover the case where the system username happens to be in some other part - // of the connection string, but this cannot be checked without full connection string parsing. - if currentUserName.Username == config.ConnConfig.User && !strings.Contains(connectionString, currentUserName.Username) { - config.ConnConfig.User = "kyoo" - } - } - if config.ConnConfig.Password == "" { - config.ConnConfig.Password = "password" - } if _, ok := config.ConnConfig.RuntimeParams["application_name"]; !ok { config.ConnConfig.RuntimeParams["application_name"] = "keibi" } diff --git a/auth/otel.go b/auth/otel.go index 8f34ef18..21801906 100644 --- a/auth/otel.go +++ b/auth/otel.go @@ -37,7 +37,6 @@ func setupOtel(ctx context.Context) (func(context.Context) error, error) { resource.WithAttributes(semconv.ServiceNameKey.String("kyoo.auth")), resource.WithFromEnv(), resource.WithTelemetrySDK(), - resource.WithProcess(), resource.WithOS(), resource.WithContainer(), resource.WithHost(), diff --git a/transcoder/src/metadata.go b/transcoder/src/metadata.go index e2885698..6170736c 100644 --- a/transcoder/src/metadata.go +++ b/transcoder/src/metadata.go @@ -6,8 +6,6 @@ import ( "errors" "fmt" "os" - "os/user" - "strings" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/service/s3" @@ -78,7 +76,7 @@ func (s *MetadataService) setupDb() (*pgxpool.Pool, error) { connectionString := os.Getenv("POSTGRES_URL") config, err := pgxpool.ParseConfig(connectionString) if err != nil { - return nil, errors.New("failed to create postgres config from environment variables") + return nil, fmt.Errorf("failed to create postgres config from environment variables: %v", err) } // Set default values @@ -88,19 +86,6 @@ func (s *MetadataService) setupDb() (*pgxpool.Pool, error) { if config.ConnConfig.Database == "" { config.ConnConfig.Database = "kyoo" } - // The pgx library will set the username to the name of the current user if not provided via - // environment variable or connection string. Make a best-effort attempt to see if the user - // was explicitly specified, without implementing full connection string parsing. If not, set - // the username to the default value of "kyoo". - if os.Getenv("PGUSER") == "" { - currentUserName, _ := user.Current() - // If the username matches the current user and it's not in the connection string, then it was set - // by the pgx library. This doesn't cover the case where the system username happens to be in some other part - // of the connection string, but this cannot be checked without full connection string parsing. - if currentUserName.Username == config.ConnConfig.User && !strings.Contains(connectionString, currentUserName.Username) { - config.ConnConfig.User = "kyoo" - } - } if _, ok := config.ConnConfig.RuntimeParams["application_name"]; !ok { config.ConnConfig.RuntimeParams["application_name"] = "gocoder" }