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

Fix windows #64

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1e0cb03
Rename the project
vdang-crabnebula Oct 9, 2024
a0b243d
Update the cli package and the quickstart section of the docs
vdang-crabnebula Oct 10, 2024
26c9f9d
Write the "manual steps" section of the docs
vdang-crabnebula Oct 10, 2024
05016da
Add new policies to the docs
vdang-crabnebula Oct 14, 2024
0882448
Fix mdbook test
vdang-crabnebula Oct 15, 2024
c0e80f3
Change crate names
vuongDang Oct 19, 2024
9118d4d
Rewrote introduction
vuongDang Oct 20, 2024
3bf5147
Rewrite Introduction chapter
vuongDang Oct 22, 2024
bc97112
Clean unecessary files
vuongDang Oct 22, 2024
8008293
Add supported platforms in intro
vuongDang Oct 22, 2024
1dad83f
Finish "Principles" chapter
vuongDang Oct 23, 2024
f2b4919
Add schema to README
vuongDang Oct 23, 2024
24d91c9
Fix duplicate schema in README
vuongDang Oct 23, 2024
be5ab61
Retest the user guide
vuongDang Oct 23, 2024
ec0dffc
Add documentation and signature for `no_error_policy`
vuongDang Oct 23, 2024
bde531d
Update fuzzer cli doc
vuongDang Oct 23, 2024
3a2d79e
Update policy template
vuongDang Oct 23, 2024
4eb9c2e
Fix typos
vuongDang Oct 23, 2024
6ac7001
Fix file that was seen as a link
vuongDang Oct 24, 2024
822933f
Fix typos
vuongDang Oct 24, 2024
c29a033
Fix compilation on Windows
vuongDang Oct 24, 2024
d947eee
Create equivalent policy for Windows: block_child_process_with_error_…
vuongDang Nov 7, 2024
e84602a
Create equivalent policy for Windows: block_on_entry
vuongDang Nov 7, 2024
23d87ca
Run rustfmt/clippy/typos
vuongDang Nov 7, 2024
3433026
Add Windows to github test workflow
vuongDang Nov 7, 2024
6ff3070
feat: add ssh tmate session to debug github actions
vuongDang Dec 13, 2024
515f9a9
debug: use tmate in detached session
vuongDang Dec 13, 2024
f28bffa
fix: clippy warnings
vuongDang Dec 13, 2024
2564e7f
fix: uses `msvc-dev-cmd` to setup dev environment for github windows …
vuongDang Dec 14, 2024
f4dfe1f
fix: compiler warnings
vuongDang Dec 14, 2024
e02a357
fix: rustfmt and clippy
vuongDang Dec 14, 2024
298f6e7
fix: ignore tests to fs_readFile as it has become async and we can't …
vuongDang Dec 15, 2024
f6034b2
fix: leftover code from debugging
vuongDang Dec 15, 2024
25c0601
fix: format and clippy
vuongDang Dec 15, 2024
e908612
fix: clippy
vuongDang Dec 15, 2024
6b481bf
Merge branch 'main' into fix_windows
vuongDang Dec 15, 2024
63e8efc
fix: type conversion error when dealing with C types
vuongDang Dec 15, 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
9 changes: 7 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ jobs:
Build-and-test-Fuzzer:
strategy:
matrix:
os: [ubuntu-latest] #[ubuntu-latest, windows-latest, macOS-latest]
# os: [ubuntu-latest, windows-latest] #[ubuntu-latest, windows-latest, macOS-latest]
# os: [ubuntu-latest] #[ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-latest, windows-latest] #[ubuntu-latest, windows-latest, macOS-latest]
# os: [windows-latest] #[ubuntu-latest, windows-latest, macOS-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 45
steps:
Expand All @@ -52,6 +53,10 @@ jobs:
- uses: actions/checkout@v4
name: Checkout repository

- name: use Windows developer command prompt
if: contains(matrix.os, 'windows-latest')
uses: ilammy/msvc-dev-cmd@v1

- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable

Expand Down
5 changes: 2 additions & 3 deletions crates/tauri-fuzz-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright 2023-2024 CrabNebula Ltd., Alexandre Dang
// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
#![allow(clippy::single_match_else, clippy::semicolon_if_nothing_returned)]

use clap::{ArgAction, Parser, Subcommand};
use log::Level;
Expand Down Expand Up @@ -37,7 +38,7 @@ enum Commands {
Fuzz(fuzz::Options),
}

fn main() -> anyhow::Result<()> {
fn main() {
let cli = Cli::parse_from(std::env::args_os().skip(1));

if !cli.quiet {
Expand All @@ -55,8 +56,6 @@ fn main() -> anyhow::Result<()> {
log::error!("{}", e);
std::process::exit(1);
}

Ok(())
}

fn setup_logger(cli: &Cli) -> anyhow::Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-fuzz-cli/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub fn tauri_dir() -> anyhow::Result<PathBuf> {
} else if is_tauri_config_file(&path) {
return path
.parent()
.map(|p| p.to_path_buf())
.map(Path::to_path_buf)
.context("failed to get parent from path");
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-fuzz-policies/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn add_manifest() {
let mut manifest = std::env::current_dir().unwrap();
manifest.push(WINDOWS_MANIFEST_FILE);

println!("cargo:rerun-if-changed={}", WINDOWS_MANIFEST_FILE);
println!("cargo:rerun-if-changed={WINDOWS_MANIFEST_FILE}");
// Embed the Windows application manifest file.
println!("cargo:rustc-link-arg=/MANIFEST:EMBED");
println!(
Expand Down
19 changes: 12 additions & 7 deletions crates/tauri-fuzz-policies/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ pub struct FunctionPolicy {

impl FunctionPolicy {
/// Check the function policy in the specified context and if the invocation should be blocked
///
/// # Panics
/// This may panic if the `Rule` was not built correctly.
/// For example a `Rule` on entry with a context on exit.
/// Or trying to access registers that does not contain a parameter or a return value of the
/// target function
pub fn should_block(&mut self, context: &Context) -> bool {
let should_block = self.rule.should_block(context);
match should_block {
Expand Down Expand Up @@ -62,17 +68,17 @@ impl FunctionPolicy {
// maybe using cloneable `Box` can improve performance such as in this example:
// https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6ca48c4cff92370c907ecf4c548ee33c

/// ConditionOnParameters is a closure on the registers containing the parameters of the function.
/// `ConditionOnParameters` is a closure on the registers containing the parameters of the function.
/// Registers can contain a value but also a pointer depending on the type of the parameters.
pub type ConditionOnParameters = Arc<dyn Fn(&[usize]) -> Result<bool, RuleError>>;
/// ConditionOnReturnValue is a closure on the value contained in the return value register
/// `ConditionOnReturnValue` is a closure on the value contained in the return value register
/// This can contain a value but also a pointer depending on the type of the return value.
pub type ConditionOnReturnValue = Arc<dyn Fn(usize) -> Result<bool, RuleError>>;
/// ConditionOnParameters but with an additional argument that can be used as storage to pass
/// `ConditionOnParameters` but with an additional argument that can be used as storage to pass
/// information for later usage
pub type ConditionOnParametersWithStorage =
Arc<dyn Fn(&[usize], &mut Option<usize>) -> Result<bool, RuleError>>;
/// ConditionOnReturnValue but with an additional argument that can be used for the analysis
/// `ConditionOnReturnValue` but with an additional argument that can be used for the analysis
pub type ConditionOnReturnValueWithStorage =
Arc<dyn Fn(usize, &mut Option<usize>) -> Result<bool, RuleError>>;

Expand Down Expand Up @@ -146,13 +152,12 @@ impl Debug for Context {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Context::EntryContext(parameters) => {
write!(f, "Function entry with parameters: {:?}", parameters)
write!(f, "Function entry with parameters: {parameters:?}")
}
Context::LeaveContext(return_value) => {
write!(
f,
"Function exit with return value as usize: {:?}",
return_value
"Function exit with return value as usize: {return_value:?}"
)
}
}
Expand Down
8 changes: 8 additions & 0 deletions crates/tauri-fuzz-policies/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
// Copyright 2023-2024 CrabNebula Ltd., Alexandre Dang
// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0

#![allow(
clippy::must_use_candidate,
clippy::unnecessary_wraps,
clippy::missing_panics_doc,
clippy::wildcard_imports,
clippy::enum_glob_use
)]

pub mod engine;
pub mod policies;
pub use policies::*;
Loading
Loading