(self, result: Result)
return result_buf.getvalue()
Build readable message on the found incidents.

        :param result: The result from scanning API
        :param nb_lines: The number of lines to display before and after a secret in the
        patch
        :param show_secrets: Option to show secrets value
        :return: The formatted message to display
Build readable message on the found incidents.
Build readable message on the found incidents .
def process_result(self, result: Result) -> str:
        """
        Build readable message on the found incidents.

        :param result: The result from scanning API
        :param nb_lines: The number of lines to display before and after a secret in the
        patch
        :param show_secrets: Option to show secrets value
        :return: The formatted message to display
        """
        result_buf = StringIO()
        policy_breaks = result.scan.policy_breaks
        is_patch = result.filemode != Filemode.FILE
        sha_dict = leak_dictionary_by_ignore_sha(policy_breaks)

        if self.show_secrets:
            content = result.content
        else:
            content = censor_content(result.content, result.scan.policy_breaks)

        lines = get_lines_from_content(
            content, result.filemode, is_patch, self.show_secrets
        )
        padding = get_padding(lines)
        offset = get_offset(padding, is_patch)

        if len(lines) == 0:
            raise click.ClickException("Parsing of scan result failed.")

        result_buf.write(file_info(result.filename, len(sha_dict)))

        for issue_n, (ignore_sha, policy_breaks) in enumerate(sha_dict.items(), 1):
            result_buf.write(policy_break_header(issue_n, policy_breaks, ignore_sha))
            for policy_break in policy_breaks:
                policy_break.matches = TextOutputHandler.make_matches(
                    policy_break.matches, lines, is_patch
                )

            if policy_breaks[0].policy == "Secrets detection":
                result_buf.write(
                    leak_message_located(
                        flatten_policy_breaks_by_line(policy_breaks),
                        lines,
                        padding,
                        offset,
                        self.nb_lines,
                        clip_long_lines=not self.verbose,
                    )
                )

        return result_buf.getvalue()
def process_result ( self , result : Result ) -> str : result_buf = StringIO ( ) policy_breaks = result . scan . policy_breaks is_patch = result . filemode != Filemode . FILE sha_dict = leak_dictionary_by_ignore_sha ( policy_breaks ) if self . show_secrets : content = result . content else : content = censor_content ( result . content , result . scan . policy_breaks ) lines = get_lines_from_content ( content , result . filemode , is_patch , self . show_secrets ) padding = get_padding ( lines ) offset = get_offset ( padding , is_patch ) if len ( lines ) == 0 : raise click . ClickException ( "Parsing of scan result failed." ) result_buf . write ( file_info ( result . filename , len ( sha_dict ) ) ) for issue_n , ( ignore_sha , policy_breaks ) in enumerate ( sha_dict . items ( ) , 1 ) : result_buf . write ( policy_break_header ( issue_n , policy_breaks , ignore_sha ) ) for policy_break in policy_breaks : policy_break . matches = TextOutputHandler . make_matches ( policy_break . matches , lines , is_patch ) if policy_breaks [ 0 ] . policy == "Secrets detection" : result_buf . write ( leak_message_located ( flatten_policy_breaks_by_line ( policy_breaks ) , lines , padding , offset , self . nb_lines , clip_long_lines = not self . verbose , ) ) return result_buf . getvalue ( )