Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Commit 8e2e11f

Browse files
authored
Downloading files to locally repro crashes (#3160)
Add `repro get_files` command
1 parent e448947 commit 8e2e11f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/cli/onefuzz/api.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,38 @@ def get(self, vm_id: UUID_EXPANSION) -> models.Repro:
546546
"GET", models.Repro, data=requests.ReproGet(vm_id=vm_id_expanded)
547547
)
548548

549+
def get_files(
550+
self,
551+
report_container: primitives.Container,
552+
report_name: str,
553+
include_setup: bool = False,
554+
output_dir: primitives.Directory = primitives.Directory("."),
555+
) -> None:
556+
"""downloads the files necessary to locally repro the crash from a given report"""
557+
report_bytes = self.onefuzz.containers.files.get(report_container, report_name)
558+
report = json.loads(report_bytes)
559+
560+
self.logger.info(
561+
"downloading files necessary to locally repro crash %s",
562+
report["input_blob"]["name"],
563+
)
564+
565+
self.onefuzz.containers.files.download(
566+
report["input_blob"]["container"],
567+
report["input_blob"]["name"],
568+
os.path.join(output_dir, report["input_blob"]["name"]),
569+
)
570+
571+
if include_setup:
572+
setup_container = list(
573+
self.onefuzz.jobs.containers.list(
574+
report["job_id"], enums.ContainerType.setup
575+
)
576+
)[0]
577+
self.onefuzz.containers.files.download_dir(
578+
primitives.Container(setup_container), output_dir
579+
)
580+
549581
def create(
550582
self, container: primitives.Container, path: str, duration: int = 24
551583
) -> models.Repro:

0 commit comments

Comments
 (0)