当前位置: 首页>>代码示例>>Python>>正文


Python CrashInfo.CrashInfo类代码示例

本文整理汇总了Python中FTB.Signatures.CrashInfo.CrashInfo的典型用法代码示例。如果您正苦于以下问题:Python CrashInfo类的具体用法?Python CrashInfo怎么用?Python CrashInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CrashInfo类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: runTest

    def runTest(self):
        # test that a forward slash assertion signature matches a backwards slash crash, but only on windows
        cfg_linux = ProgramConfiguration('test', 'x86-64', 'linux')
        cfg_windows = ProgramConfiguration('test', 'x86-64', 'windows')

        fs_lines = testAssertionPathFwSlashes.splitlines()
        bs_lines = testAssertionPathBwSlashes.splitlines()

        # native paths on linux use forward slash
        fs_linux = CrashInfo.fromRawCrashData([], [], cfg_linux, auxCrashData=fs_lines)
        # backward slash path on linux -- this is invalid and should never happen
        bs_linux = CrashInfo.fromRawCrashData([], [], cfg_linux, auxCrashData=bs_lines)
        # forward slashes on windows are valid, and this does happen
        fs_windows = CrashInfo.fromRawCrashData([], [], cfg_windows, auxCrashData=fs_lines)
        # native paths on windows use backslash
        bs_windows = CrashInfo.fromRawCrashData([], [], cfg_windows, auxCrashData=bs_lines)

        # test that signature generated from linux assertion matches both
        linux_sig = fs_linux.createCrashSignature()
        assert linux_sig.matches(fs_linux)
        assert not linux_sig.matches(bs_linux)  # this is invalid and should not match
        assert linux_sig.matches(fs_windows)
        assert linux_sig.matches(bs_windows)

        # test that signature generated from windows assertion matches both
        windows_sig = bs_windows.createCrashSignature()
        assert windows_sig.matches(fs_linux)
        assert not windows_sig.matches(bs_linux)  # this is invalid and should not match
        assert windows_sig.matches(fs_windows)
        assert windows_sig.matches(bs_windows)
开发者ID:nth10sd,项目名称:FuzzManager,代码行数:30,代码来源:test_CrashSignature.py

示例2: runTest

    def runTest(self):
        config = ProgramConfiguration("test", "x86", "linux")

        crashInfo1 = CrashInfo.fromRawCrashData([], [], config, auxCrashData=asanTraceCrash.splitlines())
        crashInfo2 = CrashInfo.fromRawCrashData([], asanTraceUAF.splitlines(), config)
        
        self.assertIsInstance(crashInfo1, ASanCrashInfo)
        self.assertIsInstance(crashInfo2, ASanCrashInfo)
开发者ID:jruderman,项目名称:FuzzManager,代码行数:8,代码来源:tests.py

示例3: runTest

    def runTest(self):
        config = ProgramConfiguration("test", "x86", "linux")
        crashInfoNeg = CrashInfo.fromRawCrashData([], [], config, auxCrashData=testTraceHeapWithCrashAddress.splitlines())
        crashInfoPos = CrashInfo.fromRawCrashData([], [], config, auxCrashData=testTraceHeapWithoutCrashAddress.splitlines())

        testSigEmptyCrashAddress = CrashSignature(testSignatureEmptyCrashAddress)

        self.assertTrue(testSigEmptyCrashAddress.matches(crashInfoPos))
        self.assertFalse(testSigEmptyCrashAddress.matches(crashInfoNeg))
开发者ID:crowell,项目名称:FuzzManager,代码行数:9,代码来源:test_CrashSignature.py

示例4: getCrashInfo

    def getCrashInfo(self, attachTestcase=False, requiredOutputSources=("stdout", "stderr", "crashdata")):
        # TODO: This should be cached at some level
        # TODO: Need to include environment and program arguments here
        configuration = ProgramConfiguration(self.product.name, self.platform.name, self.os.name, self.product.version)

        cachedCrashInfo = None
        if self.cachedCrashInfo:
            cachedCrashInfo = json.loads(self.cachedCrashInfo)

        # We can skip loading raw output fields from the database iff
        #   1) we know we don't need them for matching *and*
        #   2) we already have the crash data cached
        (rawStdout, rawStderr, rawCrashData) = (None, None, None)
        if cachedCrashInfo is None or "stdout" in requiredOutputSources:
            rawStdout = self.rawStdout
        if cachedCrashInfo is None or "stderr" in requiredOutputSources:
            rawStderr = self.rawStderr
        if cachedCrashInfo is None or "crashdata" in requiredOutputSources:
            rawCrashData = self.rawCrashData

        crashInfo = CrashInfo.fromRawCrashData(rawStdout, rawStderr, configuration, rawCrashData,
                                               cacheObject=cachedCrashInfo)

        if attachTestcase and self.testcase is not None and not self.testcase.isBinary:
            self.testcase.loadTest()
            crashInfo.testcase = self.testcase.content

        return crashInfo
开发者ID:nth10sd,项目名称:FuzzManager,代码行数:28,代码来源:models.py

示例5: runTest

    def runTest(self):
        config = ProgramConfiguration("test", "x86-64", "macosx")

        with open('apple-crash-report-example.txt', 'r') as f:
            crashData = f.read().splitlines()

        crashInfo = CrashInfo.fromRawCrashData([], [], config, crashData)
        self.assertEqual(crashInfo.crashAddress, long(0x00007fff5f3fff98))
开发者ID:stillwarter,项目名称:FuzzManager,代码行数:8,代码来源:tests.py

示例6: create

    def create(self, attrs):
        '''
        Create a CrashEntry instance based on the given dictionary of values
        received. We need to unflatten foreign relationships like product,
        platform, os and client and create the foreign objects on the fly
        if they don't exist in our database yet.
        '''
        missing_keys = {'rawStdout', 'rawStderr', 'rawCrashData'} - set(attrs.keys())
        if missing_keys:
            raise InvalidArgumentException({key: ["This field is required."] for key in missing_keys})

        attrs['product'] = Product.objects.get_or_create(**attrs['product'])[0]
        attrs['platform'] = Platform.objects.get_or_create(**attrs['platform'])[0]
        attrs['os'] = OS.objects.get_or_create(**attrs['os'])[0]
        attrs['client'] = Client.objects.get_or_create(**attrs['client'])[0]
        attrs['tool'] = Tool.objects.get_or_create(**attrs['tool'])[0]

        # Parse the incoming data using the crash signature package from FTB
        configuration = ProgramConfiguration(attrs['product'].name, attrs['platform'].name, attrs['os'].name,
                                             attrs['product'].version)
        crashInfo = CrashInfo.fromRawCrashData(attrs['rawStdout'], attrs['rawStderr'], configuration,
                                               attrs['rawCrashData'])

        # Populate certain fields here from the CrashInfo object we just got
        if crashInfo.crashAddress is not None:
            attrs['crashAddress'] = '0x%x' % crashInfo.crashAddress
        attrs['shortSignature'] = crashInfo.createShortSignature()

        # If a testcase is supplied, create a testcase object and store it
        if 'test' in attrs['testcase']:

            testcase = attrs['testcase']
            testcase_ext = attrs.pop('testcase_ext', None)
            testcase_quality = testcase.get('quality', 0)
            testcase_isbinary = testcase.get('isBinary', False)
            testcase = testcase['test']

            if testcase_ext is None:
                raise RuntimeError("Must provide testcase extension when providing testcase")

            h = hashlib.new('sha1')
            if testcase_isbinary:
                testcase = base64.b64decode(testcase)
                h.update(testcase)
            else:
                h.update(repr(testcase).encode("utf-8"))

            dbobj = TestCase(quality=testcase_quality, isBinary=testcase_isbinary, size=len(testcase))
            dbobj.test.save("%s.%s" % (h.hexdigest(), testcase_ext), ContentFile(testcase))
            dbobj.save()
            attrs['testcase'] = dbobj
        else:
            attrs['testcase'] = None

        # Create our CrashEntry instance
        return super(CrashEntrySerializer, self).create(attrs)
开发者ID:nth10sd,项目名称:FuzzManager,代码行数:56,代码来源:serializers.py

示例7: getCrashInfo

 def getCrashInfo(self, attachTestcase=False):
     # TODO: This should be cached at some level
     # TODO: Need to include environment and program arguments here
     configuration = ProgramConfiguration(self.product.name, self.platform.name, self.os.name, self.product.version)
     crashInfo = CrashInfo.fromRawCrashData(self.rawStdout, self.rawStderr, configuration, self.rawCrashData)
     
     if attachTestcase and self.testcase != None and not self.testcase.isBinary:
         self.testcase.loadTest()
         crashInfo.testcase = self.testcase.content
     
     return crashInfo
开发者ID:killvxk,项目名称:FuzzManager,代码行数:11,代码来源:models.py

示例8: add_fault

        def add_fault(self):
            # Setup FuzzManager with target information and platform data.
            program_configuration = ProgramConfiguration.fromBinary(self.binary)

            # Prepare FuzzManager with crash information.
            stdout = "N/A"  # Todo: There is no plain stdout logger yet.
            stderr = "N/A"  # Todo: There is no plain stderr logger yet.
            auxdat = self.bucket.get("crashlog", "N/A").get("data", "N/A")
            metaData = None
            testcase = self.save_bucket_as_zip(self.bucket)
            crash_info = CrashInfo.fromRawCrashData(stdout, stderr, program_configuration, auxdat)

            # Submit crash report with testcase to FuzzManager.
            collector = Collector(tool="dharma")
            collector.submit(crash_info, testcase, metaData)
开发者ID:drptbl,项目名称:quokka,代码行数:15,代码来源:fuzzmanager.py

示例9: test_collector_generate_search

def test_collector_generate_search(tmpdir):
    '''Test sigcache generation and search'''
    # create a cache dir
    cache_dir = tmpdir.mkdir('sigcache').strpath

    # create a collector
    collector = Collector(sigCacheDir=cache_dir)

    # generate a signature from the crash data
    config = ProgramConfiguration('mozilla-central', 'x86-64', 'linux', version='ba0bc4f26681')
    crashInfo = CrashInfo.fromRawCrashData([], asanTraceCrash.splitlines(), config)
    sig = collector.generate(crashInfo, False, False, 8)
    assert {f.strpath for f in tmpdir.join('sigcache').listdir()} == {sig}

    # search the sigcache and see that it matches the original
    sigMatch, meta = collector.search(crashInfo)
    assert sigMatch == sig
    assert meta is None

    # write metadata and make sure that's returned if it exists
    sigBase, _ = os.path.splitext(sig)
    with open(sigBase + '.metadata', 'w') as f:
        f.write('{}')
    sigMatch, meta = collector.search(crashInfo)
    assert sigMatch == sig
    assert meta == {}

    # make sure another crash doesn't match
    crashInfo = CrashInfo.fromRawCrashData([], [], config)
    sigMatch, meta = collector.search(crashInfo)
    assert sigMatch is None
    assert meta is None

    # returns None if sig generation fails
    result = collector.generate(crashInfo, True, True, 8)
    assert result is None
开发者ID:nth10sd,项目名称:FuzzManager,代码行数:36,代码来源:test_Collector.py

示例10: runTest

 def runTest(self):
     collector = Collector(self.tmpCacheDir, 
                           serverHost='127.0.0.1', 
                           serverPort='8000',
                           serverProtocol='http',
                           serverUser=testAuthCreds[0],
                           serverPass=testAuthCreds[1],  
                           clientId='test-fuzzer1')
     
     config = ProgramConfiguration("mozilla-central", "x86-64", "linux", version="ba0bc4f26681")
     crashInfo = CrashInfo.fromRawCrashData([], asanTraceCrash.splitlines(), config)
     
     # TODO: This is only a rudimentary check to see if we submitted *something*.
     # We should check more precisely that the information submitted is correct.
     issueCount = self.getRemoteCrashEntryCount()
     collector.submit(crashInfo, exampleTestCase)
     self.assertEqual(self.getRemoteCrashEntryCount(), issueCount + 1)
开发者ID:crowell,项目名称:FuzzManager,代码行数:17,代码来源:tests.py

示例11: OnFault

        def OnFault(self, run, test, variationCount, monitorData, actionValues):
            # Setup FuzzManager with information about target and platform data.
            program_configuration = ProgramConfiguration.fromBinary(self.target_binary)

            # Prepare FuzzManager with target and crash information.
            stdout = self._get_value_by_key(monitorData, "stdout.txt", "N/A")
            stderr = self._get_value_by_key(monitorData, "stderr.txt", "N/A")
            auxdat = self._get_value_by_key(monitorData, "auxdat.txt", "N/A")

            crash_info = CrashInfo.fromRawCrashData(stdout, stderr, program_configuration, auxdat)

            collector = Collector(tool="peach")

            # Write testcase content and any additional meta information to a temporary ZIP archive.
            buffer = StringIO.StringIO()
            zip_buffer = zipfile.ZipFile(buffer, 'w')

            # Collect |actionValues| crash information from Peach.
            for i in range(len(actionValues)):
                if len(actionValues[i]) > 2:
                    data = actionValues[i][2]
                    fileName = "data_%d_%s_%s.txt" % (i, actionValues[i][1], actionValues[i][0])
                    zip_buffer.writestr(fileName, data)

                    if len(actionValues[i]) > 3 and actionValues[i][1] != 'output':
                        data = repr(actionValues[i][3])
                        fileName = "data_%d_%s_%s_action.txt" % (i, actionValues[i][1], actionValues[i][0])
                        zip_buffer.writestr(fileName, data)

                    if len(actionValues[i]) > 3 and actionValues[i][1] == 'output':
                        fileName = "data_%d_%s_%s_fileName.txt" % (i, actionValues[i][1], actionValues[i][0])
                        data = actionValues[i][3]
                        zip_buffer.writestr(fileName, data)

            # Collect |monitorData| crash information from Peach.
            for k, v in monitorData.items():
                zip_buffer.writestr(k, v)

            zip_buffer.close()
            with tempfile.NamedTemporaryFile(delete=False, suffix='.zip') as testcase:
                buffer.seek(0)
                testcase.write(buffer.getvalue())
                testcase.close()
                # Submit crash report with testcase to FuzzManager.
                collector.submit(crash_info, testcase.name, metaData=None)
开发者ID:KurSh,项目名称:peach,代码行数:45,代码来源:logger.py


注:本文中的FTB.Signatures.CrashInfo.CrashInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。