mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-15 22:51:37 -07:00
coderabbit suggestions
This commit is contained in:
@@ -40,6 +40,10 @@ Set these sysctls at container runtime.
|
|||||||
jokob-sk/netalertx:latest
|
jokob-sk/netalertx:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> **Note:** Setting `net.ipv4.conf.all.arp_ignore` and `net.ipv4.conf.all.arp_announce` may fail with "operation not permitted" unless the container is run with elevated privileges. To resolve this, you can:
|
||||||
|
> - Use `--privileged` with `docker run`.
|
||||||
|
> - Use the more restrictive `--cap-add=NET_ADMIN` (or `cap_add: [NET_ADMIN]` in `docker-compose` service definitions) to allow the sysctls to be applied at runtime.
|
||||||
|
|
||||||
## Additional Resources
|
## Additional Resources
|
||||||
|
|
||||||
For broader Docker Compose guidance, see:
|
For broader Docker Compose guidance, see:
|
||||||
|
|||||||
@@ -12,10 +12,13 @@ fi
|
|||||||
if [ -n "${LOADED_PLUGINS:-}" ]; then
|
if [ -n "${LOADED_PLUGINS:-}" ]; then
|
||||||
echo "[ENV] Applying LOADED_PLUGINS override"
|
echo "[ENV] Applying LOADED_PLUGINS override"
|
||||||
value=$(printf '%s' "$LOADED_PLUGINS" | tr -d '\n\r')
|
value=$(printf '%s' "$LOADED_PLUGINS" | tr -d '\n\r')
|
||||||
escaped=$(printf '%s\n' "$value" | sed 's/[\/&]/\\&/g')
|
# declare delimiter for sed and escape it along with / and &
|
||||||
|
delim='|'
|
||||||
|
escaped=$(printf '%s\n' "$value" | sed "s/[\/${delim}&]/\\&/g")
|
||||||
|
|
||||||
if grep -q '^LOADED_PLUGINS=' "${NETALERTX_CONFIG}/app.conf"; then
|
if grep -q '^LOADED_PLUGINS=' "${NETALERTX_CONFIG}/app.conf"; then
|
||||||
sed -i "s|^LOADED_PLUGINS=.*|LOADED_PLUGINS=${escaped}|" "${NETALERTX_CONFIG}/app.conf"
|
# use same delimiter when substituting
|
||||||
|
sed -i "s${delim}^LOADED_PLUGINS=.*${delim}LOADED_PLUGINS=${escaped}${delim}" "${NETALERTX_CONFIG}/app.conf"
|
||||||
else
|
else
|
||||||
echo "LOADED_PLUGINS=${value}" >> "${NETALERTX_CONFIG}/app.conf"
|
echo "LOADED_PLUGINS=${value}" >> "${NETALERTX_CONFIG}/app.conf"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -86,7 +86,8 @@ for script in "${ENTRYPOINT_CHECKS}"/*; do
|
|||||||
fi
|
fi
|
||||||
script_name=$(basename "$script" | sed 's/^[0-9]*-//;s/\.(sh|py)$//;s/-/ /g')
|
script_name=$(basename "$script" | sed 's/^[0-9]*-//;s/\.(sh|py)$//;s/-/ /g')
|
||||||
echo "--> ${script_name} "
|
echo "--> ${script_name} "
|
||||||
if [ -n "${SKIP_STARTUP_CHECKS:-}" ] && echo "${SKIP_STARTUP_CHECKS}" | grep -Fq "${script_name}"; then
|
if [ -n "${SKIP_STARTUP_CHECKS:-}" ] &&
|
||||||
|
printf '%s' "${SKIP_STARTUP_CHECKS}" | grep -wFq -- "${script_name}"; then
|
||||||
printf "%sskip%s\n" "${GREY}" "${RESET}"
|
printf "%sskip%s\n" "${GREY}" "${RESET}"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -48,8 +48,9 @@ else
|
|||||||
log_error "python /app/server is not running"
|
log_error "python /app/server is not running"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 5. Check port 20211 is open and contains "netalertx"
|
# 5. Check port 20211 is open
|
||||||
[ "${LISTEN_ADDR}" == "0.0.0.0" ] && CHECK_ADDR="127.0.0.1" || CHECK_ADDR="${LISTEN_ADDR}";
|
CHECK_ADDR="${LISTEN_ADDR:-127.0.0.1}"
|
||||||
|
[ "${CHECK_ADDR}" == "0.0.0.0" ] && CHECK_ADDR="127.0.0.1"
|
||||||
if timeout 10 bash -c "</dev/tcp/${CHECK_ADDR}/${PORT:-20211}" 2>/dev/null; then
|
if timeout 10 bash -c "</dev/tcp/${CHECK_ADDR}/${PORT:-20211}" 2>/dev/null; then
|
||||||
log_success "Port ${PORT:-20211} is responding"
|
log_success "Port ${PORT:-20211} is responding"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -168,8 +168,12 @@ def test_devices_totals(client, api_token, test_mac):
|
|||||||
expected_length = len(conditions)
|
expected_length = len(conditions)
|
||||||
assert len(data) == expected_length
|
assert len(data) == expected_length
|
||||||
|
|
||||||
# 4. Check that at least 1 device exists
|
# 4. Check that at least 1 device exists when there are any conditions
|
||||||
|
if expected_length > 0:
|
||||||
assert data[0] >= 1 # 'devices' count includes the dummy device
|
assert data[0] >= 1 # 'devices' count includes the dummy device
|
||||||
|
else:
|
||||||
|
# no conditions defined; data should be an empty list
|
||||||
|
assert data == []
|
||||||
finally:
|
finally:
|
||||||
delete_dummy(client, api_token, test_mac)
|
delete_dummy(client, api_token, test_mac)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user