mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-12 18:18:08 +00:00
fix local generic analysis (#729)
This commit is contained in:
@ -29,7 +29,12 @@ pub fn build_analysis_config(
|
|||||||
let analyzer_env = get_hash_map(args, ANALYZER_ENV)?;
|
let analyzer_env = get_hash_map(args, ANALYZER_ENV)?;
|
||||||
let analysis = get_synced_dir(ANALYSIS_DIR, common.job_id, common.task_id, args)?;
|
let analysis = get_synced_dir(ANALYSIS_DIR, common.job_id, common.task_id, args)?;
|
||||||
let tools = get_synced_dir(TOOLS_DIR, common.job_id, common.task_id, args)?;
|
let tools = get_synced_dir(TOOLS_DIR, common.job_id, common.task_id, args)?;
|
||||||
let crashes = get_synced_dir(CRASHES_DIR, common.job_id, common.task_id, args).ok();
|
let crashes = if input_queue.is_none() {
|
||||||
|
get_synced_dir(CRASHES_DIR, common.job_id, common.task_id, args).ok()
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
let reports = get_synced_dir(REPORTS_DIR, common.job_id, common.task_id, args).ok();
|
let reports = get_synced_dir(REPORTS_DIR, common.job_id, common.task_id, args).ok();
|
||||||
let no_repro = get_synced_dir(NO_REPRO_DIR, common.job_id, common.task_id, args).ok();
|
let no_repro = get_synced_dir(NO_REPRO_DIR, common.job_id, common.task_id, args).ok();
|
||||||
let unique_reports =
|
let unique_reports =
|
||||||
|
@ -6,10 +6,10 @@ use crate::tasks::{
|
|||||||
};
|
};
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
use onefuzz::{az_copy, blob::url::BlobUrl, fs::SyncPath};
|
use onefuzz::{az_copy, blob::url::BlobUrl};
|
||||||
use onefuzz::{
|
use onefuzz::{
|
||||||
expand::Expand,
|
expand::Expand,
|
||||||
fs::{copy, set_executable, OwnedDir},
|
fs::{set_executable, OwnedDir},
|
||||||
jitter::delay_with_jitter,
|
jitter::delay_with_jitter,
|
||||||
process::monitor_process,
|
process::monitor_process,
|
||||||
syncdir::SyncedDir,
|
syncdir::SyncedDir,
|
||||||
@ -22,7 +22,7 @@ use std::{
|
|||||||
str,
|
str,
|
||||||
};
|
};
|
||||||
use storage_queue::{QueueClient, EMPTY_QUEUE_DELAY};
|
use storage_queue::{QueueClient, EMPTY_QUEUE_DELAY};
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir_in;
|
||||||
use tokio::{fs, process::Command};
|
use tokio::{fs, process::Command};
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
@ -48,8 +48,16 @@ pub struct Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn run(config: Config) -> Result<()> {
|
pub async fn run(config: Config) -> Result<()> {
|
||||||
let tmp_dir = PathBuf::from(format!("./{}/tmp", config.common.task_id));
|
let task_dir = config
|
||||||
let tmp = OwnedDir::new(tmp_dir);
|
.analysis
|
||||||
|
.path
|
||||||
|
.parent()
|
||||||
|
.ok_or_else(|| anyhow!("Invalid input path"))?;
|
||||||
|
let temp_path = task_dir.join(".temp");
|
||||||
|
tokio::fs::create_dir_all(&temp_path).await?;
|
||||||
|
let tmp_dir = tempdir_in(&temp_path)?;
|
||||||
|
let tmp = OwnedDir::new(tmp_dir.path());
|
||||||
|
|
||||||
tmp.reset().await?;
|
tmp.reset().await?;
|
||||||
|
|
||||||
config.analysis.init().await?;
|
config.analysis.init().await?;
|
||||||
@ -60,7 +68,7 @@ pub async fn run(config: Config) -> Result<()> {
|
|||||||
// report SyncedDir. The idea is that the option for where to write reports
|
// report SyncedDir. The idea is that the option for where to write reports
|
||||||
// is only available for target option / env expansion if one of the reports
|
// is only available for target option / env expansion if one of the reports
|
||||||
// SyncedDir is provided.
|
// SyncedDir is provided.
|
||||||
let reports_dir = tempdir()?;
|
let reports_dir = tempdir_in(temp_path)?;
|
||||||
let (reports_path, reports_monitor_future) =
|
let (reports_path, reports_monitor_future) =
|
||||||
if config.unique_reports.is_some() || config.reports.is_some() || config.no_repro.is_some()
|
if config.unique_reports.is_some() || config.reports.is_some() || config.no_repro.is_some()
|
||||||
{
|
{
|
||||||
@ -175,20 +183,14 @@ async fn _copy(input_url: BlobUrl, destination_folder: &OwnedDir) -> Result<Path
|
|||||||
destination_path.push(file_name);
|
destination_path.push(file_name);
|
||||||
match input_url {
|
match input_url {
|
||||||
BlobUrl::AzureBlob(input_url) => {
|
BlobUrl::AzureBlob(input_url) => {
|
||||||
az_copy::copy(input_url.as_ref(), destination_path.clone(), false).await?
|
az_copy::copy(input_url.as_ref(), &destination_path, false).await?
|
||||||
}
|
}
|
||||||
BlobUrl::LocalFile(path) => {
|
BlobUrl::LocalFile(path) => {
|
||||||
copy(
|
tokio::fs::copy(path, &destination_path).await?;
|
||||||
SyncPath::file(path),
|
|
||||||
SyncPath::dir(destination_path.clone()),
|
|
||||||
false,
|
|
||||||
)
|
|
||||||
.await?
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(destination_path)
|
Ok(destination_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn run_tool(
|
pub async fn run_tool(
|
||||||
input: impl AsRef<Path>,
|
input: impl AsRef<Path>,
|
||||||
config: &Config,
|
config: &Config,
|
||||||
|
@ -70,17 +70,24 @@ impl BlobUrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn name(&self) -> String {
|
pub fn name(&self) -> String {
|
||||||
let name_segments: Vec<_> = self
|
match self {
|
||||||
.url()
|
Self::AzureBlob(url) => {
|
||||||
.path_segments()
|
let name_segments: Vec<_> = url
|
||||||
.unwrap()
|
.path_segments()
|
||||||
.skip(match self {
|
.unwrap()
|
||||||
Self::AzureBlob(_) => 1,
|
.skip(1)
|
||||||
_ => 0,
|
.map(|s| s.to_owned())
|
||||||
})
|
.collect();
|
||||||
.map(|s| s.to_owned())
|
name_segments.join("/")
|
||||||
.collect();
|
}
|
||||||
name_segments.join("/")
|
Self::LocalFile(path) => path
|
||||||
|
.file_name()
|
||||||
|
.expect("Invalid file path")
|
||||||
|
.to_os_string()
|
||||||
|
.to_str()
|
||||||
|
.expect("Invalid file path")
|
||||||
|
.into(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user