Repository navigation
Sync + WIFICANARY: attribute synced detections to their node #1858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jokob-sk
merged 2 commits into
netalertx:main
from
mauricio-camayo:fix/sync-hub-node-name
Oct 23, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| """ | ||
| Tests for utils.plugin_utils.get_sync_hub_node_name(). | ||
|
|
||
| Regression coverage: server/plugin.py used filename.split(".")[2] to tag | ||
| plugin objects received from a sync node, but by the time the hub processes | ||
| them decode_and_rename_files() has renamed the file to | ||
| last_result.<PREFIX>.decoded.<NodeName>.<N>.log - so index 2 is the literal | ||
| "decoded", and every synced plugin object (e.g. a WIFICANARY detection from a | ||
| WiFi satellite) was stored with syncHubNodeName = "decoded" instead of the | ||
| node's name. | ||
|
|
||
| Run from inside the NetAlertX container (utils.plugin_utils imports conf, | ||
| logger and helper): | ||
|
|
||
| pytest "test/server/test_sync_hub_node_name.py" -v | ||
| """ | ||
|
|
||
| import os | ||
| import sys | ||
|
|
||
| import pytest | ||
|
|
||
| INSTALL_PATH = os.getenv("NETALERTX_APP", "/app") | ||
| sys.path.extend([f"{INSTALL_PATH}/server/plugins", f"{INSTALL_PATH}/server"]) | ||
|
|
||
| from utils.plugin_utils import get_sync_hub_node_name # noqa: E402 | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "filename, expected", | ||
| [ | ||
| # What the hub actually processes: already decrypted and renamed | ||
| ("last_result.WIFICANARY.decoded.satelite.6.log", "satelite"), | ||
| # Same file before decode_and_rename_files() touches it | ||
| ("last_result.WIFICANARY.encoded.satelite.6.log", "satelite"), | ||
| ("last_result.ARPSCAN.decoded.Node_1.1.log", "Node_1"), | ||
| # Node names containing dots must survive intact | ||
| ("last_result.ARPSCAN.decoded.sat.office.12.log", "sat.office"), | ||
| ], | ||
| ) | ||
| def test_node_name_from_received_file(filename, expected): | ||
| """A received node file yields the node's name, never the encoded/decoded marker.""" | ||
| assert get_sync_hub_node_name(filename) == expected | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "filename", | ||
| [ | ||
| "last_result.ARPSCAN.log", # local plugin result | ||
| "last_result.log", # sync's own progress file | ||
| "last_result.satelite.log", # PULL-mode device dump (handled by sync.py, not here) | ||
| ], | ||
| ) | ||
| def test_local_result_file_has_no_node_name(filename): | ||
| """Local result files are not tagged with any sync node.""" | ||
| assert get_sync_hub_node_name(filename) == "" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π Maintainability & Code Quality | π Major | β‘ Quick win
π Supported by static analysis
π Script executed:
Repository: netalertx/NetAlertX
Length of output: 2872
π Script executed:
Repository: netalertx/NetAlertX
Length of output: 2442
Add a docstring to
execute_plugin.execute_pluginis a touched Python function, but its first statement issql = db.sql. The preceding comment is not a docstring.Suggested fix
def execute_plugin(db, all_plugins, plugin): + """Execute the configured plugin command and process its result files.""" sql = db.sqlπ€ Prompt for AI Agents