fix extra container intilization (#2887)

* fix extra container intilization

* fix extra url download

* fix extra dir parameter to the agent

* rename extra to extra_dir
This commit is contained in:
Cheick Keita
2023-02-27 13:57:32 -08:00
committed by GitHub
parent a7eab4d973
commit 3d299ce51e
5 changed files with 33 additions and 7 deletions

View File

@ -26,7 +26,7 @@ The following values are replaced with the specific values at runtime.
* `{crashes_container}`: Container name for the `crashes` container * `{crashes_container}`: Container name for the `crashes` container
* `{microsoft_telemetry_key}`: Application Insights key used for collecting [non-attributable telemetry](telemetry.md) to improve OneFuzz. * `{microsoft_telemetry_key}`: Application Insights key used for collecting [non-attributable telemetry](telemetry.md) to improve OneFuzz.
* `{instance_telemetry_key}`: Application Insights key used for private, instance-owned telemetry and logging (See [OneFuzz Telemetry](telemetry.md). * `{instance_telemetry_key}`: Application Insights key used for private, instance-owned telemetry and logging (See [OneFuzz Telemetry](telemetry.md).
* `{extra}`: Path to the optionally provided `extra` directory * `{extra_dir}`: Path to the optionally provided `extra` directory
## Example ## Example

View File

@ -43,12 +43,15 @@ pub struct SetupRunner {
impl SetupRunner { impl SetupRunner {
pub async fn run(&self, work_set: &WorkSet) -> Result<SetupOutput> { pub async fn run(&self, work_set: &WorkSet) -> Result<SetupOutput> {
if let (Some(extra_url), Some(extra_dir)) = (&work_set.extra_url, work_set.extra_dir()?) { if let (Some(extra_container), Some(extra_dir)) =
(&work_set.extra_url, work_set.extra_dir()?)
{
info!("downloading extra container"); info!("downloading extra container");
// `azcopy sync` requires the local dir to exist. // `azcopy sync` requires the local dir to exist.
fs::create_dir_all(&extra_dir).await.with_context(|| { fs::create_dir_all(&extra_dir).await.with_context(|| {
format!("unable to create extra container: {}", extra_dir.display()) format!("unable to create extra container: {}", extra_dir.display())
})?; })?;
let extra_url = extra_container.url()?;
az_copy::sync(extra_url.to_string(), &extra_dir, false).await?; az_copy::sync(extra_url.to_string(), &extra_dir, false).await?;
debug!( debug!(
"synced extra container from {} to {}", "synced extra container from {} to {}",

View File

@ -279,7 +279,6 @@ impl IWorkerRunner for WorkerRunner {
cmd.arg("config.json"); cmd.arg("config.json");
cmd.arg(setup_dir); cmd.arg(setup_dir);
if let Some(extra_dir) = extra_dir { if let Some(extra_dir) = extra_dir {
cmd.arg("--extra_dir");
cmd.arg(extra_dir); cmd.arg(extra_dir);
} }

View File

@ -74,7 +74,6 @@ class Libfuzzer(Command):
analyzer_options: Optional[List[str]] = None, analyzer_options: Optional[List[str]] = None,
analyzer_env: Optional[Dict[str, str]] = None, analyzer_env: Optional[Dict[str, str]] = None,
tools: Optional[Container] = None, tools: Optional[Container] = None,
extra_container: Optional[Container] = None,
) -> None: ) -> None:
target_options = target_options or [] target_options = target_options or []
@ -88,6 +87,11 @@ class Libfuzzer(Command):
), ),
] ]
if ContainerType.extra in containers:
regression_containers.append(
(ContainerType.extra, containers[ContainerType.extra])
)
# We don't really need a separate timeout for crash reporting, and we could just # We don't really need a separate timeout for crash reporting, and we could just
# use `target_timeout`. But `crash_report_timeout` was introduced first, so we # use `target_timeout`. But `crash_report_timeout` was introduced first, so we
# can't remove it without a breaking change. Since both timeouts may be present, # can't remove it without a breaking change. Since both timeouts may be present,
@ -129,6 +133,11 @@ class Libfuzzer(Command):
) )
) )
if ContainerType.extra in containers:
fuzzer_containers.append(
(ContainerType.extra, containers[ContainerType.extra])
)
self.logger.info("creating libfuzzer task") self.logger.info("creating libfuzzer task")
# disable ensemble sync if only one VM is used # disable ensemble sync if only one VM is used
@ -172,6 +181,11 @@ class Libfuzzer(Command):
(ContainerType.readonly_inputs, containers[ContainerType.inputs]), (ContainerType.readonly_inputs, containers[ContainerType.inputs]),
] ]
if ContainerType.extra in containers:
coverage_containers.append(
(ContainerType.extra, containers[ContainerType.extra])
)
if ContainerType.readonly_inputs in containers: if ContainerType.readonly_inputs in containers:
coverage_containers.append( coverage_containers.append(
( (
@ -232,6 +246,11 @@ class Libfuzzer(Command):
(ContainerType.no_repro, containers[ContainerType.no_repro]), (ContainerType.no_repro, containers[ContainerType.no_repro]),
] ]
if ContainerType.extra in containers:
report_containers.append(
(ContainerType.extra, containers[ContainerType.extra])
)
self.logger.info("creating libfuzzer_crash_report task") self.logger.info("creating libfuzzer_crash_report task")
self.onefuzz.tasks.create( self.onefuzz.tasks.create(
job.job_id, job.job_id,
@ -270,6 +289,11 @@ class Libfuzzer(Command):
(ContainerType.crashes, containers[ContainerType.crashes]), (ContainerType.crashes, containers[ContainerType.crashes]),
] ]
if ContainerType.extra in containers:
analysis_containers.append(
(ContainerType.extra, containers[ContainerType.extra])
)
self.onefuzz.tasks.create( self.onefuzz.tasks.create(
job.job_id, job.job_id,
TaskType.generic_analysis, TaskType.generic_analysis,

View File

@ -109,7 +109,7 @@ TARGETS: Dict[str, Integration] = {
}, },
reboot_after_setup=True, reboot_after_setup=True,
inject_fake_regression=True, inject_fake_regression=True,
fuzzing_target_options=["--test:{extra}"], fuzzing_target_options=["--test:{extra_dir}"],
), ),
"linux-libfuzzer-with-options": Integration( "linux-libfuzzer-with-options": Integration(
template=TemplateType.libfuzzer, template=TemplateType.libfuzzer,
@ -181,7 +181,7 @@ TARGETS: Dict[str, Integration] = {
os=OS.linux, os=OS.linux,
target_exe="fuzz_target_1", target_exe="fuzz_target_1",
wait_for_files={ContainerType.unique_reports: 1, ContainerType.coverage: 1}, wait_for_files={ContainerType.unique_reports: 1, ContainerType.coverage: 1},
fuzzing_target_options=["--test:{extra}"], fuzzing_target_options=["--test:{extra_dir}"],
), ),
"linux-trivial-crash": Integration( "linux-trivial-crash": Integration(
template=TemplateType.radamsa, template=TemplateType.radamsa,
@ -211,7 +211,7 @@ TARGETS: Dict[str, Integration] = {
ContainerType.coverage: 1, ContainerType.coverage: 1,
}, },
inject_fake_regression=True, inject_fake_regression=True,
fuzzing_target_options=["--test:{extra}"], fuzzing_target_options=["--test:{extra_dir}"],
), ),
"windows-libfuzzer-linked-library": Integration( "windows-libfuzzer-linked-library": Integration(
template=TemplateType.libfuzzer, template=TemplateType.libfuzzer,