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
04dccc92
Commit
04dccc92
authored
Feb 26, 2020
by
aniket-engg
Committed by
Aniket
Mar 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
method updates
parent
e9ac30cb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
31 additions
and
41 deletions
+31
-41
abstractAstView.ts
...analyzer/src/solidity-analyzer/modules/abstractAstView.ts
+3
-3
constantFunctions.ts
...alyzer/src/solidity-analyzer/modules/constantFunctions.ts
+1
-1
deleteDynamicArrays.ts
...yzer/src/solidity-analyzer/modules/deleteDynamicArrays.ts
+3
-3
forLoopIteratesOverDynamicArray.ts
...idity-analyzer/modules/forLoopIteratesOverDynamicArray.ts
+9
-17
intDivisionTruncate.ts
...yzer/src/solidity-analyzer/modules/intDivisionTruncate.ts
+3
-3
lowLevelCalls.ts
...x-analyzer/src/solidity-analyzer/modules/lowLevelCalls.ts
+3
-3
staticAnalysisCommon.ts
...zer/src/solidity-analyzer/modules/staticAnalysisCommon.ts
+0
-0
thisLocal.ts
remix-analyzer/src/solidity-analyzer/modules/thisLocal.ts
+3
-3
types.ts
remix-analyzer/src/types.ts
+6
-8
No files found.
remix-analyzer/src/solidity-analyzer/modules/abstractAstView.ts
View file @
04dccc92
...
...
@@ -3,7 +3,7 @@ import { getStateVariableDeclarationsFormContractNode,
getFunctionOrModifierDefinitionParameterPart
,
getType
,
getDeclaredVariableName
,
getFunctionDefinitionReturnParameterPart
}
from
'./staticAnalysisCommon'
import
{
AstWalker
}
from
'remix-astwalker'
import
{
CommonAstNode
,
FunctionDefinitionAstNode
,
ParameterListAstNode
}
from
'types'
import
{
CommonAstNode
,
FunctionDefinitionAstNode
,
ParameterListAstNode
,
ModifierDefinitionAstNode
}
from
'types'
export
default
class
abstractAstView
{
contracts
=
[]
...
...
@@ -159,11 +159,11 @@ export default class abstractAstView {
return
that
.
getCurrentContract
(
that
).
modifiers
[
that
.
currentModifierIndex
]
}
private
getLocalParameters
(
funcNode
)
{
private
getLocalParameters
(
funcNode
:
FunctionDefinitionAstNode
|
ModifierDefinitionAstNode
)
{
return
getFunctionOrModifierDefinitionParameterPart
(
funcNode
).
parameters
.
map
(
getType
)
}
private
getReturnParameters
(
funcNode
)
{
private
getReturnParameters
(
funcNode
:
FunctionDefinitionAstNode
)
{
return
this
.
getLocalVariables
(
getFunctionDefinitionReturnParameterPart
(
funcNode
)).
map
((
n
)
=>
{
return
{
type
:
getType
(
n
),
...
...
remix-analyzer/src/solidity-analyzer/modules/constantFunctions.ts
View file @
04dccc92
...
...
@@ -17,7 +17,7 @@ export default class constantFunctions implements AnalyzerModule {
abstractAst
:
AbstractAst
=
new
AbstractAst
()
visit
=
this
.
abstractAst
.
build_visit
(
(
node
:
CommonAstNode
)
=>
isLowLevelCall
(
node
)
||
(
node
:
any
)
=>
isLowLevelCall
(
node
)
||
isTransfer
(
node
)
||
isExternalDirectCall
(
node
)
||
isEffect
(
node
)
||
...
...
remix-analyzer/src/solidity-analyzer/modules/deleteDynamicArrays.ts
View file @
04dccc92
import
{
default
as
category
}
from
'./categories'
import
{
isDeleteOfDynamicArray
}
from
'./staticAnalysisCommon'
import
{
default
as
algorithm
}
from
'./algorithmCategories'
import
{
AnalyzerModule
,
ModuleAlgorithm
,
ModuleCategory
,
ReportObj
,
AstNodeLegacy
,
CompilationResult
}
from
'./../../types'
import
{
AnalyzerModule
,
ModuleAlgorithm
,
ModuleCategory
,
ReportObj
,
CompilationResult
,
UnaryOperationAstNode
}
from
'./../../types'
export
default
class
deleteDynamicArrays
implements
AnalyzerModule
{
rel
:
AstNodeLegacy
[]
=
[]
rel
:
UnaryOperationAstNode
[]
=
[]
name
:
string
=
'Delete on dynamic Array: '
description
:
string
=
'Use require and appropriately'
category
:
ModuleCategory
=
category
.
GAS
algorithm
:
ModuleAlgorithm
=
algorithm
.
EXACT
visit
(
node
:
AstNodeLegacy
):
void
{
visit
(
node
:
UnaryOperationAstNode
):
void
{
if
(
isDeleteOfDynamicArray
(
node
))
this
.
rel
.
push
(
node
)
}
...
...
remix-analyzer/src/solidity-analyzer/modules/forLoopIteratesOverDynamicArray.ts
View file @
04dccc92
import
{
default
as
category
}
from
'./categories'
import
{
default
as
algorithm
}
from
'./algorithmCategories'
import
{
is
ForLoop
,
isDynamicArrayLengthAccess
,
isBinaryOperation
}
from
'./staticAnalysisCommon'
import
{
AnalyzerModule
,
ModuleAlgorithm
,
ModuleCategory
,
ReportObj
,
AstNodeLegacy
,
CompilationResult
,
Common
AstNode
}
from
'./../../types'
import
{
is
DynamicArrayLengthAccess
}
from
'./staticAnalysisCommon'
import
{
AnalyzerModule
,
ModuleAlgorithm
,
ModuleCategory
,
ReportObj
,
CompilationResult
,
ForStatement
AstNode
}
from
'./../../types'
export
default
class
forLoopIteratesOverDynamicArray
implements
AnalyzerModule
{
relevantNodes
:
Common
AstNode
[]
=
[]
relevantNodes
:
ForStatement
AstNode
[]
=
[]
name
:
string
=
'For loop iterates over dynamic array: '
description
:
string
=
'The number of
\'
for
\'
loop iterations depends on dynamic array
\'
s size'
category
:
ModuleCategory
=
category
.
GAS
algorithm
:
ModuleAlgorithm
=
algorithm
.
EXACT
visit
(
node
:
CommonAstNode
):
void
{
if
(
node
.
nodeType
===
"Forstatement"
&&
node
.
children
)
{
let
conditionChildrenNode
:
AstNodeLegacy
|
null
=
null
// Access 'condition' node of 'for' loop statement
const
forLoopConditionNode
:
AstNodeLegacy
=
node
.
children
[
1
]
// Access right side of condition as its children
if
(
forLoopConditionNode
&&
forLoopConditionNode
.
children
){
conditionChildrenNode
=
forLoopConditionNode
.
children
[
1
]
}
// Check if it is a binary operation. if yes, check if its children node access length of dynamic array
if
(
conditionChildrenNode
&&
conditionChildrenNode
.
children
&&
isBinaryOperation
(
conditionChildrenNode
)
&&
isDynamicArrayLengthAccess
(
conditionChildrenNode
.
children
[
0
]))
{
this
.
relevantNodes
.
push
(
node
)
}
else
if
(
isDynamicArrayLengthAccess
(
conditionChildrenNode
))
{
// else check if condition node itself access length of dynamic array
visit
(
node
:
ForStatementAstNode
):
void
{
const
{
condition
}
=
node
// Check if condition is `i < array.length - 1`
if
((
condition
.
nodeType
===
"BinaryOperation"
&&
condition
.
rightExpression
.
nodeType
===
"BinaryOperation"
&&
isDynamicArrayLengthAccess
(
condition
.
rightExpression
.
leftExpression
))
||
// or condition is `i < array.length`
(
condition
.
nodeType
===
"BinaryOperation"
&&
isDynamicArrayLengthAccess
(
condition
.
rightExpression
)))
{
this
.
relevantNodes
.
push
(
node
)
}
}
}
report
(
compilationResults
:
CompilationResult
):
ReportObj
[]
{
...
...
remix-analyzer/src/solidity-analyzer/modules/intDivisionTruncate.ts
View file @
04dccc92
import
{
default
as
category
}
from
'./categories'
import
{
isIntDivision
}
from
'./staticAnalysisCommon'
import
{
default
as
algorithm
}
from
'./algorithmCategories'
import
{
AnalyzerModule
,
ModuleAlgorithm
,
ModuleCategory
,
ReportObj
,
AstNodeLegacy
,
CompilationResult
}
from
'./../../types'
import
{
AnalyzerModule
,
ModuleAlgorithm
,
ModuleCategory
,
ReportObj
,
CompilationResult
,
BinaryOperationAstNode
}
from
'./../../types'
export
default
class
intDivisionTruncate
implements
AnalyzerModule
{
warningNodes
:
AstNodeLegacy
[]
=
[]
warningNodes
:
BinaryOperationAstNode
[]
=
[]
name
:
string
=
'Data Truncated: '
description
:
string
=
'Division on int/uint values truncates the result.'
category
:
ModuleCategory
=
category
.
MISC
algorithm
:
ModuleAlgorithm
=
algorithm
.
EXACT
visit
(
node
:
AstNodeLegacy
):
void
{
visit
(
node
:
BinaryOperationAstNode
):
void
{
if
(
isIntDivision
(
node
))
this
.
warningNodes
.
push
(
node
)
}
...
...
remix-analyzer/src/solidity-analyzer/modules/lowLevelCalls.ts
View file @
04dccc92
...
...
@@ -2,10 +2,10 @@ import { default as category } from './categories'
import
{
isLowLevelCallInst
,
isLowLevelCallInst050
,
isLowLevelCallcodeInst
,
isLowLevelDelegatecallInst
,
isLowLevelSendInst
,
isLowLevelSendInst050
,
isLLDelegatecallInst050
,
lowLevelCallTypes
}
from
'./staticAnalysisCommon'
import
{
default
as
algorithm
}
from
'./algorithmCategories'
import
{
AnalyzerModule
,
ModuleAlgorithm
,
ModuleCategory
,
ReportObj
,
AstNodeLegacy
,
CompilationResult
}
from
'./../../types'
import
{
AnalyzerModule
,
ModuleAlgorithm
,
ModuleCategory
,
ReportObj
,
CompilationResult
,
MemberAccessAstNode
}
from
'./../../types'
interface
llcNode
{
node
:
AstNodeLegacy
node
:
MemberAccessAstNode
type
:
{
ident
:
string
,
type
:
string
...
...
@@ -19,7 +19,7 @@ export default class lowLevelCalls implements AnalyzerModule {
category
:
ModuleCategory
=
category
.
SECURITY
algorithm
:
ModuleAlgorithm
=
algorithm
.
EXACT
visit
(
node
:
AstNodeLegacy
):
void
{
visit
(
node
:
MemberAccessAstNode
):
void
{
if
(
isLowLevelCallInst
(
node
))
{
this
.
llcNodes
.
push
({
node
:
node
,
type
:
lowLevelCallTypes
.
CALL
})
}
else
if
(
isLowLevelCallInst050
(
node
))
{
...
...
remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.ts
View file @
04dccc92
This diff is collapsed.
Click to expand it.
remix-analyzer/src/solidity-analyzer/modules/thisLocal.ts
View file @
04dccc92
import
{
default
as
category
}
from
'./categories'
import
{
isThisLocalCall
}
from
'./staticAnalysisCommon'
import
{
default
as
algorithm
}
from
'./algorithmCategories'
import
{
AnalyzerModule
,
ModuleAlgorithm
,
ModuleCategory
,
ReportObj
,
AstNodeLegacy
,
CompilationResult
}
from
'./../../types'
import
{
AnalyzerModule
,
ModuleAlgorithm
,
ModuleCategory
,
ReportObj
,
AstNodeLegacy
,
CompilationResult
,
MemberAccessAstNode
}
from
'./../../types'
export
default
class
thisLocal
implements
AnalyzerModule
{
warningNodes
:
AstNodeLegacy
[]
=
[]
warningNodes
:
MemberAccessAstNode
[]
=
[]
name
:
string
=
'This on local calls: '
description
:
string
=
'Invocation of local functions via this'
category
:
ModuleCategory
=
category
.
GAS
algorithm
:
ModuleAlgorithm
=
algorithm
.
EXACT
visit
(
node
:
AstNodeLegacy
):
void
{
visit
(
node
:
MemberAccessAstNode
):
void
{
if
(
isThisLocalCall
(
node
))
this
.
warningNodes
.
push
(
node
)
}
...
...
remix-analyzer/src/types.ts
View file @
04dccc92
...
...
@@ -337,7 +337,7 @@ export interface WhileStatementAstNode {
id
:
number
nodeType
:
'WhileStatement'
|
'DoWhileStatement'
src
:
string
condition
:
object
condition
:
any
body
:
BlockAstNode
}
...
...
@@ -346,7 +346,7 @@ export interface ForStatementAstNode {
nodeType
:
'ForStatement'
src
:
string
initializationExpression
:
VariableDeclarationStatementAstNode
condition
:
object
condition
:
any
loopExpression
:
ExpressionStatementAstNode
body
:
BlockAstNode
}
...
...
@@ -397,7 +397,7 @@ export interface ExpressionStatementAstNode {
id
:
number
nodeType
:
'ExpressionStatement'
src
:
string
expression
:
object
expression
:
any
}
interface
ExpressionAttributes
{
...
...
@@ -441,7 +441,7 @@ export interface UnaryOperationAstNode extends ExpressionAttributes {
src
:
string
prefix
:
boolean
operator
:
string
subExpression
:
object
subExpression
:
any
}
export
interface
BinaryOperationAstNode
extends
ExpressionAttributes
{
...
...
@@ -458,7 +458,7 @@ export interface FunctionCallAstNode extends ExpressionAttributes {
id
:
number
nodeType
:
'FunctionCall'
src
:
string
expression
:
object
expression
:
any
names
:
Array
<
any
>
arguments
:
object
tryCall
:
boolean
...
...
@@ -481,10 +481,8 @@ export interface NewExpressionAstNode extends ExpressionAttributes {
typeName
:
UserDefinedTypeNameAstNode
|
ElementaryTypeNameAstNode
}
export
interface
MemberAccessAstNode
extends
ExpressionAttributes
{
id
:
number
export
interface
MemberAccessAstNode
extends
CommonAstNode
,
ExpressionAttributes
{
nodeType
:
'MemberAccess'
src
:
string
memberName
:
string
expression
:
object
referencedDeclaration
:
number
|
null
...
...
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