docs: def scan_file(project, project_dir, binaries, ips, urls, file_audit_list,
                file_audit_project_list, flag_list, ignore_list, hashlist,
                file_ignore, ignore_directories, url_ignore, ip_ignore, apikey):
      """
      Main scan tasks begin
      """
      logger.info("Commencing scan tasks..")
      for root, dirs, files in os.walk(project_dir):
          # Filter out ignored directories from list.
          for items in files:
              full_path = os.path.join(root, items)
              split_path = full_path.split(project + '/', 1)[-1]
              # Check for Blacklisted file names
              if not any(x in split_path for x in ignore_directories):
                  if file_audit_list.search(full_path) and not \
                          file_audit_project_list.search(full_path):
                      match = file_audit_list.search(full_path)
                      logger.error('Blacklisted filename: %s', full_path)
                      logger.error('Matched String: %s', match.group())
                      with open(reports_dir + "file-names_" + project + ".log",
                                "a") as gate_report:
                                  gate_report. \
                                      write('Blacklisted filename: {0}\n'.
                                            format(full_path))
                                  gate_report. \
                                      write('Matched String: {0}'.
                                            format(match.group()))
  
                  # Check if Binary is whitelisted
                  if is_binary(full_path) and binaries:
  
                      split_path = full_path.split(project + '/', 1)[-1]
                      binary_hash = hashlist.binary_hash(project, split_path)
                      with open(full_path, 'rb') as afile:
                          hasher = hashlib.sha256()
                          buf = afile.read()
                          hasher.update(buf)
                          sha256hash = hasher.hexdigest()
                      if sha256hash in binary_hash:
                          logger.info('Found matching file hash for: %s', full_path)
                          logger.info('No further action needed for: %s', full_path)
                      else:
                          logger.info('Non Whitelisted Binary file: %s', full_path)
                          scan_binary(full_path, split_path, project, sha256hash, apikey)
  
                  else:
                      if not items.endswith(tuple(file_ignore)) and not is_binary(full_path):
                          try:
                              fo = open(full_path, 'r')
                              lines = fo.readlines()
                          except IOError:
                              logger.error('%s does not exist', full_path)
  
                          for line in lines:
                              # Find IP Addresses and send for report to Virus Total
                              if ips:
                                  ipaddr = re.findall(r'(?:\d{1,3}\.)+(?:\d{1,3})', line)
                                  if ipaddr:
                                      ipaddr = ipaddr[0]
                                      if re.search(ip_ignore, ipaddr):
                                          logger.info('%s is in IP ignore list.', ipaddr)
                                      else:
                                          try:
                                              ipaddress.ip_address(ipaddr).is_global
                                              scan_ipaddr(ipaddr, line, project, split_path, apikey)
                                          except:
                                              pass  # Ok to pass here, as this captures the odd string which is nt an IP Address
  
                              # Check for URLs and send for report to Virus Total
                              if urls:
                                  url = re.search("(?P<url>https?://[^\s]+)", line) or re.search("(?P<url>www[^\s]+)", line)
                                  if url:
                                      url = url.group("url")
                                      if re.search(url_ignore, url):
                                          logger.info('%s is in URL ignore list.', url)
                                      else:
                                          scan_url(url, line, project, split_path, apikey)
  
                              # Check flagged content in files
                              for key, value in flag_list.items():
                                  regex = value['regex']
                                  desc = value['desc']
                                  if re.search(regex, line) and not re.search(ignore_list, line):
                                      logger.error('File contains violation: %s', full_path)
                                      logger.error('Flagged Content: %s', line.rstrip())
                                      logger.error('Matched Regular Exp: %s', regex)
                                      logger.error('Rationale: %s', desc.rstrip())
                                      with open(reports_dir + "contents-" + project + ".log", "a") as gate_report:
                                          gate_report.write('File contains violation: {0}\n'.format(full_path))
                                          gate_report.write('Flagged Content: {0}'.format(line))
                                          gate_report.write('Matched Regular Exp: {0}'.format(regex))
                                          gate_report.write('Rationale: {0}\n'.format(desc.rstrip()))