imbajin commented on code in PR #3189:
URL: https://github.com/apache/hugegraph/pull/3189#discussion_r3945718233
##########
hugegraph-server/hugegraph-dist/src/assembly/travis/start-pd.sh:
##########
@@ -31,6 +31,11 @@ fi
PD_DIR=$HOME_DIR/hugegraph-pd/apache-hugegraph-pd-$VersionInBash
+# conf/application.yml ships auth.secret-key empty on purpose, so PD would
+# refuse every authenticated REST request. Supply a test-only secret; it must
+# match the value the PD test suites send.
+export
SPRING_APPLICATION_JSON='{"auth":{"secret-key":"pd-ci-test-secret-not-for-production"}}'
Review Comment:
⚠️ This export leaks into the next service when the existing HStore
installer sources both startup scripts. `install-hstore.sh:22-23` runs `.
start-pd.sh` and then `. start-store.sh` in the same shell, so this exported
`SPRING_APPLICATION_JSON` remains set for Store. It contains PD's
`grpc.port=8686`, `server.port=8620`, and PD raft/data properties, while Store
expects `grpc.port=8500` and `server.port=8520` in
`hugegraph-store/hg-store-node/src/main/resources/application.yml`; Spring Boot
consumes `SPRING_APPLICATION_JSON` for both apps. Please scope this JSON to the
PD process or unset/restore it before `start-pd.sh` returns.
##########
hugegraph-server/hugegraph-dist/src/assembly/travis/test-pd-shipped-config.sh:
##########
@@ -0,0 +1,59 @@
+#!/usr/bin/env 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.
+#
+# Every PD configuration that ships in the archive or the jar must carry the
+# same REST hardening: no wildcard actuator exposure (that path is anonymous),
+# an auth.secret-key that is present and empty, and no copy of the secret that
+# earlier revisions published. A fix applied to one variant and not the others
+# is what this catches.
+
+set -euo pipefail
+
+ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../../../.." && pwd)"
+PUBLISHED_SECRET='FXQXbJtbCLxODc6tGci732pkH1cyf8Qg'
+FAIL=0
+
+check() {
+ local file="$1" rel="${1#"${ROOT}/"}" before="$FAIL"
+ [[ -f "$file" ]] || { echo " FAIL ${rel}: missing"; FAIL=1; return; }
+
+ # The actuator exposure specifically: a config that grows an unrelated
+ # include: above this block must not satisfy the check by accident.
+ local exposure
+ exposure=$(awk '/^[[:space:]]*exposure:/ {found = 1; next}
+ found && /^[[:space:]]*include:/
{sub(/^[[:space:]]*include:[[:space:]]*/, ""); print; exit}' "$file")
+ if [[ "$exposure" == *'*'* ]]; then
+ echo " FAIL ${rel}: actuator exposure is a wildcard (${exposure})";
FAIL=1
+ fi
+ if ! grep -qE '^[[:space:]]*secret-key:[[:space:]]*$' "$file"; then
+ echo " FAIL ${rel}: auth.secret-key must be present and empty"; FAIL=1
+ fi
+ if grep -q "${PUBLISHED_SECRET}" "$file"; then
+ echo " FAIL ${rel}: contains the published secret"; FAIL=1
+ fi
+ # Only when nothing above raised FAIL, or the file contradicts its own
report
+ if [[ "$FAIL" == "$before" ]]; then
+ echo " ok ${rel}"
+ fi
+}
+
+echo "PD shipped configuration hardening"
+for f in
"${ROOT}"/hugegraph-pd/hg-pd-dist/src/assembly/static/conf/application.yml* \
Review Comment:
⚠️ This regression check does not cover the PD template used by the
cluster-test distribution.
`hugegraph-cluster-test/hugegraph-clustertest-dist/src/assembly/static/conf/pd-application.yml.template`
is copied to each PD node by `PDNodeWrapper`, but it still has
`management.endpoints.web.exposure.include: "*"` and no `auth.secret-key`. With
this PR's `PDConfig`, REST credentials fail closed while actuator endpoints
such as `/actuator/env` remain anonymously exposed. Please update that shipped
template to the same allowlist/empty secret contract and include it in this
check.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]