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

Commit

Permalink
Fixing agent code. (#1516)
Browse files Browse the repository at this point in the history
* Fixing agent code.

* Update src/agent/stacktrace-parser/src/lib.rs

Co-authored-by: Cheick Keita <kcheick@gmail.com>

* Update src/agent/stacktrace-parser/src/lib.rs

Co-authored-by: Cheick Keita <kcheick@gmail.com>

* Formatting lib.rs

* Adding additional fix.

* Correct regex fix.

* Fixing var names.

* working to remove more clippy issues.

* Removing clippy and adding allows.

* Fixing tag for dead code

* Trying to figure out issue.

* Fixing jobs.rs.

* Adding tag.

* Running into syntax errors.

* Adding newline.

* Trying to add tag correctly.

* Another windows clippy fix.

* Adding allow tag to struct that appears used.

Co-authored-by: nharper285 <nharper285@gmail.com>
Co-authored-by: Cheick Keita <kcheick@gmail.com>
  • Loading branch information
3 people authored Dec 10, 2021
1 parent 3ffd7c4 commit 94e2904
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/agent/coverage/src/block/pe_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ where
// reverse the instrumented basic blocks.
fn provide_from_inline_table(&mut self, inline_table: SancovTable) -> Result<BTreeSet<u32>> {
let mut visitor =
SancovInlineAccessVisitor::new(inline_table, self.data, self.pe, &mut self.pdb)?;
SancovInlineAccessVisitor::new(inline_table, self.data, self.pe, self.pdb)?;

let debug_info = self.pdb.debug_information()?;
let mut modules = debug_info.modules()?;
Expand Down
1 change: 1 addition & 0 deletions src/agent/input-tester/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ where
}

#[derive(Debug)]
#[allow(dead_code)]
pub struct ProcessDetails<'a> {
pid: u32,
output: &'a Output,
Expand Down
1 change: 1 addition & 0 deletions src/agent/onefuzz-agent/src/local/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const FILE_MONITOR_POLLING_PERIOD: Duration = Duration::from_secs(5);
const EVENT_POLLING_PERIOD: Duration = Duration::from_secs(1);

#[derive(Debug, Default)]
#[allow(dead_code)]
struct CoverageData {
covered: Option<u64>,
features: Option<u64>,
Expand Down
7 changes: 0 additions & 7 deletions src/agent/onefuzz-agent/src/tasks/merge/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ use std::{
use storage_queue::{QueueClient, EMPTY_QUEUE_DELAY};
use tokio::process::Command;

#[derive(Debug, Deserialize)]
struct QueueMessage {
content_length: u32,

url: Url,
}

#[derive(Debug, Deserialize)]
pub struct Config {
pub supervisor_exe: String,
Expand Down
6 changes: 0 additions & 6 deletions src/agent/onefuzz-agent/src/tasks/merge/libfuzzer_merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ use std::{
};
use storage_queue::{QueueClient, EMPTY_QUEUE_DELAY};

#[derive(Debug, Deserialize)]
struct QueueMessage {
content_length: u32,
url: Url,
}

#[derive(Debug, Deserialize)]
pub struct Config {
pub target_exe: PathBuf,
Expand Down
8 changes: 4 additions & 4 deletions src/agent/onefuzz-agent/src/tasks/report/crash_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ pub struct NoCrash {
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum CrashTestResult {
CrashReport(CrashReport),
NoRepro(NoCrash),
CrashReport(Box<CrashReport>),
NoRepro(Box<NoCrash>),
}

#[derive(Debug, Deserialize, Serialize)]
Expand Down Expand Up @@ -268,13 +268,13 @@ pub async fn parse_report_file(path: PathBuf) -> Result<CrashTestResult> {
let report: Result<CrashReport, serde_json::Error> = serde_json::from_value(json.clone());

let report_err = match report {
Ok(report) => return Ok(CrashTestResult::CrashReport(report)),
Ok(report) => return Ok(CrashTestResult::CrashReport(Box::new(report))),
Err(err) => err,
};
let no_repro: Result<NoCrash, serde_json::Error> = serde_json::from_value(json);

let no_repro_err = match no_repro {
Ok(no_repro) => return Ok(CrashTestResult::NoRepro(no_repro)),
Ok(no_repro) => return Ok(CrashTestResult::NoRepro(Box::new(no_repro))),
Err(err) => err,
};

Expand Down
4 changes: 2 additions & 2 deletions src/agent/onefuzz-agent/src/tasks/report/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ pub async fn test_input(args: TestInputArgs<'_>) -> Result<CrashTestResult> {
input_sha256,
args.minimized_stack_depth,
);
Ok(CrashTestResult::CrashReport(crash_report))
Ok(CrashTestResult::CrashReport(Box::new(crash_report)))
} else {
let no_repro = NoCrash {
input_blob,
Expand All @@ -164,7 +164,7 @@ pub async fn test_input(args: TestInputArgs<'_>) -> Result<CrashTestResult> {
error: test_report.error.map(|e| format!("{}", e)),
};

Ok(CrashTestResult::NoRepro(no_repro))
Ok(CrashTestResult::NoRepro(Box::new(no_repro)))
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/agent/onefuzz-agent/src/tasks/report/libfuzzer_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ pub async fn test_input(args: TestInputArgs<'_>) -> Result<CrashTestResult> {
input_sha256,
args.minimized_stack_depth,
);
Ok(CrashTestResult::CrashReport(crash_report))
Ok(CrashTestResult::CrashReport(Box::new(crash_report)))
}
None => {
let no_repro = NoCrash {
Expand All @@ -163,7 +163,7 @@ pub async fn test_input(args: TestInputArgs<'_>) -> Result<CrashTestResult> {
error: test_report.error.map(|e| format!("{}", e)),
};

Ok(CrashTestResult::NoRepro(no_repro))
Ok(CrashTestResult::NoRepro(Box::new(no_repro)))
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/agent/onefuzz/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ impl ManagedIdentityCredentials {
// #get-an-access-token-using-the-vms-system-assigned-managed-identity
// -and-use-it-to-call-resource-manager
#[derive(Clone, Debug, Deserialize)]
#[allow(dead_code)]
struct ManagedIdentityAccessTokenBody {
access_token: Secret<String>,
resource: String,
Expand Down
4 changes: 2 additions & 2 deletions src/agent/srcview/src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl Report {
srcview: &SrcView,
include_regex: Option<&str>,
) -> Result<Self> {
let include = include_regex.map(|f| Regex::new(f)).transpose()?;
let include = include_regex.map(Regex::new).transpose()?;
let filecov = Self::compute_filecov(coverage, srcview, &include)?;

// should this function take &[ModOff] and perform the conversion itself?
Expand Down Expand Up @@ -352,7 +352,7 @@ impl Report {
/// println!("{}", xml);
/// ```
pub fn cobertura(&self, filter_regex: Option<&str>) -> Result<String> {
let filter = filter_regex.map(|f| Regex::new(f)).transpose()?;
let filter = filter_regex.map(Regex::new).transpose()?;

let mut backing: Vec<u8> = Vec::new();
let mut ew = EmitterConfig::new()
Expand Down
6 changes: 3 additions & 3 deletions src/agent/stacktrace-parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ fn function_without_args(func: &str) -> String {
// with ClusterFuzz, this is going to stay this way for now. This is used to
// fill in `minimized_stack_functions_names`. The unstripped version will be
// in `minimized_stack`.
func.splitn(2, '(')
.next()
.expect("splitn should always return at least one item")
func.split_once('(')
.map(|(x, _)| x)
.unwrap_or(func)
.to_string()
}

Expand Down
1 change: 1 addition & 0 deletions src/agent/win-util/src/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ impl JobInformation {
}

#[derive(Debug)]
#[allow(dead_code)]
pub struct JobObjectLimitNotification {
io_read_bytes_limit: Option<u64>,
io_write_bytes_limit: Option<u64>,
Expand Down

0 comments on commit 94e2904

Please sign in to comment.