Skip to content

Feat: make errors more helpful - #1263

Merged
jokob-sk merged 14 commits into
netalertx:mainfrom
adamoutler:FEAT--Make-Errors-More-Helpful
Nov 2, 2025
Merged

Feat: make errors more helpful#1263
jokob-sk merged 14 commits into
netalertx:mainfrom
adamoutler:FEAT--Make-Errors-More-Helpful

Conversation

@adamoutler

@adamoutler adamoutler commented Nov 1, 2025

Copy link
Copy Markdown
Member

🎯 Pull Request: Enhanced Error Visibility and Comprehensive Testing

Overview

This PR significantly improves NetAlertX's error reporting and diagnostic capabilities by introducing a visual status grid, comprehensive documentation links, and extensive unit testing. The primary feature is an intuitive ✅/❌/➖ status table that makes configuration issues immediately visible to users.

Key Features

🏗️ Visual Status Grid

  • New diagnostic table showing mount configuration status with clear visual indicators:
    • Good: Configuration meets requirements
    • Issue: Problem detected that needs attention
    • N/A: Not applicable for this path type
  • Columns: Writeable | Mount | RAMDisk | Performance | DataLoss
  • Rows: All critical NetAlertX paths (DB, Config, API, Log, Services)

📚 Comprehensive Documentation

  • 12 new troubleshooting guides with specific solutions for each error type
  • Direct links from error messages to relevant documentation
  • Security-focused explanations for why each issue matters
  • Actionable remediation steps for each problem type

🧪 Extensive Test Suite

  • 53 Docker integration tests covering all error scenarios
  • 25 mount diagnostic tests validating the status grid
  • Automated test infrastructure using docker-compose configurations
  • Container lifecycle testing for startup checks and runtime diagnostics

Technical Changes

Script Reorganization

  • Consolidated 11 separate check scripts into organized /entrypoint.d/ directory
  • Improved startup sequence and error handling
  • Enhanced permission and capability validation

Enhanced Diagnostics

  • Created comprehensive mount diagnostic script (10-mounts.py)
  • Implemented visual status grid with emoji indicators
  • Added documentation links to all error messages

Testing Infrastructure

  • Migrated from manual docker run to docker-compose based testing
  • Added 24 docker-compose test configurations
  • Improved test reliability and speed
  • Fixed test expectations for root user warnings vs failures

Example Output

+---------------+-----------+-------+---------+-------------+----------+
| Path          | Writeable | Mount | RAMDisk | Performance | DataLoss |
+---------------+-----------+-------+---------+-------------+----------+
| /app/db       | ✅        | ✅    | ➖      | ➖          | ✅       |
| /app/config   | ✅        | ✅    | ➖      | ➖          | ✅       |
| /app/api      | ✅        | ❌    | ❌      | ❌          | ✅       |
| /app/log      | ✅        | ❌    | ❌      | ❌          | ✅       |
| /services/run | ✅        | ❌    | ❌      | ❌          | ✅       |

══════════════════════════════════════════════════════════════════════════════
⚠️ ATTENTION: Configuration issues detected (marked with ❌).

Your configuration has write permission, dataloss, or performance issues
as shown in the table above.

We recommend starting with the default [docker-compose.yml](http://_vscodecontentref_/1) as the
configuration can be quite complex.

Review the documentation for a correct setup:
https://github.com/jokob-sk/NetAlertX/blob/main/docs/DOCKER_COMPOSE.md
https://github.com/jokob-sk/NetAlertX/blob/main/docs/docker-troubleshooting/mount-configuration-issues.md
══════════════════════════════════════════════════════════════════════════════

Impact

  • User Experience: Errors are now immediately understandable with visual indicators
  • Troubleshooting: Direct links to specific solutions reduce support burden
  • Reliability: Comprehensive testing ensures configuration issues are caught early
  • Security: Clear warnings about data loss and permission risks

Testing

  • ✅ All 53 Docker tests passing
  • ✅ Mount diagnostics working correctly
  • ✅ Error messages include documentation links
  • ✅ Visual grid displays properly in all scenarios

This PR transforms NetAlertX's error handling from cryptic messages to actionable, visually clear diagnostics that guide users to correct configurations quickly and confidently.

I will check back tomorrow on CodeRabbit analysis.

Summary by CodeRabbit

  • New Features

    • New startup checks and diagnostics: human-readable mount/permission/capability/port table, integrity and port-availability warnings, and a configurable checks directory; startup now continues to allow inspection.
  • Documentation

    • Added comprehensive Docker troubleshooting guides covering mounts, permissions, users/capabilities, ports, read-only root, and related remediation.
  • Tests

    • Large expansion of Docker Compose and mount/permission integration tests across many scenarios.
  • Bug Fixes

    • Clearer startup messages and improved handling of file-permission and capability warnings.

@coderabbitai

coderabbitai Bot commented Nov 1, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds an entrypoint checks directory, many new entrypoint.d health/permission/mount-check scripts (including a Python mount analyzer), updates entrypoint orchestration to run those checks and continue on failures, removes several legacy service scripts, updates Dockerfiles to include the checks path and adjust permissions, and adds extensive Docker troubleshooting docs and compose test fixtures.

Changes

Cohort / File(s) Summary
Dockerfiles
\.devcontainer/Dockerfile, Dockerfile
Introduce ENTRYPOINT_CHECKS=/entrypoint.d and SYSTEM_SERVICES_ACTIVE_CONFIG; include ${ENTRYPOINT_CHECKS} in READ_ONLY_FOLDERS; extend final chmod to cover ${SYSTEM_SERVICES_SCRIPTS}/* and ${ENTRYPOINT_CHECKS}/*.
New entrypoint checks
install/production-filesystem/entrypoint.d/*
Add many scripts: 0-storage-permission.sh, 10-mounts.py (mount analyzer), 15-first-run-config.sh, 20-first-run-db.sh, 30-writable-config.sh, 35-nginx-config.sh (PORT gating, uses SYSTEM_SERVICES_ACTIVE_CONFIG), 60-user-netalertx.sh, 80-host-mode-network.sh, 85-layer-2-capabilities.sh, 90-excessive-capabilities.sh, 95-appliance-integrity.sh, 99-ports-available.sh.
Entrypoint orchestration
install/production-filesystem/entrypoint.sh
Discover and execute ${ENTRYPOINT_CHECKS}/* directly (strip numeric prefixes for display); run scripts as executables; log failures but continue startup (no immediate exit); banner rendered via color variables.
Removed legacy checks
install/production-filesystem/services/scripts/*
Delete legacy scripts: check-app-permissions.sh, check-nonpersistent-storage.sh, check-persistent-storage.sh, check-ramdisk.sh, check-root.sh (functionality migrated into new entrypoint.d set).
Mount analyzer (Python)
install/production-filesystem/entrypoint.d/10-mounts.py
New MountCheckResult dataclass and full mount analysis: parse /proc/mounts, evaluate writeability, mount point, fstype/ramdisk, set performance/dataloss/write-error flags, print table, warn and exit 1 on write errors (unless NETALERTX_DEBUG=1).
Writability & PORT gating
install/production-filesystem/entrypoint.d/35-nginx-config.sh
Switch to SYSTEM_SERVICES_ACTIVE_CONFIG, add early exit when PORT=20211 (skip checks), and append doc links to messages.
Formatting & docs tweaks
install/production-filesystem/entrypoint.d/15-first-run-config.sh, 20-first-run-db.sh, 60-user-netalertx.sh, 80-host-mode-network.sh, 85-layer-2-capabilities.sh
Use printf for ANSI escapes, adjust header text and troubleshooting links; behavioral logic unchanged.
Capability & integrity checks
install/production-filesystem/entrypoint.d/90-excessive-capabilities.sh, 95-appliance-integrity.sh
New scripts: detect excessive bounding capabilities and warn; detect root FS not mounted read-only and warn.
Port availability check
install/production-filesystem/entrypoint.d/99-ports-available.sh
New non-fatal checks for port conflicts (uses netstat where available), warns if app/GraphQL ports collide or are in use.
Permission remediation relocated
install/production-filesystem/entrypoint.d/0-storage-permission.sh
New root-run remediation/ownership adjustments (replaces prior check-app-permissions.sh behavior) and then sleeps to draw attention when run as root.
Docs: troubleshooting
docs/docker-troubleshooting/*
Add many docs: excessive-capabilities.md, file-permissions.md, incorrect-user.md, missing-capabilities.md, mount-configuration-issues.md, network-mode.md, nginx-configuration-mount.md, port-conflicts.md, read-only-filesystem.md, running-as-root.md.
Tests: docker-compose fixtures
test/docker_tests/configurations/*, .../mount-tests/*
Add ~27 docker-compose fixtures (readonly/writable + mount-tests matrix) covering mount, capability, port and permission scenarios.
Tests: suites & runners
test/docker_tests/test_*.py, test/docker_tests/configurations/test_all_docker_composes.sh
Add/modify tests and helpers: test_container_environment.py, test_docker_compose_scenarios.py, test_mount_diagnostics_pytest.py, test_ports_available.py, and test_all_docker_composes.sh to exercise new checks and compose fixtures.

Sequence Diagram(s)

sequenceDiagram
    participant C as Container Init
    participant E as entrypoint.sh
    participant EC as ${ENTRYPOINT_CHECKS}/*
    participant M as 10-mounts.py
    participant A as Application

    C->>E: start
    E->>E: render banner
    loop each script in ${ENTRYPOINT_CHECKS}
        E->>EC: exec script (executable)
        EC-->>E: output + exit code
        E->>E: log result (continue even on failure)
    end
    alt 10-mounts.py reports write errors and NETALERTX_DEBUG != "1"
        EC->>E: prints table & warnings
        E->>C: propagate non-zero exit (entrypoint behavior may stop)
    else
        E->>A: proceed to start application
    end
Loading
sequenceDiagram
    participant P as 10-mounts.py
    participant V as Env vars
    participant F as /proc/mounts
    participant O as stderr/table

    P->>V: read PATHS_TO_CHECK and flags
    P->>F: parse mounted filesystems
    loop per path
        P->>V: resolve path value
        P->>F: match mount point & fstype
        P->>P: evaluate writeable/mounted/ramdisk & risk flags
    end
    P->>O: print diagnostic table
    alt write errors and NETALERTX_DEBUG != "1"
        P->>O: print warnings
        P->>P: exit(1)
    else
        P->>P: exit(0)
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Focus areas for review:

  • install/production-filesystem/entrypoint.d/10-mounts.py — mount matching, RAM-disk classification, risk logic, table formatting, and exit semantics.
  • install/production-filesystem/entrypoint.sh — discovery/exec model, name-stripping logic, and changed failure handling (now continues).
  • Dockerfile & .devcontainer — ensure ${ENTRYPOINT_CHECKS} inclusion and final chmod targets are correct.
  • Verification that removed legacy scripts’ checks are fully covered by new entrypoint.d scripts to avoid regressions.
  • Test fixtures and pytest assertions — confirm expected outputs align with new startup behavior.

Possibly related PRs

Poem

🐰 I hopped in at boot to guard each mount and port,
I sniffed the caps and perms and gave a tiny snort.
A table I drew, I warn and I cheer,
With carrot-powered scripts I keep the startup clear.
🥕 Soft paws, loud warnings — I watch this container fort.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "Feat: make errors more helpful" is directly related to a primary objective of the changeset. The raw summary and PR objectives confirm that a core goal is to improve error reporting and diagnostics through the addition of 12 new troubleshooting documentation files, enhanced error messages with direct documentation links, a new comprehensive mount diagnostic script with visual status grids using emoji indicators, and actionable remediation guidance. While the PR also includes significant refactoring of entrypoint scripts and extensive test infrastructure changes, the title accurately captures the user-facing intent of making error information more helpful and actionable. A developer scanning git history would clearly understand this PR is about improving error visibility and guidance.
Docstring Coverage ✅ Passed Docstring coverage is 91.67% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 23a0fac and dde542c.

📒 Files selected for processing (2)
  • .devcontainer/Dockerfile (3 hunks)
  • Dockerfile (3 hunks)
🧰 Additional context used
🧠 Learnings (9)
📓 Common learnings
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1263
File: install/production-filesystem/entrypoint.sh:60-86
Timestamp: 2025-11-01T19:02:10.609Z
Learning: In the NetAlertX project (install/production-filesystem/entrypoint.sh), when fail-fast behavior is adopted for entrypoint checks in the future, be lenient during review because tests will be removed or changed to accommodate that behavior. The current continue-on-failure approach exists to support the existing test suite, but this is expected to change along with corresponding test adjustments.
📚 Learning: 2025-09-20T03:01:19.912Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/Dockerfile:18-19
Timestamp: 2025-09-20T03:01:19.912Z
Learning: In the NetAlertX repository, .devcontainer/Dockerfile is auto-generated and should not be reviewed directly. Review comments about dependencies and build steps should be directed at the root Dockerfile where the actual source commands are located.

Applied to files:

  • .devcontainer/Dockerfile
📚 Learning: 2025-10-19T15:29:49.532Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1230
File: install/production-filesystem/build/init-nginx.sh:3-3
Timestamp: 2025-10-19T15:29:49.532Z
Learning: In Docker build-time initialization scripts (like those in install/production-filesystem/build/), environment variables set in the Dockerfile do not need explicit validation within the scripts. The Docker build process will fail if required environment variables are undefined, providing implicit validation.

Applied to files:

  • .devcontainer/Dockerfile
  • Dockerfile
📚 Learning: 2025-09-20T02:56:24.501Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/devcontainer.json:5-8
Timestamp: 2025-09-20T02:56:24.501Z
Learning: In the NetAlertX devcontainer setup, the final .devcontainer/Dockerfile is generated by combining the root Dockerfile with .devcontainer/resources/devcontainer-Dockerfile using the generate-dockerfile.sh script. The devcontainer.json should reference the generated file, not the root Dockerfile.

Applied to files:

  • .devcontainer/Dockerfile
📚 Learning: 2025-10-19T01:40:57.095Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1230
File: .devcontainer/resources/devcontainer-overlay/services/config/nginx/netalertx.conf.template:1-2
Timestamp: 2025-10-19T01:40:57.095Z
Learning: In the NetAlertX repository, .devcontainer/resources/devcontainer-overlay/services/config/nginx/netalertx.conf.template is an auto-generated file that is intentionally committed to source control. It cannot be regenerated automatically outside the devcontainer environment and is required for the devcontainer to start, creating a bootstrap dependency.

Applied to files:

  • .devcontainer/Dockerfile
  • Dockerfile
📚 Learning: 2025-09-20T14:08:44.152Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/Dockerfile:82-92
Timestamp: 2025-09-20T14:08:44.152Z
Learning: In devcontainer builds, source repository files are not available during the Docker build phase. The source code gets mounted into the container after it's built and started, so COPY commands referencing source files will fail. Configuration files need to be handled at runtime (e.g., in setup scripts) rather than during the build stage.

Applied to files:

  • .devcontainer/Dockerfile
📚 Learning: 2025-10-26T17:09:18.621Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1235
File: .devcontainer/scripts/setup.sh:146-148
Timestamp: 2025-10-26T17:09:18.621Z
Learning: In `.devcontainer/scripts/setup.sh` and other devcontainer setup scripts for NetAlertX, chmod 666 on /var/run/docker.sock is acceptable because devcontainer environments are single-user development contexts where convenience can take priority over strict permission hardening.

Applied to files:

  • .devcontainer/Dockerfile
  • Dockerfile
📚 Learning: 2025-09-20T14:09:29.159Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/scripts/setup.sh:103-116
Timestamp: 2025-09-20T14:09:29.159Z
Learning: In NetAlertX devcontainer setup, the netalertx user has write permissions to /var/log/nginx/ directory as it's explicitly chowned to netalertx:www-data in the Dockerfile, so setup.sh can write to nginx log files without sudo.

Applied to files:

  • .devcontainer/Dockerfile
  • Dockerfile
📚 Learning: 2025-10-26T17:12:30.237Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1235
File: install/production-filesystem/services/start-php-fpm.sh:25-26
Timestamp: 2025-10-26T17:12:30.237Z
Learning: In NetAlertX's start-php-fpm.sh, PHP-FPM error logging is handled through the PHP-FPM configuration file (PHP_FPM_CONFIG_FILE) rather than through shell redirection. The current redirection pattern (stdout to LOG_APP_PHP_ERRORS, stderr to /dev/stderr) is intentional.

Applied to files:

  • .devcontainer/Dockerfile
  • Dockerfile
🔇 Additional comments (4)
Dockerfile (3)

72-72: Environment variables correctly defined for entrypoint checks and nginx active config.

Line 72 introduces ENTRYPOINT_CHECKS=/entrypoint.d for the consolidated check scripts, and line 78 adds SYSTEM_SERVICES_ACTIVE_CONFIG to reference the nginx active configuration. Both variables follow project naming conventions and support the entrypoint diagnostic workflow described in the PR.

Also applies to: 78-78


87-87: READ_ONLY_FOLDERS correctly includes entrypoint checks directory.

Adding ${ENTRYPOINT_CHECKS} to READ_ONLY_FOLDERS ensures check scripts remain immutable at runtime, which aligns with the security-hardened stage design and prevents accidental or malicious modification of diagnostics.


186-186: All entrypoint check scripts have proper shebangs and chmod 005 permissions are correctly applied.

Verification confirms:

  • All 13 scripts in /entrypoint.d/ have valid shebangs (10× #!/bin/sh, 2× #!/bin/bash, 1× #!/usr/bin/env python3)
  • entrypoint.sh executes scripts directly via "$script" (line 59), requiring both execute permission and shebangs
  • chmod 005 permissions on ${ENTRYPOINT_CHECKS}/* correctly grants read-execute to the netalertx user
  • The hardened security model is sound and functional
.devcontainer/Dockerfile (1)

75-75: Auto-generated file: changes consistent with main Dockerfile.

This file is auto-generated by .devcontainer/scripts/generate-configs.sh (per line 1). The changes to lines 75, 81, 90, and 189 mirror the main Dockerfile updates and require no separate review. Any issues flagged for the main Dockerfile apply here as well.

Also applies to: 81-81, 90-90, 189-189


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 17

🧹 Nitpick comments (3)
test/docker_tests/configurations/mount-tests/docker-compose.mount-test.active_config_mounted.yml (1)

44-52: Unused volume declarations reduce clarity.

Lines 44-52 declare 8 named volumes, but only 3 are actually referenced in the service (netalertx_db, netalertx_config, test_system_services_active_config). The others (test_netalertx_db, test_netalertx_config, test_netalertx_api, test_netalertx_log, test_system_services_run) appear unused.

Consider removing unused declarations or adding comments explaining their purpose. If they're shared across multiple test configurations, consolidating them into a separate compose file or clarifying their intent would improve maintainability.

test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_ramdisk.yml (1)

41-49: Duplicate unused volume declarations.

This file repeats the same unused volume declarations from the previous mount-test configuration (8 declared, only 3 referenced in netalertx_db, netalertx_config, and test_system_services_run).

Consider consolidating these common volume declarations into a shared base or compose fragment to reduce duplication across test configurations.

test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_no-mount.yml (1)

40-48: Unused volume declarations reduce clarity (consistent pattern).

This file repeats the same 8 unused volume declarations from previous test configurations. Only 3 are actually referenced (netalertx_db, netalertx_config, test_netalertx_api).

Consolidate these common declarations across all mount-test configurations into a shared compose fragment or base file to improve maintainability.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ff96d38 and 79887f0.

⛔ Files ignored due to path filters (1)
  • test/docker_tests/configurations/test_results.log is excluded by !**/*.log
📒 Files selected for processing (64)
  • .devcontainer/Dockerfile (3 hunks)
  • Dockerfile (3 hunks)
  • docs/docker-troubleshooting/excessive-capabilities.md (1 hunks)
  • docs/docker-troubleshooting/file-permissions.md (1 hunks)
  • docs/docker-troubleshooting/incorrect-user.md (1 hunks)
  • docs/docker-troubleshooting/missing-capabilities.md (1 hunks)
  • docs/docker-troubleshooting/mount-configuration-issues.md (1 hunks)
  • docs/docker-troubleshooting/network-mode.md (1 hunks)
  • docs/docker-troubleshooting/nginx-configuration-mount.md (1 hunks)
  • docs/docker-troubleshooting/port-conflicts.md (1 hunks)
  • docs/docker-troubleshooting/read-only-filesystem.md (1 hunks)
  • docs/docker-troubleshooting/running-as-root.md (1 hunks)
  • install/production-filesystem/entrypoint.d/0-storage-permission.sh (1 hunks)
  • install/production-filesystem/entrypoint.d/10-mounts.py (1 hunks)
  • install/production-filesystem/entrypoint.d/15-first-run-config.sh (1 hunks)
  • install/production-filesystem/entrypoint.d/20-first-run-db.sh (2 hunks)
  • install/production-filesystem/entrypoint.d/30-writable-config.sh (1 hunks)
  • install/production-filesystem/entrypoint.d/35-nginx-config.sh (3 hunks)
  • install/production-filesystem/entrypoint.d/60-user-netalertx.sh (1 hunks)
  • install/production-filesystem/entrypoint.d/80-host-mode-network.sh (3 hunks)
  • install/production-filesystem/entrypoint.d/85-layer-2-capabilities.sh (2 hunks)
  • install/production-filesystem/entrypoint.d/90-excessive-capabilities.sh (1 hunks)
  • install/production-filesystem/entrypoint.d/95-appliance-integrity.sh (1 hunks)
  • install/production-filesystem/entrypoint.d/99-ports-available.sh (1 hunks)
  • install/production-filesystem/entrypoint.sh (1 hunks)
  • install/production-filesystem/services/scripts/check-app-permissions.sh (0 hunks)
  • install/production-filesystem/services/scripts/check-nonpersistent-storage.sh (0 hunks)
  • install/production-filesystem/services/scripts/check-persistent-storage.sh (0 hunks)
  • install/production-filesystem/services/scripts/check-ramdisk.sh (0 hunks)
  • install/production-filesystem/services/scripts/check-root.sh (0 hunks)
  • test/docker_tests/configurations/README.md (1 hunks)
  • test/docker_tests/configurations/docker-compose.missing-caps.yml (1 hunks)
  • test/docker_tests/configurations/docker-compose.readonly.yml (1 hunks)
  • test/docker_tests/configurations/docker-compose.writable.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/README.md (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.active_config_mounted.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.active_config_no-mount.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.active_config_ramdisk.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.active_config_unwritable.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_mounted.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_no-mount.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_ramdisk.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_unwritable.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_mounted.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_no-mount.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_ramdisk.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_unwritable.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_mounted.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_no-mount.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_ramdisk.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_unwritable.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_mounted.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_no-mount.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_ramdisk.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_unwritable.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_mounted.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_no-mount.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_ramdisk.yml (1 hunks)
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_unwritable.yml (1 hunks)
  • test/docker_tests/configurations/test_all_docker_composes.sh (1 hunks)
  • test/docker_tests/test_container_environment.py (10 hunks)
  • test/docker_tests/test_docker_compose_scenarios.py (1 hunks)
  • test/docker_tests/test_mount_diagnostics_pytest.py (1 hunks)
  • test/docker_tests/test_ports_available.py (1 hunks)
💤 Files with no reviewable changes (5)
  • install/production-filesystem/services/scripts/check-app-permissions.sh
  • install/production-filesystem/services/scripts/check-ramdisk.sh
  • install/production-filesystem/services/scripts/check-root.sh
  • install/production-filesystem/services/scripts/check-persistent-storage.sh
  • install/production-filesystem/services/scripts/check-nonpersistent-storage.sh
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use 'logger.mylog' for logging at levels: none, minimal, verbose, debug, or trace.

Files:

  • test/docker_tests/test_container_environment.py
  • install/production-filesystem/entrypoint.d/10-mounts.py
  • test/docker_tests/test_mount_diagnostics_pytest.py
  • test/docker_tests/test_docker_compose_scenarios.py
  • test/docker_tests/test_ports_available.py
test/**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Tests must reside under 'test/' and use pytest.

Files:

  • test/docker_tests/test_container_environment.py
  • test/docker_tests/test_mount_diagnostics_pytest.py
  • test/docker_tests/test_docker_compose_scenarios.py
  • test/docker_tests/test_ports_available.py
🧠 Learnings (18)
📓 Common learnings
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/Dockerfile:18-19
Timestamp: 2025-09-20T03:01:19.912Z
Learning: In the NetAlertX repository, .devcontainer/Dockerfile is auto-generated and should not be reviewed directly. Review comments about dependencies and build steps should be directed at the root Dockerfile where the actual source commands are located.
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1235
File: .devcontainer/scripts/setup.sh:146-148
Timestamp: 2025-10-26T17:09:18.621Z
Learning: In `.devcontainer/scripts/setup.sh` and other devcontainer setup scripts for NetAlertX, chmod 666 on /var/run/docker.sock is acceptable because devcontainer environments are single-user development contexts where convenience can take priority over strict permission hardening.
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/scripts/setup.sh:103-116
Timestamp: 2025-09-20T14:09:29.159Z
Learning: In NetAlertX devcontainer setup, the netalertx user has write permissions to /var/log/nginx/ directory as it's explicitly chowned to netalertx:www-data in the Dockerfile, so setup.sh can write to nginx log files without sudo.
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/devcontainer.json:5-8
Timestamp: 2025-09-20T02:56:24.501Z
Learning: In the NetAlertX devcontainer setup, the final .devcontainer/Dockerfile is generated by combining the root Dockerfile with .devcontainer/resources/devcontainer-Dockerfile using the generate-dockerfile.sh script. The devcontainer.json should reference the generated file, not the root Dockerfile.
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/scripts/stream-logs.sh:5-6
Timestamp: 2025-09-20T14:08:44.292Z
Learning: The .devcontainer/scripts/stream-logs.sh script in NetAlertX is designed as a diagnostic tool for troubleshooting devcontainer startup issues. When log files don't exist, this indicates that the executable/services didn't start properly, which is valuable diagnostic information. Pre-creating missing files would mask this diagnostic behavior.
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/scripts/setup.sh:90-96
Timestamp: 2025-09-20T14:08:48.256Z
Learning: In the NetAlertX devcontainer setup, the setup.sh script intentionally removes user_notifications.json from the API directory during development environment initialization to prevent notification clutter that accumulates during container launches and development work.
📚 Learning: 2025-10-26T17:09:18.621Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1235
File: .devcontainer/scripts/setup.sh:146-148
Timestamp: 2025-10-26T17:09:18.621Z
Learning: In `.devcontainer/scripts/setup.sh` and other devcontainer setup scripts for NetAlertX, chmod 666 on /var/run/docker.sock is acceptable because devcontainer environments are single-user development contexts where convenience can take priority over strict permission hardening.

Applied to files:

  • docs/docker-troubleshooting/running-as-root.md
  • docs/docker-troubleshooting/file-permissions.md
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_mounted.yml
  • install/production-filesystem/entrypoint.d/90-excessive-capabilities.sh
  • install/production-filesystem/entrypoint.d/30-writable-config.sh
  • docs/docker-troubleshooting/incorrect-user.md
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_ramdisk.yml
  • .devcontainer/Dockerfile
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_ramdisk.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_unwritable.yml
  • install/production-filesystem/entrypoint.d/35-nginx-config.sh
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_mounted.yml
  • docs/docker-troubleshooting/mount-configuration-issues.md
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_unwritable.yml
  • install/production-filesystem/entrypoint.d/60-user-netalertx.sh
  • test/docker_tests/configurations/docker-compose.writable.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_mounted.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_unwritable.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.active_config_unwritable.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_ramdisk.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_mounted.yml
  • install/production-filesystem/entrypoint.d/0-storage-permission.sh
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_mounted.yml
  • Dockerfile
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_unwritable.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_unwritable.yml
📚 Learning: 2025-09-20T03:01:19.912Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/Dockerfile:18-19
Timestamp: 2025-09-20T03:01:19.912Z
Learning: In the NetAlertX repository, .devcontainer/Dockerfile is auto-generated and should not be reviewed directly. Review comments about dependencies and build steps should be directed at the root Dockerfile where the actual source commands are located.

Applied to files:

  • docs/docker-troubleshooting/running-as-root.md
  • docs/docker-troubleshooting/file-permissions.md
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_mounted.yml
  • docs/docker-troubleshooting/port-conflicts.md
  • docs/docker-troubleshooting/incorrect-user.md
  • .devcontainer/Dockerfile
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_ramdisk.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_unwritable.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_mounted.yml
  • docs/docker-troubleshooting/mount-configuration-issues.md
  • install/production-filesystem/entrypoint.d/60-user-netalertx.sh
  • test/docker_tests/configurations/docker-compose.writable.yml
  • test/docker_tests/configurations/README.md
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_mounted.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_ramdisk.yml
  • test/docker_tests/configurations/docker-compose.missing-caps.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_no-mount.yml
  • test/docker_tests/configurations/docker-compose.readonly.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_mounted.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.active_config_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.active_config_ramdisk.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_mounted.yml
  • Dockerfile
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_unwritable.yml
📚 Learning: 2025-09-20T14:09:29.159Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/scripts/setup.sh:103-116
Timestamp: 2025-09-20T14:09:29.159Z
Learning: In NetAlertX devcontainer setup, the netalertx user has write permissions to /var/log/nginx/ directory as it's explicitly chowned to netalertx:www-data in the Dockerfile, so setup.sh can write to nginx log files without sudo.

Applied to files:

  • docs/docker-troubleshooting/running-as-root.md
  • docs/docker-troubleshooting/nginx-configuration-mount.md
  • docs/docker-troubleshooting/file-permissions.md
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_mounted.yml
  • install/production-filesystem/entrypoint.d/30-writable-config.sh
  • docs/docker-troubleshooting/incorrect-user.md
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_ramdisk.yml
  • .devcontainer/Dockerfile
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_ramdisk.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_unwritable.yml
  • install/production-filesystem/entrypoint.d/35-nginx-config.sh
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_mounted.yml
  • docs/docker-troubleshooting/mount-configuration-issues.md
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.active_config_mounted.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_unwritable.yml
  • install/production-filesystem/entrypoint.d/60-user-netalertx.sh
  • test/docker_tests/configurations/docker-compose.writable.yml
  • test/docker_tests/configurations/README.md
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_mounted.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_ramdisk.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_unwritable.yml
  • test/docker_tests/configurations/docker-compose.missing-caps.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.active_config_unwritable.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_ramdisk.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_no-mount.yml
  • test/docker_tests/configurations/docker-compose.readonly.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_mounted.yml
  • install/production-filesystem/entrypoint.d/0-storage-permission.sh
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.active_config_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_ramdisk.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.active_config_ramdisk.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_mounted.yml
  • Dockerfile
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_unwritable.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_unwritable.yml
📚 Learning: 2025-10-19T15:29:46.423Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1230
File: front/plugins/dhcp_servers/script.py:44-44
Timestamp: 2025-10-19T15:29:46.423Z
Learning: In the NetAlertX dhcp_servers plugin (front/plugins/dhcp_servers/script.py), the nmap command uses both 'sudo' and '--privileged' flag to maintain cross-platform compatibility. While the hardened Docker image stubs sudo and uses capabilities, hardware installations (Debian 12, Ubuntu 24) and the Debian Dockerfile require sudo for raw socket access. This approach ensures the plugin works across all deployment targets.

Applied to files:

  • docs/docker-troubleshooting/running-as-root.md
  • docs/docker-troubleshooting/missing-capabilities.md
  • docs/docker-troubleshooting/network-mode.md
  • install/production-filesystem/entrypoint.d/85-layer-2-capabilities.sh
  • docs/docker-troubleshooting/excessive-capabilities.md
📚 Learning: 2025-10-19T01:40:57.095Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1230
File: .devcontainer/resources/devcontainer-overlay/services/config/nginx/netalertx.conf.template:1-2
Timestamp: 2025-10-19T01:40:57.095Z
Learning: In the NetAlertX repository, .devcontainer/resources/devcontainer-overlay/services/config/nginx/netalertx.conf.template is an auto-generated file that is intentionally committed to source control. It cannot be regenerated automatically outside the devcontainer environment and is required for the devcontainer to start, creating a bootstrap dependency.

Applied to files:

  • docs/docker-troubleshooting/nginx-configuration-mount.md
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_mounted.yml
  • docs/docker-troubleshooting/port-conflicts.md
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_ramdisk.yml
  • .devcontainer/Dockerfile
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_ramdisk.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_no-mount.yml
  • install/production-filesystem/entrypoint.d/35-nginx-config.sh
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_mounted.yml
  • docs/docker-troubleshooting/mount-configuration-issues.md
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.active_config_mounted.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_unwritable.yml
  • install/production-filesystem/entrypoint.d/60-user-netalertx.sh
  • test/docker_tests/configurations/docker-compose.writable.yml
  • test/docker_tests/configurations/README.md
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_mounted.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_ramdisk.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_unwritable.yml
  • test/docker_tests/configurations/docker-compose.missing-caps.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.active_config_unwritable.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_ramdisk.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_no-mount.yml
  • test/docker_tests/configurations/docker-compose.readonly.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_mounted.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.active_config_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_ramdisk.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.active_config_ramdisk.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_mounted.yml
  • Dockerfile
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_unwritable.yml
📚 Learning: 2025-10-26T16:45:41.247Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1235
File: install/production-filesystem/services/scripts/check-ramdisk.sh:0-0
Timestamp: 2025-10-26T16:45:41.247Z
Learning: In NetAlertX check scripts (install/production-filesystem/services/scripts/check-*.sh), not all checks should exit with non-zero status. Some checks, like check-ramdisk.sh, are warning-only and exit 0 even when issues are detected, allowing the application to start despite suboptimal configuration.

Applied to files:

  • install/production-filesystem/entrypoint.d/95-appliance-integrity.sh
  • install/production-filesystem/entrypoint.d/30-writable-config.sh
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_ramdisk.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_ramdisk.yml
  • test/docker_tests/test_container_environment.py
  • install/production-filesystem/entrypoint.d/35-nginx-config.sh
  • install/production-filesystem/entrypoint.sh
  • install/production-filesystem/entrypoint.d/60-user-netalertx.sh
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_ramdisk.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_ramdisk.yml
  • install/production-filesystem/entrypoint.d/0-storage-permission.sh
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_ramdisk.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.active_config_ramdisk.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_no-mount.yml
📚 Learning: 2025-09-20T14:13:33.635Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/Dockerfile:11-16
Timestamp: 2025-09-20T14:13:33.635Z
Learning: In the NetAlertX devcontainer setup, the `python -m venv /opt/venv` command works successfully on Alpine 3.22 despite the typical Alpine behavior of not providing a /usr/bin/python symlink by default. The build completes successfully and pytest runs without issues.

Applied to files:

  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_mounted.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_mounted.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.active_config_mounted.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_mounted.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_mounted.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_mounted.yml
📚 Learning: 2025-10-26T15:39:36.707Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1235
File: install/production-filesystem/services/scripts/check-first-run-config.sh:0-0
Timestamp: 2025-10-26T15:39:36.707Z
Learning: In NetAlertX startup scripts, critical initialization failures (e.g., unable to create config directory or copy default config files) should exit with non-zero status to fail fast and provide clear error messages, rather than continuing in a broken state.

Applied to files:

  • install/production-filesystem/entrypoint.d/30-writable-config.sh
  • test/docker_tests/test_container_environment.py
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_unwritable.yml
  • install/production-filesystem/entrypoint.sh
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_unwritable.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.active_config_unwritable.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_unwritable.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_unwritable.yml
📚 Learning: 2025-09-20T14:08:44.292Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/scripts/stream-logs.sh:5-6
Timestamp: 2025-09-20T14:08:44.292Z
Learning: The .devcontainer/scripts/stream-logs.sh script in NetAlertX is designed as a diagnostic tool for troubleshooting devcontainer startup issues. When log files don't exist, this indicates that the executable/services didn't start properly, which is valuable diagnostic information. Pre-creating missing files would mask this diagnostic behavior.

Applied to files:

  • install/production-filesystem/entrypoint.d/30-writable-config.sh
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_ramdisk.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_unwritable.yml
  • install/production-filesystem/entrypoint.d/60-user-netalertx.sh
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_mounted.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.log_unwritable.yml
📚 Learning: 2025-09-20T14:08:48.256Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/scripts/setup.sh:90-96
Timestamp: 2025-09-20T14:08:48.256Z
Learning: In the NetAlertX devcontainer setup, the setup.sh script intentionally removes user_notifications.json from the API directory during development environment initialization to prevent notification clutter that accumulates during container launches and development work.

Applied to files:

  • docs/docker-troubleshooting/incorrect-user.md
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_no-mount.yml
  • install/production-filesystem/entrypoint.d/60-user-netalertx.sh
  • test/docker_tests/configurations/docker-compose.writable.yml
  • test/docker_tests/configurations/README.md
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_ramdisk.yml
  • test/docker_tests/configurations/docker-compose.readonly.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_mounted.yml
📚 Learning: 2025-10-19T15:29:49.532Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1230
File: install/production-filesystem/build/init-nginx.sh:3-3
Timestamp: 2025-10-19T15:29:49.532Z
Learning: In Docker build-time initialization scripts (like those in install/production-filesystem/build/), environment variables set in the Dockerfile do not need explicit validation within the scripts. The Docker build process will fail if required environment variables are undefined, providing implicit validation.

Applied to files:

  • .devcontainer/Dockerfile
  • Dockerfile
📚 Learning: 2025-09-20T02:56:24.501Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/devcontainer.json:5-8
Timestamp: 2025-09-20T02:56:24.501Z
Learning: In the NetAlertX devcontainer setup, the final .devcontainer/Dockerfile is generated by combining the root Dockerfile with .devcontainer/resources/devcontainer-Dockerfile using the generate-dockerfile.sh script. The devcontainer.json should reference the generated file, not the root Dockerfile.

Applied to files:

  • .devcontainer/Dockerfile
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.db_mounted.yml
  • install/production-filesystem/entrypoint.d/60-user-netalertx.sh
  • test/docker_tests/configurations/docker-compose.writable.yml
  • test/docker_tests/configurations/README.md
  • test/docker_tests/configurations/docker-compose.missing-caps.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.run_no-mount.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_no-mount.yml
  • test/docker_tests/configurations/docker-compose.readonly.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.config_mounted.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.active_config_ramdisk.yml
  • test/docker_tests/configurations/mount-tests/docker-compose.mount-test.api_mounted.yml
📚 Learning: 2025-09-20T14:08:44.152Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/Dockerfile:82-92
Timestamp: 2025-09-20T14:08:44.152Z
Learning: In devcontainer builds, source repository files are not available during the Docker build phase. The source code gets mounted into the container after it's built and started, so COPY commands referencing source files will fail. Configuration files need to be handled at runtime (e.g., in setup scripts) rather than during the build stage.

Applied to files:

  • .devcontainer/Dockerfile
📚 Learning: 2025-10-26T17:12:30.237Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1235
File: install/production-filesystem/services/start-php-fpm.sh:25-26
Timestamp: 2025-10-26T17:12:30.237Z
Learning: In NetAlertX's start-php-fpm.sh, PHP-FPM error logging is handled through the PHP-FPM configuration file (PHP_FPM_CONFIG_FILE) rather than through shell redirection. The current redirection pattern (stdout to LOG_APP_PHP_ERRORS, stderr to /dev/stderr) is intentional.

Applied to files:

  • .devcontainer/Dockerfile
  • Dockerfile
📚 Learning: 2025-10-26T17:11:17.499Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1235
File: install/production-filesystem/services/scripts/update_vendors.sh:22-22
Timestamp: 2025-10-26T17:11:17.499Z
Learning: In install/production-filesystem/services/scripts/update_vendors.sh, suppressing wget stderr with 2>/dev/null is intentional; the script's own error handling (line 27: "ERROR: Failed to download or process OUI data") provides adequate feedback when downloads fail in offline environments.

Applied to files:

  • install/production-filesystem/entrypoint.d/80-host-mode-network.sh
📚 Learning: 2025-10-10T22:16:02.770Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1214
File: install/ubuntu24/uninstall.sh:129-141
Timestamp: 2025-10-10T22:16:02.770Z
Learning: NetAlertX uninstall procedures should only remove files from the repository (specifically /app files) and should not touch system packages like PHP, nginx, avahi, or other shared system components to avoid damaging user systems.

Applied to files:

  • install/production-filesystem/entrypoint.d/60-user-netalertx.sh
📚 Learning: 2025-10-10T22:16:02.770Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1214
File: install/ubuntu24/uninstall.sh:129-141
Timestamp: 2025-10-10T22:16:02.770Z
Learning: In the NetAlertX project, hardware installs are not officially supported. Hardware installation methods will be moved from source code to documentation.

Applied to files:

  • install/production-filesystem/entrypoint.d/60-user-netalertx.sh
🧬 Code graph analysis (2)
test/docker_tests/test_container_environment.py (1)
test/docker_tests/test_ports_available.py (4)
  • _assert_contains (153-161)
  • _build_volume_args (80-85)
  • _run_container (88-150)
  • _setup_mount_tree (59-77)
test/docker_tests/test_ports_available.py (1)
test/docker_tests/test_container_environment.py (4)
  • _setup_mount_tree (94-149)
  • _build_volume_args (166-176)
  • _run_container (187-279)
  • _assert_contains (283-293)
🪛 LanguageTool
docs/docker-troubleshooting/read-only-filesystem.md

[style] ~15-~15: Consider using a different verb for a more formal wording.
Context: ...nt filesystem modifications. ## How to Correct the Issue Enable read-only mode: - In...

(FIX_RESOLVE)

docs/docker-troubleshooting/running-as-root.md

[style] ~15-~15: Consider using a different verb for a more formal wording.
Context: ...ervice account for security. ## How to Correct the Issue Switch to the dedicated 'net...

(FIX_RESOLVE)

docs/docker-troubleshooting/nginx-configuration-mount.md

[style] ~15-~15: Consider using a different verb for a more formal wording.
Context: ...n running in read-only mode. ## How to Correct the Issue If you want to use a custom ...

(FIX_RESOLVE)

docs/docker-troubleshooting/file-permissions.md

[style] ~15-~15: Consider using a different verb for a more formal wording.
Context: ...nt, not root or other users. ## How to Correct the Issue Fix permissions on the host ...

(FIX_RESOLVE)

docs/docker-troubleshooting/port-conflicts.md

[style] ~19-~19: Consider using a different verb for a more formal wording.
Context: ...es are set to the same value ## How to Correct the Issue ### Check for Existing NetAl...

(FIX_RESOLVE)

docs/docker-troubleshooting/incorrect-user.md

[style] ~15-~15: Consider using a different verb for a more formal wording.
Context: ...r proper security isolation. ## How to Correct the Issue Restore the container to the...

(FIX_RESOLVE)

docs/docker-troubleshooting/missing-capabilities.md

[style] ~15-~15: Consider using a different verb for a more formal wording.
Context: ...elevated network privileges. ## How to Correct the Issue Add the required capabilitie...

(FIX_RESOLVE)

docs/docker-troubleshooting/network-mode.md

[style] ~15-~15: Consider using a different verb for a more formal wording.
Context: ...scovery and active scanning. ## How to Correct the Issue Enable host networking mode:...

(FIX_RESOLVE)

docs/docker-troubleshooting/mount-configuration-issues.md

[style] ~15-~15: Consider using a different verb for a more formal wording.
Context: ... others should be temporary. ## How to Correct the Issue Review and correct your volu...

(FIX_RESOLVE)

docs/docker-troubleshooting/excessive-capabilities.md

[style] ~15-~15: Consider using a different verb for a more formal wording.
Context: ...ilities for proper function. ## How to Correct the Issue Limit capabilities to only t...

(FIX_RESOLVE)

🪛 Ruff (0.14.2)
test/docker_tests/test_container_environment.py

202-202: subprocess call: check for execution of untrusted input

(S603)


203-203: Starting a process with a partial executable path

(S607)


283-283: PEP 484 prohibits implicit Optional

Convert to T | None

(RUF013)


665-665: String contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF001)


666-666: String contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF001)


694-694: String contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF001)


695-695: String contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF001)

install/production-filesystem/entrypoint.d/10-mounts.py

173-173: String contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF001)


175-175: Do not assign a lambda expression, use a def

Rewrite bool_to_check as a def

(E731)

test/docker_tests/test_mount_diagnostics_pytest.py

1-1: Shebang is present but file is not executable

(EXE001)


12-12: Docstring contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF002)


12-12: Docstring contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF002)


13-13: Docstring contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF002)


13-13: Docstring contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF002)


21-21: Docstring contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF002)


43-43: Comment contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF003)


44-44: Comment contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF003)


86-86: String contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF001)


160-160: subprocess call: check for execution of untrusted input

(S603)


161-161: Starting a process with a partial executable path

(S607)


232-232: Unused function argument: netalertx_test_image

(ARG001)


247-247: subprocess call: check for execution of untrusted input

(S603)


254-254: subprocess call: check for execution of untrusted input

(S603)


268-268: subprocess call: check for execution of untrusted input

(S603)


269-269: Starting a process with a partial executable path

(S607)


275-275: subprocess call: check for execution of untrusted input

(S603)


276-276: Starting a process with a partial executable path

(S607)


287-287: subprocess call: check for execution of untrusted input

(S603)


288-288: Starting a process with a partial executable path

(S607)


374-374: subprocess call: check for execution of untrusted input

(S603)


393-393: subprocess call: check for execution of untrusted input

(S603)


401-401: String contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF001)


401-401: String contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF001)

test/docker_tests/test_docker_compose_scenarios.py

22-22: PEP 484 prohibits implicit Optional

Convert to T | None

(RUF013)


38-38: subprocess call: check for execution of untrusted input

(S603)


50-50: subprocess call: check for execution of untrusted input

(S603)


50-50: Starting a process with a partial executable path

(S607)


55-55: subprocess call: check for execution of untrusted input

(S603)


55-55: Starting a process with a partial executable path

(S607)


66-66: Redefinition of unused time from line 11

Remove definition: time

(F811)


81-81: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


103-103: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


126-126: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


168-168: Unused function argument: env_vars

(ARG001)


168-168: PEP 484 prohibits implicit Optional

Convert to T | None

(RUF013)


180-180: subprocess call: check for execution of untrusted input

(S603)


191-191: subprocess call: check for execution of untrusted input

(S603)


191-191: Starting a process with a partial executable path

(S607)


196-196: subprocess call: check for execution of untrusted input

(S603)


196-196: Starting a process with a partial executable path

(S607)


244-244: Redefinition of unused test_host_network_compose from line 218

(F811)


273-273: Redefinition of unused test_host_network_compose from line 244

(F811)


359-359: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


364-364: f-string without any placeholders

Remove extraneous f prefix

(F541)


365-365: f-string without any placeholders

Remove extraneous f prefix

(F541)


366-366: f-string without any placeholders

Remove extraneous f prefix

(F541)


367-367: f-string without any placeholders

Remove extraneous f prefix

(F541)


412-412: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


417-417: f-string without any placeholders

Remove extraneous f prefix

(F541)


418-418: f-string without any placeholders

Remove extraneous f prefix

(F541)


419-419: f-string without any placeholders

Remove extraneous f prefix

(F541)


420-420: f-string without any placeholders

Remove extraneous f prefix

(F541)

test/docker_tests/test_ports_available.py

43-43: subprocess call: check for execution of untrusted input

(S603)


44-44: Starting a process with a partial executable path

(S607)


56-56: subprocess call: check for execution of untrusted input

(S603)


56-56: Starting a process with a partial executable path

(S607)


70-70: Loop control variable target not used within loop body

Rename unused target to _target

(B007)


107-107: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


131-131: subprocess call: check for execution of untrusted input

(S603)


153-153: PEP 484 prohibits implicit Optional

Convert to T | None

(RUF013)


157-161: Avoid specifying long messages outside the exception class

(TRY003)


164-164: PEP 484 prohibits implicit Optional

Convert to T | None

(RUF013)


168-172: Avoid specifying long messages outside the exception class

(TRY003)


220-220: Unused function argument: dummy_container

(ARG001)

🪛 Shellcheck (0.11.0)
test/docker_tests/configurations/test_all_docker_composes.sh

[warning] 39-39: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 40-40: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 47-47: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)


[warning] 51-51: To redirect stdout+stderr, 2>&1 must be last (or use '{ cmd > file; } 2>&1' to clarify).

(SC2069)

install/production-filesystem/entrypoint.sh

[warning] 42-42: RESET appears unused. Verify use (or export if used externally).

(SC2034)

Comment thread docs/docker-troubleshooting/nginx-configuration-mount.md
Comment thread install/production-filesystem/entrypoint.d/0-storage-permission.sh Outdated
Comment thread install/production-filesystem/entrypoint.d/0-storage-permission.sh Outdated
Comment thread install/production-filesystem/entrypoint.d/0-storage-permission.sh Outdated
Comment thread install/production-filesystem/entrypoint.d/80-host-mode-network.sh Outdated
Comment thread test/docker_tests/test_docker_compose_scenarios.py Outdated
Comment thread test/docker_tests/test_docker_compose_scenarios.py Outdated
Comment thread test/docker_tests/test_mount_diagnostics_pytest.py Outdated
Comment thread test/docker_tests/test_mount_diagnostics_pytest.py Outdated
Comment thread test/docker_tests/test_ports_available.py
@jokob-sk

jokob-sk commented Nov 1, 2025

Copy link
Copy Markdown
Collaborator

This is a big PR - let me know once ready and I'll merge. The table is amazing - easy to recognize what's wrong

@adamoutler
adamoutler marked this pull request as draft November 1, 2025 11:06
@adamoutler
adamoutler marked this pull request as ready for review November 1, 2025 18:19

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (3)
install/production-filesystem/entrypoint.d/0-storage-permission.sh (1)

57-58: Fix find command syntax errors.

Lines 57–58 are missing the terminator for -exec; each must end with + (or ; if preferred). Currently, these commands are malformed and will fail to execute.

-    find ${READ_WRITE_PATHS} -type d -exec chmod u+rwx {}
-    find ${READ_WRITE_PATHS} -type f -exec chmod u+rw {}
+    find "${READ_WRITE_PATHS}" -type d -exec chmod u+rwx {} + 2>/dev/null || true
+    find "${READ_WRITE_PATHS}" -type f -exec chmod u+rw {} + 2>/dev/null || true

The diff also quotes the variable to prevent word-splitting on paths with spaces, adds error suppression for consistency with line 54, and uses + (parallel execution) for efficiency.

test/docker_tests/configurations/test_all_docker_composes.sh (1)

49-55: Remove duplicate cd and docker-compose up commands.

Lines 49 and 51 contain duplicate cd commands (the second lacks error handling). Lines 53 and 55 contain duplicate docker-compose up invocations with different redirect orders. Line 55's redirect order is incorrect (2>&1 must come after >>).

Apply this diff:

     cd "$dirname" || exit 1
-    # Change to the directory containing the docker-compose file
-    cd "$dirname"
 
+    echo "Running docker-compose up..." >> "$LOG_FILE"
     timeout 10s docker-compose -f "$basename" up >> "$LOG_FILE" 2>&1
-    echo "Running docker-compose up..." >> "$LOG_FILE"
-    timeout 10s docker-compose -f "$basename" up 2>&1 >> "$LOG_FILE"
test/docker_tests/test_ports_available.py (1)

122-124: Resolve script path relative to repo root.

The hard-coded relative path "install/production-filesystem/entrypoint.d/99-ports-available.sh" assumes execution from the repo root. In CI or non-standard environments, this open() will raise FileNotFoundError. Use dynamic repo root resolution similar to test_container_environment.py (lines 113-131 in relevant_code_snippets).

Apply this diff:

-    # Copy the script content and run it
-    script_path = "install/production-filesystem/entrypoint.d/99-ports-available.sh"
-    with open(script_path, 'r') as f:
+    # Determine repo root from env or by walking up from this file
+    repo_root_env = os.environ.get("NETALERTX_REPO_ROOT")
+    if repo_root_env:
+        repo_root = pathlib.Path(repo_root_env)
+    else:
+        repo_root = None
+        cur = pathlib.Path(__file__).resolve()
+        for parent in cur.parents:
+            if (parent / "pyproject.toml").exists() or (parent / ".git").exists():
+                repo_root = parent
+                break
+        if repo_root is None:
+            repo_root = cur.parents[2]
+    
+    script_path = repo_root / "install" / "production-filesystem" / "entrypoint.d" / "99-ports-available.sh"
+    with script_path.open('r', encoding='utf-8') as f:
         script_content = f.read()
🧹 Nitpick comments (2)
install/production-filesystem/entrypoint.d/0-storage-permission.sh (1)

54-54: Quote variable expansion in chown for robustness.

Unquoted variable expansion can cause word-splitting if any paths contain spaces or special characters. This is a lower-risk issue than lines 57–58 (syntax errors), but quoting is a defensive best practice:

-    chown -R netalertx ${READ_WRITE_PATHS} 2>/dev/null || true
+    chown -R netalertx "${READ_WRITE_PATHS}" 2>/dev/null || true
test/docker_tests/test_docker_compose_scenarios.py (1)

273-276: Remove extraneous f-string prefixes.

Lines 273-276 (and 326-329) use f-string prefixes without any placeholders. Remove the f prefix for clarity.

Apply this diff:

                 "volumes": [
-                    f"./test_data/app_log:/app/log",
-                    f"./test_data/app_api:/app/api",
-                    f"./test_data/nginx_conf:/services/config/nginx/conf.active",
-                    f"./test_data/services_run:/services/run"
+                    "./test_data/app_log:/app/log",
+                    "./test_data/app_api:/app/api",
+                    "./test_data/nginx_conf:/services/config/nginx/conf.active",
+                    "./test_data/services_run:/services/run"
                 ],

Apply the same fix to lines 326-329.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 79887f0 and 70373b1.

📒 Files selected for processing (8)
  • docs/docker-troubleshooting/nginx-configuration-mount.md (1 hunks)
  • install/production-filesystem/entrypoint.d/0-storage-permission.sh (1 hunks)
  • install/production-filesystem/entrypoint.d/80-host-mode-network.sh (2 hunks)
  • install/production-filesystem/entrypoint.d/90-excessive-capabilities.sh (1 hunks)
  • test/docker_tests/configurations/test_all_docker_composes.sh (1 hunks)
  • test/docker_tests/test_docker_compose_scenarios.py (1 hunks)
  • test/docker_tests/test_mount_diagnostics_pytest.py (1 hunks)
  • test/docker_tests/test_ports_available.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • install/production-filesystem/entrypoint.d/90-excessive-capabilities.sh
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use 'logger.mylog' for logging at levels: none, minimal, verbose, debug, or trace.

Files:

  • test/docker_tests/test_mount_diagnostics_pytest.py
  • test/docker_tests/test_ports_available.py
  • test/docker_tests/test_docker_compose_scenarios.py
test/**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Tests must reside under 'test/' and use pytest.

Files:

  • test/docker_tests/test_mount_diagnostics_pytest.py
  • test/docker_tests/test_ports_available.py
  • test/docker_tests/test_docker_compose_scenarios.py
🧠 Learnings (8)
📚 Learning: 2025-10-26T16:45:41.247Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1235
File: install/production-filesystem/services/scripts/check-ramdisk.sh:0-0
Timestamp: 2025-10-26T16:45:41.247Z
Learning: In NetAlertX check scripts (install/production-filesystem/services/scripts/check-*.sh), not all checks should exit with non-zero status. Some checks, like check-ramdisk.sh, are warning-only and exit 0 even when issues are detected, allowing the application to start despite suboptimal configuration.

Applied to files:

  • install/production-filesystem/entrypoint.d/80-host-mode-network.sh
  • install/production-filesystem/entrypoint.d/0-storage-permission.sh
📚 Learning: 2025-09-20T14:08:44.292Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/scripts/stream-logs.sh:5-6
Timestamp: 2025-09-20T14:08:44.292Z
Learning: The .devcontainer/scripts/stream-logs.sh script in NetAlertX is designed as a diagnostic tool for troubleshooting devcontainer startup issues. When log files don't exist, this indicates that the executable/services didn't start properly, which is valuable diagnostic information. Pre-creating missing files would mask this diagnostic behavior.

Applied to files:

  • install/production-filesystem/entrypoint.d/80-host-mode-network.sh
  • test/docker_tests/test_ports_available.py
📚 Learning: 2025-09-20T03:01:19.912Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/Dockerfile:18-19
Timestamp: 2025-09-20T03:01:19.912Z
Learning: In the NetAlertX repository, .devcontainer/Dockerfile is auto-generated and should not be reviewed directly. Review comments about dependencies and build steps should be directed at the root Dockerfile where the actual source commands are located.

Applied to files:

  • test/docker_tests/test_ports_available.py
  • test/docker_tests/test_docker_compose_scenarios.py
  • docs/docker-troubleshooting/nginx-configuration-mount.md
📚 Learning: 2025-10-26T17:09:18.621Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1235
File: .devcontainer/scripts/setup.sh:146-148
Timestamp: 2025-10-26T17:09:18.621Z
Learning: In `.devcontainer/scripts/setup.sh` and other devcontainer setup scripts for NetAlertX, chmod 666 on /var/run/docker.sock is acceptable because devcontainer environments are single-user development contexts where convenience can take priority over strict permission hardening.

Applied to files:

  • test/docker_tests/test_ports_available.py
  • install/production-filesystem/entrypoint.d/0-storage-permission.sh
📚 Learning: 2025-09-20T14:13:33.635Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/Dockerfile:11-16
Timestamp: 2025-09-20T14:13:33.635Z
Learning: In the NetAlertX repository with Alpine 3.22 base image, the `python -m venv` command works correctly in the devcontainer setup, likely due to symlink creation in the root Dockerfile that makes `python` available as an alias to `python3`.

Applied to files:

  • test/docker_tests/test_ports_available.py
📚 Learning: 2025-09-20T02:56:24.501Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/devcontainer.json:5-8
Timestamp: 2025-09-20T02:56:24.501Z
Learning: In the NetAlertX devcontainer setup, the final .devcontainer/Dockerfile is generated by combining the root Dockerfile with .devcontainer/resources/devcontainer-Dockerfile using the generate-dockerfile.sh script. The devcontainer.json should reference the generated file, not the root Dockerfile.

Applied to files:

  • test/docker_tests/test_ports_available.py
📚 Learning: 2025-10-19T01:40:57.095Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1230
File: .devcontainer/resources/devcontainer-overlay/services/config/nginx/netalertx.conf.template:1-2
Timestamp: 2025-10-19T01:40:57.095Z
Learning: In the NetAlertX repository, .devcontainer/resources/devcontainer-overlay/services/config/nginx/netalertx.conf.template is an auto-generated file that is intentionally committed to source control. It cannot be regenerated automatically outside the devcontainer environment and is required for the devcontainer to start, creating a bootstrap dependency.

Applied to files:

  • docs/docker-troubleshooting/nginx-configuration-mount.md
📚 Learning: 2025-09-20T14:09:29.159Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/scripts/setup.sh:103-116
Timestamp: 2025-09-20T14:09:29.159Z
Learning: In NetAlertX devcontainer setup, the netalertx user has write permissions to /var/log/nginx/ directory as it's explicitly chowned to netalertx:www-data in the Dockerfile, so setup.sh can write to nginx log files without sudo.

Applied to files:

  • docs/docker-troubleshooting/nginx-configuration-mount.md
  • install/production-filesystem/entrypoint.d/0-storage-permission.sh
🧬 Code graph analysis (1)
test/docker_tests/test_ports_available.py (1)
test/docker_tests/test_container_environment.py (4)
  • _setup_mount_tree (94-149)
  • _build_volume_args (166-176)
  • _run_container (187-279)
  • _assert_contains (283-293)
🪛 LanguageTool
docs/docker-troubleshooting/nginx-configuration-mount.md

[style] ~15-~15: Consider using a different verb for a more formal wording.
Context: ...n running in read-only mode. ## How to Correct the Issue If you want to use a custom ...

(FIX_RESOLVE)

🪛 Ruff (0.14.2)
test/docker_tests/test_mount_diagnostics_pytest.py

1-1: Shebang is present but file is not executable

(EXE001)


12-12: Docstring contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF002)


12-12: Docstring contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF002)


13-13: Docstring contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF002)


13-13: Docstring contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF002)


21-21: Docstring contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF002)


43-43: Comment contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF003)


44-44: Comment contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF003)


86-86: String contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF001)


160-160: subprocess call: check for execution of untrusted input

(S603)


161-161: Starting a process with a partial executable path

(S607)


309-309: Unused function argument: netalertx_test_image

(ARG001)


324-324: subprocess call: check for execution of untrusted input

(S603)


331-331: subprocess call: check for execution of untrusted input

(S603)


345-345: subprocess call: check for execution of untrusted input

(S603)


346-346: Starting a process with a partial executable path

(S607)


352-352: subprocess call: check for execution of untrusted input

(S603)


353-353: Starting a process with a partial executable path

(S607)


364-364: subprocess call: check for execution of untrusted input

(S603)


365-365: Starting a process with a partial executable path

(S607)


381-381: subprocess call: check for execution of untrusted input

(S603)


415-415: subprocess call: check for execution of untrusted input

(S603)


423-423: String contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF001)


423-423: String contains ambiguous (HEAVY MINUS SIGN). Did you mean - (HYPHEN-MINUS)?

(RUF001)

test/docker_tests/test_ports_available.py

43-43: subprocess call: check for execution of untrusted input

(S603)


44-44: Starting a process with a partial executable path

(S607)


56-56: subprocess call: check for execution of untrusted input

(S603)


56-56: Starting a process with a partial executable path

(S607)


70-70: Loop control variable target not used within loop body

Rename unused target to _target

(B007)


107-107: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


131-131: subprocess call: check for execution of untrusted input

(S603)


153-153: PEP 484 prohibits implicit Optional

Convert to T | None

(RUF013)


157-161: Avoid specifying long messages outside the exception class

(TRY003)


164-164: PEP 484 prohibits implicit Optional

Convert to T | None

(RUF013)


168-172: Avoid specifying long messages outside the exception class

(TRY003)


220-220: Unused function argument: dummy_container

(ARG001)

test/docker_tests/test_docker_compose_scenarios.py

30-30: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


52-52: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


75-75: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


117-117: Unused function argument: env_vars

(ARG001)


117-117: PEP 484 prohibits implicit Optional

Convert to T | None

(RUF013)


129-129: subprocess call: check for execution of untrusted input

(S603)


140-140: subprocess call: check for execution of untrusted input

(S603)


140-140: Starting a process with a partial executable path

(S607)


145-145: subprocess call: check for execution of untrusted input

(S603)


145-145: Starting a process with a partial executable path

(S607)


268-268: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


273-273: f-string without any placeholders

Remove extraneous f prefix

(F541)


274-274: f-string without any placeholders

Remove extraneous f prefix

(F541)


275-275: f-string without any placeholders

Remove extraneous f prefix

(F541)


276-276: f-string without any placeholders

Remove extraneous f prefix

(F541)


321-321: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


326-326: f-string without any placeholders

Remove extraneous f prefix

(F541)


327-327: f-string without any placeholders

Remove extraneous f prefix

(F541)


328-328: f-string without any placeholders

Remove extraneous f prefix

(F541)


329-329: f-string without any placeholders

Remove extraneous f prefix

(F541)

🪛 Shellcheck (0.11.0)
test/docker_tests/configurations/test_all_docker_composes.sh

[warning] 51-51: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)


[warning] 55-55: To redirect stdout+stderr, 2>&1 must be last (or use '{ cmd > file; } 2>&1' to clarify).

(SC2069)


[error] 70-70: Parsing stopped here. Is this keyword correctly matched up?

(SC1089)

install/production-filesystem/entrypoint.d/0-storage-permission.sh

[error] 57-57: Missing ';' or + terminating -exec. You can't use |/||/&&, and ';' has to be a separate, quoted argument.

(SC2067)


[error] 58-58: Missing ';' or + terminating -exec. You can't use |/||/&&, and ';' has to be a separate, quoted argument.

(SC2067)

🔇 Additional comments (9)
docs/docker-troubleshooting/nginx-configuration-mount.md (1)

1-36: Comprehensive troubleshooting guide with clear remediation steps.

The documentation clearly explains the issue, security implications, root cause, and provides actionable remediation with specific commands and configuration snippets. Content aligns well with the PR's goal of making errors more helpful with direct remediation guidance.

The remediation steps reference correct mount paths (/app/system/services/active/config), user ID (20211), and permissions, which align with the mount-configuration status system introduced in this PR.

Note: The past review flagged a duplicate "Additional Resources" section at lines 37–38, but that's not visible in the current code, suggesting it's already been addressed. If the duplicate remains beyond the visible range, remove the redundant block to avoid repetition.

install/production-filesystem/entrypoint.d/80-host-mode-network.sh (3)

47-66: Stdout/stderr redirection correctly restored.

The diagnostic warning messages on lines 49, 50, and 65 now correctly use >&2 redirection to send output to stderr. This aligns with Unix conventions and is consistent with other diagnostic scripts in the entrypoint.d directory, addressing the issue flagged in the previous review.


2-2: Documentation link aligns with PR objectives.

The updated comment on Line 2 and the new documentation link on Line 62 are well-positioned to help users troubleshoot network configuration issues. This supports the PR's goal of providing actionable remediation steps via direct documentation links.

Also applies to: 62-62


43-66: Warning-only behavior is appropriate.

The script correctly exits with status 0, allowing the container to start despite non-optimal networking configuration. This follows the pattern of diagnostic-only checks (per the learnings from check-ramdisk.sh) and gives users the option to reconfigure while still running the application.

install/production-filesystem/entrypoint.d/0-storage-permission.sh (1)

1-51: Security alert and initialization look good. The comprehensive warning with direct documentation link and clear remediation guidance aligns well with the PR's goal of making error messages more helpful. The POSIX shell constructs and environment variable setup are sound.

test/docker_tests/test_ports_available.py (1)

220-240: Fixture parameter dummy_container is required for test execution.

While Ruff flags dummy_container as unused (ARG001), this fixture parameter is essential—it ensures the dummy container is started before the test runs. Removing it would break the test's port-conflict verification. The static analysis hint is a false positive.

test/docker_tests/test_mount_diagnostics_pytest.py (3)

293-303: LGTM: active_config_ scenarios now execute correctly.

The active_config_ block is properly structured as a peer elif alongside other path handlers (db_, config_, api_, log_, run_), ensuring these test scenarios execute as intended.


376-407: LGTM: Live-container diagnostics path is now reachable.

The diagnostic execution and assertions for running containers are correctly unindented and will execute when containers remain up, properly validating the mount diagnostic table output.


86-86: Unicode characters are intentional for table parsing.

The ➖ (HEAVY MINUS SIGN) characters flagged by Ruff (RUF001-003) are intentional—they match the emoji output format of the mount diagnostic table from 10-mounts.py. These should not be changed to ASCII hyphens.

Comment thread test/docker_tests/configurations/test_all_docker_composes.sh Outdated
Comment thread test/docker_tests/configurations/test_all_docker_composes.sh Outdated
Comment thread test/docker_tests/test_docker_compose_scenarios.py Outdated
Comment thread docs/docker-troubleshooting/nginx-configuration-mount.md
Comment thread install/production-filesystem/entrypoint.d/0-storage-permission.sh Outdated
Comment thread install/production-filesystem/entrypoint.d/0-storage-permission.sh Outdated
Comment thread install/production-filesystem/entrypoint.d/0-storage-permission.sh Outdated
Comment thread install/production-filesystem/entrypoint.d/80-host-mode-network.sh Outdated
Comment thread test/docker_tests/test_ports_available.py
Comment on lines +39 to +40
local dirname=$(dirname "$file")
local basename=$(basename "$file")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines +63 to +66
find "$SCRIPT_DIR" -name "docker-compose*.yml" -type f | sort | while read -r file; do
extract_comments "$file"
run_test "$file"
done

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread test/docker_tests/test_mount_diagnostics_pytest.py Outdated
Comment thread test/docker_tests/test_mount_diagnostics_pytest.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
test/docker_tests/configurations/test_all_docker_composes.sh (1)

48-48: Fix stderr/stdout redirection order.

The redirect 2>&1 >> "$LOG_FILE" sends stderr to the original stdout before redirecting stdout to the file, causing stderr to be lost. Move 2>&1 to come after the file redirect.

-    timeout 10s docker-compose -f "$basename" up 2>&1 >> "$LOG_FILE"
+    timeout 10s docker-compose -f "$basename" up >> "$LOG_FILE" 2>&1
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 70373b1 and 51aa3d4.

📒 Files selected for processing (1)
  • test/docker_tests/configurations/test_all_docker_composes.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.11.0)
test/docker_tests/configurations/test_all_docker_composes.sh

[error] 37-37: Couldn't parse this brace group. Fix to allow more checks.

(SC1073)


[error] 61-61: Expected a '}'. If you have one, try a ; or \n in front of it.

(SC1056)


[error] 61-61: Missing '}'. Fix any mentioned problems and try again.

(SC1072)

Comment thread test/docker_tests/configurations/test_all_docker_composes.sh
adamoutler and others added 2 commits November 1, 2025 14:57
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
test/docker_tests/test_docker_compose_scenarios.py (2)

279-282: Remove unnecessary f-string prefixes.

These strings contain no placeholders; the f prefix is unnecessary.

Apply this diff:

                 "volumes": [
-                    f"./test_data/app_log:/app/log",
-                    f"./test_data/app_api:/app/api",
-                    f"./test_data/nginx_conf:/services/config/nginx/conf.active",
-                    f"./test_data/services_run:/services/run"
+                    "./test_data/app_log:/app/log",
+                    "./test_data/app_api:/app/api",
+                    "./test_data/nginx_conf:/services/config/nginx/conf.active",
+                    "./test_data/services_run:/services/run"
                 ],

332-335: Remove unnecessary f-string prefixes.

These strings contain no placeholders; the f prefix is unnecessary.

Apply this diff:

                 "volumes": [
-                    f"./test_data/app_log:/app/log",
-                    f"./test_data/app_api:/app/api",
-                    f"./test_data/nginx_conf:/services/config/nginx/conf.active",
-                    f"./test_data/services_run:/services/run"
+                    "./test_data/app_log:/app/log",
+                    "./test_data/app_api:/app/api",
+                    "./test_data/nginx_conf:/services/config/nginx/conf.active",
+                    "./test_data/services_run:/services/run"
                 ],
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a9d352 and f1fbc47.

📒 Files selected for processing (1)
  • test/docker_tests/test_docker_compose_scenarios.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use 'logger.mylog' for logging at levels: none, minimal, verbose, debug, or trace.

Files:

  • test/docker_tests/test_docker_compose_scenarios.py
test/**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Tests must reside under 'test/' and use pytest.

Files:

  • test/docker_tests/test_docker_compose_scenarios.py
🧠 Learnings (1)
📚 Learning: 2025-09-20T03:01:19.912Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/Dockerfile:18-19
Timestamp: 2025-09-20T03:01:19.912Z
Learning: In the NetAlertX repository, .devcontainer/Dockerfile is auto-generated and should not be reviewed directly. Review comments about dependencies and build steps should be directed at the root Dockerfile where the actual source commands are located.

Applied to files:

  • test/docker_tests/test_docker_compose_scenarios.py
🪛 Ruff (0.14.2)
test/docker_tests/test_docker_compose_scenarios.py

30-30: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


52-52: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


75-75: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


134-134: subprocess call: check for execution of untrusted input

(S603)


146-146: subprocess call: check for execution of untrusted input

(S603)


146-146: Starting a process with a partial executable path

(S607)


151-151: subprocess call: check for execution of untrusted input

(S603)


151-151: Starting a process with a partial executable path

(S607)


274-274: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


279-279: f-string without any placeholders

Remove extraneous f prefix

(F541)


280-280: f-string without any placeholders

Remove extraneous f prefix

(F541)


281-281: f-string without any placeholders

Remove extraneous f prefix

(F541)


282-282: f-string without any placeholders

Remove extraneous f prefix

(F541)


327-327: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


332-332: f-string without any placeholders

Remove extraneous f prefix

(F541)


333-333: f-string without any placeholders

Remove extraneous f prefix

(F541)


334-334: f-string without any placeholders

Remove extraneous f prefix

(F541)


335-335: f-string without any placeholders

Remove extraneous f prefix

(F541)

🔇 Additional comments (1)
test/docker_tests/test_docker_compose_scenarios.py (1)

117-156: LGTM! Environment variable handling is now correct.

The env_vars parameter is properly merged with the current environment and passed to all subprocess.run calls. This addresses the previous review concern.

Comment thread test/docker_tests/test_docker_compose_scenarios.py Outdated
Comment thread test/docker_tests/test_docker_compose_scenarios.py Outdated
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@adamoutler
adamoutler marked this pull request as draft November 1, 2025 20:39
@adamoutler
adamoutler marked this pull request as ready for review November 1, 2025 23:56

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (6)
test/docker_tests/test_ports_available.py (4)

42-42: Remove redundant import.

subprocess is already imported at line 8. This duplicate import is unnecessary.

Apply this diff:

-    import subprocess

70-75: Rename unused loop variable.

The target variable from VOLUME_MAP.items() is not used within the loop body. Rename it to _target to signal it's intentionally unused.

Apply this diff:

     paths = {}
-    for key, target in VOLUME_MAP.items():
+    for key, _target in VOLUME_MAP.items():
         folder_name = f"{label}_{key.upper()}_INTENTIONAL_NETALERTX_TEST"

121-128: Consider safer script injection method.

The current shell escaping pattern using chr(39)+chr(92)+chr(39)+chr(39) is fragile and difficult to maintain. For injecting multi-line shell scripts, consider using base64 encoding or mounting the script as a volume instead.

Here's a safer alternative using base64:

     # Copy the script content and run it
     script_path = pathlib.Path("install/production-filesystem/entrypoint.d/99-ports-available.sh")
     with script_path.open('r', encoding='utf-8') as f:
         script_content = f.read()
 
-    # Use printf to avoid shell interpretation issues
-    script = f"printf '%s\\n' '{script_content.replace(chr(39), chr(39)+chr(92)+chr(39)+chr(39))}' > /tmp/ports-check.sh && chmod +x /tmp/ports-check.sh && sh /tmp/ports-check.sh"
+    # Use base64 to safely inject the script
+    import base64
+    encoded = base64.b64encode(script_content.encode('utf-8')).decode('ascii')
+    script = f"echo '{encoded}' | base64 -d > /tmp/ports-check.sh && chmod +x /tmp/ports-check.sh && sh /tmp/ports-check.sh"
     cmd.extend(["--entrypoint", "/bin/sh", IMAGE, "-c", script])

153-153: Fix implicit Optional type hints.

PEP 484 prohibits implicit Optional. Use explicit union syntax for optional parameters.

Apply this diff:

-def _assert_contains(result, snippet: str, cmd: list[str] = None) -> None:
+def _assert_contains(result, snippet: str, cmd: list[str] | None = None) -> None:
     """Assert that the result output contains the given snippet."""
     if snippet not in result.output:
         cmd_str = " ".join(cmd) if cmd else ""
         raise AssertionError(
             f"Expected to find '{snippet}' in container output.\n"
             f"Got:\n{result.output}\n"
             f"Container command:\n{cmd_str}"
         )


-def _assert_not_contains(result, snippet: str, cmd: list[str] = None) -> None:
+def _assert_not_contains(result, snippet: str, cmd: list[str] | None = None) -> None:
     """Assert that the result output does not contain the given snippet."""

Also applies to: 164-164

test/docker_tests/test_docker_compose_scenarios.py (2)

152-152: Consider using list unpacking for concatenation.

For consistency with modern Python style, consider using unpacking syntax instead of + concatenation.

Apply this diff:

-    up_cmd = cmd + ["up"]
+    up_cmd = [*cmd, "up"]
     if detached:
         up_cmd.append("-d")
     else:
         up_cmd.extend([
             "--abort-on-container-exit",
             "--timeout", str(timeout)
         ])
 
     # ... later in the function ...
 
-            logs_cmd = cmd + ["logs"]
+            logs_cmd = [*cmd, "logs"]
             logs_result = subprocess.run(
 
     # ... and at the end ...
 
     if detached:
-        logs_cmd_display = cmd + ["logs"]
+        logs_cmd_display = [*cmd, "logs"]
         print("[compose logs command]", " ".join(logs_cmd_display))

Also applies to: 179-179, 230-230


371-374: Remove extraneous f-string prefixes.

These strings don't contain any interpolation placeholders, so the f prefix is unnecessary.

Apply this diff:

                 "volumes": [
-                    f"./test_data/app_log:/app/log",
-                    f"./test_data/app_api:/app/api",
-                    f"./test_data/nginx_conf:/services/config/nginx/conf.active",
-                    f"./test_data/services_run:/services/run"
+                    "./test_data/app_log:/app/log",
+                    "./test_data/app_api:/app/api",
+                    "./test_data/nginx_conf:/services/config/nginx/conf.active",
+                    "./test_data/services_run:/services/run"
                 ],

And similarly at lines 424-427:

                 "volumes": [
-                    f"./test_data/app_log:/app/log",
-                    f"./test_data/app_api:/app/api",
-                    f"./test_data/nginx_conf:/services/config/nginx/conf.active",
-                    f"./test_data/services_run:/services/run"
+                    "./test_data/app_log:/app/log",
+                    "./test_data/app_api:/app/api",
+                    "./test_data/nginx_conf:/services/config/nginx/conf.active",
+                    "./test_data/services_run:/services/run"
                 ],

Also applies to: 424-427

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f1fbc47 and 23a0fac.

📒 Files selected for processing (2)
  • test/docker_tests/test_docker_compose_scenarios.py (1 hunks)
  • test/docker_tests/test_ports_available.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use 'logger.mylog' for logging at levels: none, minimal, verbose, debug, or trace.

Files:

  • test/docker_tests/test_docker_compose_scenarios.py
  • test/docker_tests/test_ports_available.py
test/**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Tests must reside under 'test/' and use pytest.

Files:

  • test/docker_tests/test_docker_compose_scenarios.py
  • test/docker_tests/test_ports_available.py
🧠 Learnings (7)
📚 Learning: 2025-09-20T03:01:19.912Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/Dockerfile:18-19
Timestamp: 2025-09-20T03:01:19.912Z
Learning: In the NetAlertX repository, .devcontainer/Dockerfile is auto-generated and should not be reviewed directly. Review comments about dependencies and build steps should be directed at the root Dockerfile where the actual source commands are located.

Applied to files:

  • test/docker_tests/test_docker_compose_scenarios.py
  • test/docker_tests/test_ports_available.py
📚 Learning: 2025-10-26T17:09:18.621Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1235
File: .devcontainer/scripts/setup.sh:146-148
Timestamp: 2025-10-26T17:09:18.621Z
Learning: In `.devcontainer/scripts/setup.sh` and other devcontainer setup scripts for NetAlertX, chmod 666 on /var/run/docker.sock is acceptable because devcontainer environments are single-user development contexts where convenience can take priority over strict permission hardening.

Applied to files:

  • test/docker_tests/test_docker_compose_scenarios.py
  • test/docker_tests/test_ports_available.py
📚 Learning: 2025-11-01T19:02:10.609Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1263
File: install/production-filesystem/entrypoint.sh:60-86
Timestamp: 2025-11-01T19:02:10.609Z
Learning: In the NetAlertX project (install/production-filesystem/entrypoint.sh), when fail-fast behavior is adopted for entrypoint checks in the future, be lenient during review because tests will be removed or changed to accommodate that behavior. The current continue-on-failure approach exists to support the existing test suite, but this is expected to change along with corresponding test adjustments.

Applied to files:

  • test/docker_tests/test_docker_compose_scenarios.py
  • test/docker_tests/test_ports_available.py
📚 Learning: 2025-09-20T14:08:44.292Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/scripts/stream-logs.sh:5-6
Timestamp: 2025-09-20T14:08:44.292Z
Learning: The .devcontainer/scripts/stream-logs.sh script in NetAlertX is designed as a diagnostic tool for troubleshooting devcontainer startup issues. When log files don't exist, this indicates that the executable/services didn't start properly, which is valuable diagnostic information. Pre-creating missing files would mask this diagnostic behavior.

Applied to files:

  • test/docker_tests/test_docker_compose_scenarios.py
  • test/docker_tests/test_ports_available.py
📚 Learning: 2025-09-20T14:13:33.635Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/Dockerfile:11-16
Timestamp: 2025-09-20T14:13:33.635Z
Learning: In the NetAlertX repository with Alpine 3.22 base image, the `python -m venv` command works correctly in the devcontainer setup, likely due to symlink creation in the root Dockerfile that makes `python` available as an alias to `python3`.

Applied to files:

  • test/docker_tests/test_ports_available.py
📚 Learning: 2025-09-20T02:56:24.501Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/devcontainer.json:5-8
Timestamp: 2025-09-20T02:56:24.501Z
Learning: In the NetAlertX devcontainer setup, the final .devcontainer/Dockerfile is generated by combining the root Dockerfile with .devcontainer/resources/devcontainer-Dockerfile using the generate-dockerfile.sh script. The devcontainer.json should reference the generated file, not the root Dockerfile.

Applied to files:

  • test/docker_tests/test_ports_available.py
📚 Learning: 2025-09-20T14:13:33.635Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/Dockerfile:11-16
Timestamp: 2025-09-20T14:13:33.635Z
Learning: In the NetAlertX devcontainer setup, the `python -m venv /opt/venv` command works successfully on Alpine 3.22 despite the typical Alpine behavior of not providing a /usr/bin/python symlink by default. The build completes successfully and pytest runs without issues.

Applied to files:

  • test/docker_tests/test_ports_available.py
🧬 Code graph analysis (1)
test/docker_tests/test_ports_available.py (1)
test/docker_tests/test_container_environment.py (4)
  • _setup_mount_tree (94-149)
  • _build_volume_args (166-176)
  • _run_container (187-279)
  • _assert_contains (283-293)
🪛 Ruff (0.14.2)
test/docker_tests/test_docker_compose_scenarios.py

33-33: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


55-55: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


85-85: Probable insecure usage of temporary file or directory: "/tmp:uid=20211,gid=20211,mode=1700,rw,noexec,nosuid,nodev,async,noatime,nodiratime"

(S108)


152-152: Consider [*cmd, "up"] instead of concatenation

Replace with [*cmd, "up"]

(RUF005)


168-168: subprocess call: check for execution of untrusted input

(S603)


179-179: Consider [*cmd, "logs"] instead of concatenation

Replace with [*cmd, "logs"]

(RUF005)


180-180: subprocess call: check for execution of untrusted input

(S603)


198-198: subprocess call: check for execution of untrusted input

(S603)


210-210: subprocess call: check for execution of untrusted input

(S603)


210-210: Starting a process with a partial executable path

(S607)


215-215: subprocess call: check for execution of untrusted input

(S603)


215-215: Starting a process with a partial executable path

(S607)


230-230: Consider [*cmd, "logs"] instead of concatenation

Replace with [*cmd, "logs"]

(RUF005)


366-366: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


371-371: f-string without any placeholders

Remove extraneous f prefix

(F541)


372-372: f-string without any placeholders

Remove extraneous f prefix

(F541)


373-373: f-string without any placeholders

Remove extraneous f prefix

(F541)


374-374: f-string without any placeholders

Remove extraneous f prefix

(F541)


419-419: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


424-424: f-string without any placeholders

Remove extraneous f prefix

(F541)


425-425: f-string without any placeholders

Remove extraneous f prefix

(F541)


426-426: f-string without any placeholders

Remove extraneous f prefix

(F541)


427-427: f-string without any placeholders

Remove extraneous f prefix

(F541)

test/docker_tests/test_ports_available.py

43-43: subprocess call: check for execution of untrusted input

(S603)


44-44: Starting a process with a partial executable path

(S607)


56-56: subprocess call: check for execution of untrusted input

(S603)


56-56: Starting a process with a partial executable path

(S607)


70-70: Loop control variable target not used within loop body

Rename unused target to _target

(B007)


107-107: Probable insecure usage of temporary file or directory: "/tmp:mode=777"

(S108)


131-131: subprocess call: check for execution of untrusted input

(S603)


153-153: PEP 484 prohibits implicit Optional

Convert to T | None

(RUF013)


157-161: Avoid specifying long messages outside the exception class

(TRY003)


164-164: PEP 484 prohibits implicit Optional

Convert to T | None

(RUF013)


168-172: Avoid specifying long messages outside the exception class

(TRY003)


220-220: Unused function argument: dummy_container

(ARG001)

🔇 Additional comments (2)
test/docker_tests/test_ports_available.py (1)

220-240: LGTM: Fixture usage is correct.

The dummy_container parameter appears unused in the function body, but this is the correct pytest pattern—the fixture's side effect (occupying ports 20211 and 20212) is what the test relies on. The static analysis warning can be safely ignored.

test/docker_tests/test_docker_compose_scenarios.py (1)

291-342: LGTM: Test assertions are now consistent.

The test correctly verifies that a properly configured startup shows success indicators in the mounts table without critical errors or permission issues. The assertions align with the expected behavior.

@adamoutler

Copy link
Copy Markdown
Member Author

I think CodeRabbit is done @jokob-sk . I'm fine with this if you are.

It does not include fail-fast. Errors will continue until they cause the system to attempt to start, fail to start, and then reboot instead of failing immediately and rebooting. I will rework the tests for a fail fast soon. That would be a separate reworking required.

@adamoutler

Copy link
Copy Markdown
Member Author

@jokob-sk I realized there were changes to the /Dockerfile already in this so I addressed that request from earlier with making the scripts executable instead of needing to run bash script.sh

@jokob-sk
jokob-sk merged commit 71646e1 into netalertx:main Nov 2, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants