Close the security gaps found by the application audit
Imported toolboxes could run scripts on the site origin through image data URLs, so only bitmap images are now accepted at import, display and opening. The Cards game and its fake admin login no longer turn on when NODE_ENV is missing, and the Node server now sends a CSP and the other security headers. The deployment script no longer runs files owned by the service account as root, the services cannot gain privileges through sudo, and the deployment key stays in a single workflow step with actions pinned by commit. The script and systemd units must still be reinstalled on the server after delivery. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1adccb4e04
commit
7046515d20
20 changed files with 233 additions and 36 deletions
|
|
@ -42,9 +42,9 @@ as_app_user() {
|
|||
restore_previous_release() {
|
||||
local previous_commit=$1
|
||||
|
||||
rm -rf -- "$APP_ROOT/website/dist"
|
||||
as_app_user rm -rf -- "$APP_ROOT/website/dist"
|
||||
if [[ -n "$backup_dist" && -d "$backup_dist" ]]; then
|
||||
mv "$backup_dist" "$APP_ROOT/website/dist"
|
||||
as_app_user mv "$backup_dist" "$APP_ROOT/website/dist"
|
||||
fi
|
||||
as_app_user git -C "$APP_ROOT" checkout --detach "$previous_commit"
|
||||
systemctl restart "$SERVICE_NAME" || true
|
||||
|
|
@ -74,8 +74,9 @@ command -v flock >/dev/null
|
|||
echo "Node 24.11.1 and npm 11.17.0 must be installed under $NODE_HOME." >&2
|
||||
exit 1
|
||||
}
|
||||
[[ "$($NODE_BIN --version)" == "v24.11.1" ]]
|
||||
[[ "$(env PATH="$NODE_HOME/bin:/usr/bin:/bin" "$NPM_BIN" --version)" == "11.17.0" ]]
|
||||
# Ces fichiers appartiennent au compte du service : les lancer en root lui donnerait les droits root.
|
||||
[[ "$(as_app_user "$NODE_BIN" --version)" == "v24.11.1" ]]
|
||||
[[ "$(as_app_user env PATH="$NODE_HOME/bin:/usr/bin:/bin" "$NPM_BIN" --version)" == "11.17.0" ]]
|
||||
systemctl show --property=ExecStart --value "$SERVICE_NAME" | grep -Fq "$NPM_BIN"
|
||||
|
||||
exec 9>"$LOCK_FILE"
|
||||
|
|
@ -113,10 +114,9 @@ as_app_user env \
|
|||
as_app_user git -C "$APP_ROOT" checkout --detach "$requested_commit"
|
||||
backup_dist="$build_root/previous-dist"
|
||||
if [[ -d "$APP_ROOT/website/dist" ]]; then
|
||||
mv "$APP_ROOT/website/dist" "$backup_dist"
|
||||
as_app_user mv "$APP_ROOT/website/dist" "$backup_dist"
|
||||
fi
|
||||
mv "$worktree/website/dist" "$APP_ROOT/website/dist"
|
||||
chown -R "$APP_USER:$APP_USER" "$APP_ROOT/website/dist"
|
||||
as_app_user mv "$worktree/website/dist" "$APP_ROOT/website/dist"
|
||||
|
||||
if ! systemctl restart "$SERVICE_NAME" || ! systemctl is-active --quiet "$SERVICE_NAME"; then
|
||||
echo "The new release did not start; restoring $previous_commit." >&2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue