Skip to content

Commit

Permalink
Merge pull request #73 from newrelic/scutler_20240822_2
Browse files Browse the repository at this point in the history
fixing build error
  • Loading branch information
cutler-scott-newrelic authored Aug 22, 2024
2 parents c607cf9 + df2858a commit 0b34a00
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
33 changes: 12 additions & 21 deletions src/bin/ankamali_hog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ extern crate yup_oauth2 as oauth2;
use clap::{Arg, ArgAction, ArgMatches, Command};
use drive3::DriveHub;
use log::{self, error, info};
use oauth2::{InstalledFlowAuthenticator, InstalledFlowReturnMethod};
use rusty_hog_scanner::{SecretScanner, SecretScannerBuilder};
use rusty_hogs::google_scanning::{GDriveFileInfo, GDriveScanner};
use simple_error::SimpleError;
Expand Down Expand Up @@ -136,33 +135,25 @@ async fn run(arg_matches: ArgMatches) -> Result<(), SimpleError> {
.get_one::<String>("OAUTHSECRETFILE")
.map(|s| s.as_str())
.unwrap_or("clientsecret.json");
let oauthtokenfile = arg_matches
.get_one::<String>("OAUTHTOKENFILE")
.map(|s| s.as_str())
.unwrap_or("temp_token");
let file_id = arg_matches.get_one::<String>("GDRIVEID").unwrap();
let secret_scanner = SecretScannerBuilder::new().conf_argm(&arg_matches).build();
let gdrive_scanner = GDriveScanner::new_from_scanner(secret_scanner);

// Start with GDrive auth - based on example code from drive3 API and yup-oauth2
let secret = yup_oauth2::read_application_secret(Path::new(oauthsecretfile))
// https://docs.rs/google-drive3/latest/google_drive3/
let secret = drive3::oauth2::read_application_secret(Path::new(oauthsecretfile))
.await
.expect(oauthsecretfile);
let auth = InstalledFlowAuthenticator::builder(secret, InstalledFlowReturnMethod::HTTPRedirect)
.persist_tokens_to_disk(Path::new(oauthtokenfile))
.build()
.await
.expect("failed to create authenticator (try deleting temp_token and restarting)");
let hub = DriveHub::new(
hyper::Client::builder().build(
hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
.https_only()
.enable_all_versions()
.build(),
),
auth,
);
// Instantiate the authenticator. It will choose a suitable authentication flow for you,
// unless you replace `None` with the desired Flow.
// Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
// what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
// retrieve them from storage.
let auth = drive3::oauth2::InstalledFlowAuthenticator::builder(
secret,
drive3::oauth2::InstalledFlowReturnMethod::HTTPRedirect,
).build().await.unwrap();
let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);

// get some initial info about the file
let gdriveinfo = GDriveFileInfo::new(file_id, &hub).await.unwrap();
Expand Down
6 changes: 3 additions & 3 deletions src/git_scanning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
//! assert_eq!(findings.len(), 8);
//! ```
use chrono::NaiveDateTime;
use chrono::{DateTime};
use chrono::Utc;
use encoding::all::ASCII;
use encoding::{DecoderTrap, Encoding};
Expand Down Expand Up @@ -243,8 +243,8 @@ impl GitScanner {
diff: ASCII
.decode(&new_line, DecoderTrap::Ignore)
.unwrap_or_else(|_| "<STRING DECODE ERROR>".parse().unwrap()),
date: NaiveDateTime::from_timestamp(commit.time().seconds(), 0)
.to_string(),
date: DateTime::from_timestamp(commit.time().seconds(), 0)
.expect("Failed to parse timestamp").to_string(),
strings_found: secrets.clone(),
path,
reason: reason.clone(),
Expand Down

0 comments on commit 0b34a00

Please sign in to comment.