diff --git a/crates/forge_analyzer/src/checkers.rs b/crates/forge_analyzer/src/checkers.rs index 10212f82..c645b84a 100644 --- a/crates/forge_analyzer/src/checkers.rs +++ b/crates/forge_analyzer/src/checkers.rs @@ -73,42 +73,38 @@ impl JoinSemiLattice for Vec { } pub struct TaintDataflow { - needs_call: Vec, started: bool, } impl<'cx> Dataflow<'cx> for TaintDataflow { type State = Vec; - fn with_interp>(interp: &Interp<'cx, C>) -> Self { - Self { - needs_call: vec![], - started: false, - } + fn with_interp>(_interp: &Interp<'cx, C>) -> Self { + Self { started: false } } fn transfer_call>( &mut self, - interp: &Interp<'cx, C>, - def: DefId, - loc: Location, - block: &'cx BasicBlock, - callee: &'cx Operand, + _interp: &Interp<'cx, C>, + _def: DefId, + _loc: Location, + _block: &'cx BasicBlock, + _callee: &'cx Operand, initial_state: Self::State, - oprands: SmallVec<[crate::ir::Operand; 4]>, + _oprands: SmallVec<[crate::ir::Operand; 4]>, ) -> Self::State { initial_state } fn transfer_intrinsic>( &mut self, - interp: &mut Interp<'cx, C>, - def: DefId, - loc: Location, - block: &'cx BasicBlock, - intrinsic: &'cx Intrinsic, + _interp: &mut Interp<'cx, C>, + _def: DefId, + _loc: Location, + _block: &'cx BasicBlock, + _intrinsic: &'cx Intrinsic, initial_state: Self::State, - operands: SmallVec<[crate::ir::Operand; 4]>, + _operands: SmallVec<[crate::ir::Operand; 4]>, ) -> Self::State { initial_state } @@ -165,7 +161,7 @@ impl<'cx> Dataflow<'cx> for TaintDataflow { bb: BasicBlockId, block: &'cx BasicBlock, mut initial_state: Self::State, - arguments: Option>, + _arguments: Option>, ) -> Self::State { if initial_state.len() < interp.body().vars.len() { initial_state.resize(interp.body().vars.len(), Taint::Unknown); @@ -336,24 +332,24 @@ impl<'cx> Runner<'cx> for PrototypePollutionChecker { fn visit_intrinsic( &mut self, - interp: &Interp<'cx, Self>, - intrinsic: &'cx Intrinsic, - def: DefId, + _interp: &Interp<'cx, Self>, + _intrinsic: &'cx Intrinsic, + _def: DefId, state: &Self::State, - operands: Option>, + _operands: Option>, ) -> ControlFlow<(), Self::State> { ControlFlow::Continue(state.clone()) } fn visit_block( &mut self, - interp: &Interp<'cx, Self>, - def: DefId, - id: BasicBlockId, + _interp: &Interp<'cx, Self>, + _def: DefId, + _id: BasicBlockId, block: &'cx BasicBlock, curr_state: &Self::State, ) -> ControlFlow<(), Self::State> { for inst in &block.insts { - if let Inst::Assign(l, r) = inst { + if let Inst::Assign(l, _r) = inst { if let [Projection::Computed(Base::Var(fst)), Projection::Computed(Base::Var(snd)), ..] = *l.projections { @@ -371,16 +367,12 @@ impl<'cx> Runner<'cx> for PrototypePollutionChecker { } pub struct AuthZChecker { - visit: bool, vulns: Vec, } impl AuthZChecker { pub fn new() -> Self { - Self { - visit: true, - vulns: vec![], - } + Self { vulns: vec![] } } pub fn into_vulns(self) -> impl IntoIterator { @@ -476,9 +468,9 @@ impl<'cx> Runner<'cx> for AuthZChecker { &mut self, interp: &Interp<'cx, Self>, intrinsic: &'cx Intrinsic, - def: DefId, + _def: DefId, state: &Self::State, - operands: Option>, + _operands: Option>, ) -> ControlFlow<(), Self::State> { match *intrinsic { Intrinsic::Authorize(_) => { @@ -555,7 +547,7 @@ impl<'cx> Dataflow<'cx> for AuthenticateDataflow { _block: &'cx BasicBlock, intrinsic: &'cx Intrinsic, initial_state: Self::State, - operands: SmallVec<[crate::ir::Operand; 4]>, + _operands: SmallVec<[crate::ir::Operand; 4]>, ) -> Self::State { match *intrinsic { Intrinsic::Authorize(_) => initial_state, @@ -579,7 +571,7 @@ impl<'cx> Dataflow<'cx> for AuthenticateDataflow { _block: &'cx BasicBlock, callee: &'cx crate::ir::Operand, initial_state: Self::State, - operands: SmallVec<[crate::ir::Operand; 4]>, + _operands: SmallVec<[crate::ir::Operand; 4]>, ) -> Self::State { let Some((callee_def, _body)) = self.resolve_call(interp, callee) else { return initial_state; @@ -617,16 +609,12 @@ impl<'cx> Dataflow<'cx> for AuthenticateDataflow { } pub struct AuthenticateChecker { - visit: bool, vulns: Vec, } impl AuthenticateChecker { pub fn new() -> Self { - Self { - visit: false, - vulns: vec![], - } + Self { vulns: vec![] } } pub fn into_vulns(self) -> impl IntoIterator { @@ -650,9 +638,9 @@ impl<'cx> Runner<'cx> for AuthenticateChecker { &mut self, interp: &Interp<'cx, Self>, intrinsic: &'cx Intrinsic, - def: DefId, + _def: DefId, state: &Self::State, - operands: Option>, + _operands: Option>, ) -> ControlFlow<(), Self::State> { match *intrinsic { Intrinsic::Authorize(_) => ControlFlow::Continue(*state), @@ -789,9 +777,9 @@ impl<'cx> Dataflow<'cx> for SecretDataflow { _def: DefId, _loc: Location, _block: &'cx BasicBlock, - intrinsic: &'cx Intrinsic, + _intrinsic: &'cx Intrinsic, initial_state: Self::State, - operands: SmallVec<[crate::ir::Operand; 4]>, + _operands: SmallVec<[crate::ir::Operand; 4]>, ) -> Self::State { initial_state } @@ -799,12 +787,12 @@ impl<'cx> Dataflow<'cx> for SecretDataflow { fn transfer_call>( &mut self, interp: &Interp<'cx, C>, - def: DefId, - loc: Location, + _def: DefId, + _loc: Location, _block: &'cx BasicBlock, callee: &'cx crate::ir::Operand, initial_state: Self::State, - operands: SmallVec<[crate::ir::Operand; 4]>, + _operands: SmallVec<[crate::ir::Operand; 4]>, ) -> Self::State { let Some((callee_def, _body)) = self.resolve_call(interp, callee) else { return initial_state; @@ -829,16 +817,12 @@ impl<'cx> Dataflow<'cx> for SecretDataflow { } pub struct SecretChecker { - visit: bool, vulns: Vec, } impl SecretChecker { pub fn new() -> Self { - Self { - visit: true, - vulns: vec![], - } + Self { vulns: vec![] } } pub fn into_vulns(self) -> impl IntoIterator { @@ -1197,7 +1181,7 @@ impl<'cx> Dataflow<'cx> for PermissionDataflow { &mut self, interp: &Interp<'cx, C>, def: DefId, - loc: Location, + _loc: Location, _block: &'cx BasicBlock, callee: &'cx crate::ir::Operand, initial_state: Self::State, @@ -1221,7 +1205,7 @@ impl<'cx> Dataflow<'cx> for PermissionDataflow { bb: BasicBlockId, block: &'cx BasicBlock, initial_state: Self::State, - arguments: Option>, + _arguments: Option>, ) -> Self::State { let mut state = initial_state; @@ -1241,7 +1225,7 @@ impl<'cx> Dataflow<'cx> for PermissionDataflow { worklist: &mut WorkList, ) { self.super_join_term(interp, def, block, state, worklist); - for (def, arguments) in self.needs_call.drain(..) { + for (def, _arguments) in self.needs_call.drain(..) { worklist.push_front_blocks(interp.env(), def, interp.call_all); } } @@ -1326,11 +1310,11 @@ impl<'cx> Runner<'cx> for PermissionChecker { fn visit_intrinsic( &mut self, - interp: &Interp<'cx, Self>, - intrinsic: &'cx Intrinsic, - def: DefId, + _interp: &Interp<'cx, Self>, + _intrinsic: &'cx Intrinsic, + _def: DefId, state: &Self::State, - operands: Option>, + _operands: Option>, ) -> ControlFlow<(), Self::State> { ControlFlow::Continue(*state) } @@ -1368,11 +1352,11 @@ impl<'cx> Runner<'cx> for DefintionAnalysisRunner { fn visit_intrinsic( &mut self, - interp: &Interp<'cx, Self>, - intrinsic: &'cx Intrinsic, - def: DefId, - state: &Self::State, - operands: Option>, + _interp: &Interp<'cx, Self>, + _intrinsic: &'cx Intrinsic, + _def: DefId, + _state: &Self::State, + _operands: Option>, ) -> ControlFlow<(), Self::State> { ControlFlow::Break(()) } @@ -1401,9 +1385,9 @@ impl<'cx> Dataflow<'cx> for DefintionAnalysisRunner { _def: DefId, _loc: Location, _block: &'cx BasicBlock, - intrinsic: &'cx Intrinsic, + _intrinsic: &'cx Intrinsic, initial_state: Self::State, - operands: SmallVec<[crate::ir::Operand; 4]>, + _operands: SmallVec<[crate::ir::Operand; 4]>, ) -> Self::State { initial_state } @@ -1412,7 +1396,7 @@ impl<'cx> Dataflow<'cx> for DefintionAnalysisRunner { &mut self, interp: &Interp<'cx, C>, def: DefId, - loc: Location, + _loc: Location, _block: &'cx BasicBlock, callee: &'cx crate::ir::Operand, initial_state: Self::State, @@ -1488,7 +1472,7 @@ impl<'cx> Dataflow<'cx> for DefintionAnalysisRunner { } } } - Rvalue::Read(operand) => { + Rvalue::Read(_operand) => { if let Rvalue::Read(read) = rvalue { match read { Operand::Lit(lit) => { @@ -1530,7 +1514,7 @@ impl<'cx> Dataflow<'cx> for DefintionAnalysisRunner { Operand::Var(var) => { // println!("{var}"); if let Base::Var(varid) = var.base { - let values = interp + let _values = interp .value_manager .varid_to_value .get(&(def, varid, None)); @@ -1635,7 +1619,7 @@ impl<'cx> Dataflow<'cx> for DefintionAnalysisRunner { if let Operand::Var(variable) = operand { if let Base::Var(varid_rval) = variable.base { interp.value_manager.varid_to_value.clone().iter().for_each( - |((defid, varid_rval_potential, projection), value)| { + |((_defid, varid_rval_potential, projection), value)| { if varid_rval_potential == &varid_rval { interp.add_value(def, *varid, value.clone(), projection.clone()) } diff --git a/crates/forge_analyzer/src/interp.rs b/crates/forge_analyzer/src/interp.rs index 32dc3611..b35bd736 100644 --- a/crates/forge_analyzer/src/interp.rs +++ b/crates/forge_analyzer/src/interp.rs @@ -146,7 +146,7 @@ pub trait Dataflow<'cx>: Sized { bb: BasicBlockId, block: &'cx BasicBlock, initial_state: Self::State, - arguments: Option>, + _arguments: Option>, ) -> Self::State { let mut state = initial_state; for (stmt, inst) in block.iter().enumerate() { @@ -158,22 +158,22 @@ pub trait Dataflow<'cx>: Sized { fn add_variable>( &mut self, - interp: &mut Interp<'cx, C>, - lval: &Variable, - varid: &VarId, - def: DefId, - rvalue: &Rvalue, + _interp: &mut Interp<'cx, C>, + _lval: &Variable, + _varid: &VarId, + _def: DefId, + _rvalue: &Rvalue, ) { } fn insert_value>( &mut self, - interp: &mut Interp<'cx, C>, - operand: &Operand, - lval: &Variable, - varid: &VarId, - def: DefId, - prev_values: Option>, + _interp: &mut Interp<'cx, C>, + _operand: &Operand, + _lval: &Variable, + _varid: &VarId, + _def: DefId, + _prev_values: Option>, ) { } @@ -233,7 +233,7 @@ pub trait Dataflow<'cx>: Sized { fn read_class_from_variable>( &mut self, _interp: &Interp<'cx, C>, - defid: DefId, + _defid: DefId, ) -> Option { None } @@ -241,7 +241,7 @@ pub trait Dataflow<'cx>: Sized { fn read_class_from_object>( &mut self, _interp: &Interp<'cx, C>, - defid: DefId, + _defid: DefId, ) -> Option { None } @@ -250,18 +250,18 @@ pub trait Dataflow<'cx>: Sized { &self, _interp: &Interp<'cx, C>, _def: DefId, - const_var: Const, + _const_var: Const, ) -> Option<&Value> { None } fn insert_with_existing_value>( &mut self, - operand: &Operand, - value: &Value, - varid: &VarId, - def: DefId, - interp: &Interp<'cx, C>, + _operand: &Operand, + _value: &Value, + _varid: &VarId, + _def: DefId, + _interp: &Interp<'cx, C>, ) { } @@ -269,7 +269,7 @@ pub trait Dataflow<'cx>: Sized { &self, _interp: &Interp<'cx, C>, _def: DefId, - obj: Class, + _obj: Class, ) -> Option<&Value> { None } @@ -316,7 +316,7 @@ pub trait Dataflow<'cx>: Sized { &self, _interp: &Interp<'cx, C>, _def: DefId, - defid: DefId, + _defid: DefId, ) -> Option<&Value> { None } @@ -340,8 +340,8 @@ pub trait Dataflow<'cx>: Sized { &self, _interp: &Interp<'cx, C>, _def: DefId, - const_var: Const, - intrinsic_argument: &mut IntrinsicArguments, + _const_var: Const, + _intrinsic_argument: &mut IntrinsicArguments, ) { } } diff --git a/crates/forge_loader/src/manifest.rs b/crates/forge_loader/src/manifest.rs index f980e78e..b811e73b 100644 --- a/crates/forge_loader/src/manifest.rs +++ b/crates/forge_loader/src/manifest.rs @@ -5,7 +5,7 @@ use std::{ path::{Path, PathBuf}, }; -use crate::{forgepermissions::ForgePermissions, Error}; +use crate::Error; use forge_utils::FxHashMap; use itertools::{Either, Itertools}; use serde::Deserialize;