mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
(extra) check on storage event_id uuid-ness before using in filenames
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import uuid
|
||||
import contextlib
|
||||
import os.path
|
||||
from pathlib import Path
|
||||
@@ -41,6 +42,13 @@ class FileEventStorage(EventStorage):
|
||||
def _event_path(self, event_id):
|
||||
# the dashes in uuid are preserved in the filename for readability; since their location is consistent, this is
|
||||
# not a problem.
|
||||
|
||||
# event_id comes from event.id, i.e. it's a UUID object which is generated by Bugsink itself (i.e. trusted).
|
||||
# The check below exists exclusively such that the security-implications of os.path.join can be understood right
|
||||
# here in the code without needing to inspect all call-sites:
|
||||
if not isinstance(event_id, uuid.UUID):
|
||||
raise ValueError("event_id must be a UUID")
|
||||
|
||||
return os.path.join(self.basepath, str(event_id) + ".json")
|
||||
|
||||
@contextlib.contextmanager
|
||||
|
||||
Reference in New Issue
Block a user