File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed
Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 11# Use Python 3.13 slim image
22FROM python:3.13-slim
33
4+ # Create non-root user
5+ RUN groupadd -r syncuser && useradd -r -g syncuser -u 1000 syncuser
6+
47# Set working directory
58WORKDIR /app
69
@@ -10,6 +13,7 @@ RUN apt-get update && \
1013 libldap2-dev \
1114 libsasl2-dev \
1215 gcc \
16+ procps \
1317 && rm -rf /var/lib/apt/lists/*
1418
1519# Copy requirements first for better layer caching
@@ -21,12 +25,17 @@ RUN pip install --no-cache-dir -r requirements.txt
2125# Copy application code
2226COPY *.py ./
2327
24- # Create log directory
25- RUN mkdir -p /var/log/ldap-openfga-sync
26-
28+ # Copy entrypoint script
2729COPY entrypoint.sh /app/entrypoint.sh
2830RUN chmod +x /app/entrypoint.sh
2931
32+ # Create log directory and set ownership
33+ RUN mkdir -p /var/log/ldap-openfga-sync && \
34+ chown -R syncuser:syncuser /app /var/log/ldap-openfga-sync
35+
36+ # Switch to non-root user
37+ USER syncuser
38+
3039# Expose volume for logs
3140VOLUME ["/var/log/ldap-openfga-sync" ]
3241
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ This script synchronizes group memberships from LDAP to OpenFGA using the [diffs
99- Supports dry-run mode to preview changes before applying them
1010- Users are identified by their email addresses
1111- Comprehensive logging
12+ - Runs as non-root user for enhanced security
1213
1314## Requirements
1415
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ podLabels: {}
3131podSecurityContext :
3232 runAsNonRoot : true
3333 runAsUser : 1000
34+ runAsGroup : 1000
3435 fsGroup : 1000
3536
3637securityContext :
@@ -39,6 +40,8 @@ securityContext:
3940 drop :
4041 - ALL
4142 readOnlyRootFilesystem : false
43+ runAsNonRoot : true
44+ runAsUser : 1000
4245
4346resources :
4447 limits :
You can’t perform that action at this time.
0 commit comments