with one click
netalertx-code-standards
// NetAlertX coding standards and conventions. Use this when writing code, reviewing code, or implementing features.
// NetAlertX coding standards and conventions. Use this when writing code, reviewing code, or implementing features.
Manage NetAlertX configuration settings. Use this when asked to add setting, read config, get_setting_value, ccd, or configure options.
Guide for identifying, managing, and running commands within the NetAlertX development container. Use this when asked to run commands, testing, setup scripts, or troubleshoot container issues.
Enables live interaction with the NetAlertX runtime. This skill configures the Model Context Protocol (MCP) connection, granting full API access for debugging, troubleshooting, and real-time operations including database queries, network scans, and device management.
Enables live interaction with the NetAlertX runtime. This skill configures the Model Context Protocol (MCP) connection, granting full API access for debugging, troubleshooting, and real-time operations including database queries, network scans, and device management.
Read before running tests. Detailed instructions for single, standard unit tests (fast), full suites (slow), handling authentication, and obtaining the API Token. Tests must be run when a job is complete.
Develop and extend NetAlertX REST API endpoints. Use this when asked to create endpoint, add API route, implement API, or modify API responses.
| name | netalertx-code-standards |
| description | NetAlertX coding standards and conventions. Use this when writing code, reviewing code, or implementing features. |
/test/config folder, the /config folder should allow you to restore most of your functionality (excluding historical data)server/db/db_helper.py and implement new functionality in handlers (e.g., DeviceInstance in server/models/device_instance.py)normalize_mac from plugin_helper.py)timeNowUTC from utils.datetime_utils for all time-related operations and DB timestamps (store all timestamps in UTC)server/helper.py for user input before storing in DBtest/db_test_helpers.py for tests, never redefine them locallyKeep code files under 500 lines. Split larger files into modules.
Do not re-implement functionality. Reuse existing methods or refactor to create shared methods.
server/db/db_helper.py functions (e.g., get_table_json)DeviceInstance in server/models/device_instance.py)Always validate and normalize MACs before DB writes:
from plugin_helper import normalize_mac
mac = normalize_mac(raw_mac)
MANDATORY: All subprocess calls must set explicit timeouts.
result = subprocess.run(cmd, timeout=60) # Minimum 60s
Nested subprocess calls need their own timeoutโouter timeout won't save you.
from utils.datetime_utils import timeNowUTC
timestamp = timeNowUTC()
This is the ONLY function that calls datetime.datetime.now() in the entire codebase.
โ ๏ธ CRITICAL: ALL database timestamps MUST be stored in UTC This is the SINGLE SOURCE OF TRUTH for current time in NetAlertX Use timeNowUTC() for DB writes (returns UTC string by default) Use timeNowUTC(as_string=False) for datetime operations (scheduling, comparisons, logging)
Use sanitizers from server/helper.py before storing user input. MAC addresses are always lowercased and normalized. IP addresses should be validated.
chmod or chown during operations.devcontainer/scripts/setup.shReuse shared mocks and factories from test/db_test_helpers.py. Never redefine DummyDB, make_db, or inline DDL in individual test files.
import sys, os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from db_test_helpers import make_db, DummyDB, insert_device, minutes_ago
If a helper you need doesn't exist yet, add it to db_test_helpers.py โ not locally in the test file.
/data for persistent config/db/tmp for runtime logs/api/nginx state/data/db or use relative paths