Exemplo n.º 1
0
    def __init__(self, get_repository, config):
        """Set the paramaters of the model - i.e. the weights and features.

    For some explanation of why the paramaters were set this way see these docs:
      https://docs.google.com/a/google.com/document/d/1TdDEDlUJX81-5yvB9IfdJFq5-kJBb_DwAgDH9cGfNao/edit?usp=sharing
      https://docs.google.com/a/google.com/document/d/1FHaghBX_FANjtiUP7D1pihZGxzEYdXA3Y7t0rSA4bWU/edit?usp=sharing
    As well as the following CLs:
      https://chromium-review.googlesource.com/c/599071
      https://chromium-review.googlesource.com/c/585784
    """
        super(PredatorForUMASamplingProfiler,
              self).__init__(get_repository, config)
        meta_weight = MetaWeight({
            'TouchCrashedFileMeta':
            MetaWeight({
                'MinDistance': Weight(2.),
                'TopFrameIndex': Weight(0.),
                'TouchCrashedFile': Weight(1.),
            })
        })

        min_distance_feature = MinDistanceFeature(get_repository)
        top_frame_index_feature = TopFrameIndexFeature()
        touch_crashed_file_feature = TouchCrashedFileFeature()
        meta_feature = WrapperMetaFeature([
            TouchCrashedFileMetaFeature([
                min_distance_feature, top_frame_index_feature,
                touch_crashed_file_feature
            ],
                                        include_renamed_paths=True)
        ])

        self._predator = Predator(
            ChangelistClassifier(get_repository, meta_feature, meta_weight),
            self._component_classifier, self._project_classifier)
Exemplo n.º 2
0
  def __init__(self, get_repository,
               max_line_distance=DEFAULT_MAX_LINE_DISTANCE,
               max_frame_index=DEFAULT_MAX_FRAME_INDEX):
    """
    Args:
      get_repository (callable): a function from DEP urls to ``Repository``
        objects, so we can get changelogs and blame for each dep. Notably,
        to keep the code here generic, we make no assumptions about
        which subclass of ``Repository`` this function returns. Thus,
        it is up to the caller to decide what class to return and handle
        any other arguments that class may require (e.g., an http client
        for ``GitilesRepository``).
        This factory is needed because the ``MinDistanceFeature`` in this meta
        feature needs to get blame for files touched by suspect.
      max_line_distance (int): An upper bound on the min_distance to
        consider. This argument is optional and defaults to
        ``DEFAULT_MAX_LINE_DISTANCE``.
      max_frame_index (int): An upper bound on the minimum frame index
        to consider. This argument is optional and defaults to
        ``DEFAULT_MAX_FRAME_INDEX``.
    """
    min_distance_feature = MinDistanceFeature(get_repository, max_line_distance)
    top_frame_index_feature = TopFrameIndexFeature(max_frame_index)
    touch_crashed_file_feature = TouchCrashedFileFeature()

    super(TouchCrashedFileMetaFeature, self).__init__({
        min_distance_feature.name: min_distance_feature,
        top_frame_index_feature.name: top_frame_index_feature,
        touch_crashed_file_feature.name: touch_crashed_file_feature
    })
Exemplo n.º 3
0
    def RedefineClassifierIfLargeRegressionRange(self, analysis):
        """Disable features for revisions in regression range > 100 commits.

    For crash with big regression range, it's easy to get false positives if we
    enable TouchCrashedComponentFeature and TouchCrashedDirectoryFeature,
    Because it has a big chance to hit these features and cause false positives.
    So we should disable these 2 features.
    """
        if (analysis.commit_count_in_regression_range <
                _BIG_REGRESSION_RANGE_COMMITS_THRESHOLD):
            return

        get_repository = self._predator.changelist_classifier._get_repository
        meta_weight = MetaWeight({
            'TouchCrashedFileMeta':
            MetaWeight({
                'MinDistance': Weight(1.),
                'TopFrameIndex': Weight(1.),
                'TouchCrashedFile': Weight(1.),
            }),
        })

        meta_feature = WrapperMetaFeature([
            TouchCrashedFileMetaFeature([
                MinDistanceFeature(get_repository),
                TopFrameIndexFeature(),
                TouchCrashedFileFeature()
            ])
        ])

        self._predator.changelist_classifier = ChangelistClassifier(
            get_repository, meta_feature, meta_weight)
 def setUp(self):
     super(TouchCrashedFileMetaFeatureTest, self).setUp()
     get_repository = GitilesRepository.Factory(self.GetMockHttpClient())
     min_distance_feature = MinDistanceFeature(get_repository)
     top_frame_index_feature = TopFrameIndexFeature()
     touch_crashed_file_feature = TouchCrashedFileFeature()
     self._feature = TouchCrashedFileMetaFeature([
         min_distance_feature, top_frame_index_feature,
         touch_crashed_file_feature
     ])
Exemplo n.º 5
0
    def __init__(self, get_repository, config):
        super(PredatorForClusterfuzz, self).__init__(get_repository, config)
        meta_weight = MetaWeight({
            'TouchCrashedFileMeta':
            MetaWeight({
                'MinDistance': Weight(2.),
                'TopFrameIndex': Weight(1.),
                'TouchCrashedFile': Weight(1.),
            }),
            'TouchCrashedDirectory':
            Weight(1.),
            'TouchCrashedComponent':
            Weight(1.),
            'NumberOfTouchedFiles':
            Weight(0.5),
        })

        min_distance_feature = MinDistanceFeature(get_repository)
        top_frame_index_feature = TopFrameIndexFeature()
        touch_crashed_file_feature = TouchCrashedFileFeature()

        meta_feature = WrapperMetaFeature([
            TouchCrashedFileMetaFeature([
                min_distance_feature, top_frame_index_feature,
                touch_crashed_file_feature
            ],
                                        options=config.feature_options.get(
                                            'TouchCrashedFileMetaFeature')),
            TouchCrashedDirectoryFeature(
                options=config.feature_options['TouchCrashedDirectory']),
            TouchCrashedComponentFeature(
                self._component_classifier,
                options=config.feature_options['TouchCrashedComponent']),
            NumberOfTouchedFilesFeature()
        ])

        self._predator = Predator(
            ChangelistClassifier(get_repository, meta_feature, meta_weight),
            self._component_classifier, self._project_classifier)
Exemplo n.º 6
0
    def setUp(self):
        super(ChangelistClassifierTest, self).setUp()
        meta_weight = MetaWeight({
            'TouchCrashedFileMeta':
            MetaWeight({
                'MinDistance': Weight(1.),
                'TopFrameIndex': Weight(1.),
                'TouchCrashedFile': Weight(1.),
            })
        })
        get_repository = GitilesRepository.Factory(self.GetMockHttpClient())
        min_distance_feature = MinDistanceFeature(get_repository)
        top_frame_index_feature = TopFrameIndexFeature()
        touch_crashed_file_feature = TouchCrashedFileFeature()

        meta_feature = WrapperMetaFeature([
            TouchCrashedFileMetaFeature([
                min_distance_feature, top_frame_index_feature,
                touch_crashed_file_feature
            ])
        ])

        self.changelist_classifier = ChangelistClassifier(
            get_repository, meta_feature, meta_weight)