Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/server-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ jobs:
run: |
mvn clean compile -U -Dmaven.javadoc.skip=true -ntp

- name: Run Java security properties tests
if: ${{ env.BACKEND == 'rocksdb' }}
run: |
mvn package -Dmaven.test.skip=true -pl hugegraph-server/hugegraph-dist -am -ntp

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This step does not execute the newly added HugeGraphServerBootstrapTest: it runs mvn package -Dmaven.test.skip=true, while run-unit-test.sh only runs hugegraph-test for the memory matrix and does nothing for RocksDB. As a result, the workflow's RocksDB path validates only the shell smoke script, not these two unit tests; please add an explicit mvn test -pl hugegraph-server/hugegraph-dist -am -Dtest=HugeGraphServerBootstrapTest (or include the module in an existing test command) so the added assertions are exercised in CI.

VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
SERVER_DIR=hugegraph-server/apache-hugegraph-server-$VERSION/
$TRAVIS_DIR/test-java-security-properties.sh $SERVER_DIR

- name: Check startup test prerequisites
id: server-preflight
if: ${{ env.BACKEND == 'rocksdb' }}
Expand All @@ -86,7 +94,6 @@ jobs:
- name: Run start-hugegraph.sh foreground mode tests
if: ${{ env.BACKEND == 'rocksdb' && steps.server-preflight.outputs.can_run == 'true' }}
run: |
mvn package -Dmaven.test.skip=true -pl hugegraph-server/hugegraph-dist -am -ntp
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
SERVER_DIR=hugegraph-server/apache-hugegraph-server-$VERSION/
$TRAVIS_DIR/test-start-hugegraph.sh $SERVER_DIR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ ensure_path_writable "$PLUGINS"
MAX_MEM=$((32 * 1024))
MIN_MEM=$((1 * 512))
MIN_JAVA_VERSION=11
# JDK 24 removed the Security Manager (JEP 486): "-Djava.security.manager=allow"
# is a fatal VM initialization error there and System.setSecurityManager() always
# throws, so HugeSecurityManager cannot be installed on newer runtimes.
MAX_SECURITY_JAVA_VERSION=23

# Add the slf4j-log4j12 binding
CP=$(find -L $LIB -name 'log4j-slf4j-impl*.jar' | sort | tr '\n' ':')
Expand Down Expand Up @@ -93,8 +97,15 @@ else
JAVA="$JAVA_HOME/bin/java -server"
fi

JAVA_VERSION=$($JAVA -version 2>&1 | head -1 | cut -d'"' -f2 | sed 's/^1\.//' | cut -d'.' -f1)
if [[ $? -ne 0 || $JAVA_VERSION -lt $MIN_JAVA_VERSION ]]; then
# Pick the version line explicitly: the JVM prints a preamble such as
# "Picked up JAVA_TOOL_OPTIONS: ..." before it whenever JAVA_TOOL_OPTIONS or
# _JAVA_OPTIONS is set, and reading that line instead would leave JAVA_VERSION
# unusable and silently skip every version-gated option below.
JAVA_VERSION=$($JAVA -version 2>&1 | awk -F'"' '/version "/ {print $2; exit}' |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This still accepts the first arbitrary line containing version ", not specifically the JVM banner. For example, APM agent version "7.2.0" before openjdk version "21.0.8" makes this pipeline return 7, so a supported JDK is rejected; a preamble containing version "24" can likewise trigger the new upper-bound branch. The test helper uses the same broad match, so it cannot catch this. Please anchor the match to the actual java/openjdk version line and add a tool-options/agent preamble regression.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9d53f15. The match is now anchored to the JVM banner line itself — only lines starting with java version " or openjdk version " are considered — in both the launcher and the test helper's own JAVA_MAJOR parse.

Added two mock-JVM regressions where an agent banner precedes the JVM's:

  • Elastic APM agent version "7.2.0" ahead of a JDK 21 banner must still emit -Djava.security.manager=allow (the unanchored match reads 7 and rejects the runtime as below the minimum).
  • APM agent version "24.0.1" ahead of a JDK 11 banner must not trip the JDK 24+ guard and must reach the bootstrap without a security-manager option.

Both fail against the unanchored match (re-verified by mutating the packaged launcher back to /version "/).

sed 's/^1\.//' | cut -d'.' -f1)
# Drop any pre-release suffix, e.g. "24-ea" -> "24"
JAVA_VERSION="${JAVA_VERSION%%[!0-9]*}"
if [[ -z $JAVA_VERSION || $JAVA_VERSION -lt $MIN_JAVA_VERSION ]]; then
echo "Make sure the JDK is installed and the version >= $MIN_JAVA_VERSION, current is $JAVA_VERSION" \
>> "${OUTPUT}"
exit 1
Expand Down Expand Up @@ -142,8 +153,39 @@ case "$GC_OPTION" in
esac

JVM_OPTIONS="-Dlog4j.configurationFile=${CONF}/log4j2.xml"
SECURITY_MANAGER_OPTION=""
if [[ ${OPEN_SECURITY_CHECK} == "true" ]]; then
JVM_OPTIONS="${JVM_OPTIONS} -Djava.security.manager=org.apache.hugegraph.security.HugeSecurityManager"
if [[ ${JAVA_VERSION} -gt ${MAX_SECURITY_JAVA_VERSION} ]]; then
SECURITY_UNSUPPORTED_MSG=$(cat <<EOF
The security check requires Java ${MIN_JAVA_VERSION}-${MAX_SECURITY_JAVA_VERSION}, current is ${JAVA_VERSION}.
JDK 24+ removed the Security Manager (JEP 486), so HugeSecurityManager can no longer be installed.
Run the server on Java ${MAX_SECURITY_JAVA_VERSION} or lower, or start it with the security check
disabled: 'start-hugegraph.sh -s false'.
EOF
)
echo "${SECURITY_UNSUPPORTED_MSG}" >&2
echo "${SECURITY_UNSUPPORTED_MSG}" >> "${OUTPUT}"
exit 1
fi

SECURITY_PROPERTIES="${CONF}/java-security.properties"
if [[ ! -r ${SECURITY_PROPERTIES} ]]; then
# The bootstrap validates the effective policy and refuses to start, but
# its stderr goes to the stdout log in daemon mode. Name the cause here
# so it also reaches the log start-hugegraph.sh points operators at.
cat >> "${OUTPUT}" <<EOF
ERROR: Missing or unreadable '${SECURITY_PROPERTIES}'.
An upgraded deployment that reuses an older conf/ directory must add this file,
or supply its own -Djava.security.properties=<file> setting a finite positive
networkaddress.cache.ttl.
EOF
fi
JVM_OPTIONS="${JVM_OPTIONS} \
-Djava.security.properties=${SECURITY_PROPERTIES}"
if [[ ${JAVA_VERSION} -ge 18 ]]; then
Comment thread
bitflicker64 marked this conversation as resolved.
# Required to install HugeSecurityManager programmatically on JDK 18+.
SECURITY_MANAGER_OPTION="-Djava.security.manager=allow"
fi
fi

if [ "${OPEN_TELEMETRY}" == "true" ]; then
Expand Down Expand Up @@ -186,10 +228,14 @@ fi

# Turn on security check
if [[ "${STDOUT_MODE:-false}" == "true" ]]; then
exec ${JAVA} -Dname="HugeGraphServer" ${JVM_OPTIONS} ${JAVA_OPTIONS} -cp ${CLASSPATH}: \
org.apache.hugegraph.dist.HugeGraphServer ${GREMLIN_SERVER_CONF} ${REST_SERVER_CONF}
exec ${JAVA} -Dname="HugeGraphServer" ${JVM_OPTIONS} ${JAVA_OPTIONS} \
${SECURITY_MANAGER_OPTION} -cp ${CLASSPATH}: \
org.apache.hugegraph.bootstrap.HugeGraphServerBootstrap \
${OPEN_SECURITY_CHECK} ${GREMLIN_SERVER_CONF} ${REST_SERVER_CONF}
else
exec ${JAVA} -Dname="HugeGraphServer" ${JVM_OPTIONS} ${JAVA_OPTIONS} -cp ${CLASSPATH}: \
org.apache.hugegraph.dist.HugeGraphServer ${GREMLIN_SERVER_CONF} ${REST_SERVER_CONF} \
exec ${JAVA} -Dname="HugeGraphServer" ${JVM_OPTIONS} ${JAVA_OPTIONS} \
${SECURITY_MANAGER_OPTION} -cp ${CLASSPATH}: \
org.apache.hugegraph.bootstrap.HugeGraphServerBootstrap \
${OPEN_SECURITY_CHECK} ${GREMLIN_SERVER_CONF} ${REST_SERVER_CONF} \
>> ${LOGS}/hugegraph-server-stdout.log 2>&1
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.

# Permit failed network clients to resolve a changed address instead of
# retaining the first successful DNS result for the lifetime of the JVM.
networkaddress.cache.ttl=30
Loading
Loading