Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ stricter subset of Keep a Changelog).

### Changed

- Ignore symlinks and hidden bookkeeping files when copying artifact inputs and forwarding artifacts into the exchange directory in `CRSCompose`.
- Auditing CRS type: does not require a target harness and produces bug-candidates
- `oss-crs export` and `oss-crs import` commands — imports/exports docker images/CRS source code to transfer to another host.
- Run-phase modules now default to `target_dependent: true`, so their images are built once per target during `build-target`. Set `target_dependent: false` for modules that can be built once during `prepare`.
Expand Down
10 changes: 9 additions & 1 deletion oss_crs/src/crs_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -1653,6 +1653,8 @@ def _copy_forward_artifact_sources(
dst_dir,
dirs_exist_ok=True,
copy_function=shutil.copy2,
ignore=shutil.ignore_patterns(".*"),
symlinks=False,
)
copied_counts[artifact_dir] = count
records.append(
Expand Down Expand Up @@ -2483,12 +2485,18 @@ def _copy_artifact_input(
dst_dir,
dirs_exist_ok=True,
copy_function=shutil.copy2,
ignore=shutil.ignore_patterns(".*"),
symlinks=False,
)
else:
# Flat types (povs, seeds) are hash-named files; subdirectories
# would break the consumers' flat-listing assumption.
for f in artifact_input.directory.iterdir():
if f.is_file():
if (
f.is_file()
and not f.is_symlink()
and not f.name.startswith(".")
):
shutil.copy2(f, dst_dir / f.name)

def copy_artifact_inputs(progress: MultiTaskProgress) -> TaskResult:
Expand Down
53 changes: 53 additions & 0 deletions oss_crs/tests/unit/test_directed_inputs_behavior.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# SPDX-License-Identifier: MIT
import sys
from pathlib import Path
from unittest.mock import MagicMock

# Polyfill fcntl on platforms (such as Windows) where it is missing
if "fcntl" not in sys.modules:
try:
import fcntl # noqa: F401
except ImportError:
sys.modules["fcntl"] = MagicMock()

import oss_crs.src.crs_compose as crs_compose_module
from oss_crs.src.crs_compose import ArtifactInput, CRSCompose, ForwardArtifactSource
Expand Down Expand Up @@ -622,3 +631,47 @@ def test_forward_artifacts_prefers_processed_povs_and_forwards_patches(
assert (dst / "povs" / "triaged").read_text() == "triaged"
assert (dst / "patches" / "fix.diff").read_text() == "patch"
assert records[0]["copied"] == {"povs": 1, "patches": 1}


def test_copy_forward_artifact_sources_skips_hidden_and_symlinks(
tmp_path: Path,
) -> None:
compose = _make_run_compose(tmp_path)
target = Target(tmp_path / "work", tmp_path / "proj", None, "harness")
run_dir = tmp_path / "old" / "address" / "runs" / "run-1"
exchange = run_dir / "EXCHANGE_DIR" / "target_latest" / "harness"
(exchange / "patches").mkdir(parents=True)
(exchange / "patches" / "valid.diff").write_text("valid patch")
(exchange / "patches" / ".hidden.diff").write_text("hidden")

outside = tmp_path / "outside.txt"
outside.write_text("outside")
symlink_file = exchange / "patches" / "link.diff"
try:
symlink_file.symlink_to(outside)
except OSError:
pass

source = ForwardArtifactSource(
requested_run_id="run-1",
run_id="run-1",
sanitizer="address",
compose_hash="old",
run_dir=run_dir,
target_key="target_latest",
harness="harness",
exchange_dir=exchange,
processed_exchange_dir=None,
)

compose._copy_forward_artifact_sources(
sources=[source],
target=target,
run_id="new-run-symlink",
sanitizer="address",
)

dst = compose.work_dir.get_exchange_dir(target, "new-run-symlink", "address")
assert (dst / "patches" / "valid.diff").exists()
assert not (dst / "patches" / ".hidden.diff").exists()
assert not (dst / "patches" / "link.diff").exists()