Skip to content

Commit

Permalink
Allow unordered mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
jgcrosta committed Mar 14, 2024
1 parent 68481d6 commit c1bd75a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions detectors/unprotected-mapping-operation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct UnprotectedMappingOperationFinder<'tcx, 'tcx_ref> {
unauthorized_span: Vec<UnauthorizedAddress>,
}

const SOROBAN_MAP_WITH_ADDRESS: &str = "soroban_sdk::Map<soroban_sdk::Address";
const SOROBAN_MAP: &str = "soroban_sdk::Map";
const SOROBAN_ADDRESS: &str = "soroban_sdk::Address";

impl<'tcx> LateLintPass<'tcx> for UnprotectedMappingOperation {
Expand Down Expand Up @@ -99,7 +99,11 @@ impl<'tcx> Visitor<'tcx> for UnprotectedMappingOperationFinder<'tcx, '_> {
// Get the method expression type and check if it's a map with address
let method_expr_type = self.get_node_type(method_expr.hir_id);

if method_expr_type.contains(SOROBAN_MAP_WITH_ADDRESS) {
println!("Method expression type: {}", method_expr_type);

if method_expr_type.starts_with(SOROBAN_MAP)
&& method_expr_type.contains(SOROBAN_ADDRESS)
{
// Iterate through the method arguments and check if any of them is an address and not authed
method_args.iter().for_each(|arg| {
if_chain! {
Expand Down

0 comments on commit c1bd75a

Please sign in to comment.