Fixed CI by ignoring python, resolved multiple warnings (#303)

* fixing ci

* ignoring dev deps

* fmt

* trying to fix dockerfile

* fix cargo build

* can't build sancov edges and hitcounts together

* fixed warnings

* fixed more warnings
This commit is contained in:
Dominik Maier 2021-09-28 01:56:07 +02:00 committed by GitHub
parent a0cdaf71ff
commit 9d669bbc63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 38 additions and 48 deletions

View File

@ -52,11 +52,15 @@ jobs:
- name: Run a normal build - name: Run a normal build
run: cargo build --verbose run: cargo build --verbose
# cargo-hack tests/checks each crate in the workspace # cargo-hack tests/checks each crate in the workspace
- name: Run tests #- name: Run tests
run: cargo hack test --all-features # run: cargo hack test --all-features
# cargo-hack's --feature-powerset would be nice here but libafl has a too many knobs # cargo-hack's --feature-powerset would be nice here but libafl has a too many knobs
- name: Check each feature - name: Check each feature
run: cargo hack check --each-feature # Skipping python as it has to be built with the `maturin` tool
run: cargo hack check --feature-powerset --depth=2 --exclude-features=python,sancov_pcguard_edges,sancov_pcguard_edges_ptr --no-dev-deps
# pcguard edges and pcguard hitcounts are not compatible and we need to build them seperately
- name: Check pcguard edges
run: cargo check --features=sancov_pcguard_edges,sancov_pcguard_edges_ptr
- name: Build examples - name: Build examples
run: cargo build --examples --verbose run: cargo build --examples --verbose
- uses: actions/checkout@v2 - uses: actions/checkout@v2

View File

@ -39,7 +39,6 @@ COPY libafl_frida/src/gettls.c libafl_frida/src/gettls.c
COPY libafl_qemu/Cargo.toml libafl_qemu/build.rs libafl_qemu/ COPY libafl_qemu/Cargo.toml libafl_qemu/build.rs libafl_qemu/
COPY scripts/dummy.rs libafl_qemu/src/lib.rs COPY scripts/dummy.rs libafl_qemu/src/lib.rs
COPY libafl_qemu/src/weaks.c libafl_qemu/src/weaks.c
COPY libafl_sugar/Cargo.toml libafl_sugar/ COPY libafl_sugar/Cargo.toml libafl_sugar/
COPY scripts/dummy.rs libafl_sugar/src/lib.rs COPY scripts/dummy.rs libafl_sugar/src/lib.rs

View File

@ -39,7 +39,6 @@ pub fn main() {
if buf.len() > 1 && buf[1] == b'b' { if buf.len() > 1 && buf[1] == b'b' {
signals_set(2); signals_set(2);
if buf.len() > 2 && buf[2] == b'c' { if buf.len() > 2 && buf[2] == b'c' {
unsafe {
#[cfg(unix)] #[cfg(unix)]
panic!("=("); panic!("=(");
@ -48,6 +47,7 @@ pub fn main() {
// Extending the windows exception handler is a TODO. Maybe we can refer to what winafl code does. // Extending the windows exception handler is a TODO. Maybe we can refer to what winafl code does.
// https://github.com/googleprojectzero/winafl/blob/ea5f6b85572980bb2cf636910f622f36906940aa/winafl.c#L728 // https://github.com/googleprojectzero/winafl/blob/ea5f6b85572980bb2cf636910f622f36906940aa/winafl.c#L728
#[cfg(windows)] #[cfg(windows)]
unsafe {
write_volatile(0 as *mut u32, 0); write_volatile(0 as *mut u32, 0);
} }
} }

View File

@ -139,9 +139,9 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re
&mut fuzzer, &mut fuzzer,
&mut executor, &mut executor,
&mut restarting_mgr, &mut restarting_mgr,
&corpus_dirs, corpus_dirs,
) )
.unwrap_or_else(|_| panic!("Failed to load initial corpus at {:?}", &corpus_dirs)); .unwrap_or_else(|_| panic!("Failed to load initial corpus at {:?}", corpus_dirs));
println!("We imported {} inputs from disk.", state.corpus().count()); println!("We imported {} inputs from disk.", state.corpus().count());
} }

View File

@ -149,9 +149,9 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re
&mut fuzzer, &mut fuzzer,
&mut executor, &mut executor,
&mut restarting_mgr, &mut restarting_mgr,
&corpus_dirs, corpus_dirs,
) )
.unwrap_or_else(|_| panic!("Failed to load initial corpus at {:?}", &corpus_dirs)); .unwrap_or_else(|_| panic!("Failed to load initial corpus at {:?}", corpus_dirs));
println!("We imported {} inputs from disk.", state.corpus().count()); println!("We imported {} inputs from disk.", state.corpus().count());
} }

View File

@ -1675,11 +1675,6 @@ where
/// This allows us to intercept messages right in the broker /// This allows us to intercept messages right in the broker
/// This keeps the out map clean. /// This keeps the out map clean.
pub llmp_clients: Vec<LlmpReceiver<SP>>, pub llmp_clients: Vec<LlmpReceiver<SP>>,
/// This is the socket name, when unix domain sockets are used.
socket_name: Option<String>,
/// This flag is used to indicate that shutdown has been requested by the SIGINT and SIGTERM
/// handlers
shutting_down: bool,
/// The ShMemProvider to use /// The ShMemProvider to use
shmem_provider: SP, shmem_provider: SP,
} }
@ -1726,8 +1721,6 @@ where
shmem_provider: shmem_provider.clone(), shmem_provider: shmem_provider.clone(),
}, },
llmp_clients: vec![], llmp_clients: vec![],
socket_name: None,
shutting_down: false,
shmem_provider, shmem_provider,
}) })
} }
@ -2350,7 +2343,6 @@ pub struct LlmpClient<SP>
where where
SP: ShMemProvider, SP: ShMemProvider,
{ {
shmem_provider: SP,
/// Outgoing channel to the broker /// Outgoing channel to the broker
pub sender: LlmpSender<SP>, pub sender: LlmpSender<SP>,
/// Incoming (broker) broadcast map /// Incoming (broker) broadcast map
@ -2381,11 +2373,10 @@ where
last_msg_recvd_offset, last_msg_recvd_offset,
)?, )?,
sender: LlmpSender::on_existing_map( sender: LlmpSender::on_existing_map(
shmem_provider.clone(), shmem_provider,
current_broker_map, current_broker_map,
last_msg_recvd_offset, last_msg_recvd_offset,
)?, )?,
shmem_provider,
}) })
} }
@ -2398,10 +2389,9 @@ where
&format!("{}_SENDER", env_name), &format!("{}_SENDER", env_name),
)?, )?,
receiver: LlmpReceiver::on_existing_from_env( receiver: LlmpReceiver::on_existing_from_env(
shmem_provider.clone(), shmem_provider,
&format!("{}_RECEIVER", env_name), &format!("{}_RECEIVER", env_name),
)?, )?,
shmem_provider,
}) })
} }
@ -2432,10 +2422,9 @@ where
&description.sender, &description.sender,
)?, )?,
receiver: LlmpReceiver::on_existing_from_description( receiver: LlmpReceiver::on_existing_from_description(
shmem_provider.clone(), shmem_provider,
&description.receiver, &description.receiver,
)?, )?,
shmem_provider,
}) })
} }
@ -2484,7 +2473,6 @@ where
last_msg_recvd: ptr::null_mut(), last_msg_recvd: ptr::null_mut(),
shmem_provider: shmem_provider.clone(), shmem_provider: shmem_provider.clone(),
}, },
shmem_provider,
}) })
} }

View File

@ -88,7 +88,7 @@ use crate::{
start_timer, Evaluator, start_timer, Evaluator,
}; };
#[cfg(feature = "concolic_mutation")] #[cfg(all(feature = "concolic_mutation", feature = "introspection"))]
use crate::stats::PerfFeature; use crate::stats::PerfFeature;
#[cfg(feature = "concolic_mutation")] #[cfg(feature = "concolic_mutation")]

View File

@ -247,7 +247,6 @@ where
{ {
print_fn: F, print_fn: F,
start_time: Duration, start_time: Duration,
corpus_size: usize,
client_stats: Vec<ClientStats>, client_stats: Vec<ClientStats>,
} }
@ -308,7 +307,6 @@ where
Self { Self {
print_fn, print_fn,
start_time: current_time(), start_time: current_time(),
corpus_size: 0,
client_stats: vec![], client_stats: vec![],
} }
} }
@ -318,7 +316,6 @@ where
Self { Self {
print_fn, print_fn,
start_time, start_time,
corpus_size: 0,
client_stats: vec![], client_stats: vec![],
} }
} }

View File

@ -19,7 +19,6 @@ where
{ {
print_fn: F, print_fn: F,
start_time: Duration, start_time: Duration,
corpus_size: usize,
client_stats: Vec<ClientStats>, client_stats: Vec<ClientStats>,
} }
@ -99,7 +98,6 @@ where
Self { Self {
print_fn, print_fn,
start_time: current_time(), start_time: current_time(),
corpus_size: 0,
client_stats: vec![], client_stats: vec![],
} }
} }
@ -109,7 +107,6 @@ where
Self { Self {
print_fn, print_fn,
start_time, start_time,
corpus_size: 0,
client_stats: vec![], client_stats: vec![],
} }
} }

View File

@ -144,7 +144,10 @@ pub fn init(args: &[String], env: &[(String, String)]) -> i32 {
let args: Vec<String> = args.iter().map(|x| x.clone() + "\0").collect(); let args: Vec<String> = args.iter().map(|x| x.clone() + "\0").collect();
let argv: Vec<*const u8> = args.iter().map(|x| x.as_bytes().as_ptr()).collect(); let argv: Vec<*const u8> = args.iter().map(|x| x.as_bytes().as_ptr()).collect();
assert!(argv.len() < i32::MAX as usize); assert!(argv.len() < i32::MAX as usize);
let env_strs: Vec<String> = env.iter().map(|(k, v)| format!("{}={}\0", &k, &v)).collect(); let env_strs: Vec<String> = env
.iter()
.map(|(k, v)| format!("{}={}\0", &k, &v))
.collect();
let mut envp: Vec<*const u8> = env_strs.iter().map(|x| x.as_bytes().as_ptr()).collect(); let mut envp: Vec<*const u8> = env_strs.iter().map(|x| x.as_bytes().as_ptr()).collect();
envp.push(null()); envp.push(null());
#[allow(clippy::cast_possible_wrap)] #[allow(clippy::cast_possible_wrap)]

View File

@ -45,13 +45,15 @@ pub fn python_module(_py: Python, m: &PyModule) -> PyResult<()> {
use pyo3::exceptions::PyValueError; use pyo3::exceptions::PyValueError;
#[pyfn(m)] #[pyfn(m)]
#[allow(clippy::needless_pass_by_value)]
fn init(args: Vec<String>, env: Vec<(String, String)>) -> i32 { fn init(args: Vec<String>, env: Vec<(String, String)>) -> i32 {
emu::init(&args, &env) emu::init(&args, &env)
} }
#[pyfn(m)] #[pyfn(m)]
#[allow(clippy::needless_pass_by_value)]
fn write_mem(addr: u64, buf: &[u8]) { fn write_mem(addr: u64, buf: &[u8]) {
emu::write_mem(addr, buf) emu::write_mem(addr, buf);
} }
#[pyfn(m)] #[pyfn(m)]
fn read_mem(addr: u64, size: usize) -> Vec<u8> { fn read_mem(addr: u64, size: usize) -> Vec<u8> {
@ -65,27 +67,27 @@ pub fn python_module(_py: Python, m: &PyModule) -> PyResult<()> {
} }
#[pyfn(m)] #[pyfn(m)]
fn write_reg(reg: i32, val: u64) -> PyResult<()> { fn write_reg(reg: i32, val: u64) -> PyResult<()> {
emu::write_reg(reg, val).map_err(|e| PyValueError::new_err(e)) emu::write_reg(reg, val).map_err(PyValueError::new_err)
} }
#[pyfn(m)] #[pyfn(m)]
fn read_reg(reg: i32) -> PyResult<u64> { fn read_reg(reg: i32) -> PyResult<u64> {
emu::read_reg(reg).map_err(|e| PyValueError::new_err(e)) emu::read_reg(reg).map_err(PyValueError::new_err)
} }
#[pyfn(m)] #[pyfn(m)]
fn set_breakpoint(addr: u64) { fn set_breakpoint(addr: u64) {
emu::set_breakpoint(addr) emu::set_breakpoint(addr);
} }
#[pyfn(m)] #[pyfn(m)]
fn remove_breakpoint(addr: u64) { fn remove_breakpoint(addr: u64) {
emu::remove_breakpoint(addr) emu::remove_breakpoint(addr);
} }
#[pyfn(m)] #[pyfn(m)]
fn run() { fn run() {
emu::run() emu::run();
} }
#[pyfn(m)] #[pyfn(m)]
fn g2h(addr: u64) -> u64 { fn g2h(addr: u64) -> u64 {
unsafe { transmute(emu::g2h::<*const u8>(addr)) } unsafe { emu::g2h::<*const u8>(addr) as u64 }
} }
#[pyfn(m)] #[pyfn(m)]
fn h2g(addr: u64) -> u64 { fn h2g(addr: u64) -> u64 {

View File

@ -13,13 +13,13 @@ use crate::coverage::{EDGES_MAP, MAX_EDGES_NUM};
))] ))]
#[cfg(not(any(doc, feature = "clippy")))] #[cfg(not(any(doc, feature = "clippy")))]
compile_error!( compile_error!(
"the libafl_targets `pcguard_edges_ptr` and `pcguard_hitcounts_ptr` features are mutually exclusive." "the libafl_targets `sancov_pcguard_edges_ptr` and `sancov_pcguard_hitcounts_ptr` features are mutually exclusive."
); );
#[cfg(all(feature = "sancov_pcguard_edges", feature = "sancov_pcguard_hitcounts"))] #[cfg(all(feature = "sancov_pcguard_edges", feature = "sancov_pcguard_hitcounts"))]
#[cfg(not(any(doc, feature = "clippy")))] #[cfg(not(any(doc, feature = "clippy")))]
compile_error!( compile_error!(
"the libafl_targets `pcguard_edges` and `pcguard_hitcounts` features are mutually exclusive." "the libafl_targets `sancov_pcguard_edges` and `sancov_pcguard_hitcounts` features are mutually exclusive."
); );
/// Callback for sancov `pc_guard` - usually called by `llvm` on each block or edge. /// Callback for sancov `pc_guard` - usually called by `llvm` on each block or edge.