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

[STAL-2617] Add Windows Support #480

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ num_cpus,https://github.com/seanmonstar/num_cpus,MIT, Copyright (c) 2015 Sean Mc
percent-encoding,https://github.com/servo/rust-url/,MIT, Copyright (c) 2013-2022 The rust-url developers
prettytable-rs,https://github.com/phsym/prettytable-rs/,BSD-3-Clause,Copyright (c) 2022 Pierre-Henri Symoneaux
rayon,https://crates.io/crates/rayon,MIT,Copyright (c) 2010 The Rust Project Developers
path_slash,https://github.com/rhysd/path-slash,MIT,Copyright (c) 2018 rhysd
pretty_yaml,https://github.com/g-plane/pretty_yaml,MIT,Copyright (c) 2024-present Pig Fang
rocket,https://github.com/SergioBenitez/Rocket,Apache-2.0,Copyright 2016 Sergio Benitez
tree-sitter,https://github.com/tree-sitter/tree-sitter,MIT,2014 Max Brunsfeld
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ sha2 = { workspace = true }
uuid = { workspace = true }
# other
csv = "1.3.0"

path-slash = "0.2.1"
percent-encoding = "2.3.1"
prettytable-rs = "0.10.0"
reqwest = { version = "0.11", features = ["blocking", "json"] }
Expand Down
21 changes: 14 additions & 7 deletions crates/cli/src/sarif/sarif_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use kernel::model::{
rule::{Rule, RuleResult},
violation::{Edit, EditType},
};
use path_slash::PathExt;
use percent_encoding::{utf8_percent_encode, AsciiSet, CONTROLS};
use secrets::model::secret_result::SecretResult;
use secrets::model::secret_rule::SecretRule;
Expand Down Expand Up @@ -142,10 +143,16 @@ impl SarifRuleResult {
}
}

fn file_path(&self) -> &str {
fn file_path(&self) -> String {
match self {
SarifRuleResult::StaticAnalysis(r) => r.filename.as_str(),
SarifRuleResult::Secret(r) => r.filename.as_str(),
SarifRuleResult::StaticAnalysis(r) => Path::new(r.filename.as_str())
.to_slash()
.unwrap()
.to_string(),
SarifRuleResult::Secret(r) => Path::new(r.filename.as_str())
.to_slash()
.unwrap()
.to_string(),
}
}

Expand Down Expand Up @@ -551,7 +558,7 @@ fn generate_results(
PhysicalLocationBuilder::default()
.artifact_location(
ArtifactLocationBuilder::default()
.uri(encode_filename(rule_result.file_path().to_string()))
.uri(encode_filename(rule_result.file_path()))
.build()
.unwrap(),
)
Expand All @@ -577,7 +584,7 @@ fn generate_results(
let changes = ArtifactChangeBuilder::default()
.artifact_location(
ArtifactLocationBuilder::default()
.uri(encode_filename(rule_result.file_path().to_string()))
.uri(encode_filename(rule_result.file_path()))
.build()?,
)
.replacements(replacements)
Expand All @@ -595,7 +602,7 @@ fn generate_results(

let sha_option = if options.add_git_info {
get_sha_for_line(
rule_result.file_path(),
rule_result.file_path().as_str(),
violation.start.line as usize,
&options,
)
Expand All @@ -607,7 +614,7 @@ fn generate_results(
rule_result.rule_name().to_string(),
&violation,
Path::new(options.repository_directory.as_str()),
Path::new(rule_result.file_path()),
Path::new(rule_result.file_path().as_str()),
options.debug,
);

Expand Down
Loading