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

Update dependencies #62

Merged
merged 26 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
65ea283
Update deps for nested crate...
zcarlson-signifai Dec 3, 2023
22272ce
rusty-hogs dep update: clap: duroc_hog
zcarlson-signifai Dec 3, 2023
6eba5c7
rusty-hogs dep update: clap: choctaw_hog
zcarlson-signifai Dec 3, 2023
efc4f9c
rusty-hogs dep update: clap: berkshire_hog
zcarlson-signifai Dec 3, 2023
aecd3fe
rusty-hogs dep update: clap: hante_hog
zcarlson-signifai Dec 3, 2023
c1000df
rusty-hogs dep update: clap: ankamali_hog, essex_hog, gottingen_hog
zcarlson-signifai Dec 4, 2023
8d83222
Update some deps I know haven't changed
zcarlson-signifai Dec 4, 2023
60fb41c
Couple more bumps that worked out
zcarlson-signifai Dec 4, 2023
21835ff
base64
zcarlson-signifai Dec 4, 2023
9a5f580
lambda_runtime
zcarlson-signifai Dec 4, 2023
c1d3a5c
rust-s3
zcarlson-signifai Dec 4, 2023
401d39f
rust-s3 again
zcarlson-signifai Dec 4, 2023
f6b748f
Update hyper_rustls, hyper, and google-drive3
zcarlson-signifai Dec 4, 2023
a221670
Do a more appropriately generic structure
zcarlson-signifai Dec 4, 2023
86035e1
rustfmt google_scanning
zcarlson-signifai Dec 4, 2023
48a0d30
Update deps in Cargo.toml
zcarlson-signifai Dec 4, 2023
f84a962
rustfmt the rest of the owl
zcarlson-signifai Dec 4, 2023
f17e6b5
rustfmt rusty-hog-scanner crate
zcarlson-signifai Dec 22, 2023
ad455ad
x86_64-linux-musl: install openssl dev before compiling
zcarlson-signifai Dec 22, 2023
913ed26
arg DEFAULT_ENTROPY_THRESHOLD fix
zcarlson-signifai Dec 22, 2023
eb75fdc
default_entropy_threshold parse update
zcarlson-signifai Dec 22, 2023
76b1c15
Fix tests, cargo fmt again
zcarlson-signifai Dec 22, 2023
affa345
the git-scanning test needs git history to work
zcarlson-signifai Jan 19, 2024
b3b7520
insecure-file path affected by Windows
zcarlson-signifai Jan 19, 2024
17795de
cargo fmt
zcarlson-signifai Jan 19, 2024
8272a01
two double-backslashes
zcarlson-signifai Jan 19, 2024
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
3 changes: 3 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
# git-scanning tests need entire git history to work
fetch-depth: 0
- name: Install ${{ matrix.rust }}-${{ matrix.target }} toolchain
uses: actions-rs/toolchain@v1
with:
Expand Down
33 changes: 18 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ members = [
name = "rusty_hogs"
version = "1.0.11"
authors = ["Scott Cutler <scutler@newrelic.com>"]
edition = "2018"
edition = "2021"
description = "This project provides a set of scanners that will use regular expressions to try and detect the presence of sensitive information such as API keys, passwords, and personal information. It includes a set of regular expressions by default, but will also accept a JSON object containing your custom regular expressions."
homepage = "https://github.com/newrelic/rusty-hog"
keywords = ["secret", "scanner", "regex", "rusty", "hog"]
Expand All @@ -18,38 +18,41 @@ license = "Apache-2.0"
[dependencies]
rusty_hog_scanner = { path = "crates/rusty-hog-scanner" }
tokio = { version = "1", features = ["full"] }
git2 = "0.13"
git2 = "0.18"
serde = "1.0"
serde_json = "1.0"
serde_derive = "^1"
clap = "2"
clap = "4"
regex = "1"
url = "2"
tempdir = "0.3"
base64 = "0.13"
base64 = "0.21"
log = "0.4"
simple_logger = "1.11"
simple-error = "0.2"
simple_logger = "4.3"
simple-error = "0.3"
chrono = "0.4"
encoding = "0.2"
hex = "0.4"
lambda_runtime = "0.3"
rust-s3 = "0.26"
google-drive3 = "2.0.4"
hyper = "^0.14"
hyper-rustls = "^0.22"
yup-oauth2 = "^5.0"
lambda_runtime = "0.8"
rust-s3 = { version = "0.33", features = ["blocking"] }
google-drive3 = "5.0"
hyper = { version = "^0.14", features = ["client"] }
hyper-rustls = "^0.24"
yup-oauth2 = "^8.3"
walkdir = "2"
zip = "0.5"
zip = "0.6"
tar = "0.4"
flate2 = "1.0"
tempfile = "3.2"
path-clean = "0.1.0"
path-clean = "1.0"
anyhow = "1.0"

[dev-dependencies]
escargot = "0.5.0"

[profile.release]
lto = true
codegen-units = 1
codegen-units = 1

[package.metadata.cross.target.x86_64-unknown-linux-musl]
dockerfile = "Dockerfile.lambda"
16 changes: 16 additions & 0 deletions Dockerfile.lambda
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ARG CROSS_BASE_IMAGE
FROM ${CROSS_BASE_IMAGE}
# Note that we're assuming an Ubuntu-based image in all cases though

ARG CFLAGS=""
ARG LDFLAGS=""

ARG OPENSSL_BUILD_VER=3.0.12
RUN cd /usr/local/src/ && curl -sLO https://www.openssl.org/source/openssl-${OPENSSL_BUILD_VER}.tar.gz && \
tar xzvf openssl-${OPENSSL_BUILD_VER}.tar.gz && cd openssl-${OPENSSL_BUILD_VER} && \
CROSS_COMPILE="x86_64-linux-musl-" ./Configure --prefix=/usr/local/openssl-${OPENSSL_BUILD_VER} linux-x86_64 && make && make install

ENV OPENSSL_DIR="/usr/local/openssl-${OPENSSL_BUILD_VER}"
ENV OPENSSL_STATIC="/usr/local/openssl-${OPENSSL_BUILD_VER}/lib"
ENV CFLAGS="${CFLAGS} -I/usr/local/openssl-${OPENSSL_BUILD_VER}/include"
ENV LDFLAGS="${LDFLAGS} -L/usr/local/openssl-${OPENSSL_BUILD_VER}/lib64"
8 changes: 4 additions & 4 deletions crates/rusty-hog-scanner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ edition = "2021"
serde = "1.0"
serde_json = "1.0"
serde_derive = "^1"
clap = "2"
simple_logger = "1.11"
simple-error = "0.2"
clap = "4"
simple_logger = "4.3"
simple-error = "0.3"
anyhow = "1.0"
log = "0.4"
base64 = "0.13"
base64 = "0.21"
regex = "1"
hex = "0.4"
42 changes: 21 additions & 21 deletions crates/rusty-hog-scanner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@
//! assert_eq!(secrets.pop().unwrap(), "Email address");
//! ```

#[macro_use]
extern crate clap;

use anyhow::Result;
use base64::{engine::general_purpose as Base64Engine, Engine as _};
use clap::ArgMatches;
use log::{self, debug, error, info, LevelFilter};
use regex::bytes::{Match, Matches, Regex, RegexBuilder};
Expand Down Expand Up @@ -372,26 +372,26 @@ impl SecretScannerBuilder {
/// Configure multiple values using the clap library's `ArgMatches` object.
/// This function looks for a "CASE" flag and "REGEX", "ALLOWLIST", "DEFAULT_ENTROPY_THRESHOLD" values.
pub fn conf_argm(mut self, arg_matches: &ArgMatches) -> Self {
self.case_insensitive = arg_matches.is_present("CASE");
self.regex_json_path = match arg_matches.value_of("REGEX") {
self.case_insensitive = arg_matches.get_flag("CASE");
self.regex_json_path = match arg_matches.get_one::<String>("REGEX") {
Some(s) => Some(String::from(s)),
None => None,
};
self.pretty_print = arg_matches.is_present("PRETTYPRINT");
self.output_path = match arg_matches.value_of("OUTPUT") {
self.pretty_print = arg_matches.get_flag("PRETTYPRINT");
self.output_path = match arg_matches.get_one::<String>("OUTPUT") {
Some(s) => Some(String::from(s)),
None => None,
};
self.allowlist_json_path = match arg_matches.value_of("ALLOWLIST") {
self.allowlist_json_path = match arg_matches.get_one::<String>("ALLOWLIST") {
Some(s) => Some(String::from(s)),
None => None,
};
self.default_entropy_threshold =
match value_t!(arg_matches.value_of("DEFAULT_ENTROPY_THRESHOLD"), f32) {
Ok(t) => t,
Err(_) => DEFAULT_ENTROPY_THRESHOLD,
match arg_matches.get_one::<f32>("DEFAULT_ENTROPY_THRESHOLD") {
Some(t) => *t,
None => DEFAULT_ENTROPY_THRESHOLD,
};
self.add_entropy_findings = arg_matches.is_present("ENTROPY");
self.add_entropy_findings = arg_matches.get_flag("ENTROPY");
self
}

Expand Down Expand Up @@ -838,11 +838,11 @@ impl SecretScanner {
let b64_words: Vec<String> = words
.iter()
.filter(|word| word.len() >= 20 && Self::is_base64_string(word))
.filter_map(|x| base64::decode(x).ok())
.filter_map(|x| Base64Engine::STANDARD_NO_PAD.decode(x).ok())
.filter(|word| {
Self::calc_normalized_entropy(word, Some(255), false) > entropy_threshold
})
.map(|word| String::from(base64::encode(&word).as_str()))
.map(|word| String::from(Base64Engine::STANDARD_NO_PAD.encode(&word).as_str()))
.collect();
let hex_words: Vec<String> = words
.iter() // there must be a better way
Expand Down Expand Up @@ -1048,12 +1048,12 @@ impl PartialEq for SecretScanner {
&& self.regex_map.keys().eq(other.regex_map.keys())
&& self.pretty_print == other.pretty_print
&& match self.output_path.as_ref() {
None => other.output_path.is_none(),
Some(s) => match other.output_path.as_ref() {
None => false,
Some(t) => *s == *t,
},
}
None => other.output_path.is_none(),
Some(s) => match other.output_path.as_ref() {
None => false,
Some(t) => *s == *t,
},
}
}
}

Expand Down Expand Up @@ -1109,7 +1109,7 @@ mod tests {
not_so_secret_but_has_the_word_secret_and_is_long
"#,
)
.into_bytes();
.into_bytes();
let output = SecretScanner::entropy_findings(test_string.as_slice(), 0.6);
// println!("{:?}", output);
assert_eq!(output.len(), 1);
Expand Down Expand Up @@ -1164,7 +1164,7 @@ mod tests {
not_so_secret_but_has_the_word_secret_and_is_long
"#,
)
.into_bytes();
.into_bytes();
let mut findings: Vec<(String, String)> = Vec::new();
// Main loop - split the data based on newlines, then run get_matches() on each line,
// then make a list of findings in output
Expand Down Expand Up @@ -1209,7 +1209,7 @@ mod tests {
<text>@<text>
"#,
)
.into_bytes();
.into_bytes();
let mut findings: Vec<(String, String)> = Vec::new();
// Main loop - split the data based on newlines, then run get_matches() on each line,
// then make a list of findings in output
Expand Down
8 changes: 4 additions & 4 deletions src/aws_scanning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
//! let region: Region = Region::UsWest2;
//! let bucket: Bucket = match Bucket::new(bucket_string, region, credentials) {
//! Ok(r) => r,
//! Err(e) => panic!(e)
//! Err(e) => panic!("{}", e)
//! };
//! let results = s3s.scan_s3_file(bucket, "s3://testbucket1/727463.json").unwrap();
//! assert_eq!(results.len(), 0);
Expand All @@ -53,11 +53,11 @@
use encoding::all::ASCII;
use encoding::{DecoderTrap, Encoding};
use log::{self, error, trace};
use rusty_hog_scanner::SecretScanner;
use s3::bucket::Bucket;
use serde_derive::{Deserialize, Serialize};
use simple_error::SimpleError;
use std::str;
use rusty_hog_scanner::SecretScanner;

#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone, Default)]
/// `serde_json` object that represents a single found secret - finding
Expand Down Expand Up @@ -105,8 +105,8 @@ impl S3Scanner {
let mut output: Vec<S3Finding> = Vec::new();

// Get the actual data from S3
let (data, code) = match bucket.get_object_blocking(filepath) {
Ok(x) => (x.0, x.1),
let (code, data) = match bucket.get_object_blocking(filepath) {
Ok(x) => (x.status_code(), x.to_vec()),
Err(e) => return Err(SimpleError::new(e.to_string())),
};
trace!("Code: {}\nData: {:?}", code, data);
Expand Down
Loading
Loading