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
52000695
Commit
52000695
authored
Mar 16, 2020
by
aniket-engg
Committed by
Aniket
Mar 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
20 contract integration tests updated
parent
2fce136c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
21 additions
and
23 deletions
+21
-23
blockBlockhash.ts
...-analyzer/src/solidity-analyzer/modules/blockBlockhash.ts
+2
-2
checksEffectsInteraction.ts
...src/solidity-analyzer/modules/checksEffectsInteraction.ts
+1
-1
etherTransferInLoop.ts
...yzer/src/solidity-analyzer/modules/etherTransferInLoop.ts
+9
-7
selfdestruct.ts
remix-analyzer/src/solidity-analyzer/modules/selfdestruct.ts
+1
-1
staticAnalysisCommon.ts
...zer/src/solidity-analyzer/modules/staticAnalysisCommon.ts
+7
-7
staticAnalysisIntegration-test-0.5.0.ts
...zer/test/analysis/staticAnalysisIntegration-test-0.5.0.ts
+0
-0
library.sol
...er/test/analysis/test-contracts/solidity-v0.5/library.sol
+1
-5
No files found.
remix-analyzer/src/solidity-analyzer/modules/blockBlockhash.ts
View file @
52000695
...
@@ -5,7 +5,7 @@ import { AnalyzerModule, ModuleAlgorithm, ModuleCategory, ReportObj, Compilation
...
@@ -5,7 +5,7 @@ import { AnalyzerModule, ModuleAlgorithm, ModuleCategory, ReportObj, Compilation
export
default
class
blockBlockhash
implements
AnalyzerModule
{
export
default
class
blockBlockhash
implements
AnalyzerModule
{
warningNodes
:
FunctionCallAstNode
[]
=
[]
warningNodes
:
FunctionCallAstNode
[]
=
[]
name
:
string
=
'Block
.block
hash usage: '
name
:
string
=
'Blockhash usage: '
description
:
string
=
'Semantics maybe unclear'
description
:
string
=
'Semantics maybe unclear'
category
:
ModuleCategory
=
category
.
SECURITY
category
:
ModuleCategory
=
category
.
SECURITY
algorithm
:
ModuleAlgorithm
=
algorithm
.
EXACT
algorithm
:
ModuleAlgorithm
=
algorithm
.
EXACT
...
@@ -17,7 +17,7 @@ export default class blockBlockhash implements AnalyzerModule {
...
@@ -17,7 +17,7 @@ export default class blockBlockhash implements AnalyzerModule {
report
(
compilationResults
:
CompilationResult
):
ReportObj
[]
{
report
(
compilationResults
:
CompilationResult
):
ReportObj
[]
{
return
this
.
warningNodes
.
map
((
item
,
i
)
=>
{
return
this
.
warningNodes
.
map
((
item
,
i
)
=>
{
return
{
return
{
warning
:
`use of "block
.blockhash": "block.
blockhash" is used to access the last 256 block hashes.
warning
:
`use of "block
hash": "
blockhash" is used to access the last 256 block hashes.
A miner computes the block hash by "summing up" the information in the current block mined.
A miner computes the block hash by "summing up" the information in the current block mined.
By "summing up" the information in a clever way a miner can try to influence the outcome of a transaction in the current block.
By "summing up" the information in a clever way a miner can try to influence the outcome of a transaction in the current block.
This is especially easy if there are only a small number of equally likely outcomes.`
,
This is especially easy if there are only a small number of equally likely outcomes.`
,
...
...
remix-analyzer/src/solidity-analyzer/modules/checksEffectsInteraction.ts
View file @
52000695
...
@@ -78,7 +78,7 @@ export default class checksEffectsInteraction implements AnalyzerModule {
...
@@ -78,7 +78,7 @@ export default class checksEffectsInteraction implements AnalyzerModule {
private
isLocalCallWithStateChange
(
node
:
FunctionCallAstNode
,
context
:
Context
):
boolean
{
private
isLocalCallWithStateChange
(
node
:
FunctionCallAstNode
,
context
:
Context
):
boolean
{
if
(
isLocalCallGraphRelevantNode
(
node
))
{
if
(
isLocalCallGraphRelevantNode
(
node
))
{
const
func
=
resolveCallGraphSymbol
(
context
.
callGraph
,
getFullQualifiedFunctionCallIdent
(
context
.
currentContract
.
node
,
node
))
const
func
=
resolveCallGraphSymbol
(
context
.
callGraph
,
getFullQualifiedFunctionCallIdent
(
context
.
currentContract
.
node
,
node
))
return
!
func
||
(
func
&&
func
[
'changesState'
])
return
!
func
||
(
func
&&
func
.
node
[
'changesState'
])
}
}
return
false
return
false
}
}
...
...
remix-analyzer/src/solidity-analyzer/modules/etherTransferInLoop.ts
View file @
52000695
import
{
default
as
category
}
from
'./categories'
import
{
default
as
category
}
from
'./categories'
import
{
default
as
algorithm
}
from
'./algorithmCategories'
import
{
default
as
algorithm
}
from
'./algorithmCategories'
import
{
isTransfer
}
from
'./staticAnalysisCommon'
import
{
is
Loop
,
is
Transfer
}
from
'./staticAnalysisCommon'
import
{
AnalyzerModule
,
ModuleAlgorithm
,
ModuleCategory
,
ReportObj
,
CompilationResult
,
ForStatementAstNode
,
WhileStatementAstNode
,
CommonAstNode
,
ExpressionStatementAstNode
}
from
'./../../types'
import
{
AnalyzerModule
,
ModuleAlgorithm
,
ModuleCategory
,
ReportObj
,
CompilationResult
,
ForStatementAstNode
,
WhileStatementAstNode
,
CommonAstNode
,
ExpressionStatementAstNode
}
from
'./../../types'
export
default
class
etherTransferInLoop
implements
AnalyzerModule
{
export
default
class
etherTransferInLoop
implements
AnalyzerModule
{
...
@@ -12,14 +12,16 @@ export default class etherTransferInLoop implements AnalyzerModule {
...
@@ -12,14 +12,16 @@ export default class etherTransferInLoop implements AnalyzerModule {
visit
(
node
:
ForStatementAstNode
|
WhileStatementAstNode
):
void
{
visit
(
node
:
ForStatementAstNode
|
WhileStatementAstNode
):
void
{
let
transferNodes
:
ExpressionStatementAstNode
[]
=
[]
let
transferNodes
:
ExpressionStatementAstNode
[]
=
[]
if
(
node
.
body
&&
node
.
body
.
nodeType
===
'Block'
)
if
(
isLoop
(
node
))
{
if
(
node
.
body
&&
node
.
body
.
nodeType
===
'Block'
)
transferNodes
=
node
.
body
.
statements
.
filter
(
child
=>
(
child
.
nodeType
===
'ExpressionStatement'
&&
transferNodes
=
node
.
body
.
statements
.
filter
(
child
=>
(
child
.
nodeType
===
'ExpressionStatement'
&&
child
.
expression
.
nodeType
===
'FunctionCall'
&&
isTransfer
(
child
.
expression
.
expression
)))
child
.
expression
.
nodeType
===
'FunctionCall'
&&
isTransfer
(
child
.
expression
.
expression
)))
// When loop body is described without braces
// When loop body is described without braces
else
if
(
node
.
body
&&
node
.
body
.
nodeType
===
'ExpressionStatement'
&&
node
.
body
.
expression
.
nodeType
===
'FunctionCall'
&&
isTransfer
(
node
.
body
.
expression
.
expression
))
else
if
(
node
.
body
&&
node
.
body
.
nodeType
===
'ExpressionStatement'
&&
node
.
body
.
expression
.
nodeType
===
'FunctionCall'
&&
isTransfer
(
node
.
body
.
expression
.
expression
))
transferNodes
.
push
(
node
.
body
)
transferNodes
.
push
(
node
.
body
)
if
(
transferNodes
.
length
>
0
)
{
if
(
transferNodes
.
length
>
0
)
{
this
.
relevantNodes
.
push
(...
transferNodes
)
this
.
relevantNodes
.
push
(...
transferNodes
)
}
}
}
}
}
...
...
remix-analyzer/src/solidity-analyzer/modules/selfdestruct.ts
View file @
52000695
...
@@ -13,7 +13,7 @@ export default class selfdestruct implements AnalyzerModule {
...
@@ -13,7 +13,7 @@ export default class selfdestruct implements AnalyzerModule {
abstractAst
:
AbstractAst
=
new
AbstractAst
()
abstractAst
:
AbstractAst
=
new
AbstractAst
()
visit
:
Function
=
this
.
abstractAst
.
build_visit
(
visit
:
Function
=
this
.
abstractAst
.
build_visit
(
(
node
:
any
)
=>
isStatement
(
node
)
||
(
node
.
nodeType
===
'FunctionCall'
&&
isSelfdestructCall
(
node
.
expression
)
)
(
node
:
any
)
=>
isStatement
(
node
)
||
(
node
.
nodeType
===
'FunctionCall'
&&
isSelfdestructCall
(
node
)
)
)
)
report
:
Function
=
this
.
abstractAst
.
build_report
(
this
.
_report
.
bind
(
this
))
report
:
Function
=
this
.
abstractAst
.
build_report
(
this
.
_report
.
bind
(
this
))
...
...
remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.ts
View file @
52000695
...
@@ -438,7 +438,7 @@ function getFullQualifiedFunctionCallIdent (contract: ContractDefinitionAstNode,
...
@@ -438,7 +438,7 @@ function getFullQualifiedFunctionCallIdent (contract: ContractDefinitionAstNode,
else
if
(
isThisLocalCall
(
func
.
expression
))
return
getThisLocalCallContractName
(
func
)
+
'.'
+
getThisLocalCallName
(
func
)
+
'('
+
getFunctionCallTypeParameterType
(
func
)
+
')'
else
if
(
isThisLocalCall
(
func
.
expression
))
return
getThisLocalCallContractName
(
func
)
+
'.'
+
getThisLocalCallName
(
func
)
+
'('
+
getFunctionCallTypeParameterType
(
func
)
+
')'
else
if
(
isSuperLocalCall
(
func
.
expression
))
return
getContractName
(
contract
)
+
'.'
+
getSuperLocalCallName
(
func
)
+
'('
+
getFunctionCallTypeParameterType
(
func
)
+
')'
else
if
(
isSuperLocalCall
(
func
.
expression
))
return
getContractName
(
contract
)
+
'.'
+
getSuperLocalCallName
(
func
)
+
'('
+
getFunctionCallTypeParameterType
(
func
)
+
')'
else
if
(
isExternalDirectCall
(
func
))
return
getExternalDirectCallContractName
(
func
)
+
'.'
+
getExternalDirectCallMemberName
(
func
)
+
'('
+
getFunctionCallTypeParameterType
(
func
)
+
')'
else
if
(
isExternalDirectCall
(
func
))
return
getExternalDirectCallContractName
(
func
)
+
'.'
+
getExternalDirectCallMemberName
(
func
)
+
'('
+
getFunctionCallTypeParameterType
(
func
)
+
')'
else
if
(
isLibraryCall
(
func
.
expression
))
return
getLibraryCallContractName
(
func
.
expression
)
+
'.'
+
getLibraryCallMemberName
(
func
)
+
'('
+
getFunctionCallTypeParameterType
(
func
)
+
')'
else
if
(
isLibraryCall
(
func
.
expression
))
return
getLibraryCallContractName
(
func
)
+
'.'
+
getLibraryCallMemberName
(
func
)
+
'('
+
getFunctionCallTypeParameterType
(
func
)
+
')'
else
throw
new
Error
(
'staticAnalysisCommon.js: Can not get function name from non function call node'
)
else
throw
new
Error
(
'staticAnalysisCommon.js: Can not get function name from non function call node'
)
}
}
...
@@ -995,11 +995,11 @@ function isBytesLengthCheck (node: MemberAccessAstNode): boolean {
...
@@ -995,11 +995,11 @@ function isBytesLengthCheck (node: MemberAccessAstNode): boolean {
* @node {ASTNode} some AstNode
* @node {ASTNode} some AstNode
* @return {bool}
* @return {bool}
*/
*/
//
function isLoop (node) {
function
isLoop
(
node
)
{
//
return nodeType(node, exactMatch(nodeTypes.FORSTATEMENT)) ||
return
nodeType
(
node
,
exactMatch
(
nodeTypes
.
FORSTATEMENT
))
||
//
nodeType(node, exactMatch(nodeTypes.WHILESTATEMENT)) ||
nodeType
(
node
,
exactMatch
(
nodeTypes
.
WHILESTATEMENT
))
||
//
nodeType(node, exactMatch(nodeTypes.DOWHILESTATEMENT))
nodeType
(
node
,
exactMatch
(
nodeTypes
.
DOWHILESTATEMENT
))
//
}
}
/**
/**
* True if it is a 'for' loop
* True if it is a 'for' loop
...
@@ -1202,7 +1202,7 @@ export {
...
@@ -1202,7 +1202,7 @@ export {
isIntDivision
,
isIntDivision
,
isStringToBytesConversion
,
isStringToBytesConversion
,
isBytesLengthCheck
,
isBytesLengthCheck
,
// isFor
Loop,
is
Loop
,
// #################### Trivial Node Identification
// #################### Trivial Node Identification
isDeleteUnaryOperation
,
isDeleteUnaryOperation
,
...
...
remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.5.0.ts
View file @
52000695
This diff is collapsed.
Click to expand it.
remix-analyzer/test/analysis/test-contracts/solidity-v0.5/library.sol
View file @
52000695
pragma solidity >=0.4.9 <0.
7
.0;
pragma solidity >=0.4.9 <0.
6
.0;
library Set {
library Set {
// We define a new struct datatype that will be used to
// We define a new struct datatype that will be used to
...
@@ -51,8 +51,5 @@ contract C {
...
@@ -51,8 +51,5 @@ contract C {
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