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
48352e01
Commit
48352e01
authored
Jun 10, 2018
by
Paulius
Committed by
yann300
Sep 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Static analysis: Add module for deletion from dynamic array
parent
20eae79a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
1 deletion
+51
-1
list.js
remix-analyzer/src/solidity-analyzer/modules/list.js
+2
-1
staticAnalysisCommon.js
...zer/src/solidity-analyzer/modules/staticAnalysisCommon.js
+20
-0
deleteFromDynamicArray.js
...x-solidity/src/analysis/modules/deleteFromDynamicArray.js
+29
-0
No files found.
remix-analyzer/src/solidity-analyzer/modules/list.js
View file @
48352e01
...
@@ -15,5 +15,6 @@ module.exports = [
...
@@ -15,5 +15,6 @@ module.exports = [
require
(
'./deleteDynamicArrays'
),
require
(
'./deleteDynamicArrays'
),
require
(
'./assignAndCompare'
),
require
(
'./assignAndCompare'
),
require
(
'./erc20Decimals'
),
require
(
'./erc20Decimals'
),
require
(
'./stringBytesLength'
)
require
(
'./stringBytesLength'
),
require
(
'./deleteFromDynamicArray'
)
]
]
remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js
View file @
48352e01
...
@@ -502,6 +502,24 @@ function isDynamicArrayAccess (node) {
...
@@ -502,6 +502,24 @@ function isDynamicArrayAccess (node) {
}
}
/**
/**
* True if node is a delete instruction for an element from a dynamic array
* @node {ASTNode} node to check for
* @return {bool}
*/
function
isDeleteFromDynamicArray
(
node
)
{
return
isDeleteUnaryOperation
(
node
)
&&
isIndexAccess
(
node
.
children
[
0
])
}
/**
* True if node is the access of an index
* @node {ASTNode} node to check for
* @return {bool}
*/
function
isIndexAccess
(
node
)
{
return
node
&&
node
.
name
===
'IndexAccess'
}
/**
* True if call to code within the current contracts context including (delegate) library call
* True if call to code within the current contracts context including (delegate) library call
* @node {ASTNode} some AstNode
* @node {ASTNode} some AstNode
* @return {bool}
* @return {bool}
...
@@ -999,9 +1017,11 @@ module.exports = {
...
@@ -999,9 +1017,11 @@ module.exports = {
// #################### Complex Node Identification
// #################### Complex Node Identification
isDeleteOfDynamicArray
:
isDeleteOfDynamicArray
,
isDeleteOfDynamicArray
:
isDeleteOfDynamicArray
,
isDeleteFromDynamicArray
:
isDeleteFromDynamicArray
,
isAbiNamespaceCall
:
isAbiNamespaceCall
,
isAbiNamespaceCall
:
isAbiNamespaceCall
,
isSpecialVariableAccess
:
isSpecialVariableAccess
,
isSpecialVariableAccess
:
isSpecialVariableAccess
,
isDynamicArrayAccess
:
isDynamicArrayAccess
,
isDynamicArrayAccess
:
isDynamicArrayAccess
,
isIndexAccess
:
isIndexAccess
,
isSubScopeWithTopLevelUnAssignedBinOp
:
isSubScopeWithTopLevelUnAssignedBinOp
,
isSubScopeWithTopLevelUnAssignedBinOp
:
isSubScopeWithTopLevelUnAssignedBinOp
,
hasFunctionBody
:
hasFunctionBody
,
hasFunctionBody
:
hasFunctionBody
,
isInteraction
:
isInteraction
,
isInteraction
:
isInteraction
,
...
...
remix-solidity/src/analysis/modules/deleteFromDynamicArray.js
0 → 100644
View file @
48352e01
var
name
=
'Delete from dynamic Array: '
var
desc
=
'Using delete on an array leaves a gap'
var
categories
=
require
(
'./categories'
)
var
common
=
require
(
'./staticAnalysisCommon'
)
function
deleteFromDynamicArray
()
{
this
.
relevantNodes
=
[]
}
deleteFromDynamicArray
.
prototype
.
visit
=
function
(
node
)
{
if
(
common
.
isDeleteFromDynamicArray
(
node
))
this
.
relevantNodes
.
push
(
node
)
}
deleteFromDynamicArray
.
prototype
.
report
=
function
(
compilationResults
)
{
return
this
.
relevantNodes
.
map
((
node
)
=>
{
return
{
warning
:
'Using delete on an array leaves a gap. The length of the array remains the same. If you want to remove the empty position you need to shift items manually and update the length property.
\
n'
,
location
:
node
.
src
,
more
:
'https://github.com/miguelmota/solidity-idiosyncrasies'
}
})
}
module
.
exports
=
{
name
:
name
,
description
:
desc
,
category
:
categories
.
MISC
,
Module
:
deleteFromDynamicArray
}
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