Skip to content
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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Rust/gscan #639

wants to merge 12 commits into from

Conversation

pstadermann
Copy link
Contributor

Fix bugs (-f, -u)
Concurrent scans
Iterate over directories

@pstadermann
Copy link
Contributor Author

Line endings were CRLF. Diff is not really usable.

@GermanCoding GermanCoding marked this pull request as ready for review October 29, 2024 12:34
Copy link
Collaborator

@GermanCoding GermanCoding left a 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>,
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's consider adding args 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()));
Copy link
Collaborator

@GermanCoding GermanCoding Oct 29, 2024

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());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.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>>> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
) -> VResult<HashMap<Url, Result<VaasVerdict, vaas::error::Error>>> {
) -> HashMap<Url, VResult<VaasVerdict>> {

verdicts.insert(url.to_owned(), verdict);
}

Ok(verdicts)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Ok(verdicts)
verdicts

print_verdicts(p.display().to_string(), &verdict);
}).await;

let url_verdicts = scan_urls(args.urls.as_ref(), &vaas_connection).await?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let url_verdicts = scan_urls(args.urls.as_ref(), &vaas_connection).await?;
let url_verdicts = scan_urls(args.urls.as_ref(), &vaas_connection).await;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants