flawfinder: Improve error-handling. Warn of non-existent files (esp long dash)

- Provide a separate warning for filenames listed on the command line
    but do not actually exist.
  - Provide a SPECIAL warning for filenames that begin with
    the UTF-8 sequence of long dashes. Users might
    copy-and-paste from the pdf version of the man page, and that might
    produce long dashes (instead of normal dashes).  This problem
    can be hard to detect, so specially warning about it should help.
This commit is contained in:
David A. Wheeler 2014-08-03 15:29:05 -04:00
parent 547d1f3e17
commit 5156456c79
1 changed files with 6 additions and 0 deletions

View File

@ -1596,6 +1596,12 @@ def process_file_args(files, patch_infos):
# built-in doesn't give us enough control over symbolic links.
# So, we'll walk the filesystem hierarchy ourselves:
maybe_process_file(f, patch_infos)
elif not os.path.exists(f):
if not quiet:
if h(f).startswith("\342\210\222"):
print_warning("Skipping non-existent filename starting with UTF-8 long dash " + h(f))
else:
print_warning("Skipping non-existent file " + h(f))
else:
if not quiet: print_warning("Skipping non-regular file " + h(f))