Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Smart Contract Security
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
POTHURI HARIKA
Smart Contract Security
Commits
c1e69ff4
Commit
c1e69ff4
authored
2 years ago
by
POTHURI HARIKA
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
2eeb1186
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tools/SmartCheck/Solidity/Rules/SOLIDITY_DEPRECATED_CONSTRUCTIONS.md
+210
-0
210 additions, 0 deletions
...Check/Solidity/Rules/SOLIDITY_DEPRECATED_CONSTRUCTIONS.md
with
210 additions
and
0 deletions
Tools/SmartCheck/Solidity/Rules/SOLIDITY_DEPRECATED_CONSTRUCTIONS.md
0 → 100644
+
210
−
0
View file @
c1e69ff4
# Analysis of Smart Contract Security Vulnerabilities and Tools 






<br/>
!
[](
https://img.shields.io/badge/BlockchainCourse-21CY712-green
)


<br/>

<br/>

## SOLIDITY_DEPRECATED_CONSTRUCTIONS
### Rule Description
Deprecated constructions
### Solidity-Rules


```
//functionCall/functionName//identifier[matches(text()[1], "^suicide$")]
| //assemblyCall/identifier[matches(text()[1], "^suicide$")]
```


```
//functionCall/functionName//identifier[matches(text()[1], "^sha3$")]
| //assemblyCall/identifier[matches(text()[1], "^sha3$")]
```


```
//statement/throwRevertStatement[matches(text()[1], "^throw$")]
```


```
//functionDefinition[stateMutability/constantType]
```


```
//numberLiteral/numberUnit[text()[1] = "years"]
```
### Sample Code
```
pragma solidity 0.4.24;
contract C {
function kill() {
// <yes> <report> SOLIDITY_DEPRECATED_CONSTRUCTIONS 27cb59
suicide(0x0);
}
function hashingsha3 (string s) returns (bytes32 hash){
// <yes> <report> SOLIDITY_DEPRECATED_CONSTRUCTIONS 187b5a
return sha3(s);
}
function delegatecallSetN(address _e, uint _n) {
// <yes> <report> SOLIDITY_DEPRECATED_CONSTRUCTIONS 49bd2a
if (_e != address(0)) throw;
}
function killer() {
uint r;
assembly {
// <yes> <report> SOLIDITY_DEPRECATED_CONSTRUCTIONS 187b5a
r := sha3('','')
// <yes> <report> SOLIDITY_DEPRECATED_CONSTRUCTIONS 27cb59
suicide(0x0)
}
}
// <yes> <report> SOLIDITY_DEPRECATED_CONSTRUCTIONS 28fa69
function returnSenderBalance(uint a) constant returns (uint){
return a;
}
function usingYears() returns(uint) {
// <yes> <report> SOLIDITY_DEPRECATED_CONSTRUCTIONS 852kwn
return 100 years;
}
}
```
### Abstract Syntax Tree
[
Click Here
](
https://astexplorer.net/#/gist/cebc0980b1be99cd5ed88b8c85e929dd/b0800a58bab995065466b0276ee3fa75f2a19a02
)
to view the AST for the above code. Code generated from AST Explorer using _solidity-parser-antlr-0.4.11_
### Code Result
```
SOLIDITY_ADDRESS_HARDCODED
patternId: c67a09
severity: 1
line: 6
column: 16
content: 0x0
ruleId: SOLIDITY_DEPRECATED_CONSTRUCTIONS
patternId: 27cb59
severity: 1
line: 6
column: 8
content: suicide
ruleId: SOLIDITY_DEPRECATED_CONSTRUCTIONS
patternId: 27cb59
severity: 1
line: 22
column: 12
content: suicide
ruleId: SOLIDITY_DEPRECATED_CONSTRUCTIONS
patternId: 187b5a
severity: 1
line: 10
column: 15
content: sha3
ruleId: SOLIDITY_DEPRECATED_CONSTRUCTIONS
patternId: 187b5a
severity: 1
line: 20
column: 17
content: sha3
ruleId: SOLIDITY_DEPRECATED_CONSTRUCTIONS
patternId: 49bd2a
severity: 1
line: 14
column: 30
content: throw
ruleId: SOLIDITY_DEPRECATED_CONSTRUCTIONS
patternId: 28fa69
severity: 1
line: 26
column: 4
content: functionreturnSenderBalance(uinta)constantreturns(uint){returna;}
ruleId: SOLIDITY_DEPRECATED_CONSTRUCTIONS
patternId: 852kwn
severity: 1
line: 32
column: 19
content: years
ruleId: SOLIDITY_REVERT_REQUIRE
patternId: c56b12
severity: 1
line: 14
column: 8
content: if(_e!=address(0))throw;
ruleId: SOLIDITY_USING_INLINE_ASSEMBLY
patternId: 109cd5
severity: 1
line: 18
column: 8
content: assembly{r:=sha3('','')suicide(0x0)}
ruleId: SOLIDITY_VISIBILITY
patternId: 910067
severity: 1
line: 4
column: 4
content: functionkill(){suicide(0x0);}
ruleId: SOLIDITY_VISIBILITY
patternId: 910067
severity: 1
line: 8
column: 4
content: functionhashingsha3(strings)returns(bytes32hash){returnsha3(s);}
ruleId: SOLIDITY_VISIBILITY
patternId: 910067
severity: 1
line: 12
column: 4
content: functiondelegatecallSetN(address_e,uint_n){if(_e!=address(0))throw;}
ruleId: SOLIDITY_VISIBILITY
patternId: 910067
severity: 1
line: 16
column: 4
content: functionkiller(){uintr;assembly{r:=sha3('','')suicide(0x0)}}
ruleId: SOLIDITY_VISIBILITY
patternId: 910067
severity: 1
line: 26
column: 4
content: functionreturnSenderBalance(uinta)constantreturns(uint){returna;}
ruleId: SOLIDITY_VISIBILITY
patternId: 910067
severity: 1
line: 30
column: 4
content: functionusingYears()returns(uint){return100years;}
SOLIDITY_VISIBILITY :6
SOLIDITY_DEPRECATED_CONSTRUCTIONS :7
SOLIDITY_REVERT_REQUIRE :1
SOLIDITY_ADDRESS_HARDCODED :1
SOLIDITY_USING_INLINE_ASSEMBLY :1
```
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment