Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
47 lines (34 sloc) 1.38 KB
import base64
import logging
from polyswarmclient.abstractmicroengine import AbstractMicroengine
from polyswarmclient.abstractscanner import AbstractScanner, ScanResult
logger = logging.getLogger(__name__)
EICAR = base64.b64decode(
b'WDVPIVAlQEFQWzRcUFpYNTQoUF4pN0NDKTd9JEVJQ0FSLVNUQU5EQVJELUFOVElWSVJVUy1URVNULUZJTEUhJEgrSCo=')
class Scanner(AbstractScanner):
def __init__(self):
super(Scanner, self).__init__()
async def scan(self, guid, content, chain):
"""Scan an artifact
Args:
guid (str): GUID of the bounty under analysis, use to track artifacts in the same bounty
content (bytes): Content of the artifact to be scan
chain (str): Chain we are operating on
Returns:
ScanResult: Result of this scan
"""
if content == EICAR:
return ScanResult(bit=True, verdict=True)
return ScanResult(bit=True, verdict=False)
class Microengine(AbstractMicroengine):
"""
Microengine which tests for the EICAR test file.
Args:
client (`Client`): Client to use
testing (int): How many test bounties to respond to
chains (set[str]): Chain(s) to operate on
"""
def __init__(self, client, testing=0, scanner=None, chains=None):
"""Initialize Scanner"""
scanner = Scanner()
super().__init__(client, testing, scanner, chains)