Skip to content

Commit 581d4fb

Browse files
authored
1 parent d7ab97b commit 581d4fb

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

localdev.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
#!/usr/bin/env sh
2-
# TODO: OWASP RULE#7 https://cheatsheetseries.owasp.org/cheatsheets/Docker_Security_Cheat_Sheet.html#rule-7-limit-resources-memory-cpu-file-descriptors-processes-restarts
3-
# TODO: Same OWASP rules in test.sh file
42
# TODO: document security recommendations adapted to this project
53
# TODO: document requirements for OWASP RULE#8 https://cheatsheetseries.owasp.org/cheatsheets/Docker_Security_Cheat_Sheet.html#rule-7-limit-resources-memory-cpu-file-descriptors-processes-restarts
64
# TODO: try OWASP RULE#8 here
7-
# TODO: move at root of the project
85

96
set -eu
107

@@ -19,9 +16,24 @@ echo '✅ Image built successfully.'
1916

2017
echo '▶️ Starting the localdev PaperMC server...'
2118

19+
# Apply security best practices based on OWASP recommendations:
20+
# https://cheatsheetseries.owasp.org/cheatsheets/Docker_Security_Cheat_Sheet.html
21+
#
22+
# Simulate a production-like environment by enforcing strict security policies:
23+
# - Drop all Linux capabilities (PaperMC does not require any).
24+
# - Disable privilege escalation within the container.
25+
# - Set ulimits:
26+
# - `nofile` (open files): 16384 — sufficient for typical Java-based Minecraft servers.
27+
# - `nproc` (processes): 4096 — a safe and generous limit for JVM workloads.
28+
# - `core`: 0 — disables core dumps to preserve disk space and avoid leaking sensitive information.
2229
docker run --rm -it \
2330
--cap-drop all \
2431
--security-opt no-new-privileges \
32+
--ulimit nofile=16384 \
33+
--ulimit nproc=4096 \
34+
--ulimit core=0 \
35+
--cpus=4 \
36+
--memory=8GB \
2537
-p 25565:25565/tcp -p 25565:25565/udp \
2638
-e EULA=true \
2739
'djaytan/papermc-server:dev'

src/main/docker/runtime/start.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,5 @@ echo 'File eula.txt processed'
7070

7171
echo 'PaperMC server ready to start!'
7272

73+
# TODO: ensure that the server replace PID 1 instead of spawning a child process (exec command)
7374
java $JVM_ARGUMENTS -jar "${SCRIPT_DIR}"/papermc-server-*.jar $SERVER_ARGS

src/test/docker/test.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,24 @@ echo '📋 Testing the Docker PaperMC server image...'
99

1010
echo '▶️ Starting the PaperMC server in background...'
1111

12+
# Apply security best practices based on OWASP recommendations:
13+
# https://cheatsheetseries.owasp.org/cheatsheets/Docker_Security_Cheat_Sheet.html
14+
#
15+
# Simulate a production-like environment by enforcing strict security policies:
16+
# - Drop all Linux capabilities (PaperMC does not require any).
17+
# - Disable privilege escalation within the container.
18+
# - Set ulimits:
19+
# - `nofile` (open files): 16384 — sufficient for typical Java-based Minecraft servers.
20+
# - `nproc` (processes): 4096 — a safe and generous limit for JVM workloads.
21+
# - `core`: 0 — disables core dumps to preserve disk space and avoid leaking sensitive information.
1222
docker run --rm -d --name "$CONTAINER_NAME" \
1323
--cap-drop all \
1424
--security-opt no-new-privileges \
25+
--ulimit nofile=16384 \
26+
--ulimit nproc=4096 \
27+
--ulimit core=0 \
28+
--cpus=4 \
29+
--memory=8GB \
1530
-p 25565:25565/tcp -p 25565:25565/udp \
1631
-e EULA=true \
1732
'djaytan/papermc-server:dev'

0 commit comments

Comments
 (0)