Ejemplo n.º 1
0
 def find_secrets(self):
     print_color('Starting secrets detection', LOG_COLORS.GREEN)
     is_circle = self.is_circle
     branch_name = self.get_branch_name()
     is_forked = re.match(EXTERNAL_PR_REGEX, branch_name) is not None
     if not is_forked:
         secrets_found = self.get_secrets(branch_name, is_circle)
         if secrets_found:
             return True
         else:
             print_color('Finished validating secrets, no secrets were found.', LOG_COLORS.GREEN)
             return False
Ejemplo n.º 2
0
 def get_file_contents(self, file_path, file_extension):
     try:
         # if pdf or README.md file, parse text
         integration_readme = re.match(pattern=PACKS_INTEGRATION_README_REGEX,
                                       string=file_path,
                                       flags=re.IGNORECASE)
         if file_extension == '.pdf':
             file_contents = self.extract_text_from_pdf(file_path)
         elif file_extension == '.md' and integration_readme:
             file_contents = self.extract_text_from_md_html(file_path)
         else:
             # Open each file, read its contents in UTF-8 encoding to avoid unicode characters
             with io.open(file_path, mode="r", encoding="utf-8", errors='ignore') as commited_file:
                 file_contents = commited_file.read()
         file_contents = self.ignore_base64(file_contents)
         return file_contents
     except Exception as ex:
         print("Failed opening file: {}. Exception: {}".format(file_path, ex))
         raise