mirror of https://github.com/crytic/slither
parent
cfe987ef52
commit
ef32f484e0
@ -0,0 +1,67 @@ |
||||
JSON AST: |
||||
|
||||
|
||||
======= old_solc.sol ======= |
||||
{ |
||||
"attributes" : |
||||
{ |
||||
"absolutePath" : "old_solc.sol", |
||||
"exportedSymbols" : |
||||
{ |
||||
"Contract" : |
||||
[ |
||||
2 |
||||
] |
||||
} |
||||
}, |
||||
"children" : |
||||
[ |
||||
{ |
||||
"attributes" : |
||||
{ |
||||
"literals" : |
||||
[ |
||||
"solidity", |
||||
"0.4", |
||||
".21" |
||||
] |
||||
}, |
||||
"id" : 1, |
||||
"name" : "PragmaDirective", |
||||
"src" : "0:23:0" |
||||
}, |
||||
{ |
||||
"attributes" : |
||||
{ |
||||
"baseContracts" : |
||||
[ |
||||
null |
||||
], |
||||
"contractDependencies" : |
||||
[ |
||||
null |
||||
], |
||||
"contractKind" : "contract", |
||||
"documentation" : null, |
||||
"fullyImplemented" : true, |
||||
"linearizedBaseContracts" : |
||||
[ |
||||
2 |
||||
], |
||||
"name" : "Contract", |
||||
"nodes" : |
||||
[ |
||||
null |
||||
], |
||||
"scope" : 3 |
||||
}, |
||||
"id" : 2, |
||||
"name" : "ContractDefinition", |
||||
"src" : "25:21:0" |
||||
} |
||||
], |
||||
"id" : 3, |
||||
"name" : "SourceUnit", |
||||
"src" : "0:47:0" |
||||
} |
||||
======= old_solc.sol:Contract ======= |
@ -0,0 +1,36 @@ |
||||
""" |
||||
Check if an old version of solc is used |
||||
Solidity >= 0.4.23 should be used |
||||
""" |
||||
|
||||
from slither.detectors.abstractDetector import AbstractDetector |
||||
from slither.detectors.detectorClassification import DetectorClassification |
||||
|
||||
class OldSolc(AbstractDetector): |
||||
""" |
||||
Check if an old version of solc is used |
||||
""" |
||||
|
||||
ARGUMENT = 'solc-version' |
||||
HELP = 'an old version of Solidity used (<0.4.23)' |
||||
CLASSIFICATION = DetectorClassification.CODE_QUALITY |
||||
|
||||
|
||||
def detect(self): |
||||
""" |
||||
""" |
||||
|
||||
results = [] |
||||
pragma = self.slither.pragma_directives |
||||
pragma = [''.join(p[1:]) for p in pragma] |
||||
pragma = [p.replace('solidity','').replace('^','') for p in pragma] |
||||
pragma = list(set(pragma)) |
||||
old_pragma = [p for p in pragma if p not in ['0.4.23', '0.4.24']] |
||||
|
||||
if old_pragma: |
||||
info = "Old version of Solidity used in {}: {}".format(self.filename, old_pragma) |
||||
self.log(info) |
||||
|
||||
results.append({'vuln':'OldPragma', 'pragma': old_pragma}) |
||||
|
||||
return results |
Loading…
Reference in new issue