fix: remove invalid local declarations from bash script
This commit is contained in:
@@ -67,12 +67,12 @@ else
|
|||||||
|
|
||||||
# If containers are running, verify they're not root
|
# If containers are running, verify they're not root
|
||||||
if docker compose -f "$compose_file" ps --services 2>/dev/null | grep -q .; then
|
if docker compose -f "$compose_file" ps --services 2>/dev/null | grep -q .; then
|
||||||
local root_count=0
|
root_count=0
|
||||||
while IFS= read -r service; do
|
while IFS= read -r service; do
|
||||||
[ -z "$service" ] && continue
|
[ -z "$service" ] && continue
|
||||||
local container=$(docker compose -f "$compose_file" ps -q "$service" 2>/dev/null || echo "")
|
container=$(docker compose -f "$compose_file" ps -q "$service" 2>/dev/null || echo "")
|
||||||
if [ -n "$container" ]; then
|
if [ -n "$container" ]; then
|
||||||
local user=$(docker exec "$container" whoami 2>/dev/null || echo "unknown")
|
user=$(docker exec "$container" whoami 2>/dev/null || echo "unknown")
|
||||||
if [ "$user" = "root" ]; then
|
if [ "$user" = "root" ]; then
|
||||||
echo -e " ${RED}✗${NC} Service $service running as ROOT (INF-01 violation)"
|
echo -e " ${RED}✗${NC} Service $service running as ROOT (INF-01 violation)"
|
||||||
((root_count++)) || true
|
((root_count++)) || true
|
||||||
|
|||||||
Reference in New Issue
Block a user