-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'devel' into dbeaver/dbeaver-vscode#45-server-features
- Loading branch information
Showing
118 changed files
with
1,436 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,24 @@ FROM dbeaver/base-java | |
|
||
MAINTAINER DBeaver Corp, [email protected] | ||
|
||
RUN apt-get update; \ | ||
apt-get upgrade -y; | ||
|
||
ENV DBEAVER_GID=8978 | ||
ENV DBEAVER_UID=8978 | ||
|
||
RUN apt-get update && \ | ||
apt-get upgrade -y | ||
|
||
RUN groupadd -g $DBEAVER_GID dbeaver && \ | ||
useradd -g $DBEAVER_GID -M -u $DBEAVER_UID -s /bin/bash dbeaver | ||
|
||
COPY cloudbeaver /opt/cloudbeaver | ||
COPY scripts/launch-product.sh /opt/cloudbeaver/launch-product.sh | ||
|
||
RUN chown -R $DBEAVER_UID:$DBEAVER_GID /opt/cloudbeaver | ||
|
||
EXPOSE 8978 | ||
RUN find /opt/cloudbeaver -type d -exec chmod 775 {} \; | ||
WORKDIR /opt/cloudbeaver/ | ||
ENTRYPOINT ["./run-server.sh"] | ||
|
||
RUN chmod +x "run-server.sh" "/opt/cloudbeaver/launch-product.sh" | ||
|
||
ENTRYPOINT ["./launch-product.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# This script is needed to change ownership and run the application as user dbeaver during the upgrade from version 24.2.0 | ||
|
||
# Change ownership of the WORKDIR to the dbeaver user and group | ||
# Variables DBEAVER_<UID|GID> are defined in the Dockerfile and exported to the runtime environment | ||
# PWD equals WORKDIR value from product Dockerfile | ||
chown -R $DBEAVER_UID:$DBEAVER_GID $PWD | ||
|
||
# Execute run-server.sh as the dbeaver user with the JAVA_HOME and PATH environment variables | ||
exec su dbeaver -c "JAVA_HOME=$JAVA_HOME PATH=$PATH ./run-server.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
...er/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/graphql/GraphQLLoggerUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* 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 io.cloudbeaver.model.app.BaseWebApplication; | ||
import io.cloudbeaver.model.session.WebSession; | ||
import io.cloudbeaver.server.CBApplication; | ||
import io.cloudbeaver.server.CBPlatform; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import org.jkiss.code.Nullable; | ||
import org.jkiss.utils.CommonUtils; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
public class GraphQLLoggerUtil { | ||
|
||
public static final String LOG_API_GRAPHQL_DEBUG_PARAMETER = "log.api.graphql.debug"; | ||
private static final Set<String> PROHIBITED_VARIABLES = | ||
Set.of("password", "config", "parameters", "settings", "licenseText", "credentials", "username"); | ||
|
||
public static String getUserId(HttpServletRequest request) { | ||
WebSession session = getWebSession(request); | ||
if (session == null) { | ||
return null; | ||
} | ||
String userId = session.getUserContext().getUserId(); | ||
if (userId == null && session.getUserContext().isAuthorizedInSecurityManager()) { | ||
return "anonymous"; | ||
} | ||
return userId; | ||
} | ||
|
||
public static String getSessionId(HttpServletRequest request) { | ||
WebSession session = getWebSession(request); | ||
if (session == null) { | ||
return null; | ||
} | ||
return session.getUserContext().getSmSessionId(); | ||
} | ||
|
||
@Nullable | ||
private static WebSession getWebSession(HttpServletRequest request) { | ||
if (request.getSession() == null) { | ||
return null; | ||
} | ||
|
||
if (BaseWebApplication.getInstance() instanceof CBApplication<?> cbApp) { | ||
return (WebSession)cbApp.getSessionManager() | ||
.getSession(request.getSession().getId()); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
public static String buildLoggerMessage(String sessionId, String userId, Map<String, Object> variables) { | ||
StringBuilder loggerMessage = new StringBuilder(" [user: ").append(userId) | ||
.append(", sessionId: ").append(sessionId).append("]"); | ||
|
||
if (CBPlatform.getInstance().getPreferenceStore().getBoolean(LOG_API_GRAPHQL_DEBUG_PARAMETER) | ||
&& variables != null | ||
) { | ||
loggerMessage.append(" [variables] "); | ||
String parsedVariables = parseVarialbes(variables); | ||
if (CommonUtils.isNotEmpty(parsedVariables)) { | ||
loggerMessage.append(parseVarialbes(variables)); | ||
} | ||
} | ||
return loggerMessage.toString(); | ||
} | ||
|
||
private static String parseVarialbes(Map<String, Object> map) { | ||
StringBuilder result = new StringBuilder(); | ||
|
||
for (Map.Entry<String, Object> entry : map.entrySet()) { | ||
String key = entry.getKey(); | ||
Object value = entry.getValue(); | ||
|
||
boolean isProhibited = PROHIBITED_VARIABLES.stream() | ||
.anyMatch(prohibitedKey -> key.toLowerCase().contains(prohibitedKey.toLowerCase())); | ||
|
||
if (isProhibited) { | ||
result.append(key).append(": ").append("******** "); | ||
continue; | ||
} | ||
|
||
if (value instanceof Map) { | ||
result.append(parseVarialbes((Map<String, Object>) value)); | ||
} else { | ||
result.append(key).append(": ").append(value).append(" "); | ||
} | ||
} | ||
return result.toString().trim(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.