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
85ae6115
Commit
85ae6115
authored
May 17, 2017
by
Michael Fröwis
Committed by
chriseth
May 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Static Analysis: new as const breaker
parent
d0e2d123
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
5 deletions
+27
-5
constantFunctions.js
src/app/staticanalysis/modules/constantFunctions.js
+4
-2
staticAnalysisCommon.js
src/app/staticanalysis/modules/staticAnalysisCommon.js
+23
-3
No files found.
src/app/staticanalysis/modules/constantFunctions.js
View file @
85ae6115
...
@@ -10,7 +10,7 @@ function constantFunctions () {
...
@@ -10,7 +10,7 @@ function constantFunctions () {
var
that
=
this
var
that
=
this
constantFunctions
.
prototype
.
visit
=
new
AbstractAst
().
builder
(
constantFunctions
.
prototype
.
visit
=
new
AbstractAst
().
builder
(
(
node
)
=>
common
.
isLowLevelCall
(
node
)
||
common
.
is
ExternalDirectCall
(
node
)
||
common
.
isEffect
(
node
)
||
common
.
isLocalCallGraphRelevantNode
(
node
)
||
common
.
isInlineAssembly
(
node
),
(
node
)
=>
common
.
isLowLevelCall
(
node
)
||
common
.
is
Transfer
(
node
)
||
common
.
isExternalDirectCall
(
node
)
||
common
.
isEffect
(
node
)
||
common
.
isLocalCallGraphRelevantNode
(
node
)
||
common
.
isInlineAssembly
(
node
)
||
common
.
isNewExpression
(
node
),
that
.
contracts
that
.
contracts
)
)
}
}
...
@@ -66,9 +66,11 @@ function checkIfShouldBeConstant (startFuncName, context) {
...
@@ -66,9 +66,11 @@ function checkIfShouldBeConstant (startFuncName, context) {
function
isConstBreaker
(
node
,
context
)
{
function
isConstBreaker
(
node
,
context
)
{
return
common
.
isWriteOnStateVariable
(
node
,
context
.
stateVariables
)
||
return
common
.
isWriteOnStateVariable
(
node
,
context
.
stateVariables
)
||
common
.
isLowLevelCall
(
node
)
||
common
.
isLowLevelCall
(
node
)
||
common
.
isTransfer
(
node
)
||
isCallOnNonConstExternalInterfaceFunction
(
node
,
context
)
||
isCallOnNonConstExternalInterfaceFunction
(
node
,
context
)
||
common
.
isCallToNonConstLocalFunction
(
node
)
||
common
.
isCallToNonConstLocalFunction
(
node
)
||
common
.
isInlineAssembly
(
node
)
common
.
isInlineAssembly
(
node
)
||
common
.
isNewExpression
(
node
)
}
}
function
isCallOnNonConstExternalInterfaceFunction
(
node
,
context
)
{
function
isCallOnNonConstExternalInterfaceFunction
(
node
,
context
)
{
...
...
src/app/staticanalysis/modules/staticAnalysisCommon.js
View file @
85ae6115
...
@@ -17,7 +17,8 @@ var nodeTypes = {
...
@@ -17,7 +17,8 @@ var nodeTypes = {
INHERITANCESPECIFIER
:
'InheritanceSpecifier'
,
INHERITANCESPECIFIER
:
'InheritanceSpecifier'
,
USERDEFINEDTYPENAME
:
'UserDefinedTypeName'
,
USERDEFINEDTYPENAME
:
'UserDefinedTypeName'
,
INLINEASSEMBLY
:
'InlineAssembly'
,
INLINEASSEMBLY
:
'InlineAssembly'
,
BLOCK
:
'Block'
BLOCK
:
'Block'
,
NEWEXPRESSION
:
'NewExpression'
}
}
var
basicTypes
=
{
var
basicTypes
=
{
...
@@ -40,7 +41,8 @@ var basicRegex = {
...
@@ -40,7 +41,8 @@ var basicRegex = {
var
basicFunctionTypes
=
{
var
basicFunctionTypes
=
{
SEND
:
buildFunctionSignature
([
basicTypes
.
UINT
],
[
basicTypes
.
BOOL
],
false
),
SEND
:
buildFunctionSignature
([
basicTypes
.
UINT
],
[
basicTypes
.
BOOL
],
false
),
CALL
:
buildFunctionSignature
([],
[
basicTypes
.
BOOL
],
true
),
CALL
:
buildFunctionSignature
([],
[
basicTypes
.
BOOL
],
true
),
DELEGATECALL
:
buildFunctionSignature
([],
[
basicTypes
.
BOOL
],
false
)
DELEGATECALL
:
buildFunctionSignature
([],
[
basicTypes
.
BOOL
],
false
),
TRANSFER
:
buildFunctionSignature
([
basicTypes
.
UINT
],
[],
false
)
}
}
var
builtinFunctions
=
{
var
builtinFunctions
=
{
...
@@ -60,7 +62,8 @@ var lowLevelCallTypes = {
...
@@ -60,7 +62,8 @@ var lowLevelCallTypes = {
CALL
:
{
ident
:
'call'
,
type
:
basicFunctionTypes
.
CALL
},
CALL
:
{
ident
:
'call'
,
type
:
basicFunctionTypes
.
CALL
},
CALLCODE
:
{
ident
:
'callcode'
,
type
:
basicFunctionTypes
.
CALL
},
CALLCODE
:
{
ident
:
'callcode'
,
type
:
basicFunctionTypes
.
CALL
},
DELEGATECALL
:
{
ident
:
'delegatecall'
,
type
:
basicFunctionTypes
.
DELEGATECALL
},
DELEGATECALL
:
{
ident
:
'delegatecall'
,
type
:
basicFunctionTypes
.
DELEGATECALL
},
SEND
:
{
ident
:
'send'
,
type
:
basicFunctionTypes
.
SEND
}
SEND
:
{
ident
:
'send'
,
type
:
basicFunctionTypes
.
SEND
},
TRANSFER
:
{
ident
:
'transfer'
,
type
:
basicFunctionTypes
.
TRANSFER
}
}
}
var
specialVariables
=
{
var
specialVariables
=
{
...
@@ -351,6 +354,10 @@ function isInlineAssembly (node) {
...
@@ -351,6 +354,10 @@ function isInlineAssembly (node) {
return
nodeType
(
node
,
exactMatch
(
nodeTypes
.
INLINEASSEMBLY
))
return
nodeType
(
node
,
exactMatch
(
nodeTypes
.
INLINEASSEMBLY
))
}
}
function
isNewExpression
(
node
)
{
return
nodeType
(
node
,
exactMatch
(
nodeTypes
.
NEWEXPRESSION
))
}
// #################### Complex Node Identification
// #################### Complex Node Identification
/**
/**
...
@@ -616,6 +623,17 @@ function isLLDelegatecall (node) {
...
@@ -616,6 +623,17 @@ function isLLDelegatecall (node) {
undefined
,
exactMatch
(
basicTypes
.
ADDRESS
),
exactMatch
(
lowLevelCallTypes
.
DELEGATECALL
.
ident
))
undefined
,
exactMatch
(
basicTypes
.
ADDRESS
),
exactMatch
(
lowLevelCallTypes
.
DELEGATECALL
.
ident
))
}
}
/**
* True if transfer call
* @node {ASTNode} some AstNode
* @return {bool}
*/
function
isTransfer
(
node
)
{
return
isMemberAccess
(
node
,
exactMatch
(
utils
.
escapeRegExp
(
lowLevelCallTypes
.
TRANSFER
.
type
)),
undefined
,
exactMatch
(
basicTypes
.
ADDRESS
),
exactMatch
(
lowLevelCallTypes
.
TRANSFER
.
ident
))
}
// #################### Complex Node Identification - Private
// #################### Complex Node Identification - Private
function
isMemberAccess
(
node
,
retType
,
accessor
,
accessorType
,
memberName
)
{
function
isMemberAccess
(
node
,
retType
,
accessor
,
accessorType
,
memberName
)
{
...
@@ -733,6 +751,7 @@ module.exports = {
...
@@ -733,6 +751,7 @@ module.exports = {
isLocalCall
:
isLocalCall
,
isLocalCall
:
isLocalCall
,
isWriteOnStateVariable
:
isWriteOnStateVariable
,
isWriteOnStateVariable
:
isWriteOnStateVariable
,
isStateVariable
:
isStateVariable
,
isStateVariable
:
isStateVariable
,
isTransfer
:
isTransfer
,
isLowLevelCall
:
isLowLevelCall
,
isLowLevelCall
:
isLowLevelCall
,
isLowLevelCallInst
:
isLLCall
,
isLowLevelCallInst
:
isLLCall
,
isLowLevelCallcodeInst
:
isLLCallcode
,
isLowLevelCallcodeInst
:
isLLCallcode
,
...
@@ -757,6 +776,7 @@ module.exports = {
...
@@ -757,6 +776,7 @@ module.exports = {
isContractDefinition
:
isContractDefinition
,
isContractDefinition
:
isContractDefinition
,
isConstantFunction
:
isConstantFunction
,
isConstantFunction
:
isConstantFunction
,
isInlineAssembly
:
isInlineAssembly
,
isInlineAssembly
:
isInlineAssembly
,
isNewExpression
:
isNewExpression
,
// #################### Constants
// #################### Constants
nodeTypes
:
nodeTypes
,
nodeTypes
:
nodeTypes
,
...
...
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