Skip to content

Commit 0b34a00

Browse files
Merge pull request #73 from newrelic/scutler_20240822_2
fixing build error
2 parents c607cf9 + df2858a commit 0b34a00

File tree

2 files changed

+15
-24
lines changed

2 files changed

+15
-24
lines changed

src/bin/ankamali_hog.rs

+12-21
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ extern crate yup_oauth2 as oauth2;
3232
use clap::{Arg, ArgAction, ArgMatches, Command};
3333
use drive3::DriveHub;
3434
use log::{self, error, info};
35-
use oauth2::{InstalledFlowAuthenticator, InstalledFlowReturnMethod};
3635
use rusty_hog_scanner::{SecretScanner, SecretScannerBuilder};
3736
use rusty_hogs::google_scanning::{GDriveFileInfo, GDriveScanner};
3837
use simple_error::SimpleError;
@@ -136,33 +135,25 @@ async fn run(arg_matches: ArgMatches) -> Result<(), SimpleError> {
136135
.get_one::<String>("OAUTHSECRETFILE")
137136
.map(|s| s.as_str())
138137
.unwrap_or("clientsecret.json");
139-
let oauthtokenfile = arg_matches
140-
.get_one::<String>("OAUTHTOKENFILE")
141-
.map(|s| s.as_str())
142-
.unwrap_or("temp_token");
143138
let file_id = arg_matches.get_one::<String>("GDRIVEID").unwrap();
144139
let secret_scanner = SecretScannerBuilder::new().conf_argm(&arg_matches).build();
145140
let gdrive_scanner = GDriveScanner::new_from_scanner(secret_scanner);
146141

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

167158
// get some initial info about the file
168159
let gdriveinfo = GDriveFileInfo::new(file_id, &hub).await.unwrap();

src/git_scanning.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
//! assert_eq!(findings.len(), 8);
4343
//! ```
4444
45-
use chrono::NaiveDateTime;
45+
use chrono::{DateTime};
4646
use chrono::Utc;
4747
use encoding::all::ASCII;
4848
use encoding::{DecoderTrap, Encoding};
@@ -243,8 +243,8 @@ impl GitScanner {
243243
diff: ASCII
244244
.decode(&new_line, DecoderTrap::Ignore)
245245
.unwrap_or_else(|_| "<STRING DECODE ERROR>".parse().unwrap()),
246-
date: NaiveDateTime::from_timestamp(commit.time().seconds(), 0)
247-
.to_string(),
246+
date: DateTime::from_timestamp(commit.time().seconds(), 0)
247+
.expect("Failed to parse timestamp").to_string(),
248248
strings_found: secrets.clone(),
249249
path,
250250
reason: reason.clone(),

0 commit comments

Comments
 (0)