Skip to content

Commit

Permalink
chore: default disable trust_cert
Browse files Browse the repository at this point in the history
  • Loading branch information
zu1k committed Oct 29, 2022
1 parent 3052323 commit 532f997
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 25 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ jobs:
default: true
override: true

# https://github.com/actions/virtual-environments/issues/2557#issuecomment-769611326
- if: ${{ matrix.target }} == 'aarch64-apple-darwin'
run: |
sudo xcode-select -s /Applications/Xcode_12.4.app &&
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*
- name: Build release
shell: bash
run: |
Expand Down
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ codegen-units = 1

[dependencies]
mitm-core = { path = "crates/core", package = "good-mitm-core" }
rule = { path = "crates/rule", package = "good-mitm-rule" }
rule = { path = "crates/rule", package = "good-mitm-rule", features = ["js"] }

anyhow = "1.0"
clap = { version = "4", features = ["derive"] }
Expand All @@ -30,10 +30,13 @@ serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.9"
hyper-proxy = { version = "0.9", default-features = false }
rustls-pemfile = "1.0"
tokio = { version = "1", features = ["rt", "signal"] }
tokio = { version = "1", features = ["rt-multi-thread", "signal"] }
rustls = "0.20"
trust_cert = { path = "crates/trust_cert" }
trust_cert = { path = "crates/trust_cert", optional = true }

[features]
default = []
trust-cert = ["dep:trust_cert"]

[workspace]
members = [
Expand Down
2 changes: 1 addition & 1 deletion crates/rule/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mitm-core = { path = "../core", package = "good-mitm-core" }

anyhow = "1.0"
async-trait = "0.1"
cached = "0.39"
cached = "0.40"
cookie = "0.16"
fancy-regex = "0.10"
http = "0.2"
Expand Down
4 changes: 2 additions & 2 deletions crates/trust_cert/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "trust_cert"
version = "0.0.4"
version = "0.0.5"
edition = "2021"
description = "Install certificate to your system trust zone."
homepage = "https://github.com/zu1k/good-mitm"
Expand All @@ -14,4 +14,4 @@ rcgen = { version = "0.10", features = ["x509-parser"] }
nix = { version = "0.25", default-features = false, features = ["user"] }

[target.'cfg(windows)'.dependencies]
windows = { version = "0.42", features = ["Win32_Security_Cryptography", "Win32_Foundation"] }
windows = { version = "0.43", features = ["Win32_Security_Cryptography", "Win32_Foundation"] }
21 changes: 15 additions & 6 deletions src/file/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use anyhow::Result;
use std::{fs, io::BufReader, path::Path};

use log::error;
use single_multi::SingleOrMulti;
use std::{fs, io::BufReader, path::Path};

pub mod frule;
mod single_multi;

pub fn load_rules_amd_mitm_filters<P: AsRef<Path>>(
pub fn load_rules_amd_mitm_filters<P: AsRef<Path> + Clone>(
path: P,
) -> Result<(Vec<rule::Rule>, Vec<String>)> {
let m = fs::metadata(&path).expect("Not a valid path");
Expand All @@ -17,12 +17,21 @@ pub fn load_rules_amd_mitm_filters<P: AsRef<Path>>(
}
}

fn load_rules_amd_mitm_filters_from_file<P: AsRef<Path>>(
fn load_rules_amd_mitm_filters_from_file<P: AsRef<Path> + Clone>(
path: P,
) -> Result<(Vec<rule::Rule>, Vec<String>)> {
let file = fs::File::open(path)?;
let file = fs::File::open(path.clone())?;
let reader = BufReader::new(file);
let rules: Vec<frule::Rule> = serde_yaml::from_reader(reader)?;
let rules: Vec<frule::Rule> = match serde_yaml::from_reader(reader) {
Ok(rules) => rules,
Err(err) => {
error!(
"load rule ({}) failed: {err}",
path.as_ref().to_str().unwrap()
);
return Err(err.into());
}
};

let (rules, filters) = rules
.into_iter()
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub mod file;

pub use hyper_proxy;
pub use mitm_core;
#[cfg(feature = "trust-cert")]
pub use trust_cert;

pub async fn shutdown_signal() {
Expand Down
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ fn main() {
run(&opts).unwrap();
}
SubCommand::Genca(opts) => {
#[allow(unused_variables)]
let cert = ca::gen_ca();
if opts.trust {
#[cfg(feature = "trust-cert")]
trust_cert::trust_cert(cert);
}
}
Expand Down

1 comment on commit 532f997

@vercel
Copy link

@vercel vercel bot commented on 532f997 Oct 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.