From 0f32f181f70592f9269eaf87d37a2071c57c34e7 Mon Sep 17 00:00:00 2001 From: "denis.sinelnikov" Date: Mon, 11 Nov 2024 15:21:50 +0100 Subject: [PATCH] CB-5584. Rename parameter --- .../bundles/io.cloudbeaver.server/plugin.xml | 2 +- .../server/graphql/GraphQLLoggerUtil.java | 19 +++++--- .../graphql/GraphQLProhibitedVariables.java | 48 ------------------- 3 files changed, 13 insertions(+), 56 deletions(-) delete mode 100644 server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/graphql/GraphQLProhibitedVariables.java diff --git a/server/bundles/io.cloudbeaver.server/plugin.xml b/server/bundles/io.cloudbeaver.server/plugin.xml index f21f24c320..f73f9043fd 100644 --- a/server/bundles/io.cloudbeaver.server/plugin.xml +++ b/server/bundles/io.cloudbeaver.server/plugin.xml @@ -77,7 +77,7 @@ - diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/graphql/GraphQLLoggerUtil.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/graphql/GraphQLLoggerUtil.java index dd1e1968e3..c5550a97aa 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/graphql/GraphQLLoggerUtil.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/graphql/GraphQLLoggerUtil.java @@ -27,25 +27,30 @@ public class GraphQLLoggerUtil { - private static final Set PROHIBITED_VARIABLES = GraphQLProhibitedVariables.getAllProhibitedVariables(); + private static final Set PROHIBITED_VARIABLES = + Set.of("password", "config", "parameters", "settings", "licenseText", "credentials", "username"); public static String getUserId(HttpServletRequest request) { String userId = null; - WebSession session = (WebSession) CBApplication.getInstance().getSessionManager().getSession(request.getSession().getId()); - if (session != null) { - userId = session.getUserContext().getUserId(); - if (userId == null && session.getUserContext().isAuthorizedInSecurityManager()) { - userId = "anonymous"; + if (request.getSession() != null) { + WebSession session = + (WebSession) CBApplication.getInstance().getSessionManager().getSession(request.getSession().getId()); + if (session != null) { + userId = session.getUserContext().getUserId(); + if (userId == null && session.getUserContext().isAuthorizedInSecurityManager()) { + userId = "anonymous"; + } } } return userId; + } public static String buildLoggerMessage(String sessionId, String userId, Map variables) { StringBuilder loggerMessage = new StringBuilder(" [user: ").append(userId) .append(", sessionId: ").append(sessionId).append("]"); - if (CBPlatform.getInstance().getPreferenceStore().getBoolean("log.debug") && variables != null) { + if (CBPlatform.getInstance().getPreferenceStore().getBoolean("log.api.graphql.debug") && variables != null) { loggerMessage.append(" [variables] "); String parsedVariables = parseVarialbes(variables); if (CommonUtils.isNotEmpty(parsedVariables)) { diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/graphql/GraphQLProhibitedVariables.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/graphql/GraphQLProhibitedVariables.java deleted file mode 100644 index dfd46231ec..0000000000 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/graphql/GraphQLProhibitedVariables.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2024 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.cloudbeaver.server.graphql; - -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -public enum GraphQLProhibitedVariables { - - - PASSWORD("password"), - CONFIG("config"), - PARAMETERS("parameters"), - SETTINGS("settings"), - LICENSE_TEXT("licenseText"); - - private final String name; - - GraphQLProhibitedVariables(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public static Set getAllProhibitedVariables() { - return Arrays.stream(GraphQLProhibitedVariables.values()) - .map(GraphQLProhibitedVariables::getName) - .collect(Collectors.toSet()); - } -}