Skip to content

Commit f36faa9

Browse files
committed
Revert "feat!: Update output path writing"
This reverts commit 3dbf4d9.
1 parent 3240cdf commit f36faa9

File tree

1 file changed

+6
-56
lines changed

1 file changed

+6
-56
lines changed

buildbot_nix/__init__.py

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -756,57 +756,16 @@ def __init__(self, project: GitProject, path: Path, **kwargs: Any) -> None:
756756
self.project = project
757757
self.path = path
758758

759-
def join_traversalsafe(self, root: Path, joined: Path) -> Path:
760-
root = root.resolve()
761-
762-
for part in joined.parts:
763-
new_root = (root / part).resolve()
764-
765-
if not new_root.is_relative_to(root):
766-
msg = f"Joined path attempted to traverse upwards when processing {root} against {part} (gave {new_root})"
767-
raise ValueError(msg)
768-
769-
root = new_root
770-
771-
return root
772-
773-
def join_all_traversalsafe(self, root: Path, *paths: Path) -> Path:
774-
for path in paths:
775-
root = self.join_traversalsafe(root, path)
776-
777-
return root
778-
779-
@defer.inlineCallbacks
780759
def run(self) -> Generator[Any, object, Any]:
781760
props = self.build.getProperties()
782-
783-
pr = props.getProperty("pr_number")
784-
785-
if not pr and props.getProperty("branch") != self.project.default_branch:
761+
if props.getProperty("branch") != self.project.default_branch:
786762
return util.SKIPPED
787763

764+
attr = Path(props.getProperty("attr")).name
788765
out_path = props.getProperty("out_path")
789-
790-
if not out_path: # if, e.g., the build fails and doesn't produce an output
791-
return util.SKIPPED
792-
793-
project_name = Path(props.getProperty("projectname"))
794-
795-
target = Path(f"pulls/{pr}") if pr else Path(props.getProperty("branch"))
796-
797-
attr = Path(props.getProperty("attr"))
798-
799-
try:
800-
file = self.join_all_traversalsafe(self.path, project_name, target, attr)
801-
except ValueError as e:
802-
error_log: StreamLog = yield self.addLog("path_error")
803-
error_log.addStderr(f"Path traversal prevented ... skipping update: {e}")
804-
return util.FAILURE
805-
806-
file.parent.mkdir(parents=True, exist_ok=True)
807-
808-
file.write_text(out_path)
809-
766+
# XXX don't hardcode this
767+
self.path.mkdir(parents=True, exist_ok=True)
768+
(self.path / attr).write_text(out_path)
810769
return util.SUCCESS
811770

812771

@@ -1115,7 +1074,6 @@ def nix_cached_failure_config(
11151074
def nix_skipped_build_config(
11161075
project: GitProject,
11171076
worker_names: list[str],
1118-
outputs_path: Path | None = None,
11191077
) -> BuilderConfig:
11201078
"""Dummy builder that is triggered when a build is skipped."""
11211079
factory = util.BuildFactory()
@@ -1144,14 +1102,6 @@ def nix_skipped_build_config(
11441102
set_properties={"report_status": False},
11451103
),
11461104
)
1147-
if outputs_path is not None:
1148-
factory.addStep(
1149-
UpdateBuildOutput(
1150-
project=project,
1151-
name="Update build output",
1152-
path=outputs_path,
1153-
),
1154-
)
11551105
return util.BuilderConfig(
11561106
name=f"{project.name}/nix-skipped-build",
11571107
project=project.name,
@@ -1300,7 +1250,7 @@ def config_for_project(
13001250
outputs_path=outputs_path,
13011251
post_build_steps=post_build_steps,
13021252
),
1303-
nix_skipped_build_config(project, [SKIPPED_BUILDER_NAME], outputs_path),
1253+
nix_skipped_build_config(project, [SKIPPED_BUILDER_NAME]),
13041254
nix_failed_eval_config(project, [SKIPPED_BUILDER_NAME]),
13051255
nix_dependency_failed_config(project, [SKIPPED_BUILDER_NAME]),
13061256
nix_cached_failure_config(project, [SKIPPED_BUILDER_NAME]),

0 commit comments

Comments
 (0)