Python tool for aircraft Doppler audio geolocation using historical ADS-B flight data (Source-available)
Python acoustic-geolocationads-baircraft-trackingairplaneaudio-forensicsdoppler-effectdoppler-shiftgeolocationosintsignal-processing
fix(#11): hide internal job control lock artifacts
Cinna Davisc905d2cfc49a
diff --git a/src/dopplergeist/service.py b/src/dopplergeist/service.pyindex 4965a46..76445d7 100644--- a/src/dopplergeist/service.py+++ b/src/dopplergeist/service.py@@ -8,6 +8,8 @@ from urllib.parse import unquote, urlsplitfrom .jobs import JobManager+_EXCLUDED_ARTIFACTS = {"operator.json", "cancel", ".control.lock"}+class JobServer(ThreadingHTTPServer):daemon_threads = True@@ -77,14 +79,16 @@ class Handler(BaseHTTPRequestHandler):directory = manager.directory(job_id)artifacts = []for path in sorted(directory.rglob("*")):- if path.is_file() and not path.is_symlink() and path.name not in {"operator.json", "cancel"} and not path.name.endswith(".tmp"):+ if path.is_file() and not path.is_symlink() and path.name not in _EXCLUDED_ARTIFACTS and not path.name.endswith(".tmp"):artifacts.append({"path": path.relative_to(directory).as_posix(), "bytes": path.stat().st_size})return self._reply({"artifacts": artifacts})if self.command == "GET" and len(parts) > 4 and parts[3] == "artifacts":directory = manager.directory(job_id)relative = Path(*parts[4:])path = (directory / relative).resolve()- if path == directory or directory not in path.parents or not path.is_file() or "operator.json" in relative.parts:+ if (path == directory or directory not in path.parents or not path.is_file()+ or any(part in _EXCLUDED_ARTIFACTS for part in relative.parts)+ or relative.name.endswith(".tmp")):raise KeyError("Unknown artifact")return self._file(path, download=path.suffix not in {".png", ".svg"})if self.command == "GET":diff --git a/tests/test_service.py b/tests/test_service.pyindex 246de82..8039c3e 100644--- a/tests/test_service.py+++ b/tests/test_service.py@@ -58,6 +58,24 @@ def test_upload_readback_cancel_and_original_preservation(tmp_path, monkeypatch)restarted.close()+def test_internal_control_lock_is_not_a_downloadable_artifact(tmp_path, monkeypatch):+ with running_server(tmp_path, monkeypatch) as (manager, url):+ job_id = "0123456789abcdef0123456789abcdef"+ directory = manager.root / job_id+ directory.mkdir()+ result(directory, "needs_input", reason_code="recording_time_required",+ message="Supply a defensible UTC window.", required_fields=["time_window"])+ (directory / ".control.lock").touch()+ (directory / "discovery.json").write_text("{}")++ items = request(url + f"/api/jobs/{job_id}/artifacts")[1]["artifacts"]+ assert "discovery.json" in [item["path"] for item in items]+ assert ".control.lock" not in [item["path"] for item in items]+ with pytest.raises(urllib.error.HTTPError) as error:+ request(url + f"/api/jobs/{job_id}/artifacts/.control.lock")+ assert error.value.code == 404++def test_terminal_result_survives_restart_and_interrupted_job_is_explicit(tmp_path, monkeypatch):monkeypatch.setattr(JobManager, "_run", lambda self, directory: None)manager = JobManager(tmp_path)