Beispiel #1
0
  def test_no_permissions(self):
    """Test user with no permissions."""
    self.mock.get_user_email.return_value = '*****@*****.**'
    self.mock.allowed_jobs_for_user.return_value = []
    self.mock.get_access.return_value = access.UserAccess.Denied

    with self.assertRaises(helpers.EarlyExitException):
      home.get_results()
Beispiel #2
0
  def test_results_external(self):
    """Test results for external user."""
    self.mock.get_user_email.return_value = '*****@*****.**'
    self.mock.allowed_jobs_for_user.return_value = [
        'libfuzzer_asan_lib', 'libfuzzer_msan_lib'
    ]
    self.mock.get_access.return_value = access.UserAccess.Denied
    self.mock.read_data.return_value = '{"lib": "lib_url"}'
    self.mock.exists.return_value = True

    results = home.get_results()
    self.assertEqual(
        results, {
            'info': {
                'projects': [{
                    'jobs': [{
                        'sanitizer_string': 'Sanitizer: address (ASAN)',
                        'name': u'libfuzzer_asan_lib',
                        'single_target': None,
                        'engine_display_name': 'libFuzzer',
                        'engine_name': 'libFuzzer',
                        'has_stats': True,
                    }, {
                        'sanitizer_string': 'Sanitizer: memory (MSAN)',
                        'name': u'libfuzzer_msan_lib',
                        'single_target': None,
                        'engine_name': 'libFuzzer',
                        'engine_display_name': 'libFuzzer',
                        'has_stats': True,
                    }],
                    'name':
                        u'lib',
                    'coverage_job':
                        'libfuzzer_asan_lib',
                    'has_introspector':
                        True,
                    'introspector_report':
                        'lib_url'
                }],
                'is_internal_user':
                    False,
            }
        })

    self.mock.allowed_jobs_for_user.return_value = [
        'afl_asan_lib', 'libfuzzer_asan_lib', 'libfuzzer_msan_lib',
        'afl_asan_lib2', 'libfuzzer_asan_lib2', 'libfuzzer_ubsan_lib2'
    ]

    results = home.get_results()
    self.assertEqual(
        results, {
            'info': {
                'projects': [{
                    'jobs': [{
                        'sanitizer_string': 'Sanitizer: address (ASAN)',
                        'name': u'afl_asan_lib',
                        'single_target': None,
                        'engine_display_name': 'AFL',
                        'engine_name': 'afl',
                        'has_stats': True,
                    }, {
                        'sanitizer_string': 'Sanitizer: address (ASAN)',
                        'name': u'libfuzzer_asan_lib',
                        'single_target': None,
                        'engine_display_name': 'libFuzzer',
                        'engine_name': 'libFuzzer',
                        'has_stats': True,
                    }, {
                        'sanitizer_string': 'Sanitizer: memory (MSAN)',
                        'name': u'libfuzzer_msan_lib',
                        'single_target': None,
                        'engine_display_name': 'libFuzzer',
                        'engine_name': 'libFuzzer',
                        'has_stats': True,
                    }],
                    'name':
                        u'lib',
                    'coverage_job':
                        'libfuzzer_asan_lib',
                    'has_introspector':
                        True,
                    'introspector_report':
                        'lib_url'
                }, {
                    'jobs': [{
                        'sanitizer_string': 'Sanitizer: address (ASAN)',
                        'name': u'afl_asan_lib2',
                        'single_target': 'afl_lib2_fuzzer',
                        'engine_display_name': 'AFL',
                        'engine_name': 'afl',
                        'has_stats': True,
                    }, {
                        'sanitizer_string': 'Sanitizer: address (ASAN)',
                        'name': u'libfuzzer_asan_lib2',
                        'single_target': 'libFuzzer_lib2_fuzzer',
                        'engine_display_name': 'libFuzzer',
                        'engine_name': 'libFuzzer',
                        'has_stats': True,
                    }, {
                        'sanitizer_string': 'Sanitizer: undefined (UBSAN)',
                        'name': u'libfuzzer_ubsan_lib2',
                        'single_target': 'libFuzzer_lib2_fuzzer',
                        'engine_display_name': 'libFuzzer',
                        'engine_name': 'libFuzzer',
                        'has_stats': True,
                    }],
                    'name':
                        u'lib2',
                    'coverage_job':
                        'libfuzzer_asan_lib2',
                    'has_introspector':
                        False,
                }],
                'is_internal_user':
                    False,
            }
        })
Beispiel #3
0
    def test_results_internal(self):
        """Test results for internal user."""
        self.mock.get_user_email.return_value = '*****@*****.**'
        self.mock.allowed_jobs_for_user.return_value = []
        self.mock.get_access.return_value = access.UserAccess.Allowed

        results = home.get_results()
        self.assertEqual(
            results, {
                'info': {
                    'projects': [{
                        'jobs': [{
                            'sanitizer_string': 'Sanitizer: address (ASAN)',
                            'name': u'afl_asan_lib',
                            'single_target': None,
                            'engine_display_name': 'AFL',
                            'engine_name': 'afl',
                            'has_stats': True,
                        }, {
                            'sanitizer_string': 'Sanitizer: address (ASAN)',
                            'name': u'libfuzzer_asan_lib',
                            'single_target': None,
                            'engine_display_name': 'libFuzzer',
                            'engine_name': 'libFuzzer',
                            'has_stats': True,
                        }, {
                            'sanitizer_string': 'Sanitizer: memory (MSAN)',
                            'name': u'libfuzzer_msan_lib',
                            'single_target': None,
                            'engine_display_name': 'libFuzzer',
                            'engine_name': 'libFuzzer',
                            'has_stats': True,
                        }],
                        'name':
                        u'lib',
                        'coverage_job':
                        'libfuzzer_asan_lib',
                    }, {
                        'jobs': [{
                            'sanitizer_string': 'Sanitizer: address (ASAN)',
                            'name': u'afl_asan_lib2',
                            'single_target': 'afl_lib2_fuzzer',
                            'engine_display_name': 'AFL',
                            'engine_name': 'afl',
                            'has_stats': True,
                        }, {
                            'sanitizer_string': 'Sanitizer: address (ASAN)',
                            'name': u'libfuzzer_asan_lib2',
                            'single_target': 'libFuzzer_lib2_fuzzer',
                            'engine_display_name': 'libFuzzer',
                            'engine_name': 'libFuzzer',
                            'has_stats': True,
                        }, {
                            'sanitizer_string': 'Sanitizer: undefined (UBSAN)',
                            'name': u'libfuzzer_ubsan_lib2',
                            'single_target': 'libFuzzer_lib2_fuzzer',
                            'engine_display_name': 'libFuzzer',
                            'engine_name': 'libFuzzer',
                            'has_stats': True,
                        }],
                        'name':
                        u'lib2',
                        'coverage_job':
                        'libfuzzer_asan_lib2',
                    }],
                    'is_internal_user':
                    True,
                }
            })