How to use thug - 10 common examples

To help you get started, we’ve selected a few thug examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github buffer / thug / tests / functional / test_shockwave.py View on Github external
def do_perform_test(self, caplog, sample, shockwave, expected):
        thug = ThugAPI()

        thug.set_useragent('win7ie90')
        thug.set_events('click,storage')
        thug.disable_cert_logging()
        thug.set_features_logging()

        if shockwave in ('disable', ):
            thug.disable_shockwave_flash()
        else:
            thug.set_shockwave_flash(shockwave)

        thug.log_init(sample)
        thug.run_local(sample)

        records = [r.message for r in caplog.records]
github buffer / thug / tests / functional / test_misc_ie60.py View on Github external
def do_perform_test(self, caplog, sample, expected):
        thug = ThugAPI()

        thug.set_useragent('winxpie60')
        thug.set_events('click')
        thug.set_connect_timeout(2)
        thug.disable_cert_logging()
        thug.set_features_logging()
        thug.set_ssl_verify()
        thug.log_init(sample)
        thug.run_local(sample)

        records = [r.message for r in caplog.records]

        matches = 0

        for e in expected:
            for record in records:
github buffer / thug / tests / functional / test_misc_chrome.py View on Github external
def do_perform_test(self, caplog, sample, expected):
        thug = ThugAPI()

        thug.set_useragent('win7chrome49')
        thug.set_events('click,storage')
        thug.set_connect_timeout(2)
        thug.disable_cert_logging()
        thug.set_features_logging()
        thug.set_ssl_verify()
        thug.log_init(sample)
        thug.run_local(sample)

        records = [r.message for r in caplog.records]

        matches = 0

        for e in expected:
            for record in records:
github buffer / thug / tests / functional / test_mimehandler.py View on Github external
def do_perform_test(self, caplog, url, expected, type_ = "remote"):
        thug = ThugAPI()

        thug.set_useragent('win7ie90')
        thug.set_features_logging()
        thug.set_ssl_verify()
        thug.log_init(url)

        m = getattr(thug, "run_{}".format(type_))
        m(url)

        records = [r.message for r in caplog.records]

        matches = 0

        for e in expected:
            for record in records:
                if e in record:
github buffer / thug / tests / functional / test_misc_ie90.py View on Github external
def do_perform_test(self, caplog, sample, expected, nofetch = False):
        xmlhttp = getattr(log, 'XMLHTTP', None)
        if xmlhttp:
            delattr(log, 'XMLHTTP')

        thug = ThugAPI()

        thug.set_useragent('win7ie90')
        thug.set_events('click,storage')
        thug.set_connect_timeout(2)
        thug.disable_cert_logging()
        thug.set_ssl_verify()
        thug.set_features_logging()

        if nofetch:
            thug.set_no_fetch()

        thug.log_init(sample)
        thug.run_local(sample)

        records = [r.message for r in caplog.records]
github buffer / thug / tests / functional / test_screenshot.py View on Github external
def do_perform_test(self, caplog, url, expected, type_ = "remote"):
        thug = ThugAPI()

        thug.set_useragent('win7ie90')
        thug.disable_screenshot()
        thug.enable_screenshot()
        thug.set_file_logging()
        thug.set_json_logging()
        thug.set_ssl_verify()
        thug.log_init(url)

        m = getattr(thug, "run_{}".format(type_))
        m(url)

        records = [r.message for r in caplog.records]

        matches = 0
github buffer / thug / tests / functional / test_events.py View on Github external
def do_perform_test(self, caplog, sample, expected, events = '', useragent = 'win7ie90'):
        thug = ThugAPI()

        thug.set_useragent(useragent)
        thug.set_events(events)
        thug.disable_cert_logging()
        thug.set_features_logging()
        thug.log_init(sample)
        thug.run_local(sample)

        records = [r.message for r in caplog.records]

        matches = 0

        for e in expected:
            for record in records:
                if e in record:
                    matches += 1
github buffer / thug / tests / functional / test_features.py View on Github external
def do_perform_test(self, caplog, sample):
        thug = ThugAPI()

        thug.log_init(sample)

        thug.set_useragent('win7ie90')
        thug.set_verbose()
        thug.set_json_logging()

        thug.reset_features_logging()
        assert thug.get_features_logging() is False

        thug.set_features_logging()
        assert thug.get_features_logging() is True

        thug.log_init(sample)
        thug.run_local(sample)
        thug.log_event()
github buffer / thug / tests / functional / test_adobereader.py View on Github external
def do_perform_test(self, caplog, sample, adobe, expected):
        thug = ThugAPI()

        thug.set_useragent('win7ie90')
        thug.set_events('click,storage')
        thug.disable_cert_logging()
        thug.set_features_logging()

        if adobe in ('disable', ):
            thug.disable_acropdf()
        else:
            thug.set_acropdf_pdf(adobe)

        thug.log_init(sample)
        thug.run_local(sample)

        records = [r.message for r in caplog.records]
github buffer / thug / tests / Logging / test_ThugLogging.py View on Github external
import os
import logging

import thug
from thug.ThugAPI.ThugOpts import ThugOpts
from thug.DOM.HTTPSession import HTTPSession
from thug.Logging.ThugLogging import ThugLogging
from thug.Classifier.URLClassifier import URLClassifier
from thug.Classifier.SampleClassifier import SampleClassifier

configuration_path = thug.__configuration_path__

log                    = logging.getLogger("Thug")
log.configuration_path = configuration_path
log.personalities_path = os.path.join(configuration_path, "personalities") if configuration_path else None

log.PyHooks          = dict()
log.ThugOpts         = ThugOpts()
log.HTTPSession      = HTTPSession()
log.URLClassifier    = URLClassifier()
log.SampleClassifier = SampleClassifier()

thug_logging = ThugLogging(thug.__version__)


class TestThugLogging:
    js       = "var i = 0;"