mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-18 04:38:09 +00:00
Add task_id & job_id to variable expansion (#481)
Fixes #479 Note, this is built on top of #480
This commit is contained in:
@ -16,6 +16,8 @@ The following values are replaced with the specific values at runtime.
|
|||||||
* `{runtime_dir}`: Path to the runtime directory for the task
|
* `{runtime_dir}`: Path to the runtime directory for the task
|
||||||
* `{tools_dir}`: Path to the task specific `tools` directory
|
* `{tools_dir}`: Path to the task specific `tools` directory
|
||||||
* `{setup_dir}` : Path to the setup directory
|
* `{setup_dir}` : Path to the setup directory
|
||||||
|
* `{job_id}`: UUID that indicates the Job ID
|
||||||
|
* `{task_id}`: UUID that indicates the Task ID
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
@ -38,15 +40,18 @@ If you need `supervisor_options` to expand to: `"a", "b", "c", "d"`, you should
|
|||||||
|
|
||||||
These are currently used in the following tasks:
|
These are currently used in the following tasks:
|
||||||
|
|
||||||
* libfuzzer_fuzz: `target_exe`, `target_options`, `input_corpus`, `crashes`
|
* libfuzzer\_fuzz: `target_exe`, `target_options`, `input_corpus`, `crashes`
|
||||||
* libfuzzer_crash_report: `target_exe`, `target_options`, `input`
|
* libfuzzer\_crash\_report: `target_exe`, `target_options`, `input`
|
||||||
* libfuzzer_merge: `target_exe`, `target_options`, `input_corpus`
|
* libfuzzer\_merge: `target_exe`, `target_options`, `input_corpus`
|
||||||
* libfuzzer_coverage: None
|
* libfuzzer\_coverage: None
|
||||||
* generic_analysis: `input`, `target_exe`, `target_options`, `analyzer_exe`,
|
* generic\_analysis: `input`, `target_exe`, `target_options`, `analyzer_exe`,
|
||||||
`anayzer_options`, `output_dir`, `tools_dir`
|
`anayzer_options`, `output_dir`, `tools_dir`, `job_id`, `task_id`
|
||||||
* generic_generator: `generated_inputs`, `input_corpus`, `tools_dir`,
|
* generic\_generator: `generated_inputs`, `input_corpus`, `tools_dir`,
|
||||||
`generator_exe`, `generator_options`, `target_exe`, `target_options`, `input`
|
`generator_exe`, `generator_options`, `target_exe`, `target_options`,
|
||||||
* generic_supervisor: `crashes`, `runtime_dir`, `target_exe`, `target_options`,
|
`input`, `job_id`, `task_id`
|
||||||
`input_corpus`, `input`, `supervisor_exe`, `supervisor_options`, `tools_dir`
|
* generic\_supervisor: `crashes`, `runtime_dir`, `target_exe`, `target_options`,
|
||||||
* generic_merge: `input`, `input_corpus`, `output_dir`, `target_exe`,
|
`input_corpus`, `input`, `supervisor_exe`, `supervisor_options`, `tools_dir`,
|
||||||
`target_options`, `supervisor_exe`, `supervisor_options`, `tools_dir`
|
`job_id`, `task_id`
|
||||||
|
* generic\_merge: `input`, `input_corpus`, `output_dir`, `target_exe`,
|
||||||
|
`target_options`, `supervisor_exe`, `supervisor_options`, `tools_dir`,
|
||||||
|
`job_id`, `task_id`
|
||||||
|
@ -124,7 +124,9 @@ pub async fn run_tool(input: impl AsRef<Path>, config: &Config) -> Result<()> {
|
|||||||
.analyzer_options(&config.analyzer_options)
|
.analyzer_options(&config.analyzer_options)
|
||||||
.output_dir(&config.analysis.path)
|
.output_dir(&config.analysis.path)
|
||||||
.tools_dir(&config.tools.path)
|
.tools_dir(&config.tools.path)
|
||||||
.setup_dir(&config.common.setup_dir);
|
.setup_dir(&config.common.setup_dir)
|
||||||
|
.job_id(&config.common.job_id)
|
||||||
|
.task_id(&config.common.task_id);
|
||||||
|
|
||||||
let analyzer_path = expand.evaluate_value(&config.analyzer_exe)?;
|
let analyzer_path = expand.evaluate_value(&config.analyzer_exe)?;
|
||||||
|
|
||||||
|
@ -156,7 +156,9 @@ impl GeneratorTask {
|
|||||||
.generated_inputs(&output_dir)
|
.generated_inputs(&output_dir)
|
||||||
.input_corpus(&corpus_dir)
|
.input_corpus(&corpus_dir)
|
||||||
.generator_exe(&self.config.generator_exe)
|
.generator_exe(&self.config.generator_exe)
|
||||||
.generator_options(&self.config.generator_options);
|
.generator_options(&self.config.generator_options)
|
||||||
|
.job_id(&self.config.common.job_id)
|
||||||
|
.task_id(&self.config.common.task_id);
|
||||||
|
|
||||||
if let Some(tools) = &self.config.tools {
|
if let Some(tools) = &self.config.tools {
|
||||||
expand.tools_dir(&tools.path);
|
expand.tools_dir(&tools.path);
|
||||||
|
@ -181,7 +181,9 @@ async fn start_supervisor(
|
|||||||
.crashes(&crashes.path)
|
.crashes(&crashes.path)
|
||||||
.input_corpus(&inputs.path)
|
.input_corpus(&inputs.path)
|
||||||
.reports_dir(&reports_dir)
|
.reports_dir(&reports_dir)
|
||||||
.setup_dir(&config.common.setup_dir);
|
.setup_dir(&config.common.setup_dir)
|
||||||
|
.job_id(&config.common.job_id)
|
||||||
|
.task_id(&config.common.task_id);
|
||||||
|
|
||||||
if let Some(tools) = &config.tools {
|
if let Some(tools) = &config.tools {
|
||||||
expand.tools_dir(&tools.path);
|
expand.tools_dir(&tools.path);
|
||||||
|
@ -140,7 +140,9 @@ async fn merge(config: &Config, output_dir: impl AsRef<Path>) -> Result<()> {
|
|||||||
.generated_inputs(output_dir)
|
.generated_inputs(output_dir)
|
||||||
.target_exe(&config.target_exe)
|
.target_exe(&config.target_exe)
|
||||||
.setup_dir(&config.common.setup_dir)
|
.setup_dir(&config.common.setup_dir)
|
||||||
.tools_dir(&config.tools.path);
|
.tools_dir(&config.tools.path)
|
||||||
|
.job_id(&config.common.job_id)
|
||||||
|
.task_id(&config.common.task_id);
|
||||||
|
|
||||||
let supervisor_path = expand.evaluate_value(&config.supervisor_exe)?;
|
let supervisor_path = expand.evaluate_value(&config.supervisor_exe)?;
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ use std::collections::HashMap;
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
use strum_macros::EnumIter;
|
use strum_macros::EnumIter;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
pub enum ExpandedValue<'a> {
|
pub enum ExpandedValue<'a> {
|
||||||
Path(String),
|
Path(String),
|
||||||
@ -35,6 +36,8 @@ pub enum PlaceHolder {
|
|||||||
SupervisorOptions,
|
SupervisorOptions,
|
||||||
SetupDir,
|
SetupDir,
|
||||||
ReportsDir,
|
ReportsDir,
|
||||||
|
JobId,
|
||||||
|
TaskId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PlaceHolder {
|
impl PlaceHolder {
|
||||||
@ -59,6 +62,8 @@ impl PlaceHolder {
|
|||||||
Self::SupervisorOptions => "{supervisor_options}",
|
Self::SupervisorOptions => "{supervisor_options}",
|
||||||
Self::SetupDir => "{setup_dir}",
|
Self::SetupDir => "{setup_dir}",
|
||||||
Self::ReportsDir => "{reports_dir}",
|
Self::ReportsDir => "{reports_dir}",
|
||||||
|
Self::JobId => "{job_id}",
|
||||||
|
Self::TaskId => "{task_id}",
|
||||||
}
|
}
|
||||||
.to_string()
|
.to_string()
|
||||||
}
|
}
|
||||||
@ -233,6 +238,18 @@ impl<'a> Expand<'a> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn task_id(&mut self, arg: &Uuid) -> &mut Self {
|
||||||
|
let value = arg.to_hyphenated().to_string();
|
||||||
|
self.set_value(PlaceHolder::TaskId, ExpandedValue::Scalar(value));
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn job_id(&mut self, arg: &Uuid) -> &mut Self {
|
||||||
|
let value = arg.to_hyphenated().to_string();
|
||||||
|
self.set_value(PlaceHolder::JobId, ExpandedValue::Scalar(value));
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
fn replace_value(
|
fn replace_value(
|
||||||
&self,
|
&self,
|
||||||
fmtstr: &str,
|
fmtstr: &str,
|
||||||
|
Reference in New Issue
Block a user