Skip to content

Commit

Permalink
Merge branch 'main' into 4-dos-unbounded-operation
Browse files Browse the repository at this point in the history
  • Loading branch information
jgcrosta committed Dec 15, 2023
2 parents 864ec50 + c9f5249 commit 3fc1d9f
Show file tree
Hide file tree
Showing 33 changed files with 68 additions and 65 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ test-cases/**/Cargo.lock
detectors/**/Cargo.lock
scout-audit-internal/Cargo.lock

#ignore test generated files
test-cases/**/test_snapshots/**

# -------------------------------------------------------------------------------------
# -------------------------------------- Misc -----------------------------------------
# -------------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions detectors/overflow-check/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ crate-type = ["cdylib"]
soroban-sdk = "20.0.0-rc2"

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down Expand Up @@ -63,7 +63,7 @@ crate-type = ["cdylib"]
soroban-sdk = "20.0.0-rc2"

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
soroban-sdk = { version = "20.0.0-rc2" }
soroban-sdk = { version = "=20.0.0" }

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
soroban-sdk = { version = "20.0.0-rc2" }
soroban-sdk = { version = "=20.0.0" }

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
soroban-sdk = { version = "20.0.0-rc2" }
soroban-sdk = { version = "=20.0.0" }

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
soroban-sdk = { version = "20.0.0-rc2" }
soroban-sdk = { version = "=20.0.0" }

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
soroban-sdk = { version = "20.0.0-rc2" }
soroban-sdk = { version = "=20.0.0" }

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
soroban-sdk = { version = "20.0.0-rc2" }
soroban-sdk = { version = "=20.0.0" }

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
soroban-sdk = { version = "20.0.0-rc2" }
soroban-sdk = { version = "=20.0.0" }

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
soroban-sdk = { version = "20.0.0-rc2" }
soroban-sdk = { version = "=20.0.0" }

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ crate-type = ["cdylib"]
soroban-sdk = "20.0.0-rc2"

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl Contract {
if max_val == 0 {
Err(Error::MaxValZero)
} else {
let val = env.prng().u64_in_range(0..max_val);
let val = env.prng().gen_range(0..max_val);
Ok(val)
}
}
Expand All @@ -39,16 +39,16 @@ mod test {

// When
let first_random_value = client.generate_random_value(&10);
let second_random_value = client.generate_random_value(&10);
let third_random_value = client.generate_random_value(&10);
let fourth_random_value = client.generate_random_value(&10);
let fifth_random_value = client.generate_random_value(&10);
let second_random_value = client.generate_random_value(&100);
let third_random_value = client.generate_random_value(&1000);
let fourth_random_value = client.generate_random_value(&10000);
let fifth_random_value = client.generate_random_value(&100000);

// Then
assert_eq!(first_random_value, 6);
assert_eq!(second_random_value, 5);
assert_eq!(third_random_value, 8);
assert_eq!(fourth_random_value, 8);
assert_eq!(fifth_random_value, 4);
assert!(first_random_value < 10);
assert!(second_random_value < 100);
assert!(third_random_value < 1000);
assert!(fourth_random_value < 10000);
assert!(fifth_random_value < 100000);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ crate-type = ["cdylib"]
soroban-sdk = "20.0.0-rc2"

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ crate-type = ["cdylib"]
soroban-sdk = "20.0.0-rc2"

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ crate-type = ["cdylib"]
soroban-sdk = "20.0.0-rc2"

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
soroban-sdk = { version = "20.0.0-rc2" }
soroban-sdk = { version = "=20.0.0" }

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl SetContractStorage {
let mut count: u32 = storage.get(&COUNTER).unwrap_or(0);
count += 1;
storage.set(&COUNTER, &count);
storage.bump(100, 100);
storage.extend_ttl(100, 100);
count
}
}
Expand All @@ -33,7 +33,7 @@ mod tests {
let contract_id = env.register_contract(None, SetContractStorage);
let client = SetContractStorageClient::new(&env, &contract_id);
env.mock_all_auths();
let user = <Address as testutils::Address>::random(&env);
let user = <Address as testutils::Address>::generate(&env);

// When
let first_increment = client.increment(&user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
soroban-sdk = { version = "20.0.0-rc2" }
soroban-sdk = { version = "=20.0.0" }

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl SetContractStorage {
let mut count: u32 = storage.get(&COUNTER).unwrap_or(0);
count += 1;
storage.set(&COUNTER, &count);
storage.bump(100, 100);
storage.extend_ttl(100, 100);
count
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
soroban-sdk = { version = "20.0.0-rc2" }
soroban-sdk = { version = "=20.0.0" }

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl SetContractStorage {
let mut count: u32 = storage.get(&COUNTER).unwrap_or(0);
count += 1;
storage.set(&COUNTER, &count);
storage.bump(&COUNTER, 100, 100);
storage.extend_ttl(&COUNTER, 100, 100);
count
}
}
Expand All @@ -33,7 +33,7 @@ mod tests {
let contract_id = env.register_contract(None, SetContractStorage);
let client = SetContractStorageClient::new(&env, &contract_id);
env.mock_all_auths();
let user = <Address as testutils::Address>::random(&env);
let user = <Address as testutils::Address>::generate(&env);

// When
let first_increment = client.increment(&user);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[package]
name = "set-contract-storage-vulnerable-1"
name = "set-contract-storage-vulnerable-2"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
soroban-sdk = { version = "20.0.0-rc2" }
soroban-sdk = { version = "=20.0.0" }

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl SetContractStorage {
let mut count: u32 = storage.get(&COUNTER).unwrap_or(0);
count += 1;
storage.set(&COUNTER, &count);
storage.bump(&COUNTER, 100, 100);
storage.extend_ttl(&COUNTER, 100, 100);
count
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
soroban-sdk = { version = "20.0.0-rc2" }
soroban-sdk = { version = "=20.0.0" }

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl SetContractStorage {
let mut count: u32 = storage.get(&COUNTER).unwrap_or(0);
count += 1;
storage.set(&COUNTER, &count);
storage.bump(&COUNTER, 100, 100);
storage.extend_ttl(&COUNTER, 100, 100);
count
}
}
Expand All @@ -33,7 +33,7 @@ mod tests {
let contract_id = env.register_contract(None, SetContractStorage);
let client = SetContractStorageClient::new(&env, &contract_id);
env.mock_all_auths();
let user = <Address as testutils::Address>::random(&env);
let user = <Address as testutils::Address>::generate(&env);

// When
let first_increment = client.increment(&user);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[package]
name = "set-contract-storage-vulnerable-1"
name = "set-contract-storage-vulnerable-3"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
soroban-sdk = { version = "20.0.0-rc2" }
soroban-sdk = { version = "=20.0.0" }

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl SetContractStorage {
let mut count: u32 = storage.get(&COUNTER).unwrap_or(0);
count += 1;
storage.set(&COUNTER, &count);
storage.bump(&COUNTER, 100, 100);
storage.extend_ttl(&COUNTER, 100, 100);
count
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ crate-type = ["cdylib"]
soroban-sdk = "20.0.0-rc2"

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ crate-type = ["cdylib"]
soroban-sdk = "20.0.0-rc2"

[dev_dependencies]
soroban-sdk = { version = "20.0.0-rc2", features = ["testutils"] }
soroban-sdk = { version = "=20.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand Down
Loading

0 comments on commit 3fc1d9f

Please sign in to comment.