forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add balance tree and output message effects to CEI analysis (FuelLabs…
- Loading branch information
1 parent
2faff70
commit 1b5f99c
Showing
43 changed files
with
294 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rc/e2e_vm_tests/test_programs/should_pass/static_analysis/cei_pattern_violation/test.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
category = "compile" | ||
|
||
# check: $()Storage modification after external contract interaction in function or method "deposit". Consider making all storage writes before calling another contract | ||
# check: $()Storage write after external contract interaction in function or method "deposit". Consider making all storage writes before calling another contract |
2 changes: 1 addition & 1 deletion
2
...ts/test_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block/test.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
category = "compile" | ||
|
||
# check: $()Storage modification after external contract interaction in function or method "deposit". Consider making all storage writes before calling another contract | ||
# check: $()Storage write after external contract interaction in function or method "deposit". Consider making all storage writes before calling another contract |
3 changes: 3 additions & 0 deletions
3
...est_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_bal/Forc.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[[package]] | ||
name = 'cei_pattern_violation_in_asm_block_bal' | ||
source = 'member' |
6 changes: 6 additions & 0 deletions
6
...est_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_bal/Forc.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[project] | ||
name = "cei_pattern_violation_in_asm_block_bal" | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
implicit-std = false |
18 changes: 18 additions & 0 deletions
18
...t_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_bal/src/main.sw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
contract; | ||
|
||
abi TestAbi { | ||
fn deposit(); | ||
} | ||
|
||
impl TestAbi for Contract { | ||
fn deposit() { | ||
let other_contract = abi(TestAbi, 0x3dba0a4455b598b7655a7fb430883d96c9527ef275b49739e7b0ad12f8280eae); | ||
|
||
// interaction | ||
other_contract.deposit(); | ||
// effect -- therefore violation of CEI where effect should go before interaction | ||
asm(r1, r2: 0, r3: 0) { | ||
bal r1 r2 r3; | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...est_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_bal/test.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
category = "compile" | ||
|
||
# check: $()Balance tree read after external contract interaction in function or method "deposit". Consider making all balance tree reads before calling another contract |
3 changes: 3 additions & 0 deletions
3
...est_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_smo/Forc.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[[package]] | ||
name = 'cei_pattern_violation_in_asm_block_smo' | ||
source = 'member' |
6 changes: 6 additions & 0 deletions
6
...est_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_smo/Forc.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[project] | ||
name = "cei_pattern_violation_in_asm_block_smo" | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
implicit-std = false |
18 changes: 18 additions & 0 deletions
18
...t_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_smo/src/main.sw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
contract; | ||
|
||
abi TestAbi { | ||
fn deposit(); | ||
} | ||
|
||
impl TestAbi for Contract { | ||
fn deposit() { | ||
let other_contract = abi(TestAbi, 0x3dba0a4455b598b7655a7fb430883d96c9527ef275b49739e7b0ad12f8280eae); | ||
|
||
// interaction | ||
other_contract.deposit(); | ||
// effect -- therefore violation of CEI where effect should go before interaction | ||
asm(r1: 0, r2: 0, r3: 0, r4: 0) { | ||
smo r1 r2 r3 r4; | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...est_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_smo/test.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
category = "compile" | ||
|
||
# check: $()Output message sent after external contract interaction in function or method "deposit". Consider sending all output messages before calling another contract |
13 changes: 13 additions & 0 deletions
13
...test_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_tr/Forc.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[[package]] | ||
name = 'cei_pattern_violation_in_asm_block_tr' | ||
source = 'member' | ||
dependencies = ['std'] | ||
|
||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-1F667E1725DAD261' | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-1F667E1725DAD261' | ||
dependencies = ['core'] |
8 changes: 8 additions & 0 deletions
8
...test_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_tr/Forc.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[project] | ||
name = "cei_pattern_violation_in_asm_block_tr" | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../../../sway-lib-std" } |
23 changes: 23 additions & 0 deletions
23
...st_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_tr/src/main.sw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
contract; | ||
|
||
use std::token::force_transfer_to_contract; | ||
|
||
abi TestAbi { | ||
fn deposit(); | ||
} | ||
|
||
impl TestAbi for Contract { | ||
fn deposit() { | ||
let other_contract = abi(TestAbi, 0x3dba0a4455b598b7655a7fb430883d96c9527ef275b49739e7b0ad12f8280eae); | ||
|
||
// interaction | ||
other_contract.deposit(); | ||
// effect -- therefore violation of CEI where effect should go before interaction | ||
let amount = 10; | ||
let address = 0x0000000000000000000000000000000000000000000000000000000000000001; | ||
let asset = ContractId::from(address); | ||
let pool = ContractId::from(address); | ||
// `force_transfer_to_contract` uses `tr` asm instruction | ||
force_transfer_to_contract(amount, asset, pool); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...test_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_tr/test.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
category = "compile" | ||
|
||
# check: $()Balance tree update after external contract interaction in function or method "deposit". Consider making all balance tree updates before calling another contract |
13 changes: 13 additions & 0 deletions
13
...est_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_tro/Forc.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[[package]] | ||
name = 'cei_pattern_violation_in_asm_block_tro' | ||
source = 'member' | ||
dependencies = ['std'] | ||
|
||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-D9AC6CFA47996221' | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-D9AC6CFA47996221' | ||
dependencies = ['core'] |
8 changes: 8 additions & 0 deletions
8
...est_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_tro/Forc.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[project] | ||
name = "cei_pattern_violation_in_asm_block_tro" | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../../../sway-lib-std" } |
Oops, something went wrong.