{"record":{"id":"d8466620f727cc72","repo":"stamparm/maltrail","slug":"s-not-built-cargo-build-release-manifest-path-sensor-cargo","errorCode":null,"errorMessage":"[!] %s not built - cargo build --release --manifest-path sensor/Cargo.toml","messagePattern":"\\[!\\] (.+?) not built - cargo build --release --manifest-path sensor/Cargo\\.toml","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sensor/tools/refnet.py","lineNumber":224,"sourceCode":"    false = [_ for _ in seen if _ not in planted and _ not in explained and _[0] not in scanners]\n\n    hours = meta[\"minutes\"] / 60.0\n    per_1000_day = (len(logged) / max(hours, 1e-9)) * 24.0 * (1000.0 / meta[\"hosts\"])\n    return {\n        \"planted\": len(planted), \"detected\": len(detected), \"missed\": sorted(missed)[:10],\n        \"scans_planted\": len(scanners), \"scans_detected\": len(scans_found),\n        \"false_positives\": len(false), \"false_examples\": sorted(false)[:10],\n        \"benign_packets\": meta[\"benign_packets\"], \"events\": len(logged),\n        \"detection_rate\": 100.0 * len(detected) / max(len(planted), 1),\n        \"fp_per_100k_benign\": 100000.0 * len(false) / max(meta[\"benign_packets\"], 1),\n        \"events_per_day_per_1000_hosts\": per_1000_day,\n    }\n\n\ndef replay(pcap, out, trails, sensor=None):\n    sensor = sensor or os.path.join(ROOT, \"sensor\", \"target\", \"release\", \"maltrail-sensor\")\n    if not os.path.isfile(sensor):\n        raise SystemExit(\"[!] %s not built - cargo build --release --manifest-path sensor/Cargo.toml\" % sensor)\n    logdir = os.path.join(out, \"logs\")\n    if not os.path.isdir(logdir):\n        os.makedirs(logdir)\n    conf = os.path.join(out, \"sensor.conf\")\n    with io.open(conf, \"w\", encoding=\"utf8\") as handle:\n        # USE_HEURISTICS EXPLICITLY. An absent key reads as false, so a config that simply omits it\n        # runs with every heuristic off - and the first version of this file did exactly that, then\n        # reported 0/3 scans detected as though the sensor had missed them. A reference network that\n        # forgets to turn on what it is measuring produces confident, meaningless numbers.\n        handle.write(u\"MONITOR_INTERFACE any\\nCAPTURE_BUFFER 10MB\\nSENSOR_NAME refnet\\n\"\n                     u\"USE_HEURISTICS true\\n\"\n                     u\"DISABLE_CHECK_SUDO true\\nDISABLE_TRAIL_UPDATES true\\nUSE_SERVER_UPDATE_TRAILS false\\n\"\n                     u\"UPDATE_PERIOD 86400\\nLOG_DIR %s\\nTRAILS_FILE %s\\n\" % (logdir, trails))\n    started = time.time()\n    subprocess.check_call([sensor, \"-c\", conf, \"-r\", pcap], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)\n    return logdir, time.time() - started\n\n","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/stamparm/maltrail/blob/77cfb06d7606506d101bbcec0786c77166c4255e/sensor/tools/refnet.py#L206-L242","documentation":"refnet.py's replay() drives the compiled sensor binary (default sensor/target/release/maltrail-sensor) against a generated pcap. Before running, it checks the binary exists; if it doesn't, replay exits telling you the exact cargo command to build it. This is a precondition check for the replay/scoring workflow, not a failure of replay itself.","triggerScenarios":"Running refnet.py replay (via main, without --score) when sensor/target/release/maltrail-sensor does not exist — the project was never built with cargo build --release, a `cargo clean` was run, or a custom --sensor path points to a non-existent file.","commonSituations":"Fresh clone without building; switching toolchains/target dirs; CI running the replay step before the build step; typos in a custom sensor path.","solutions":["Build the sensor: cargo build --release --manifest-path sensor/Cargo.toml","If a custom path was passed, verify the file exists there or omit --sensor to use the default target/release path","Re-run `cargo clean` victims by rebuilding after any clean or toolchain switch","In CI, ensure the build step precedes the replay step"],"exampleFix":"# before\npython sensor/tools/refnet.py replay ...   # binary missing\n# after\ncargo build --release --manifest-path sensor/Cargo.toml\npython sensor/tools/refnet.py replay ...","handlingStrategy":"validation","validationCode":"import os\nsensor = \"sensor/target/release/maltrail-sensor\"\nassert os.path.isfile(sensor), \"run: cargo build --release --manifest-path sensor/Cargo.toml\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build the sensor before running refnet replay","In CI, make build a hard prerequisite of replay/scoring steps","Avoid cargo clean right before replay runs"],"tags":["python","rust","cargo","build-artifact"],"backgroundTag":"file-not-found","analyzedSha":"77cfb06d7606506d101bbcec0786c77166c4255e","analyzedAt":"2026-09-13T03:50:16.010Z","contentChangedAt":"2026-09-13T03:50:16.010Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}