Commit 52000695 authored by aniket-engg's avatar aniket-engg Committed by Aniket

20 contract integration tests updated

parent 2fce136c
......@@ -5,7 +5,7 @@ import { AnalyzerModule, ModuleAlgorithm, ModuleCategory, ReportObj, Compilation
export default class blockBlockhash implements AnalyzerModule {
warningNodes: FunctionCallAstNode[] = []
name: string = 'Block.blockhash usage: '
name: string = 'Blockhash usage: '
description: string = 'Semantics maybe unclear'
category: ModuleCategory = category.SECURITY
algorithm: ModuleAlgorithm = algorithm.EXACT
......@@ -17,7 +17,7 @@ export default class blockBlockhash implements AnalyzerModule {
report (compilationResults: CompilationResult): ReportObj[] {
return this.warningNodes.map((item, i) => {
return {
warning: `use of "block.blockhash": "block.blockhash" is used to access the last 256 block hashes.
warning: `use of "blockhash": "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.
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.`,
......
......@@ -78,7 +78,7 @@ export default class checksEffectsInteraction implements AnalyzerModule {
private isLocalCallWithStateChange (node: FunctionCallAstNode, context: Context): boolean {
if (isLocalCallGraphRelevantNode(node)) {
const func = resolveCallGraphSymbol(context.callGraph, getFullQualifiedFunctionCallIdent(context.currentContract.node, node))
return !func || (func && func['changesState'])
return !func || (func && func.node['changesState'])
}
return false
}
......
import { default as category } from './categories'
import { default as algorithm } from './algorithmCategories'
import { isTransfer } from './staticAnalysisCommon'
import { isLoop, isTransfer } from './staticAnalysisCommon'
import { AnalyzerModule, ModuleAlgorithm, ModuleCategory, ReportObj, CompilationResult, ForStatementAstNode, WhileStatementAstNode, CommonAstNode, ExpressionStatementAstNode} from './../../types'
export default class etherTransferInLoop implements AnalyzerModule {
......@@ -12,14 +12,16 @@ export default class etherTransferInLoop implements AnalyzerModule {
visit (node: ForStatementAstNode | WhileStatementAstNode): void {
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' &&
child.expression.nodeType === 'FunctionCall' && isTransfer(child.expression.expression)))
// 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))
transferNodes.push(node.body)
if (transferNodes.length > 0) {
this.relevantNodes.push(...transferNodes)
// 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))
transferNodes.push(node.body)
if (transferNodes.length > 0) {
this.relevantNodes.push(...transferNodes)
}
}
}
......
......@@ -13,7 +13,7 @@ export default class selfdestruct implements AnalyzerModule {
abstractAst: AbstractAst = new AbstractAst()
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))
......
......@@ -438,7 +438,7 @@ function getFullQualifiedFunctionCallIdent (contract: ContractDefinitionAstNode,
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 (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')
}
......@@ -995,11 +995,11 @@ function isBytesLengthCheck (node: MemberAccessAstNode): boolean {
* @node {ASTNode} some AstNode
* @return {bool}
*/
// function isLoop (node) {
// return nodeType(node, exactMatch(nodeTypes.FORSTATEMENT)) ||
// nodeType(node, exactMatch(nodeTypes.WHILESTATEMENT)) ||
// nodeType(node, exactMatch(nodeTypes.DOWHILESTATEMENT))
// }
function isLoop (node) {
return nodeType(node, exactMatch(nodeTypes.FORSTATEMENT)) ||
nodeType(node, exactMatch(nodeTypes.WHILESTATEMENT)) ||
nodeType(node, exactMatch(nodeTypes.DOWHILESTATEMENT))
}
/**
* True if it is a 'for' loop
......@@ -1202,7 +1202,7 @@ export {
isIntDivision,
isStringToBytesConversion,
isBytesLengthCheck,
// isForLoop,
isLoop,
// #################### Trivial Node Identification
isDeleteUnaryOperation,
......
pragma solidity >=0.4.9 <0.7.0;
pragma solidity >=0.4.9 <0.6.0;
library Set {
// We define a new struct datatype that will be used to
......@@ -51,8 +51,5 @@ contract C {
revert();
}
function testt() public view returns (uint) {
return block.timestamp;
}
// In this contract, we can also directly access knownValues.flags, if we want.
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment