# Path: mwscan/settings.py
# CACHEDIR = os.path.expanduser('~/.cache/mwscan')
# LAST_RUN_FILE = os.path.join(CACHEDIR, 'last_run')
# DEFAULT_EXCLUDEFILE = os.path.expanduser('~/.config/mwscan/excludes')
# CODE_EXT = ('php', 'phtml', 'js', 'jsx', 'html', 'php3', 'php4', 'php5', 'php7', 'sh', 'ini')


import os
import re
import json
import logging
import hashlib
import requests
import yara
import time
from requests.exceptions import RequestException
from mwscan import settings
            '/\*[^*]*WHITELIST = (\{.*?\})\s*\*/', rawrules, flags=re.DOTALL)
        return set(json.loads(m.group(1)) if m else [])

    def get_rules(self):
        rawrules = self._recursive_fetch(self.rules_url)
        try:
            if type(rawrules) is unicode:
                return rawrules.encode('ascii', 'ignore')
        except NameError:
            pass # py3

        return rawrules


    def get_whitelist(self):
        if not self.whitelist_url:
            return set()

        data = self._httpget(self.whitelist_url)
        hashes = re.findall('[a-f0-9]{40}', data)  # assume sha1 hex hash
        return set(hashes)

    def transform_rules(self, rawrules):
        """For specific rules providers, to mangle into mwscan compatible form"""
        whitelist = set()
        return rawrules, whitelist

    def _get_cache_filename(self, url):
        hash = hashlib.sha1(url.encode()).hexdigest()
        cachefile = self.__class__.__name__.lower() + '.cache_' + hash

# Path: mwscan/settings.py
# CACHEDIR = os.path.expanduser('~/.cache/mwscan')
# LAST_RUN_FILE = os.path.join(CACHEDIR, 'last_run')
# DEFAULT_EXCLUDEFILE = os.path.expanduser('~/.config/mwscan/excludes')
# CODE_EXT = ('php', 'phtml', 'js', 'jsx', 'html', 'php3', 'php4', 'php5', 'php7', 'sh', 'ini')


# Path: mwscan/ruleset.py
import os
import re
import json
import logging
import hashlib
import requests
import yara
import time
from requests.exceptions import RequestException
from mwscan import settings

            '/\*[^*]*WHITELIST = (\{.*?\})\s*\*/', rawrules, flags=re.DOTALL)
        return set(json.loads(m.group(1)) if m else [])

    def get_rules(self):
        rawrules = self._recursive_fetch(self.rules_url)
        try:
            if type(rawrules) is unicode:
                return rawrules.encode('ascii', 'ignore')
        except NameError:
            pass # py3

        return rawrules


    def get_whitelist(self):
        if not self.whitelist_url:
            return set()

        data = self._httpget(self.whitelist_url)
        hashes = re.findall('[a-f0-9]{40}', data)  # assume sha1 hex hash
        return set(hashes)

    def transform_rules(self, rawrules):
        """For specific rules providers, to mangle into mwscan compatible form"""
        whitelist = set()
        return rawrules, whitelist

    def _get_cache_filename(self, url):
        hash = hashlib.sha1(url.encode()).hexdigest()
        cachefile = self.__class__.__name__.lower() + '.cache_' + hash

        cachefile = os.path.join(settings.CACHEDIR, cachefile)