Skip to content

Commit

Permalink
exec cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
fpereira24 committed Dec 17, 2024
1 parent f312d51 commit cc9ebd5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 21 deletions.
20 changes: 13 additions & 7 deletions apps/cargo-scout-audit/src/startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,26 @@ pub enum ScoutError {
}

#[derive(Default)]
pub struct ScoutResult{
pub struct ScoutResult {
pub findings: Vec<Finding>,
pub stdout_helper: String,
}

impl ScoutResult{
pub fn new(findings: Vec<Finding>, stdout_helper: String) -> Self{
Self { findings, stdout_helper }
impl ScoutResult {
pub fn new(findings: Vec<Finding>, stdout_helper: String) -> Self {
Self {
findings,
stdout_helper,
}
}
pub fn from_stdout(stdout_helper: String) -> Self{
pub fn from_stdout(stdout_helper: String) -> Self {
dbg!(&stdout_helper);
Self { findings: Vec::new(), stdout_helper }
Self {
findings: Vec::new(),
stdout_helper,
}
}
pub fn from_string<T: std::fmt::Display>(s: T) -> Self{
pub fn from_string<T: std::fmt::Display>(s: T) -> Self {
Self::from_stdout(format!("{}\n", s))
}
}
Expand Down
33 changes: 19 additions & 14 deletions apps/cargo-scout-audit/tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
mod tests {
use anyhow::{Context, Result};
use cargo_scout_audit::{
cli::{OutputFormat, Scout}, scout::findings::output_to_json, startup::run_scout, utils::json};
cli::{OutputFormat, Scout},
scout::findings::output_to_json,
startup::run_scout,
utils::json,
};
use lazy_static::lazy_static;
use std::{collections::HashMap, fs, path::PathBuf};
use std::{collections::HashMap, fs, path::PathBuf};

lazy_static! {
static ref DETECTORS_DIR: PathBuf = {
Expand Down Expand Up @@ -239,7 +243,8 @@ mod tests {
assert!(result.is_ok(), "Scout should run");
let result = result.unwrap();

let findings = result.findings
let findings = result
.findings
.iter()
.map(|value| value.code())
.filter(|x| x != "known_vulnerabilities")
Expand All @@ -259,11 +264,11 @@ mod tests {
#[test]
fn test_message_format() {
let contract_path = get_test_cases()
.iter()
.find(|y| y.to_str().unwrap().contains("substrate-pallets"))
.unwrap()
.clone();
.iter()
.find(|y| y.to_str().unwrap().contains("substrate-pallets"))
.unwrap()
.clone();

// When
let scout_opts = Scout {
manifest_path: Some(contract_path.to_path_buf()),
Expand All @@ -278,7 +283,7 @@ mod tests {

let json_output = output_to_json(output);

for val in json_output{
for val in json_output {
let json_result: Result<serde_json::Value, _> = serde_json::from_value(val);
assert!(
json_result.is_ok(),
Expand All @@ -291,11 +296,11 @@ mod tests {
#[test]
fn test_metadata() {
let contract_path = get_test_cases()
.iter()
.find(|y| y.to_str().unwrap().contains("substrate-pallets"))
.unwrap()
.clone();
.iter()
.find(|y| y.to_str().unwrap().contains("substrate-pallets"))
.unwrap()
.clone();

// When
let scout_opts = Scout {
manifest_path: Some(contract_path.to_path_buf()),
Expand Down

0 comments on commit cc9ebd5

Please sign in to comment.