fix: 18
This commit is contained in:
@@ -94,6 +94,47 @@ class BuildTest(unittest.TestCase):
|
||||
self.assertIn("location.origin", worker.split("function labC2LogUrl")[1].split("function print")[0])
|
||||
self.assertNotIn("__labExfilUrl", worker.split("function labC2LogUrl")[1].split("function print")[0])
|
||||
|
||||
def test_pe_worker_uuid_fallback_preserves_injected_uuid(self) -> None:
|
||||
"""pe_worker.js / pe_main.js line 1 must use || so the pre-snippet
|
||||
injected by rce_worker_*.__labPrependDelivery / patchExfilPayload is
|
||||
not unconditionally overwritten with the 69DD placeholder."""
|
||||
root = TOOLS.parent / "source"
|
||||
for fname in ("pe_worker.js", "pe_main.js"):
|
||||
text = (root / fname).read_text(encoding="utf-8")
|
||||
# Must NOT have unconditional assignment of the 69DD placeholder.
|
||||
self.assertNotIn(
|
||||
'__LAB_DEVICE_UUID__="69DD25B2CA8B5682BA2470D77124E2FC"',
|
||||
text,
|
||||
f"{fname} must not unconditionally overwrite __LAB_DEVICE_UUID__",
|
||||
)
|
||||
# Must have the || fallback form.
|
||||
self.assertIn(
|
||||
"__LAB_DEVICE_UUID__=globalThis.__LAB_DEVICE_UUID__||",
|
||||
text,
|
||||
f"{fname} must use || fallback for __LAB_DEVICE_UUID__",
|
||||
)
|
||||
|
||||
def test_rce_workers_propagate_device_uuid(self) -> None:
|
||||
"""All rce_worker_*.js that handle stage1_rce must read data.deviceUUID
|
||||
and inject __LAB_DEVICE_UUID__ into pe_worker/pe_main via prepend."""
|
||||
root = TOOLS.parent / "source"
|
||||
for fname in ("rce_worker_18.4.js", "rce_worker_18.6.js"):
|
||||
text = (root / fname).read_text(encoding="utf-8")
|
||||
# Must declare __labDeviceUUID variable.
|
||||
self.assertIn("__labDeviceUUID", text, f"{fname} must declare __labDeviceUUID")
|
||||
# Must read data.deviceUUID in stage1_rce handler.
|
||||
self.assertIn(
|
||||
"data.deviceUUID",
|
||||
text,
|
||||
f"{fname} must read data.deviceUUID",
|
||||
)
|
||||
# Must inject __LAB_DEVICE_UUID__ in prepend snippet.
|
||||
self.assertIn(
|
||||
"__LAB_DEVICE_UUID__",
|
||||
text.split("__labPrependDelivery")[1] if "__labPrependDelivery" in text else "",
|
||||
f"{fname} must inject __LAB_DEVICE_UUID__ in __labPrependDelivery",
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user