Merge pull request #387 from crytic/dev-pragma-filter-solidity

Pragma: detect if the directive is a solidity version
pull/390/head
Feist Josselin 5 years ago committed by GitHub
commit 642cdcf336
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      slither/core/declarations/pragma_directive.py
  2. 2
      slither/detectors/attributes/constant_pragma.py

@ -21,5 +21,11 @@ class Pragma(SourceMapping):
def name(self): def name(self):
return self.version return self.version
@property
def is_solidity_version(self):
if len(self._directive) > 0:
return self._directive[0].lower() == 'solidity'
return False
def __str__(self): def __str__(self):
return 'pragma '+''.join(self.directive) return 'pragma '+''.join(self.directive)

@ -26,7 +26,7 @@ class ConstantPragma(AbstractDetector):
def _detect(self): def _detect(self):
results = [] results = []
pragma = self.slither.pragma_directives pragma = self.slither.pragma_directives
versions = [p.version for p in pragma] versions = [p.version for p in pragma if p.is_solidity_version]
versions = sorted(list(set(versions))) versions = sorted(list(set(versions)))
if len(versions) > 1: if len(versions) > 1:

Loading…
Cancel
Save