optionally ignore dotfiles in syncdir monitors (#741)

This commit is contained in:
bmc-msft
2021-03-26 22:40:36 -04:00
committed by GitHub
parent fffaab2d25
commit b43a45187b
4 changed files with 19 additions and 8 deletions

View File

@ -80,7 +80,7 @@ impl GeneratorTask {
self.config.ensemble_sync_delay,
);
let crash_dir_monitor = self.config.crashes.monitor_results(new_result);
let crash_dir_monitor = self.config.crashes.monitor_results(new_result, false);
let fuzzer = self.fuzzing_loop(hb_client);

View File

@ -91,8 +91,8 @@ impl LibFuzzerFuzzTask {
// To be scheduled.
let resync = self.continuous_sync_inputs();
let new_inputs = self.config.inputs.monitor_results(new_coverage);
let new_crashes = self.config.crashes.monitor_results(new_result);
let new_inputs = self.config.inputs.monitor_results(new_coverage, true);
let new_crashes = self.config.crashes.monitor_results(new_result, true);
let (stats_sender, stats_receiver) = mpsc::unbounded_channel();
let report_stats = report_runtime_stats(self.workers() as usize, stats_receiver, hb_client);

View File

@ -71,7 +71,7 @@ pub async fn spawn(config: SupervisorConfig) -> Result<(), Error> {
url: config.crashes.url.clone(),
};
crashes.init().await?;
let monitor_crashes = crashes.monitor_results(new_result);
let monitor_crashes = crashes.monitor_results(new_result, false);
// setup reports
let reports_dir = tempdir()?;
@ -111,7 +111,7 @@ pub async fn spawn(config: SupervisorConfig) -> Result<(), Error> {
delay_with_jitter(delay).await;
}
}
let monitor_inputs = inputs.monitor_results(new_coverage);
let monitor_inputs = inputs.monitor_results(new_coverage, false);
let continuous_sync_task = inputs.continuous_sync(Pull, config.ensemble_sync_delay);
let process = start_supervisor(

View File

@ -155,7 +155,7 @@ impl SyncedDir {
}
}
async fn file_monitor_event(&self, event: Event) -> Result<()> {
async fn file_monitor_event(&self, event: Event, ignore_dotfiles: bool) -> Result<()> {
debug!("monitoring {}", self.path.display());
let mut monitor = DirectoryMonitor::new(self.path.clone());
monitor.start()?;
@ -167,6 +167,10 @@ impl SyncedDir {
let file_name = item
.file_name()
.ok_or_else(|| anyhow!("invalid file path"))?;
if ignore_dotfiles && file_name.to_string_lossy().starts_with('.') {
continue;
}
event!(event.clone(); EventData::Path = file_name.to_string_lossy());
let destination = path.join(file_name);
if let Err(err) = fs::copy(&item, &destination).await {
@ -188,6 +192,12 @@ impl SyncedDir {
let mut uploader = BlobUploader::new(self.url.url().clone());
while let Some(item) = monitor.next().await {
let file_name = item
.file_name()
.ok_or_else(|| anyhow!("invalid file path"))?;
if ignore_dotfiles && file_name.to_string_lossy().starts_with('.') {
continue;
}
event!(event.clone(); EventData::Path = item.display().to_string());
if let Err(err) = uploader.upload(item.clone()).await {
@ -221,7 +231,7 @@ impl SyncedDir {
/// The intent of this is to support use cases where we usually want a directory
/// to be initialized, but a user-supplied binary, (such as AFL) logically owns
/// a directory, and may reset it.
pub async fn monitor_results(&self, event: Event) -> Result<()> {
pub async fn monitor_results(&self, event: Event, ignore_dotfiles: bool) -> Result<()> {
loop {
debug!("waiting to monitor {}", self.path.display());
@ -231,7 +241,8 @@ impl SyncedDir {
}
debug!("starting monitor for {}", self.path.display());
self.file_monitor_event(event.clone()).await?;
self.file_monitor_event(event.clone(), ignore_dotfiles)
.await?;
}
}
}