Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d6bcb27
Missing devcontainer build timestamp
adamoutler Oct 21, 2025
3441f77
Fix always fresh install env
adamoutler Oct 21, 2025
05f0837
Fix missing storage check
adamoutler Oct 21, 2025
5636a15
Add check permissions script
adamoutler Oct 22, 2025
ce8bb53
Refine devcontainer setup and docker tests
adamoutler Oct 22, 2025
1af19fe
Only nginx/python errors in docker logs. no stdout from backend.
adamoutler Oct 22, 2025
0851680
Add additional startup checks
adamoutler Oct 22, 2025
59c7d7b
Add test dependencies
adamoutler Oct 23, 2025
2789946
use system speedtest, not un-updated & removed script
adamoutler Oct 23, 2025
f70d3f3
Limiter fix for older kernels
adamoutler Oct 23, 2025
d12ffb3
Update readme with simple build instructions
adamoutler Oct 23, 2025
356caca
Don't increment sqlite sequence
adamoutler Oct 23, 2025
3b7830b
Add unit tests and updated messages
adamoutler Oct 23, 2025
edd5bd2
Devcontainer setup
adamoutler Oct 23, 2025
7a3bf67
Remove code coverage from repository
adamoutler Oct 24, 2025
0897c05
Tidy up output
adamoutler Oct 24, 2025
5a63b72
Merge main into hardening-fixes
adamoutler Oct 24, 2025
7f74c2d
docker compose changes
adamoutler Oct 24, 2025
32f9111
Restore test_safe_builder_unit.py to upstream version (remove local c…
adamoutler Oct 24, 2025
c4a041e
Coderabit changes
adamoutler Oct 25, 2025
fb02774
Fix errors for tests
adamoutler Oct 26, 2025
d2c28f6
Changes for tests identified by CodeRabbit
adamoutler Oct 26, 2025
52b747b
Remove warnings in devcontainer
adamoutler Oct 26, 2025
74a67e3
Added clarifying examples to dockerfile
adamoutler Oct 26, 2025
15bc163
Update install/production-filesystem/services/scripts/check-root.sh
adamoutler Oct 26, 2025
ededd39
Coderabbit fixes
adamoutler Oct 26, 2025
5ec35aa
Build the netalertx-test image on start so tests don't fail
adamoutler Oct 26, 2025
63c4b0d
Update .devcontainer/devcontainer.json
adamoutler Oct 26, 2025
01b64cc
Changes requested by coderabbit.
adamoutler Oct 26, 2025
cfffaf4
Strengthen tests
adamoutler Oct 26, 2025
d8c2dc0
Apply coderabit's latest hare-brained idea
adamoutler Oct 26, 2025
095372a
Rename GRAPHQL_PORT to APP_CONF_OVERRIDE
adamoutler Oct 26, 2025
a6ac492
Add APP_CONF_OVERRIDE support
adamoutler Oct 27, 2025
3ba4100
Update install/production-filesystem/entrypoint.sh
adamoutler Oct 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .coverage
Binary file not shown.
28 changes: 16 additions & 12 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DO NOT MODIFY THIS FILE DIRECTLY. IT IS AUTO-GENERATED BY .devcontainer/scripts/generate-dockerfile.sh
# DO NOT MODIFY THIS FILE DIRECTLY. IT IS AUTO-GENERATED BY .devcontainer/scripts/generate-configs.sh

# ---/Dockerfile---
# The NetAlertX Dockerfile has 3 stages:
Expand Down Expand Up @@ -103,7 +103,6 @@ ENV PORT=20211
ENV NETALERTX_DEBUG=0
ENV VENDORSPATH=/app/back/ieee-oui.txt
ENV VENDORSPATH_NEWEST=/services/run/tmp/ieee-oui.txt
ENV PYTHONPATHPATH="${NETALERTX_APP}:${VIRTUAL_ENV}/bin:${PATH}"
ENV ENVIRONMENT=alpine
ENV READ_ONLY_USER=readonly READ_ONLY_GROUP=readonly
ENV NETALERTX_USER=netalertx NETALERTX_GROUP=netalertx
Expand Down Expand Up @@ -146,13 +145,14 @@ RUN apk add libcap && \
setcap cap_net_raw,cap_net_admin+eip /usr/bin/arp-scan && \
setcap cap_net_raw,cap_net_admin,cap_net_bind_service+eip /usr/bin/nbtscan && \
setcap cap_net_raw,cap_net_admin+eip /usr/bin/traceroute && \
setcap cap_net_raw,cap_net_admin+eip ${VIRTUAL_ENV_BIN}/scapy && \
setcap cap_net_raw,cap_net_admin+eip $(readlink -f ${VIRTUAL_ENV_BIN}/python) && \
/bin/sh /build/init-nginx.sh && \
/bin/sh /build/init-php-fpm.sh && \
/bin/sh /build/init-crond.sh && \
/bin/sh /build/init-backend.sh && \
rm -rf /build && \
apk del libcap
apk del libcap && \
date +%s > ${NETALERTX_FRONT}/buildtimestamp.txt


ENTRYPOINT ["/bin/sh","/entrypoint.sh"]
Expand Down Expand Up @@ -185,6 +185,9 @@ RUN chown -R ${READ_ONLY_USER}:${READ_ONLY_GROUP} ${READ_ONLY_FOLDERS} && \
find ${READ_WRITE_FOLDERS} -type d -exec chmod 700 {} + && \
chown ${READ_ONLY_USER}:${READ_ONLY_GROUP} /entrypoint.sh /opt /opt/venv && \
chmod 005 /entrypoint.sh ${SYSTEM_SERVICES}/*.sh /app /opt /opt/venv && \
for dir in ${READ_WRITE_FOLDERS}; do \
install -d -o ${NETALERTX_USER} -g ${NETALERTX_GROUP} -m 700 "$dir"; \
done && \
apk del apk-tools && \
rm -Rf /var /etc/sudoers.d/* /etc/shadow /etc/gshadow /etc/sudoers \
/lib/apk /lib/firmware /lib/modules-load.d /lib/sysctl.d /mnt /home/ /root \
Expand All @@ -210,27 +213,28 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
FROM runner AS netalertx-devcontainer
ENV INSTALL_DIR=/app

ENV PYTHONPATH=/workspaces/NetAlertX/test:/workspaces/NetAlertX/server:/app:/app/server:/opt/venv/lib/python3.12/site-packages
ENV PYTHONPATH=/workspaces/NetAlertX/test:/workspaces/NetAlertX/server:/app:/app/server:/opt/venv/lib/python3.12/site-packages:/usr/lib/python3.12/site-packages
ENV PATH=/services:${PATH}
ENV PHP_INI_SCAN_DIR=/services/config/php/conf.d:/etc/php83/conf.d
ENV LISTEN_ADDR=0.0.0.0
ENV PORT=20211
ENV NETALERTX_DEBUG=1
ENV PYDEVD_DISABLE_FILE_VALIDATION=1
COPY .devcontainer/resources/devcontainer-overlay/ /

USER root
# Install common tools, create user, and set up sudo
RUN apk add --no-cache git nano vim jq php83-pecl-xdebug py3-pip nodejs sudo gpgconf pytest pytest-cov fish shfmt sudo
RUN apk add --no-cache git nano vim jq php83-pecl-xdebug py3-pip nodejs sudo gpgconf pytest \
pytest-cov fish shfmt github-cli py3-yaml py3-docker-py docker-cli docker-cli-buildx


RUN install -d -o netalertx -g netalertx -m 755 /services/php/modules && \
cp -a /usr/lib/php83/modules/. /services/php/modules/ && \
echo "${NETALERTX_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# Install debugpy in the virtualenv if present, otherwise into system python3
RUN /bin/sh -c '(/opt/venv/bin/python3 -m pip install --no-cache-dir debugpy) || (python3 -m pip install --no-cache-dir debugpy) || true' && \
mkdir /workspaces && \
RUN mkdir /workspaces && \
install -d -o netalertx -g netalertx -m 777 /services/run/logs && \
install -d -o netalertx -g netalertx -m 777 /app/run/tmp/client_body && \
sed -i -e 's|:/app:|:/workspaces:|' /etc/passwd && \
python -m pip install -U pytest pytest-cov

find /opt/venv -type d -exec chmod o+rwx {} \;

USER netalertx
ENTRYPOINT ["/bin/sh","-c","sleep infinity"]
12 changes: 10 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
// even within this container and connect to them as needed.
// "--network=host",
],
"mounts": [
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" //used for testing various conditions in docker
],
// ATTENTION: If running with --network=host, COMMENT `forwardPorts` OR ELSE THERE WILL BE NO WEBUI!
"forwardPorts": [20211, 20212, 5678],
"portsAttributes": { // the ports we care about
Expand All @@ -40,8 +43,13 @@
}
},

"postStartCommand": "${containerWorkspaceFolder}/.devcontainer/scripts/setup.sh",

"postCreateCommand": {
"Install Pip Requirements": "/opt/venv/bin/pip3 install pytest docker debugpy"
},
"postStartCommand": {
"Start Environment":"${containerWorkspaceFolder}/.devcontainer/scripts/setup.sh",
"Build test-container":"echo building netalertx-test container in background. check /tmp/build.log for progress. && setsid docker buildx build -t netalertx-test . > /tmp/build.log 2>&1 &"
},
"customizations": {
"vscode": {
"extensions": [
Expand Down
17 changes: 9 additions & 8 deletions .devcontainer/resources/devcontainer-Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,28 @@
FROM runner AS netalertx-devcontainer
ENV INSTALL_DIR=/app

ENV PYTHONPATH=/workspaces/NetAlertX/test:/workspaces/NetAlertX/server:/app:/app/server:/opt/venv/lib/python3.12/site-packages
ENV PYTHONPATH=/workspaces/NetAlertX/test:/workspaces/NetAlertX/server:/app:/app/server:/opt/venv/lib/python3.12/site-packages:/usr/lib/python3.12/site-packages
ENV PATH=/services:${PATH}
ENV PHP_INI_SCAN_DIR=/services/config/php/conf.d:/etc/php83/conf.d
ENV LISTEN_ADDR=0.0.0.0
ENV PORT=20211
ENV NETALERTX_DEBUG=1
ENV PYDEVD_DISABLE_FILE_VALIDATION=1
COPY .devcontainer/resources/devcontainer-overlay/ /

USER root
# Install common tools, create user, and set up sudo
RUN apk add --no-cache git nano vim jq php83-pecl-xdebug py3-pip nodejs sudo gpgconf pytest pytest-cov fish shfmt github-cli
RUN apk add --no-cache git nano vim jq php83-pecl-xdebug py3-pip nodejs sudo gpgconf pytest \
pytest-cov fish shfmt github-cli py3-yaml py3-docker-py docker-cli docker-cli-buildx


RUN install -d -o netalertx -g netalertx -m 755 /services/php/modules && \
cp -a /usr/lib/php83/modules/. /services/php/modules/ && \
echo "${NETALERTX_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# Install debugpy in the virtualenv if present, otherwise into system python3
RUN /bin/sh -c '(/opt/venv/bin/python3 -m pip install --no-cache-dir debugpy) || (python3 -m pip install --no-cache-dir debugpy) || true' && \
mkdir /workspaces && \
RUN mkdir /workspaces && \
install -d -o netalertx -g netalertx -m 777 /services/run/logs && \
install -d -o netalertx -g netalertx -m 777 /app/run/tmp/client_body && \
sed -i -e 's|:/app:|:/workspaces:|' /etc/passwd && \
python -m pip install -U pytest pytest-cov

find /opt/venv -type d -exec chmod o+rwx {} \;

USER netalertx
ENTRYPOINT ["/bin/sh","-c","sleep infinity"]
47 changes: 47 additions & 0 deletions .devcontainer/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,52 @@ export PORT=20211
export SOURCE_DIR="/workspaces/NetAlertX"


ensure_docker_socket_access() {
local socket="/var/run/docker.sock"
if [ ! -S "${socket}" ]; then
echo "docker socket not present; skipping docker group configuration"
return
fi

local sock_gid
sock_gid=$(stat -c '%g' "${socket}" 2>/dev/null || true)
if [ -z "${sock_gid}" ]; then
echo "unable to determine docker socket gid; skipping docker group configuration"
return
fi

local group_entry=""
if command -v getent >/dev/null 2>&1; then
group_entry=$(getent group "${sock_gid}" 2>/dev/null || true)
else
group_entry=$(grep -E ":${sock_gid}:" /etc/group 2>/dev/null || true)
fi

local group_name=""
if [ -n "${group_entry}" ]; then
group_name=$(echo "${group_entry}" | cut -d: -f1)
else
group_name="docker-host"
sudo addgroup -g "${sock_gid}" "${group_name}" 2>/dev/null || group_name=$(grep -E ":${sock_gid}:" /etc/group | head -n1 | cut -d: -f1)
fi

if [ -z "${group_name}" ]; then
echo "failed to resolve group for docker socket gid ${sock_gid}; skipping docker group configuration"
return
fi

if ! id -nG netalertx | tr ' ' '\n' | grep -qx "${group_name}"; then
sudo addgroup netalertx "${group_name}" 2>/dev/null || true
fi
}


main() {
echo "=== NetAlertX Development Container Setup ==="
killall php-fpm83 nginx crond python3 2>/dev/null
sleep 1
echo "Setting up ${SOURCE_DIR}..."
ensure_docker_socket_access
sudo chown $(id -u):$(id -g) /workspaces
sudo chmod 755 /workspaces
configure_source
Expand Down Expand Up @@ -102,6 +143,12 @@ configure_source() {
killall python3 &>/dev/null
sleep 0.2
done
sudo chmod 777 /opt/venv/lib/python3.12/site-packages/ && \
sudo chmod 005 /opt/venv/lib/python3.12/site-packages/
sudo chmod 666 /var/run/docker.sock

echo " -> Updating build timestamp"
date +%s > ${NETALERTX_FRONT}/buildtimestamp.txt

}

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.coverage
.vscode
.dotnet
.vscode-server
Expand Down
21 changes: 21 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,26 @@
"color": "terminal.ansiBlue"
}
}
,
{
"label": "[Any] Build Unit Test Docker image",
"type": "shell",
"command": "docker buildx build -t netalertx-test . && echo 'πŸ§ͺ Unit Test Docker image built: netalertx-test'",
"presentation": {
"echo": true,
"reveal": "always",
"panel": "shared",
"showReuseMessage": false
},
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": false
},
"icon": {
"id": "beaker",
"color": "terminal.ansiBlue"
}
}
]
}
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ RUN chown -R ${READ_ONLY_USER}:${READ_ONLY_GROUP} ${READ_ONLY_FOLDERS} && \
find ${READ_WRITE_FOLDERS} -type d -exec chmod 700 {} + && \
chown ${READ_ONLY_USER}:${READ_ONLY_GROUP} /entrypoint.sh /opt /opt/venv && \
chmod 005 /entrypoint.sh ${SYSTEM_SERVICES}/*.sh /app /opt /opt/venv && \
for dir in ${READ_WRITE_FOLDERS}; do \
install -d -o ${NETALERTX_USER} -g ${NETALERTX_GROUP} -m 700 "$dir"; \
done && \
apk del apk-tools && \
rm -Rf /var /etc/sudoers.d/* /etc/shadow /etc/gshadow /etc/sudoers \
/lib/apk /lib/firmware /lib/modules-load.d /lib/sysctl.d /mnt /home/ /root \
Expand Down
38 changes: 27 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,25 @@ Get visibility of what's going on on your WIFI/LAN network and enable presence d

## πŸ“‹ Table of Contents

- [Features](#-features)
- [Documentation](#-documentation)
- [Quick Start](#-quick-start)
- [Alternative Apps](#-other-alternative-apps)
- [Security & Privacy](#-security--privacy)
- [FAQ](#-faq)
- [Known Issues](#-known-issues)
- [Donations](#-donations)
- [Contributors](#-contributors)
- [Translations](#-translations)
- [License](#license)
- [NetAlertX - Network, presence scanner and alert framework](#netalertx---network-presence-scanner-and-alert-framework)
- [πŸ“‹ Table of Contents](#-table-of-contents)
- [πŸš€ Quick Start](#-quick-start)
- [πŸ“¦ Features](#-features)
- [Scanners](#scanners)
- [Notification gateways](#notification-gateways)
- [Integrations and Plugins](#integrations-and-plugins)
- [Workflows](#workflows)
- [πŸ“š Documentation](#-documentation)
- [πŸ” Security \& Privacy](#-security--privacy)
- [❓ FAQ](#-faq)
- [🐞 Known Issues](#-known-issues)
- [πŸ“ƒ Everything else](#-everything-else)
- [πŸ“§ Get notified what's new](#-get-notified-whats-new)
- [πŸ”€ Other Alternative Apps](#-other-alternative-apps)
- [πŸ’™ Donations](#-donations)
- [πŸ— Contributors](#-contributors)
- [🌍 Translations](#-translations)
- [License](#license)


## πŸš€ Quick Start
Expand All @@ -38,6 +46,14 @@ docker run -d --rm --network=host \
ghcr.io/jokob-sk/netalertx:latest
```

To deploy a containerized instance directly from the source repository, execute the following BASH sequence:
```bash
git clone https://github.com/jokob-sk/NetAlertX.git
cd NetAlertX
docker compose up --force-recreate --build
# To customize: edit docker-compose.yaml and run that last command again
```

Need help configuring it? Check the [usage guide](https://github.com/jokob-sk/NetAlertX/blob/main/docs/README.md) or [full documentation](https://jokob-sk.github.io/NetAlertX/).

For Home Assistant users: [Click here to add NetAlertX](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Falexbelgium%2Fhassio-addons)
Expand Down
Loading