feat: allow talkingq OTA domains
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ota_url_policy.h"
|
||||
|
||||
typedef struct {
|
||||
const char *url;
|
||||
int expected;
|
||||
} url_case_t;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
static const url_case_t cases[] = {
|
||||
{"http://101.35.224.118:8080/assets/firmware/app.bin", 1},
|
||||
{"http://101.35.224.118:8080/assets/firmware/release/app.bin?token=x", 1},
|
||||
{"http://talkingq.com/app.bin", 1},
|
||||
{"https://talkingq.com/releases/app.bin", 1},
|
||||
{"https://ota.talkingq.com/releases/app.bin", 1},
|
||||
{"https://cdn.cn.talkingq.com:8443/a/B.BIN?token=x", 1},
|
||||
{"https://OTA.TALKINGQ.COM/app.bin", 1},
|
||||
{"https://eviltalkingq.com/app.bin", 0},
|
||||
{"https://talkingq.com.evil.example/app.bin", 0},
|
||||
{"https://talkingq.com@evil.example/app.bin", 0},
|
||||
{"https://evil.example@talkingq.com/app.bin", 0},
|
||||
{"https://a..talkingq.com/app.bin", 0},
|
||||
{"https://-ota.talkingq.com/app.bin", 0},
|
||||
{"https://ota-.talkingq.com/app.bin", 0},
|
||||
{"https://ota.talkingq.com:0/app.bin", 0},
|
||||
{"https://ota.talkingq.com:65536/app.bin", 0},
|
||||
{"https://ota.talkingq.com:abc/app.bin", 0},
|
||||
{"ftp://ota.talkingq.com/app.bin", 0},
|
||||
{"https://ota.talkingq.com/", 0},
|
||||
{"https://ota.talkingq.com/app.zip", 0},
|
||||
{"https://ota.talkingq.com/app.bin/extra", 0},
|
||||
{"https://ota.talkingq.com/a/../app.bin", 0},
|
||||
{"https://ota.talkingq.com/app.bin#fragment", 0},
|
||||
{"http://101.35.224.118:8080/other/app.bin", 0},
|
||||
{"http://192.168.1.1/app.bin", 0},
|
||||
};
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < sizeof(cases) / sizeof(cases[0]); ++i) {
|
||||
int actual = banban_ota_url_is_allowed(cases[i].url);
|
||||
if (actual != cases[i].expected) {
|
||||
fprintf(stderr, "case %lu failed: expected=%d actual=%d url=%s\n",
|
||||
(unsigned long)i, cases[i].expected, actual, cases[i].url);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
printf("OTA URL policy tests passed: %lu cases\n",
|
||||
(unsigned long)(sizeof(cases) / sizeof(cases[0])));
|
||||
return 0;
|
||||
}
|
||||
@@ -23,6 +23,7 @@ BUILD_MACRO = ROOT / "ql-application/threadx/interface/custom_app/lib/hal/build_
|
||||
APP_MAKEFILE = ROOT / "ql-application/threadx/interface/custom_app/Makefile"
|
||||
MQTT_SOURCE = ROOT / "ql-application/threadx/interface/custom_app/mqtt.c"
|
||||
FULLOTA2_SOURCE = ROOT / "ql-application/threadx/interface/custom_app/ota_fullfota2.c"
|
||||
URL_POLICY_SOURCE = ROOT / "ql-application/threadx/interface/custom_app/ota_url_policy.c"
|
||||
LEGACY_HTTP_SOURCE = ROOT / "ql-application/threadx/interface/custom_app/http_aofei.c"
|
||||
|
||||
FLASH_SIZE = 0x400000
|
||||
@@ -146,11 +147,18 @@ def verify_fota_contract() -> None:
|
||||
makefile = APP_MAKEFILE.read_text(encoding="utf-8", errors="replace")
|
||||
if "ota_fullfota2.c" not in makefile:
|
||||
fail("minimal FULLOTA2 implementation is not part of the application build")
|
||||
if "ota_url_policy.c" not in makefile:
|
||||
fail("OTA URL policy is not part of the application build")
|
||||
mqtt = MQTT_SOURCE.read_text(encoding="utf-8", errors="replace")
|
||||
if "banban_fullfota2_start" not in mqtt:
|
||||
fail("MQTT OTA command does not start the local-staging FULLOTA2 path")
|
||||
if "ql_fullfota_app_start(cmd->params.ota.url)" in mqtt:
|
||||
fail("MQTT OTA command still invokes the legacy FULLOTA1 path")
|
||||
if "banban_ota_url_is_allowed" not in mqtt:
|
||||
fail("MQTT OTA command does not enforce the shared URL policy")
|
||||
url_policy = URL_POLICY_SOURCE.read_text(encoding="utf-8", errors="replace")
|
||||
if 'BANBAN_OTA_BASE_DOMAIN "talkingq.com"' not in url_policy:
|
||||
fail("OTA URL policy no longer allows the talkingq.com domain family")
|
||||
legacy_http = LEGACY_HTTP_SOURCE.read_text(encoding="utf-8", errors="replace")
|
||||
if "return ql_fullfota_app_start(url)" in legacy_http:
|
||||
fail("legacy HTTP polling path can still invoke FULLOTA1")
|
||||
|
||||
Reference in New Issue
Block a user