Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
febf8804
Commit
febf8804
authored
Mar 06, 2020
by
aniket-engg
Committed by
Aniket
Mar 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
existing commons test cases updated
parent
be7805e0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
332 additions
and
174 deletions
+332
-174
lowLevelCalls.ts
...x-analyzer/src/solidity-analyzer/modules/lowLevelCalls.ts
+5
-19
staticAnalysisCommon.ts
...zer/src/solidity-analyzer/modules/staticAnalysisCommon.ts
+41
-54
abiNamespaceCallNodes.json
...alyzer/test/analysis/astBlocks/abiNamespaceCallNodes.json
+0
-0
blockHashAccess.json
remix-analyzer/test/analysis/astBlocks/blockHashAccess.json
+54
-11
blockTimestamp.json
remix-analyzer/test/analysis/astBlocks/blockTimestamp.json
+21
-0
dynamicDeleteUnaryOp.json
...nalyzer/test/analysis/astBlocks/dynamicDeleteUnaryOp.json
+29
-0
index.js
remix-analyzer/test/analysis/astBlocks/index.js
+4
-0
parameterFunctionCall.json
...alyzer/test/analysis/astBlocks/parameterFunctionCall.json
+56
-89
requireCall.json
remix-analyzer/test/analysis/astBlocks/requireCall.json
+116
-0
staticAnalysisCommon-test.ts
remix-analyzer/test/analysis/staticAnalysisCommon-test.ts
+0
-0
deleteDynamicArray.sol
...lysis/test-contracts/solidity-v0.5/deleteDynamicArray.sol
+1
-1
library.sol
...er/test/analysis/test-contracts/solidity-v0.5/library.sol
+5
-0
No files found.
remix-analyzer/src/solidity-analyzer/modules/lowLevelCalls.ts
View file @
febf8804
import
{
default
as
category
}
from
'./categories'
import
{
default
as
category
}
from
'./categories'
import
{
isL
owLevelCallInst
,
isLowLevelCallInst050
,
isLowLevelCallcodeInst
,
isLowLevelDelegatecallInst
,
import
{
isL
LCall
,
isLLDelegatecall
,
isL
owLevelSendInst
,
isLowLevelSendInst050
,
isLLDelegatecallInst050
,
lowLevelCallTypes
}
from
'./staticAnalysisCommon'
isL
LSend
,
lowLevelCallTypes
}
from
'./staticAnalysisCommon'
import
{
default
as
algorithm
}
from
'./algorithmCategories'
import
{
default
as
algorithm
}
from
'./algorithmCategories'
import
{
AnalyzerModule
,
ModuleAlgorithm
,
ModuleCategory
,
ReportObj
,
CompilationResult
,
MemberAccessAstNode
}
from
'./../../types'
import
{
AnalyzerModule
,
ModuleAlgorithm
,
ModuleCategory
,
ReportObj
,
CompilationResult
,
MemberAccessAstNode
}
from
'./../../types'
...
@@ -20,20 +20,12 @@ export default class lowLevelCalls implements AnalyzerModule {
...
@@ -20,20 +20,12 @@ export default class lowLevelCalls implements AnalyzerModule {
algorithm
:
ModuleAlgorithm
=
algorithm
.
EXACT
algorithm
:
ModuleAlgorithm
=
algorithm
.
EXACT
visit
(
node
:
MemberAccessAstNode
):
void
{
visit
(
node
:
MemberAccessAstNode
):
void
{
if
(
isL
owLevelCallInst
(
node
))
{
if
(
isL
LCall
(
node
))
{
this
.
llcNodes
.
push
({
node
:
node
,
type
:
lowLevelCallTypes
.
CALL
})
this
.
llcNodes
.
push
({
node
:
node
,
type
:
lowLevelCallTypes
.
CALL
})
}
else
if
(
isLowLevelCallInst050
(
node
))
{
}
else
if
(
isLLDelegatecall
(
node
))
{
this
.
llcNodes
.
push
({
node
:
node
,
type
:
lowLevelCallTypes
.
CALL
})
}
else
if
(
isLowLevelCallcodeInst
(
node
))
{
this
.
llcNodes
.
push
({
node
:
node
,
type
:
lowLevelCallTypes
.
CALLCODE
})
}
else
if
(
isLowLevelDelegatecallInst
(
node
))
{
this
.
llcNodes
.
push
({
node
:
node
,
type
:
lowLevelCallTypes
.
DELEGATECALL
})
this
.
llcNodes
.
push
({
node
:
node
,
type
:
lowLevelCallTypes
.
DELEGATECALL
})
}
else
if
(
isLowLevelSendInst
(
node
))
{
}
else
if
(
isLLSend
(
node
))
{
this
.
llcNodes
.
push
({
node
:
node
,
type
:
lowLevelCallTypes
.
SEND
})
}
else
if
(
isLowLevelSendInst050
(
node
))
{
this
.
llcNodes
.
push
({
node
:
node
,
type
:
lowLevelCallTypes
.
SEND
})
this
.
llcNodes
.
push
({
node
:
node
,
type
:
lowLevelCallTypes
.
SEND
})
}
else
if
(
isLLDelegatecallInst050
(
node
))
{
this
.
llcNodes
.
push
({
node
:
node
,
type
:
lowLevelCallTypes
.
DELEGATECALL
})
}
}
}
}
...
@@ -49,12 +41,6 @@ export default class lowLevelCalls implements AnalyzerModule {
...
@@ -49,12 +41,6 @@ export default class lowLevelCalls implements AnalyzerModule {
morehref
=
'http://solidity.readthedocs.io/en/develop/control-structures.html?#external-function-calls'
morehref
=
'http://solidity.readthedocs.io/en/develop/control-structures.html?#external-function-calls'
// http://solidity.readthedocs.io/en/develop/frequently-asked-questions.html?#why-is-the-low-level-function-call-less-favorable-than-instantiating-a-contract-with-a-variable-contractb-b-and-executing-its-functions-b-dosomething
// http://solidity.readthedocs.io/en/develop/frequently-asked-questions.html?#why-is-the-low-level-function-call-less-favorable-than-instantiating-a-contract-with-a-variable-contractb-b-and-executing-its-functions-b-dosomething
break
break
case
lowLevelCallTypes
.
CALLCODE
:
text
=
`use of "callcode": the use of low level "callcode" should be avoided whenever possible.
External code that is called can change the state of the calling contract and send ether from the caller's balance.
If this is wanted behaviour use the Solidity library feature if possible.`
morehref
=
'http://solidity.readthedocs.io/en/develop/contracts.html#libraries'
break
case
lowLevelCallTypes
.
DELEGATECALL
:
case
lowLevelCallTypes
.
DELEGATECALL
:
text
=
`use of "delegatecall": the use of low level "delegatecall" should be avoided whenever possible.
text
=
`use of "delegatecall": the use of low level "delegatecall" should be avoided whenever possible.
External code that is called can change the state of the calling contract and send ether from the caller's balance.
External code that is called can change the state of the calling contract and send ether from the caller's balance.
...
...
remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.ts
View file @
febf8804
This diff is collapsed.
Click to expand it.
remix-analyzer/test/analysis/astBlocks/abiNamespaceCallNodes.json
0 → 100644
View file @
febf8804
This diff is collapsed.
Click to expand it.
remix-analyzer/test/analysis/astBlocks/blockHashAccess.json
View file @
febf8804
{
{
"argumentTypes"
:[
"argumentTypes"
:
null
,
"arguments"
:
[
{
{
"typeIdentifier"
:
"t_rational_3_by_1"
,
"argumentTypes"
:
null
,
"typeString"
:
"int_const 3"
"hexValue"
:
"33"
,
"id"
:
6
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
true
,
"kind"
:
"number"
,
"lValueRequested"
:
false
,
"nodeType"
:
"Literal"
,
"src"
:
"79:1:0"
,
"subdenomination"
:
null
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_rational_3_by_1"
,
"typeString"
:
"int_const 3"
},
"value"
:
"3"
}
}
],
],
"id"
:
5
,
"expression"
:
"name"
:
"blockhash"
,
{
"nodeType"
:
"Identifier"
,
"argumentTypes"
:
"overloadedDeclarations"
:
[],
[
"referencedDeclaration"
:
-5
,
{
"src"
:
"69:9:0"
,
"typeIdentifier"
:
"t_rational_3_by_1"
,
"typeString"
:
"int_const 3"
}
],
"id"
:
5
,
"name"
:
"blockhash"
,
"nodeType"
:
"Identifier"
,
"overloadedDeclarations"
:
[],
"referencedDeclaration"
:
-5
,
"src"
:
"69:9:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_function_blockhash_view$_t_uint256_$returns$_t_bytes32_$"
,
"typeString"
:
"function (uint256) view returns (bytes32)"
}
},
"id"
:
7
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
false
,
"kind"
:
"functionCall"
,
"lValueRequested"
:
false
,
"names"
:
[],
"nodeType"
:
"FunctionCall"
,
"src"
:
"69:12:0"
,
"tryCall"
:
false
,
"typeDescriptions"
:
"typeDescriptions"
:
{
{
"typeIdentifier"
:
"t_
function_blockhash_view$_t_uint256_$returns$_t_bytes32_$
"
,
"typeIdentifier"
:
"t_
bytes32
"
,
"typeString"
:
"
function (uint256) view returns (bytes32)
"
"typeString"
:
"
bytes32
"
}
}
}
}
\ No newline at end of file
remix-analyzer/test/analysis/astBlocks/blockTimestamp.json
0 → 100644
View file @
febf8804
{
"argumentTypes"
:
null
,
"expression"
:
{
"argumentTypes"
:
null
,
"id"
:
109
,
"name"
:
"block"
,
"nodeType"
:
"Identifier"
,
"overloadedDeclarations"
:
[],
"referencedDeclaration"
:
-4
,
"src"
:
"1507:5:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_magic_block"
,
"typeString"
:
"block"
}
},
"id"
:
110
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
false
,
"lValueRequested"
:
false
,
"memberName"
:
"timestamp"
,
"nodeType"
:
"MemberAccess"
,
"referencedDeclaration"
:
null
,
"src"
:
"1507:15:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_uint256"
,
"typeString"
:
"uint256"
}
}
\ No newline at end of file
remix-analyzer/test/analysis/astBlocks/dynamicDeleteUnaryOp.json
0 → 100644
View file @
febf8804
{
"argumentTypes"
:
null
,
"id"
:
74
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
false
,
"lValueRequested"
:
false
,
"nodeType"
:
"UnaryOperation"
,
"operator"
:
"delete"
,
"prefix"
:
true
,
"src"
:
"627:12:0"
,
"subExpression"
:
{
"argumentTypes"
:
null
,
"id"
:
73
,
"name"
:
"users"
,
"nodeType"
:
"Identifier"
,
"overloadedDeclarations"
:
[],
"referencedDeclaration"
:
4
,
"src"
:
"634:5:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_array$_t_uint256_$dyn_storage"
,
"typeString"
:
"uint256[] storage ref"
}
},
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_tuple$__$"
,
"typeString"
:
"tuple()"
}
}
\ No newline at end of file
remix-analyzer/test/analysis/astBlocks/index.js
View file @
febf8804
...
@@ -2,7 +2,10 @@ module.exports = {
...
@@ -2,7 +2,10 @@ module.exports = {
localCall
:
require
(
'./localCall.json'
),
localCall
:
require
(
'./localCall.json'
),
contractDefinition
:
require
(
'./contractDefinition.json'
),
contractDefinition
:
require
(
'./contractDefinition.json'
),
unaryOperation
:
require
(
'./unaryOperation.json'
),
unaryOperation
:
require
(
'./unaryOperation.json'
),
blockTimestamp
:
require
(
'./blockTimestamp.json'
),
dynamicDeleteUnaryOp
:
require
(
'./dynamicDeleteUnaryOp.json'
),
nowAst
:
require
(
'./nowAst.json'
),
nowAst
:
require
(
'./nowAst.json'
),
requireCall
:
require
(
'./requireCall.json'
),
thisLocalCall
:
require
(
'./thisLocalCall.json'
),
thisLocalCall
:
require
(
'./thisLocalCall.json'
),
libCall
:
require
(
'./libCall.json'
),
libCall
:
require
(
'./libCall.json'
),
externalDirect
:
require
(
'./externalDirect.json'
),
externalDirect
:
require
(
'./externalDirect.json'
),
...
@@ -17,6 +20,7 @@ module.exports = {
...
@@ -17,6 +20,7 @@ module.exports = {
fullyQualifiedFunctionDefinition
:
require
(
'./fullyQualifiedFunctionDefinition.json'
),
fullyQualifiedFunctionDefinition
:
require
(
'./fullyQualifiedFunctionDefinition.json'
),
selfdestruct
:
require
(
'./selfdestruct.json'
),
selfdestruct
:
require
(
'./selfdestruct.json'
),
storageVariableNodes
:
require
(
'./storageVariableNodes.json'
),
storageVariableNodes
:
require
(
'./storageVariableNodes.json'
),
abiNamespaceCallNodes
:
require
(
'./abiNamespaceCallNodes.json'
),
lowlevelCall
:
require
(
'./lowlevelCall.json'
),
lowlevelCall
:
require
(
'./lowlevelCall.json'
),
parameterFunction
:
require
(
'./parameterFunction.json'
),
parameterFunction
:
require
(
'./parameterFunction.json'
),
parameterFunctionCall
:
require
(
'./parameterFunctionCall.json'
),
parameterFunctionCall
:
require
(
'./parameterFunctionCall.json'
),
...
...
remix-analyzer/test/analysis/astBlocks/parameterFunctionCall.json
View file @
febf8804
{
{
"attributes"
:
{
"argumentTypes"
:
null
,
"argumentTypes"
:
null
,
"arguments"
:
"isConstant"
:
false
,
[
"isLValue"
:
false
,
{
"isPure"
:
false
,
"argumentTypes"
:
null
,
"isStructConstructorCall"
:
false
,
"id"
:
216
,
"lValueRequested"
:
false
,
"name"
:
"internalPureFunc"
,
"names"
:
[
"nodeType"
:
"Identifier"
,
null
"overloadedDeclarations"
:
[],
],
"referencedDeclaration"
:
12
,
"type"
:
"uint256"
,
"src"
:
"1636:16:0"
,
"type_conversion"
:
false
"typeDescriptions"
:
},
{
"children"
:
[
"typeIdentifier"
:
"t_function_internal_pure$_t_uint256_$returns$_t_uint256_$"
,
{
"typeString"
:
"function (uint256) pure returns (uint256)"
"attributes"
:
{
}
"argumentTypes"
:
[
}
{
],
"typeIdentifier"
:
"t_function_internal_pure$_t_uint256_$_t_uint256_$returns$_t_uint256_$"
,
"expression"
:
"typeString"
:
"function (uint256,uint256) pure returns (uint256)"
{
},
"argumentTypes"
:
{
[
"typeIdentifier"
:
"t_uint256"
,
{
"typeString"
:
"uint256"
"typeIdentifier"
:
"t_function_internal_pure$_t_uint256_$returns$_t_uint256_$"
,
},
"typeString"
:
"function (uint256) pure returns (uint256)"
{
}
"typeIdentifier"
:
"t_uint256"
,
],
"typeString"
:
"uint256"
"id"
:
215
,
}
"name"
:
"funcTakesInternalPure"
,
],
"nodeType"
:
"Identifier"
,
"overloadedDeclarations"
:
[
"overloadedDeclarations"
:
[],
null
"referencedDeclaration"
:
104
,
],
"src"
:
"1614:21:0"
,
"referencedDeclaration"
:
40
,
"typeDescriptions"
:
"type"
:
"function (function (uint256,uint256) pure returns (uint256),uint256,uint256) pure returns (uint256)"
,
{
"value"
:
"eval"
"typeIdentifier"
:
"t_function_internal_pure$_t_function_internal_pure$_t_uint256_$returns$_t_uint256_$_$returns$_t_uint256_$"
,
},
"typeString"
:
"function (function (uint256) pure returns (uint256)) pure returns (uint256)"
"id"
:
49
,
}
"name"
:
"Identifier"
,
},
"src"
:
"361:4:0"
"id"
:
217
,
},
"isConstant"
:
false
,
{
"isLValue"
:
false
,
"attributes"
:
{
"isPure"
:
false
,
"argumentTypes"
:
null
,
"kind"
:
"functionCall"
,
"overloadedDeclarations"
:
[
"lValueRequested"
:
false
,
null
"names"
:
[],
],
"nodeType"
:
"FunctionCall"
,
"referencedDeclaration"
:
15
,
"src"
:
"1614:39:0"
,
"type"
:
"function (uint256,uint256) pure returns (uint256)"
,
"tryCall"
:
false
,
"value"
:
"plus"
"typeDescriptions"
:
},
{
"id"
:
50
,
"typeIdentifier"
:
"t_uint256"
,
"name"
:
"Identifier"
,
"typeString"
:
"uint256"
"src"
:
"366:4:0"
}
},
}
{
\ No newline at end of file
"attributes"
:
{
"argumentTypes"
:
null
,
"overloadedDeclarations"
:
[
null
],
"referencedDeclaration"
:
42
,
"type"
:
"uint256"
,
"value"
:
"x"
},
"id"
:
51
,
"name"
:
"Identifier"
,
"src"
:
"372:1:0"
},
{
"attributes"
:
{
"argumentTypes"
:
null
,
"overloadedDeclarations"
:
[
null
],
"referencedDeclaration"
:
44
,
"type"
:
"uint256"
,
"value"
:
"y"
},
"id"
:
52
,
"name"
:
"Identifier"
,
"src"
:
"375:1:0"
}
],
"id"
:
53
,
"name"
:
"FunctionCall"
,
"src"
:
"361:16:0"
}
\ No newline at end of file
remix-analyzer/test/analysis/astBlocks/requireCall.json
0 → 100644
View file @
febf8804
{
"argumentTypes"
:
null
,
"arguments"
:
[
{
"argumentTypes"
:
null
,
"commonType"
:
{
"typeIdentifier"
:
"t_uint256"
,
"typeString"
:
"uint256"
},
"id"
:
8
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
false
,
"lValueRequested"
:
false
,
"leftExpression"
:
{
"argumentTypes"
:
null
,
"expression"
:
{
"argumentTypes"
:
null
,
"id"
:
5
,
"name"
:
"msg"
,
"nodeType"
:
"Identifier"
,
"overloadedDeclarations"
:
[],
"referencedDeclaration"
:
-15
,
"src"
:
"56:3:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_magic_message"
,
"typeString"
:
"msg"
}
},
"id"
:
6
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
false
,
"lValueRequested"
:
false
,
"memberName"
:
"value"
,
"nodeType"
:
"MemberAccess"
,
"referencedDeclaration"
:
null
,
"src"
:
"56:9:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_uint256"
,
"typeString"
:
"uint256"
}
},
"nodeType"
:
"BinaryOperation"
,
"operator"
:
">="
,
"rightExpression"
:
{
"argumentTypes"
:
null
,
"id"
:
7
,
"name"
:
"_amount"
,
"nodeType"
:
"Identifier"
,
"overloadedDeclarations"
:
[],
"referencedDeclaration"
:
2
,
"src"
:
"69:7:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_uint256"
,
"typeString"
:
"uint256"
}
},
"src"
:
"56:20:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_bool"
,
"typeString"
:
"bool"
}
}
],
"expression"
:
{
"argumentTypes"
:
[
{
"typeIdentifier"
:
"t_bool"
,
"typeString"
:
"bool"
}
],
"id"
:
4
,
"name"
:
"require"
,
"nodeType"
:
"Identifier"
,
"overloadedDeclarations"
:
[
-18
,
-18
],
"referencedDeclaration"
:
-18
,
"src"
:
"48:7:0"
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_function_require_pure$_t_bool_$returns$__$"
,
"typeString"
:
"function (bool) pure"
}
},
"id"
:
9
,
"isConstant"
:
false
,
"isLValue"
:
false
,
"isPure"
:
false
,
"kind"
:
"functionCall"
,
"lValueRequested"
:
false
,
"names"
:
[],
"nodeType"
:
"FunctionCall"
,
"src"
:
"48:29:0"
,
"tryCall"
:
false
,
"typeDescriptions"
:
{
"typeIdentifier"
:
"t_tuple$__$"
,
"typeString"
:
"tuple()"
}
}
\ No newline at end of file
remix-analyzer/test/analysis/staticAnalysisCommon-test.ts
View file @
febf8804
This diff is collapsed.
Click to expand it.
remix-analyzer/test/analysis/test-contracts/solidity-v0.5/deleteDynamicArray.sol
View file @
febf8804
pragma solidity >=0.4.9 <0.
6
.0;
pragma solidity >=0.4.9 <0.
7
.0;
contract arr {
contract arr {
uint[] users;
uint[] users;
...
...
remix-analyzer/test/analysis/test-contracts/solidity-v0.5/library.sol
View file @
febf8804
...
@@ -50,5 +50,9 @@ contract C {
...
@@ -50,5 +50,9 @@ contract C {
if (!Set.insert(knownValues, value))
if (!Set.insert(knownValues, value))
revert();
revert();
}
}
function testt() public view returns (uint) {
return block.timestamp;
}
// In this contract, we can also directly access knownValues.flags, if we want.
// In this contract, we can also directly access knownValues.flags, if we want.
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment