Skip to content

Commit

Permalink
remove json flag from binary
Browse files Browse the repository at this point in the history
  • Loading branch information
0xOsiris committed Dec 7, 2023
1 parent b7226e5 commit 2137f7d
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions bin/sstan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,13 @@ pub struct Args {
help = "Path to `.toml` file containing a custom sstan configuration."
)]
pub toml: Option<String>,

//TODO: @0xOsiris lets remove this and write the md as well as the json report by default.
#[clap(
short,
long,
help = "Path to the directory to write the JSON report to. The JSON report will not be written without this flag."
)]
pub json: Option<String>,
}

#[derive(Default)]
pub struct Opts {
pub path: String,
pub output: String,
pub git: Option<String>,
pub json: Option<String>,
vulnerabilities: Vec<VulnerabilityTarget>,
optimizations: Vec<OptimizationTarget>,
qa: Vec<QualityAssuranceTarget>,
Expand Down Expand Up @@ -109,7 +100,6 @@ impl Opts {
path: args.path.unwrap_or(DEFAULT_PATH.into()),
output: args.output.unwrap_or_default(),
git: args.git,
json: args.json,
optimizations,
vulnerabilities,
qa,
Expand All @@ -132,15 +122,12 @@ fn main() -> eyre::Result<()> {
engine.run()?;
//Generate the report struct
let report = Report::from(engine);
//Generate the report string & write to the output path.
//Write to json if the flag is passed
if let Some(json_path) = opts.json {
std::fs::File::create(json_path)?.write_all(
serde_json::to_string(&JsonReport::from(report.clone()))
.unwrap()
.as_bytes(),
)?;
}
//Write to json
std::fs::File::create("sstan.json")?.write_all(
serde_json::to_string(&JsonReport::from(report.clone()))
.unwrap()
.as_bytes(),
)?;

//Write to markdown
std::fs::File::create("sstan.md")?.write_all(String::from(report).as_bytes())?;
Expand Down

0 comments on commit 2137f7d

Please sign in to comment.