コード例 #1
0
def get_project_name(job_type):
  """Return project name for a job type."""
  project_name = get_value_from_job_definition(job_type, 'PROJECT_NAME')
  if project_name:
    return project_name

  return utils.default_project_name()
コード例 #2
0
def fuzz_target_project_qualified_name(project, binary):
    """Get a fuzz target's project qualified name."""
    if not project:
        return binary

    if project == utils.default_project_name():
        # Don't prefix with project name if it's the default project.
        return binary

    project_prefix = project + '_'
    if binary.startswith(project_prefix):
        return binary

    return project_prefix + binary
コード例 #3
0
def fuzz_target_project_qualified_name(project, binary):
  """Get a fuzz target's project qualified name."""

  binary = normalized_name(binary)
  if not project:
    return binary

  if project == utils.default_project_name():
    # Don't prefix with project name if it's the default project.
    return binary

  normalized_project_prefix = normalized_name(project) + "_"
  if binary.startswith(normalized_project_prefix):
    return binary

  return normalized_project_prefix + binary
コード例 #4
0
ファイル: data_types.py プロジェクト: wdgreen/clusterfuzz
def fuzz_target_project_qualified_name(project, binary):
    """Get a fuzz target's project qualified name."""
    def _normalized_project():
        """Return normalized project name with special chars like slash, colon, etc
    normalized to hyphen(-). This is important as otherwise these chars break
    local and cloud storage paths."""
        return PROJECT_NAME_SPECIAL_CHARS_REGEX.sub('-', project).strip('-')

    if not project:
        return binary

    if project == utils.default_project_name():
        # Don't prefix with project name if it's the default project.
        return binary

    normalized_project_prefix = _normalized_project() + '_'
    if binary.startswith(normalized_project_prefix):
        return binary

    return normalized_project_prefix + binary
コード例 #5
0
def _git_commit_position_to_git_hash_for_chromium(revision, repository):
  """Return git hash for a git commit position using cr-rev.appspot.com."""
  request_variables = {
      'number': revision,
      'numbering_identifier': 'refs/heads/master',
      'numbering_type': 'COMMIT_POSITION',
      'project': utils.default_project_name(),
      'repo': repository,
      'fields': 'git_sha',
  }
  query_string = urllib.parse.urlencode(request_variables)
  query_url = '%s?%s' % (CRREV_NUMBERING_URL, query_string)
  url_content = _get_url_content(query_url)
  if url_content is None:
    return None

  result_dict = _to_json_dict(url_content)
  if result_dict is None:
    return None

  return result_dict['git_sha']
コード例 #6
0
ファイル: utils_test.py プロジェクト: wdgreen/clusterfuzz
 def test_overridden(self):
     """Test that env variable PROJECT_NAME does not affect default project
 name and we still default project."""
     os.environ['PROJECT_NAME'] = 'other-project'
     self.assertEqual('test-project', utils.default_project_name())
コード例 #7
0
ファイル: utils_test.py プロジェクト: wdgreen/clusterfuzz
 def test_default(self):
     """Test that it returns default project with no environment changes."""
     self.assertEqual('test-project', utils.default_project_name())
コード例 #8
0
def get_project_name(job_type):
  """Return project name for a job type."""
  default_project_name = utils.default_project_name()
  return get_value_from_job_definition(job_type, 'PROJECT_NAME',
                                       default_project_name)
コード例 #9
0
def get_issue_description(testcase,
                          reporter=None,
                          show_reporter=False,
                          hide_crash_state=False):
  """Returns testcase as string."""
  # Get issue tracker configuration parameters.
  config = db_config.get()
  domain = get_domain()
  testcase_id = testcase.key.id()

  fuzzer_name = testcase.actual_fuzzer_name()
  download_url = TESTCASE_DOWNLOAD_URL.format(
      domain=domain, testcase_id=testcase_id)
  report_url = TESTCASE_REPORT_URL.format(
      domain=domain, testcase_id=testcase_id)
  regressed_revision_range_url = TESTCASE_REVISION_RANGE_URL.format(
      domain=domain,
      job_type=testcase.job_type,
      revision_range=testcase.regression)
  fixed_revision_range_url = TESTCASE_REVISION_RANGE_URL.format(
      domain=domain, job_type=testcase.job_type, revision_range=testcase.fixed)

  if testcase.status == 'Unreproducible':
    return ('Testcase {testcase_id} failed to reproduce the crash. '
            'Please inspect the program output at {report_url}.'.format(
                testcase_id=testcase_id, report_url=report_url))

  # Now create the content string.
  content_string = 'Detailed report: %s\n\n' % report_url

  project_name = get_project_name(testcase.job_type)
  if project_name and project_name != utils.default_project_name():
    content_string += 'Project: %s\n' % project_name

  if fuzzer_name:
    content_string += 'Fuzzer: %s\n' % fuzzer_name
    binary_name = testcase.get_metadata('fuzzer_binary_name')
    if binary_name:
      content_string += 'Fuzz target binary: %s\n' % binary_name

  content_string += 'Job Type: %s\n' % testcase.job_type

  # Add platform id if other than default ones. Only applicable to Android.
  # e.g. android:shamu_asan
  if testcase.platform_id:
    content_string += 'Platform Id: %s\n\n' % testcase.platform_id

  content_string += 'Crash Type: %s\n' % get_crash_type_string(testcase)
  content_string += 'Crash Address: %s\n' % testcase.crash_address

  if hide_crash_state:
    crash_state = '...see report...'
  else:
    crash_state = testcase.crash_state
  content_string += 'Crash State:\n%s\n' % (
      utils.indent_string(crash_state + '\n', 2))

  content_string += '%s\n\n' % environment.get_memory_tool_display_string(
      testcase.job_type)

  if data_types.SecuritySeverity.is_valid(testcase.security_severity):
    content_string += (
        'Recommended Security Severity: %s\n\n' %
        severity_analyzer.severity_to_string(testcase.security_severity))

  if (testcase.regression and testcase.regression != 'NA' and
      not testcase.regression.startswith('0:') and
      not testcase.regression.endswith('!')):
    content_string += 'Regressed: %s\n' % regressed_revision_range_url

  if (testcase.fixed and testcase.fixed != 'NA' and testcase.fixed != 'Yes' and
      not testcase.fixed.endswith('!')):
    content_string += 'Fixed: %s\n' % fixed_revision_range_url

  if not content_string.endswith('\n\n'):
    content_string += '\n'

  content_string += 'Reproducer Testcase: %s\n\n' % download_url

  second_crash_stacktrace = get_stacktrace(
      testcase, stack_attribute='second_crash_stacktrace')
  if testcase.one_time_crasher_flag and second_crash_stacktrace:
    content_string += (second_crash_stacktrace.split('\n'))[0] + '\n\n'

  if testcase.gestures:
    content_string += 'Additional requirements: Requires Gestures\n\n'
  if testcase.http_flag:
    content_string += 'Additional requirements: Requires HTTP\n\n'

  if show_reporter:
    if reporter:
      content_string += (
          'Issue manually filed by: %s\n\n' % reporter.split('@')[0])
    else:
      content_string += 'Issue filed automatically.\n\n'

  # Jobs can override the help url.
  content_string += 'See %s for instructions to reproduce this bug locally.' % (
      get_reproduction_help_url(testcase, config))

  # Unreproducible crash text is only applicable when we are consistently seeing
  # it happening, and hence the reason for auto-filing it. Otherwise, someone
  # filed it manually, so skip the text in that case.
  if not reporter and testcase.one_time_crasher_flag:
    content_string += '\n\n' + FILE_UNREPRODUCIBLE_TESTCASE_TEXT

  return content_string
コード例 #10
0
 def _pre_put_hook(self):
   """Pre-put hook."""
   self.project = self.get_environment().get('PROJECT_NAME',
                                             utils.default_project_name())
コード例 #11
0
def get_component_revisions_dict(revision, job_type):
  """Retrieve revision vars dict."""
  if revision == 0 or revision == '0' or revision is None:
    # Return empty dict for zero start revision.
    return {}

  component = data_handler.get_component_name(job_type)
  config = db_config.get()
  default_project_name = utils.default_project_name()

  revision_info_url_format = db_config.get_value_for_job(
      config.revision_vars_url, job_type)
  if not revision_info_url_format:
    return None

  revisions_dict = {}

  repository = data_handler.get_repository_for_component(component)

  if repository and not _is_clank(revision_info_url_format):
    revision_hash = _git_commit_position_to_git_hash_for_chromium(
        revision, repository)
    if revision_hash is None:
      return None

    # FIXME: While we check for this explicitly appended component in all
    # applicable cases that we know of within this codebase, if the dict
    # is shared with an external service (e.g. Predator) we may need to clean
    # this up beforehand.
    revisions_dict['/src'] = {
        'name': _get_component_display_name(component, default_project_name),
        'url': _git_url_for_chromium_repository(repository),
        'rev': revision_hash,
        'commit_pos': revision
    }

    # Use revision hash for info url later.
    revision = revision_hash

  revision_info_url = revision_info_url_format % revision
  url_content = _get_url_content(revision_info_url)
  if not url_content:
    logs.log_error(
        'Failed to get component revisions from %s.' % revision_info_url)
    return None

  # Parse as per DEPS format.
  if _is_deps(revision_info_url):
    deps_revisions_dict = deps_to_revisions_dict(url_content)
    if not deps_revisions_dict:
      return None

    revisions_dict.update(deps_revisions_dict)
    return revisions_dict

  # Parse as per Clank DEPS format.
  if _is_clank(revision_info_url):
    return _clank_revision_file_to_revisions_dict(url_content)

  # Default case: parse content as json.
  revisions_dict = _to_json_dict(url_content)

  # Parse as per source map format.
  if revision_info_url.endswith(SOURCE_MAP_EXTENSION):
    revisions_dict = _src_map_to_revisions_dict(revisions_dict,
                                                default_project_name)

  return revisions_dict