GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Use the candidate Commons IO in the publisher JDK check (#416) · PastureStack/server@0adf3d7

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • publish-current-server.yml
  • scripts
    • check-server-java-patches-jdk25.sh
    • test-publisher-safety-guards.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/publish-current-server.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/publish-current-server.yml
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ jobs:
213213
done
214214
java --list-modules | grep -E "^(java.naming|java.security.jgss|jdk.crypto.ec)@25.0.5"
215215
'
216-
RC16_JDK25_CHECK_IMAGE="$CANDIDATE_IMAGE" bash scripts/check-server-java-patches-jdk25.sh
216+
RC16_JDK25_COMMONS_IO_IMAGE="$CANDIDATE_IMAGE" \
217+
RC16_JDK25_CHECK_IMAGE="$CANDIDATE_IMAGE" bash scripts/check-server-java-patches-jdk25.sh
217218
printf 'SERVER_JAVA_SECURITY_RUNTIME_OK version=25.0.5+8 official_archive_sha256=68982529869257d0ee6b824ec5aa270ff8b118bb438670da0b97ebdab178d7fb actual_candidate=1\n'
218219
} |& tee "$RUNNER_TEMP/server-evidence/java-security-runtime.txt"
219220
Collapse file

‎scripts/check-server-java-patches-jdk25.sh‎

Copy file name to clipboardExpand all lines: scripts/check-server-java-patches-jdk25.sh
+23-8Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ cd "$repo_root"
77
expected_patch="server/patches/PatchV1GlobalSubscribe.java"
88
image="${RC16_JDK25_CHECK_IMAGE:-eclipse-temurin:25.0.4_7-jdk}"
99
jdk_home="${RC16_JDK25_HOME:-}"
10+
commons_io_image="${RC16_JDK25_COMMONS_IO_IMAGE:-}"
1011
commons_io_version=2.22.0
1112
commons_io_sha256=2b9a7b1f726fb86216dbd2c8321eabe0221dbd5b1be81c18e1cb53811b104758
1213
commons_io_url="https://repo.maven.apache.org/maven2/commons-io/commons-io/${commons_io_version}/commons-io-${commons_io_version}.jar"
@@ -16,6 +17,12 @@ javac_bin=""
1617
javap_bin=""
1718
classpath_separator=":"
1819

20+
if [ "${RC16_JDK25_COMMONS_IO_IMAGE+x}" = x ] &&
21+
{ [ -z "$commons_io_image" ] || [ -n "$jdk_home" ] || [ "$commons_io_image" != "$image" ]; }; then
22+
echo "JDK25_COMMONS_IO_IMAGE_INVALID must_match_check_image=1 local_jdk_allowed=0" >&2
23+
exit 1
24+
fi
25+
1926
resolve_jdk_tool() {
2027
local tool=$1
2128
if [ -x "$jdk_home/bin/$tool" ]; then
@@ -84,14 +91,22 @@ mkdir -p \
8491
"$tmp/classes" \
8592
"$tmp/lib"
8693

87-
curl -fsSL \
88-
--retry 5 \
89-
--retry-all-errors \
90-
--retry-delay 2 \
91-
--connect-timeout 10 \
92-
--max-time 300 \
93-
-o "$tmp/lib/commons-io.jar" \
94-
"$commons_io_url"
94+
if [ -n "$commons_io_image" ]; then
95+
# Check the dependency shipped by this exact candidate, without a pull or download.
96+
docker run --rm --pull=never --network none --entrypoint /bin/cat \
97+
"$commons_io_image" \
98+
"/usr/share/cattle/war/WEB-INF/lib/commons-io-${commons_io_version}.jar" \
99+
> "$tmp/lib/commons-io.jar"
100+
else
101+
curl -fsSL \
102+
--retry 5 \
103+
--retry-all-errors \
104+
--retry-delay 2 \
105+
--connect-timeout 10 \
106+
--max-time 300 \
107+
-o "$tmp/lib/commons-io.jar" \
108+
"$commons_io_url"
109+
fi
95110
printf '%s %s\n' "$commons_io_sha256" "$tmp/lib/commons-io.jar" | sha256sum -c -
96111

97112
cat > "$tmp/src/io/github/ibuildthecloud/gdapi/model/Filter.java" <<'JAVA'
Collapse file

‎scripts/test-publisher-safety-guards.py‎

Copy file name to clipboardExpand all lines: scripts/test-publisher-safety-guards.py
+115Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
"""Exercise release guards themselves, not only the eventual command exit code."""
22
from pathlib import Path
33
import gzip
4+
import hashlib
5+
import os
46
import subprocess
57
import tempfile
68
import textwrap
79
import unittest
810

911
WORKFLOW = Path(__file__).resolve().parents[1] / '.github/workflows/publish-current-server.yml'
12+
JAVA_PATCH_GATE = WORKFLOW.parents[2] / 'scripts/check-server-java-patches-jdk25.sh'
13+
COMMONS_IO_SHA256 = '2b9a7b1f726fb86216dbd2c8321eabe0221dbd5b1be81c18e1cb53811b104758'
14+
COMMONS_IO_FIXTURE_BYTES = b'fixture Commons IO bytes; not a Java runtime acceptance result\n'
1015

1116

1217
class PublisherSafetyGuards(unittest.TestCase):
@@ -140,5 +145,115 @@ def test_collision_never_arms_cleanup_or_removes_existing_objects(self):
140145
self.assertEqual(calls[2:], ['rm -f candidate', 'volume rm cattle mysql mysqllog'])
141146

142147

148+
class CandidateCommonsIoGuards(unittest.TestCase):
149+
"""Exercise only dependency input routing; Java checks are not stubbed as PASS."""
150+
151+
def dependency_input(self, image='candidate:fixture', local_jdk=False,
152+
payload=None, docker_status=0, use_candidate=True):
153+
source = JAVA_PATCH_GATE.read_text()
154+
boundary = 'cat > "$tmp/src/io/github/ibuildthecloud/gdapi/model/Filter.java"'
155+
self.assertEqual(source.count(boundary), 1)
156+
self.assertEqual(source.count('commons_io_sha256=' + COMMONS_IO_SHA256), 1)
157+
self.assertIn('commons_io_version=2.22.0', source)
158+
prefix = source.split(boundary, 1)[0]
159+
# Tiny deterministic fixture bytes keep this test offline on a fresh CI runner.
160+
# The actual hardcoded release hash is asserted above; use real sha256sum below.
161+
# Local qualification can supply cached release bytes without changing the prefix.
162+
prefix = prefix.replace(COMMONS_IO_SHA256, hashlib.sha256(COMMONS_IO_FIXTURE_BYTES).hexdigest())
163+
with tempfile.TemporaryDirectory() as temporary:
164+
root = Path(temporary)
165+
(root / 'scripts').mkdir()
166+
(root / 'server/patches').mkdir(parents=True)
167+
(root / 'server/patches/PatchV1GlobalSubscribe.java').write_text('class PatchV1GlobalSubscribe {}\n')
168+
for name in ('Dockerfile', 'Dockerfile.auth-hotfix'):
169+
(root / 'server' / name).write_text(
170+
'javac -cp "/usr/share/cattle/war/WEB-INF/lib/*" PatchV1GlobalSubscribe.java\n')
171+
(root / 'payload').write_bytes(COMMONS_IO_FIXTURE_BYTES if payload is None else payload)
172+
jdk = root / 'jdk'
173+
(jdk / 'bin').mkdir(parents=True)
174+
for name in ('java', 'javac', 'javap'):
175+
path = jdk / 'bin' / name
176+
path.write_text('#!/bin/sh\nexit 97\n')
177+
path.chmod(0o755)
178+
environment = os.environ.copy()
179+
for name in ('RC16_JDK25_CHECK_IMAGE', 'RC16_JDK25_COMMONS_IO_IMAGE', 'RC16_JDK25_HOME'):
180+
environment.pop(name, None)
181+
environment.update(RC16_JDK25_CHECK_IMAGE='candidate:fixture', FIXTURE_ROOT=temporary,
182+
FIXTURE_DOCKER_STATUS=str(docker_status))
183+
if use_candidate:
184+
environment['RC16_JDK25_COMMONS_IO_IMAGE'] = image
185+
if local_jdk:
186+
environment['RC16_JDK25_HOME'] = str(jdk)
187+
stubs = r'''docker() {
188+
printf 'docker' >>"$FIXTURE_ROOT/calls"
189+
printf '\t%s' "$@" >>"$FIXTURE_ROOT/calls"
190+
printf '\n' >>"$FIXTURE_ROOT/calls"
191+
if [ "$FIXTURE_DOCKER_STATUS" -ne 0 ]; then return "$FIXTURE_DOCKER_STATUS"; fi
192+
cat "$FIXTURE_ROOT/payload"
193+
}
194+
curl() {
195+
printf 'curl' >>"$FIXTURE_ROOT/calls"
196+
printf '\t%s' "$@" >>"$FIXTURE_ROOT/calls"
197+
printf '\n' >>"$FIXTURE_ROOT/calls"
198+
local output=
199+
while [ "$#" -gt 0 ]; do
200+
if [ "$1" = -o ]; then output=$2; shift; fi
201+
shift
202+
done
203+
test -n "$output"
204+
cat "$FIXTURE_ROOT/payload" >"$output"
205+
}
206+
'''
207+
result = subprocess.run(['bash', '-c', stubs + prefix + '\necho DEPENDENCY_INPUT_READY\n',
208+
str(root / 'scripts/check-server-java-patches-jdk25.sh')],
209+
env=environment, capture_output=True, text=True)
210+
calls = (root / 'calls').read_text().splitlines() if (root / 'calls').exists() else []
211+
return result, [line.split('\t') for line in calls]
212+
213+
def test_candidate_commons_io_uses_same_image_offline_and_checks_bytes(self):
214+
result, calls = self.dependency_input()
215+
self.assertEqual(result.returncode, 0, result.stderr)
216+
self.assertIn('DEPENDENCY_INPUT_READY', result.stdout)
217+
self.assertEqual(calls, [['docker', 'run', '--rm', '--pull=never', '--network', 'none',
218+
'--entrypoint', '/bin/cat', 'candidate:fixture',
219+
'/usr/share/cattle/war/WEB-INF/lib/commons-io-2.22.0.jar']])
220+
221+
def test_candidate_commons_io_missing_or_wrong_bytes_never_fall_back(self):
222+
for payload, status in ((b'', 0), (b'wrong bytes', 0), (None, 1)):
223+
with self.subTest(payload=payload, status=status):
224+
result, calls = self.dependency_input(payload=payload, docker_status=status)
225+
self.assertNotEqual(result.returncode, 0)
226+
self.assertNotIn('DEPENDENCY_INPUT_READY', result.stdout)
227+
self.assertEqual(len(calls), 1)
228+
self.assertEqual(calls[0][0], 'docker')
229+
if status == 0:
230+
self.assertIn('FAILED', result.stdout)
231+
232+
def test_candidate_commons_io_rejects_wrong_empty_or_local_jdk_image_before_io(self):
233+
for image, local_jdk in (('different:fixture', False), ('', False), ('candidate:fixture', True)):
234+
with self.subTest(image=image, local_jdk=local_jdk):
235+
result, calls = self.dependency_input(image=image, local_jdk=local_jdk)
236+
self.assertNotEqual(result.returncode, 0)
237+
self.assertIn('JDK25_COMMONS_IO_IMAGE_INVALID', result.stderr)
238+
self.assertEqual(calls, [])
239+
240+
def test_candidate_commons_io_default_jdk_and_local_modes_keep_pinned_curl(self):
241+
for local_jdk in (False, True):
242+
with self.subTest(local_jdk=local_jdk):
243+
result, calls = self.dependency_input(local_jdk=local_jdk, use_candidate=False)
244+
self.assertEqual(result.returncode, 0, result.stderr)
245+
self.assertEqual(len(calls), 1)
246+
self.assertEqual(calls[0][0:2], ['curl', '-fsSL'])
247+
self.assertEqual(calls[0][-1], 'https://repo.maven.apache.org/maven2/commons-io/commons-io/2.22.0/commons-io-2.22.0.jar')
248+
self.assertIn('--retry-all-errors', calls[0])
249+
self.assertIn('DEPENDENCY_INPUT_READY', result.stdout)
250+
251+
def test_candidate_commons_io_publisher_binds_the_actual_check_image(self):
252+
source = WORKFLOW.read_text()
253+
binding = ('RC16_JDK25_COMMONS_IO_IMAGE="$CANDIDATE_IMAGE" \\\n'
254+
' RC16_JDK25_CHECK_IMAGE="$CANDIDATE_IMAGE" bash scripts/check-server-java-patches-jdk25.sh')
255+
self.assertEqual(source.count(binding), 1)
256+
257+
143258
if __name__ == '__main__':
144259
unittest.main()

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.