-
Notifications
You must be signed in to change notification settings - Fork 627
fix(server): configure finite DNS cache TTL #3126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
imbajin
merged 9 commits into
apache:master
from
bitflicker64:fix/hstore-dns-recovery-3124
Aug 4, 2026
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
10ed6d2
fix(server): configure finite DNS cache TTL
bitflicker64 35e1a24
fix(server): validate DNS security properties
bitflicker64 0a07cd8
fix(server): validate DNS policy before startup
imbajin 625d3b7
fix(server): reject security check on JDK 24+
bitflicker64 9438a94
fix(server): parse the JDK version line robustly
bitflicker64 4d0ff03
fix(server): only report a missing bundled policy when it matters
bitflicker64 9d53f15
fix(server): anchor JDK version parsing to the JVM banner line
bitflicker64 791947c
fix(server): mirror bootstrap policy rejections into the server log
bitflicker64 b40c42f
Merge branch 'master' into fix/hstore-dns-recovery-3124
bitflicker64 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
18 changes: 18 additions & 0 deletions
18
hugegraph-server/hugegraph-dist/src/assembly/static/conf/java-security.properties
This file contains hidden or 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,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 |
145 changes: 145 additions & 0 deletions
145
hugegraph-server/hugegraph-dist/src/assembly/travis/test-java-security-properties.sh
This file contains hidden or 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,145 @@ | ||
| #!/bin/bash | ||
| # | ||
| # 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. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| SERVER_ROOT_INPUT="${1:?Usage: $0 PATH_TO_SERVER_DIST}" | ||
| SERVER_ROOT=$(cd "$SERVER_ROOT_INPUT" && pwd) | ||
| SERVER_SCRIPT="${SERVER_ROOT}/bin/hugegraph-server.sh" | ||
| CONF="${SERVER_ROOT}/conf" | ||
| SECURITY_PROPERTIES="${CONF}/java-security.properties" | ||
|
|
||
| fail() { | ||
| echo "FAIL: $1" >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| assert_argument() { | ||
| local argument="$1" | ||
| local capture="$2" | ||
| grep -Fxq -- "$argument" "$capture" || \ | ||
| fail "missing JVM argument: $argument" | ||
| } | ||
|
|
||
| assert_no_argument() { | ||
| local pattern="$1" | ||
| local capture="$2" | ||
| if grep -Eq -- "$pattern" "$capture"; then | ||
| fail "unexpected JVM argument matching: $pattern" | ||
| fi | ||
| } | ||
|
|
||
| if [[ ! -x "$SERVER_SCRIPT" ]]; then | ||
| fail "server script is not executable: $SERVER_SCRIPT" | ||
| fi | ||
| if [[ ! -f "$SECURITY_PROPERTIES" ]]; then | ||
| fail "security properties file is missing: $SECURITY_PROPERTIES" | ||
| fi | ||
|
|
||
| if [[ -n "${JAVA_HOME:-}" ]]; then | ||
| JAVA_BIN="${JAVA_HOME}/bin/java" | ||
| else | ||
| JAVA_BIN="java" | ||
| fi | ||
|
|
||
| TEMP_DIR=$(mktemp -d) | ||
| trap 'rm -rf "$TEMP_DIR"' EXIT | ||
|
|
||
| CHECK_SOURCE="${TEMP_DIR}/ReadDnsCacheTtl.java" | ||
| cat > "$CHECK_SOURCE" <<'JAVA' | ||
| import java.security.Security; | ||
|
|
||
| public class ReadDnsCacheTtl { | ||
| public static void main(String[] args) { | ||
| System.out.print(Security.getProperty("networkaddress.cache.ttl")); | ||
| } | ||
| } | ||
| JAVA | ||
|
|
||
| ACTUAL_TTL=$("$JAVA_BIN" \ | ||
| -Djava.security.properties="$SECURITY_PROPERTIES" "$CHECK_SOURCE") | ||
| if [[ "$ACTUAL_TTL" != "30" ]]; then | ||
| fail "expected security property TTL 30, got: $ACTUAL_TTL" | ||
| fi | ||
|
|
||
| SYSTEM_PROPERTY_TTL=$("$JAVA_BIN" \ | ||
| -Dnetworkaddress.cache.ttl=99 \ | ||
| -Djava.security.properties="$SECURITY_PROPERTIES" "$CHECK_SOURCE") | ||
| if [[ "$SYSTEM_PROPERTY_TTL" != "30" ]]; then | ||
| fail "ordinary -D property unexpectedly changed the security property" | ||
| fi | ||
|
|
||
| OPERATOR_PROPERTIES="${TEMP_DIR}/operator-security.properties" | ||
| echo "networkaddress.cache.ttl=45" > "$OPERATOR_PROPERTIES" | ||
| OPERATOR_TTL=$("$JAVA_BIN" \ | ||
| -Djava.security.properties="$SECURITY_PROPERTIES" \ | ||
| -Djava.security.properties="$OPERATOR_PROPERTIES" "$CHECK_SOURCE") | ||
| if [[ "$OPERATOR_TTL" != "45" ]]; then | ||
| fail "operator security properties override was not honored" | ||
| fi | ||
|
|
||
| MOCK_JAVA_HOME="${TEMP_DIR}/mock-java-home" | ||
| mkdir -p "${MOCK_JAVA_HOME}/bin" | ||
| cat > "${MOCK_JAVA_HOME}/bin/java" <<'MOCK' | ||
| #!/bin/bash | ||
| if [[ " $* " == *" -version "* ]]; then | ||
| echo 'openjdk version "11.0.0"' >&2 | ||
| exit 0 | ||
| fi | ||
| printf '%s\n' "$@" > "$CAPTURE_FILE" | ||
| MOCK | ||
| chmod +x "${MOCK_JAVA_HOME}/bin/java" | ||
|
|
||
| ENABLED_CAPTURE="${TEMP_DIR}/enabled.args" | ||
| CAPTURE_FILE="$ENABLED_CAPTURE" JAVA_HOME="$MOCK_JAVA_HOME" \ | ||
| STDOUT_MODE=true "$SERVER_SCRIPT" \ | ||
| "${CONF}/gremlin-server.yaml" "${CONF}/rest-server.properties" true \ | ||
| "-Doperator.marker=preserved" >/dev/null | ||
|
|
||
| assert_argument \ | ||
| "-Djava.security.properties=${SECURITY_PROPERTIES}" "$ENABLED_CAPTURE" | ||
| assert_argument \ | ||
| "-Djava.security.manager=org.apache.hugegraph.security.HugeSecurityManager" \ | ||
| "$ENABLED_CAPTURE" | ||
| assert_argument "-Doperator.marker=preserved" "$ENABLED_CAPTURE" | ||
| assert_no_argument '^-D(networkaddress\.cache\.ttl|sun\.net\.inetaddr\.ttl)=' \ | ||
| "$ENABLED_CAPTURE" | ||
|
|
||
| DISABLED_CAPTURE="${TEMP_DIR}/disabled.args" | ||
| CAPTURE_FILE="$DISABLED_CAPTURE" JAVA_HOME="$MOCK_JAVA_HOME" \ | ||
| STDOUT_MODE=true "$SERVER_SCRIPT" \ | ||
| "${CONF}/gremlin-server.yaml" "${CONF}/rest-server.properties" false \ | ||
| "-Doperator.marker=preserved" >/dev/null | ||
|
|
||
| assert_no_argument '^-Djava\.security\.properties=' "$DISABLED_CAPTURE" | ||
| assert_no_argument '^-Djava\.security\.manager=' "$DISABLED_CAPTURE" | ||
| assert_argument "-Doperator.marker=preserved" "$DISABLED_CAPTURE" | ||
|
|
||
| OVERRIDE_CAPTURE="${TEMP_DIR}/override.args" | ||
| CAPTURE_FILE="$OVERRIDE_CAPTURE" JAVA_HOME="$MOCK_JAVA_HOME" \ | ||
| STDOUT_MODE=true "$SERVER_SCRIPT" \ | ||
| "${CONF}/gremlin-server.yaml" "${CONF}/rest-server.properties" true \ | ||
| "-Djava.security.properties=${OPERATOR_PROPERTIES}" >/dev/null | ||
|
|
||
| LAST_SECURITY_ARGUMENT=$(grep -E '^-Djava\.security\.properties=' \ | ||
| "$OVERRIDE_CAPTURE" | tail -n 1) | ||
| if [[ "$LAST_SECURITY_ARGUMENT" != \ | ||
| "-Djava.security.properties=${OPERATOR_PROPERTIES}" ]]; then | ||
| fail "operator security properties argument was overwritten" | ||
| fi | ||
|
|
||
| echo "PASS: Java security properties and startup wiring" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.