-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rust/gscan #639
base: main
Are you sure you want to change the base?
Rust/gscan #639
Conversation
Line endings were CRLF. Diff is not really usable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, only some small nits + minor feature request
help = "List of urls to scan separated by whitepace" | ||
)] | ||
urls: Vec<Url>, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's consider adding arg
s for VAAS_URL and TOKEN_URL so that non-prod envs can be used in the example.
|
||
fn expand_entry(p: &PathBuf) -> Box<dyn Iterator<Item = PathBuf>> { | ||
if p.is_file() { | ||
return Box::new(std::iter::once(p.clone())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: We can avoid the clone here by taking ownership of the PathBuf
in the function signature. This also makes sense syntactically.
.into_iter() | ||
.filter_map(|e| e.ok()) | ||
.filter(|e| e.file_type().is_file()) | ||
.map(|e| e.path().to_path_buf()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.map(|e| e.path().to_path_buf()); | |
.map(|e| e.into_path()); |
Simpler + avoids a clone
async fn scan_urls( | ||
urls: &[Url], | ||
vaas_connection: &Connection, | ||
) -> VResult<HashMap<Url, Result<VaasVerdict, vaas::error::Error>>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
) -> VResult<HashMap<Url, Result<VaasVerdict, vaas::error::Error>>> { | |
) -> HashMap<Url, VResult<VaasVerdict>> { |
verdicts.insert(url.to_owned(), verdict); | ||
} | ||
|
||
Ok(verdicts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok(verdicts) | |
verdicts |
print_verdicts(p.display().to_string(), &verdict); | ||
}).await; | ||
|
||
let url_verdicts = scan_urls(args.urls.as_ref(), &vaas_connection).await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let url_verdicts = scan_urls(args.urls.as_ref(), &vaas_connection).await?; | |
let url_verdicts = scan_urls(args.urls.as_ref(), &vaas_connection).await; |
Fix bugs (-f, -u)
Concurrent scans
Iterate over directories