Skip to main content

rusthound_ce/json/maker/
mod.rs

1use std::error::Error;
2
3extern crate zip;
4use crate::api::ADResults;
5use crate::args::Options;
6use crate::utils::date::return_current_fulldate;
7pub mod common;
8
9/// This function will create json output and zip output.
10///
11/// Objects are streamed directly to disk / into the zip archive instead of
12/// being fully materialised in memory first, so it stays flat on RAM even for
13/// domains with millions of objects.
14pub fn make_result(common_args: &Options, ad_results: ADResults) -> Result<String, Box<dyn Error>> {
15   // Format domain name
16   let filename = common_args.domain.replace('.', "-").to_lowercase();
17
18   // Datetime for output file
19   let datetime = return_current_fulldate();
20
21   if common_args.zip {
22      return common::make_a_zip(&datetime, &filename, &common_args.path, &ad_results);
23   }
24
25   common::write_json_files(&datetime, &filename, common_args, &ad_results)?;
26   Ok(String::from("No zip full path"))
27}