Exemplo n.º 1
0
 def test(self, verbose=True):
     # Don't test non-regex based plugins
     if self.regex_file_path == "":
         return
     rule_engine = RegexRuleEngine()
     rule_engine.load_config(json.load(open(self.regex_file_path)))
     (success, results) = rule_engine.test()
     if verbose == True:
         self.logger.debug(results)
     if success == False:
         raise base.PluginTestError(results)
Exemplo n.º 2
0
 def test(self, verbose=True):
     # Don't test non-regex based plugins
     if self.regex_file_path == "":
         return
     rule_engine = RegexRuleEngine()
     rule_engine.load_config(json.load(open(self.regex_file_path)))
     (success, results) = rule_engine.test()
     if verbose == True:
         logger.debug( results )
     if success == False:
         raise base.PluginTestError(results)
Exemplo n.º 3
0
    def patch(self, repository_name, repo_patch):
        if re.search(self.JAVA_SOURCE_FILE_PATTERN, repo_patch.filename):
            regex_file_path = os.path.join(os.path.dirname(__file__),"java.json")
        else:
            regex_file_path = os.path.join(os.path.dirname(__file__),"js.json")
        logger.debug("filename %s processed", (repo_patch.filename))
        all_lines = []
        all_lines.extend(repo_patch.diff.additions)
        rule_engine = RegexRuleEngine(json.load(open(regex_file_path)))

        def custom_match_callback(alert_config, alert_action, repo_patch, all_lines, offending_line):
            self.send_alert(repo_patch, repo_patch.repo_commit, alert_action.get("subject"), offending_line)

        rule_engine.match(all_lines, repo_patch, custom_match_callback=custom_match_callback)
        return
Exemplo n.º 4
0
    def patch(self, repository_name, repo_patch):
        if re.search(self.filename_pattern, repo_patch.filename):
            self.logger.debug("filename %s processed", (repo_patch.filename))
            all_lines = []
            all_lines.extend(repo_patch.diff.additions)
            rule_engine = RegexRuleEngine(json.load(open(
                self.regex_file_path)))

            def custom_match_callback(alert_config, alert_action, repo_patch,
                                      all_lines, offending_line):
                self.send_alert(repo_patch, repo_patch.repo_commit,
                                alert_action.get("subject"), offending_line)

            rule_engine.match(all_lines,
                              repo_patch,
                              custom_match_callback=custom_match_callback)
        return
Exemplo n.º 5
0
    def patch(self, repository_name, repo_patch):
        if re.search(self.JAVA_SOURCE_FILE_PATTERN, repo_patch.filename):
            regex_file_path = os.path.join(os.path.dirname(__file__),
                                           "java.json")
        else:
            regex_file_path = os.path.join(os.path.dirname(__file__),
                                           "js.json")
        logger.debug("filename %s processed", (repo_patch.filename))
        all_lines = []
        all_lines.extend(repo_patch.diff.additions)
        rule_engine = RegexRuleEngine(json.load(open(regex_file_path)))

        def custom_match_callback(alert_config, alert_action, repo_patch,
                                  all_lines, offending_line):
            self.send_alert(repo_patch, repo_patch.repo_commit,
                            alert_action.get("subject"), offending_line)

        rule_engine.match(all_lines,
                          repo_patch,
                          custom_match_callback=custom_match_callback)
        return
Exemplo n.º 6
0
    def patch(self, repository_name, repo_patch):
        # method called during the commit processing. Defines when an alert should be sent
        if re.search(self.JAVA_SOURCE_FILE_PATTERN, repo_patch.filename):
            regex_file_path = os.path.join(os.path.dirname(__file__),
                                           "java.json")
        else:
            regex_file_path = os.path.join(os.path.dirname(__file__),
                                           "js.json")
        logger.debug("filename %s processed", (repo_patch.filename))
        all_lines = []
        all_lines.extend(repo_patch.diff.additions)
        rule_engine = RegexRuleEngine(json.load(open(regex_file_path)))

        def custom_match_callback(alert_config, alert_action, repo_patch,
                                  all_lines, offending_line):
            # method called when the commit matches a regex rule. The actual sending of alerts (via email or bug tracking system) goes here
            self.send_alert(repo_patch, repo_patch.repo_commit,
                            alert_action.get("subject"), offending_line)

        # Each line in the commit goes through the rule engine. If the line matches a regex rule, custom_match_callback() is called
        rule_engine.match(all_lines,
                          repo_patch,
                          custom_match_callback=custom_match_callback)
        return