Skip to content

Commit cdcc294

Browse files
committed
url quote all paths when updating build output paths
1 parent 80ae492 commit cdcc294

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

buildbot_nix/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import multiprocessing
77
import os
88
import re
9+
import urllib.parse
910
from collections import defaultdict
1011
from collections.abc import Generator, Iterable
1112
from dataclasses import dataclass
@@ -798,9 +799,9 @@ def join_traversalsafe(self, root: Path, joined: Path) -> Path:
798799

799800
return root
800801

801-
def join_all_traversalsafe(self, root: Path, *paths: Path) -> Path:
802+
def join_all_traversalsafe(self, root: Path, *paths: str) -> Path:
802803
for path in paths:
803-
root = self.join_traversalsafe(root, path)
804+
root = self.join_traversalsafe(root, Path(path))
804805

805806
return root
806807

@@ -816,14 +817,13 @@ def run(self) -> Generator[Any, object, Any]:
816817
if not out_path: # if, e.g., the build fails and doesn't produce an output
817818
return util.SKIPPED
818819

819-
project_name = Path(props.getProperty("projectname"))
820-
821-
target = Path(props.getProperty("branch"))
822-
823-
attr = Path(props.getProperty("attr"))
820+
owner = urllib.parse.quote_plus(self.project.owner)
821+
repo = urllib.parse.quote_plus(self.project.repo)
822+
target = urllib.parse.quote_plus(props.getProperty("branch"))
823+
attr = urllib.parse.quote_plus(props.getProperty("attr"))
824824

825825
try:
826-
file = self.join_all_traversalsafe(self.path, project_name, target, attr)
826+
file = self.join_all_traversalsafe(self.path, owner, repo, target, attr)
827827
except ValueError as e:
828828
error_log: StreamLog = yield self.addLog("path_error")
829829
error_log.addStderr(f"Path traversal prevented ... skipping update: {e}")

0 commit comments

Comments
 (0)