Skip to content

Commit fcef4c7

Browse files
committed
Sanitised more logs and secured more file path inputs
1 parent 591358e commit fcef4c7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/murfey/server/api/shared.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from werkzeug.utils import secure_filename
99

1010
import murfey.server.prometheus as prom
11-
from murfey.util import safe_run, sanitise
11+
from murfey.util import safe_run, sanitise, secure_path
1212
from murfey.util.config import MachineConfig, from_file, get_machine_config, settings
1313
from murfey.util.db import (
1414
DataCollection,
@@ -207,20 +207,23 @@ def gather_upstream_files(
207207
if file.is_file():
208208
file_list.append(file)
209209
logger.info(
210-
f"Found {len(file_list)} files for download from {upstream_instrument}"
210+
f"Found {len(file_list)} files for download "
211+
f"from {sanitise(upstream_instrument)}"
211212
)
212213
else:
213214
logger.warning(
214-
f"Upstream file searching has not been configured for {upstream_instrument} on {instrument_name}"
215+
"Upstream file searching has not been configured for "
216+
f"{sanitise(upstream_instrument)} on {sanitise(instrument_name)}"
215217
)
216218
return file_list
217219

218220

219221
def get_upstream_file(file_path: str | Path):
220222
file_path = Path(file_path) if isinstance(file_path, str) else file_path
223+
file_path = secure_path(file_path)
221224
if file_path.exists() and file_path.is_file():
222225
return file_path
223-
logger.warning(f"Requested file {str(file_path)!r} was not found")
226+
logger.warning(f"Requested file {sanitise(str(file_path))!r} was not found")
224227
return None
225228

226229

0 commit comments

Comments
 (0)