-
Notifications
You must be signed in to change notification settings - Fork 16
Hardening (Security improvements) #302
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
Open
jwkaltz
wants to merge
40
commits into
GeoNodeUserGroup-DE:main
Choose a base branch
from
jwkaltz:hardening
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
f3d2a24
Split geonode PVC into individual PVCs, to allow more granular handli…
jwkaltz 4e5152e
Hardening: add security context; split geonode PVC into individual PV…
jwkaltz 16d5254
Hardening nginx: use non-root port; do not mount favicon here as that…
jwkaltz 40e224d
Remove cron command, cron should not be used within a K8S container
jwkaltz 78028e4
Hardening: add security context; split geonode PVC into individual PV…
jwkaltz 08396f0
Hardening: add security context; split geonode PVC into individual PV…
jwkaltz e3011b2
no more need to mount pvc-data into build statics job (review comment…
jwkaltz d4ffcd2
Conditional StorageClassName (as per gemini-code-assist suggestion)
jwkaltz 07efce2
allow configuring individual storage sizes for each PVC (as per gemin…
jwkaltz 367cf0a
make nginx fsGroup configurable (as per gemini-code-assist suggestion)
jwkaltz 7c579b9
Reenable custom favicon loading, but without extra mount. Change favi…
jwkaltz d9c3e11
Security improvements as suggested by gemini-code-review
jwkaltz 8b5d6c5
Add securitycontext to cleanup-job
jwkaltz eeeb54b
more robust values handling, as per gemini-code-assist suggestion
jwkaltz 8cf1094
Make geonode pod (geonode, celery) runnable as non-root
jwkaltz fa901aa
Make chart more robust, as per gemini-code-assist review
jwkaltz 27c119a
Make chart more robust, as per gemini-code-assist review
jwkaltz 97a6930
make code clearer
jwkaltz 4bb5a80
Make chart more robust, as per gemini-code-assist suggestions
jwkaltz 10b1583
Document how to run geonode/geoserver as non-root
jwkaltz 0cf6453
Add migration notice
jwkaltz af92aea
Apply upstream change to PR, and remove superfluous parameter, we sho…
jwkaltz 24a945d
By default, allow root usage for geoserver pod (to be able to use cur…
jwkaltz ca32829
Make value handling resistent to boolean and integer values
jwkaltz 5f59315
Integrate upstream PR https://github.com/GeoNode/geonode/pull/14307
jwkaltz 7d76aaf
Mount the statics PVC as readOnly: true in the geoserver deployment (…
jwkaltz b17b311
Strip setuid bits (from Review comment)
jwkaltz 380db64
start implementing readOnlyRootFilesystem (Review comment)
jwkaltz 707d8a0
continue implementing readOnlyRootFilesystem (Review comment)
jwkaltz c2a30e2
implement readOnlyRootFilesystem (Review comment) for geoserver, memc…
jwkaltz 1277752
implement readOnlyRootFilesystem (Review comment) for cleanup job
jwkaltz b809473
implement readOnlyRootFilesystem (Review comment) for remaining job c…
jwkaltz 3d298fd
Fix bug about hard-coded uid/gid (from review comment)
jwkaltz fdb9044
reduce access rights (from review comment)
jwkaltz 299c167
consistently use fsGroupChangePolicy (from review comment)
jwkaltz 9988ff5
More robust Dockerfile
jwkaltz baa230a
Improve security compliance of postgres pod by using all available op…
jwkaltz 861993d
Allow postgres to start with full securitycontext despite postgres-op…
jwkaltz dd46de7
Add documentation for postgres securitycontext issue
jwkaltz 9b3067c
Merge branch 'main' into hardening
mwallschlaeger 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
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
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,72 @@ | ||
| #!/usr/bin/env bash | ||
| # A configurable celery command. | ||
| # Luca Pasquali <luca.pasquali@geosolutionsgroup.com> | ||
| CELERY_BIN=${CELERY_BIN:-"$(which celery||echo celery)"} | ||
| CELERY_APP=${CELERY_APP:-"geonode.celery_app:app"} | ||
| CELERY__STATE_DB=${CELERY__STATE_DB:-"/mnt/volumes/statics/worker@%h.state"} | ||
| # expressed in KB | ||
| CELERY__MAX_MEMORY_PER_CHILD=${CELERY__MAX_MEMORY_PER_CHILD:-"200000"} | ||
| CELERY__AUTOSCALE_VALUES=${CELERY__AUTOSCALE_VALUES:-"10,5"} | ||
| CELERY__MAX_TASKS_PER_CHILD=${CELERY__MAX_TASKS_PER_CHILD:-"10"} | ||
| CELERY__OPTS=${CELERY__OPTS:-"--without-gossip --without-mingle -Ofair -E"} | ||
| CELERY__LOG_LEVEL=${CELERY__LOG_LEVEL:-"ERROR"} | ||
| CELERY__LOG_FILE=${CELERY__LOG_FILE:-"/var/log/celery.log"} | ||
| CELERY__WORKER_NAME=${CELERY__WORKER_NAME:-"worker1@%h"} | ||
| CELERY__WORKER_CONCURRENCY=${CELERY__WORKER_CONCURRENCY:-"4"} | ||
|
|
||
| # Celery beat settings | ||
| CELERY__BEAT_SCHEDULE=${CELERY__BEAT_SCHEDULE:-"celery.beat:PersistentScheduler"} | ||
| CELERY__BEAT_DB=${CELERY__BEAT_DB:-"/mnt/volumes/statics/celerybeat-schedule"} | ||
| CELERY__BEAT_LOG=${CELERY__BEAT_LOG:-"/var/log/celery_beat.log"} | ||
|
|
||
| # Harvester settings | ||
| CELERY__HARVESTER_WORKER_NAME=${CELERY__HARVESTER_WORKER_NAME:-"harvesting_worker@%h"} | ||
| CELERY__HARVESTER_CONCURRENCY=${CELERY__HARVESTER_CONCURRENCY:-"10"} | ||
| CELERY__HARVESTER_AUTOSCALE_VALUES=${CELERY__HARVESTER_AUTOSCALE_VALUES:-"15,10"} | ||
| CELERY__HARVESTER_MAX_MEMORY_PER_CHILD=${CELERY__HARVESTER_MAX_MEMORY_PER_CHILD:-"500000"} | ||
|
|
||
| # --- FIX: Remove stale Beat pidfile before starting beat --- | ||
| BEAT_PIDFILE="/tmp/celerybeat.pid" | ||
|
|
||
| if [ -f "$BEAT_PIDFILE" ]; then | ||
| PID=$(cat "$BEAT_PIDFILE" 2>/dev/null) | ||
|
|
||
| # If PID exists and is running → warn but continue (avoid killing) | ||
| if kill -0 "$PID" 2>/dev/null; then | ||
|
jwkaltz marked this conversation as resolved.
jwkaltz marked this conversation as resolved.
|
||
| echo "WARNING: Celery Beat seems to be running already (PID $PID). Removing stale pidfile anyway." | ||
| else | ||
| echo "Removing stale Celery Beat pidfile: $BEAT_PIDFILE" | ||
| fi | ||
|
|
||
| rm -f "$BEAT_PIDFILE" | ||
| fi | ||
| # --- END FIX --- | ||
|
|
||
| echo "Starting Celery Beat..." | ||
| $CELERY_BIN -A $CELERY_APP beat --scheduler=$CELERY__BEAT_SCHEDULE \ | ||
| --schedule=$CELERY__BEAT_DB \ | ||
| --loglevel=$CELERY__LOG_LEVEL -f $CELERY__BEAT_LOG --pidfile=/tmp/celerybeat.pid & | ||
|
|
||
| echo "Starting Default Celery Worker..." | ||
| $CELERY_BIN -A $CELERY_APP worker --autoscale=$CELERY__AUTOSCALE_VALUES \ | ||
| --max-memory-per-child=$CELERY__MAX_MEMORY_PER_CHILD $CELERY__OPTS \ | ||
| --statedb=$CELERY__STATE_DB \ | ||
| --loglevel=$CELERY__LOG_LEVEL -n $CELERY__WORKER_NAME -f $CELERY__LOG_FILE \ | ||
| --concurrency=$CELERY__WORKER_CONCURRENCY --max-tasks-per-child=$CELERY__MAX_TASKS_PER_CHILD \ | ||
| -X harvesting & | ||
|
|
||
| echo "Starting Harvester Celery Worker..." | ||
| $CELERY_BIN -A $CELERY_APP worker -Q harvesting \ | ||
| --autoscale=$CELERY__HARVESTER_AUTOSCALE_VALUES \ | ||
| --max-memory-per-child=$CELERY__HARVESTER_MAX_MEMORY_PER_CHILD \ | ||
| --loglevel=$CELERY__LOG_LEVEL \ | ||
| -n $CELERY__HARVESTER_WORKER_NAME \ | ||
| --concurrency=$CELERY__HARVESTER_CONCURRENCY \ | ||
| -f $CELERY__LOG_FILE & | ||
|
jwkaltz marked this conversation as resolved.
|
||
|
|
||
| # Wait for any process to exit | ||
| wait -n | ||
|
|
||
| # Exit with the status of the process that exited first | ||
| # Docker will restart the container if this is non-zero (i.e., a failure) | ||
| exit $? | ||
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,9 @@ | ||
| # Overlay for existing GeoNode settings | ||
|
|
||
| from pathlib import Path | ||
| from geonode.settings import * | ||
|
|
||
| settings_additions = Path("/opt/geonode-custom/settings_additions.py") | ||
|
|
||
| if settings_additions.exists(): | ||
| exec(settings_additions.read_text(encoding="utf-8")) |
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
8 changes: 8 additions & 0 deletions
8
charts/geonode/templates/geonode/celery-cmd-temporary-fix.yaml
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,8 @@ | ||
| # Temporary fix pending https://github.com/GeoNode/geonode/pull/14292 | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: {{ .Release.Name }}-celery-cmd-temporary-fix | ||
| data: | ||
| celery-cmd: | | ||
| {{ .Files.Get "files/celery-cmd-temporary-fix" | indent 4 }} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the
BEAT_PIDFILEis empty,PIDwill be empty, andkill -0 "$PID"will evaluate tokill -0 "", which fails. It is safer to check ifPIDis non-empty before runningkill.