-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
102 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
contract Test { | ||
// ok: missing-assignment | ||
struct Kek { | ||
// ok: missing-assignment | ||
mapping(uint256 => uint256) lol; | ||
} | ||
|
||
// ok: missing-assignment | ||
function smth(uint256 _id) { | ||
// ok: missing-assignment | ||
Kek puk; | ||
// ruleid: missing-assignment | ||
puk.lol[_id]; | ||
// ok: missing-assignment | ||
uint256 haha = 123; | ||
// ok: missing-assignment | ||
haha = 321; | ||
// ruleid: missing-assignment | ||
haha; | ||
// ruleid: missing-assignment | ||
haha == 123; | ||
// ok: missing-assignment | ||
haha += 1; | ||
// ok: missing-assignment | ||
haha -= 1; | ||
// ok: missing-assignment | ||
haha++; | ||
// ok: missing-assignment | ||
haha--; | ||
// ok: missing-assignment | ||
--haha; | ||
// ok: missing-assignment | ||
++haha; | ||
// ok: missing-assignment | ||
return haha; | ||
} | ||
|
||
// ok: missing-assignment | ||
function doit(uint256 a) {} | ||
|
||
function heh(uint256 _id) { | ||
// ok: missing-assignment | ||
Kek puk; | ||
// ok: missing-assignment | ||
doit(puk.lol[_id]); | ||
// ok: missing-assignment | ||
doit(puk.lol[_id]); | ||
// ruleid: missing-assignment | ||
"heh"; | ||
// ok: missing-assignment | ||
return; | ||
} | ||
} |
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,47 @@ | ||
rules: | ||
- id: missing-assignment | ||
message: Meaningless statement that does not change any values could be a sign of missed security checks or other important changes. | ||
metadata: | ||
category: security | ||
technology: | ||
- solidity | ||
cwe: "CWE-1164: Irrelevant Code" | ||
confidence: HIGH | ||
likelihood: HIGH | ||
impact: MEDIUM | ||
subcategory: | ||
- vuln | ||
patterns: | ||
- pattern-either: | ||
- pattern: | | ||
$X; | ||
- pattern: | | ||
$X[$Y]; | ||
- pattern: | | ||
$X == $Y; | ||
- pattern-not: $FUNC(...); | ||
- pattern-not: $FUNC(); | ||
- pattern-not: $VAR++; | ||
- pattern-not: $VAR--; | ||
- pattern-not: ++$VAR; | ||
- pattern-not: --$VAR; | ||
- pattern-not: ... = ...; | ||
- pattern-not: ... += ...; | ||
- pattern-not: ... -= ...; | ||
- pattern-not: $TYPE $VAR; | ||
- pattern-not: return $VAR; | ||
- pattern-not: return; | ||
- pattern-not: continue; | ||
- pattern-not: break; | ||
- pattern-not: _; | ||
- pattern-not: error $NAME(); | ||
- pattern-not: error $NAME($ARGS); | ||
#- pattern-not: function $NAME($ARGS) virtual {} # doesn't work | ||
- pattern-not: | # let's not match empty function bodies | ||
{} | ||
- metavariable-regex: | ||
metavariable: $X | ||
regex: "^\\S+$" | ||
languages: | ||
- solidity | ||
severity: WARNING |