All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
2 " Author: Christian Gibbons <cgibbons@gmu.edu>
3 " Description: This file defines a handler function that should work for the
4 " flawfinder format with the -CDQS flags.
6 " Swiped this function from the GCC handler. Not sure if needed, but doesn't
8 function! s:RemoveUnicodeQuotes(text) abort
10 let l:text = substitute(l:text, '[`´‘’]', '''', 'g')
11 let l:text = substitute(l:text, '\v\\u2018([^\\]+)\\u2019', '''\1''', 'g')
12 let l:text = substitute(l:text, '[“”]', '"', 'g')
17 function! ale#handlers#flawfinder#HandleFlawfinderFormat(buffer, lines) abort
18 " Look for lines like the following.
20 " <stdin>:12:4: [2] (buffer) char:Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length.
21 " <stdin>:31:4: [1] (buffer) strncpy:Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120).
22 let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)?:? ( \[[0-5]\] [^:]+):(.+)$'
25 for l:match in ale#util#GetMatches(a:lines, l:pattern)
26 " Use severity level to determine if it should be considered a warning
28 let l:severity = str2nr(matchstr(split(l:match[4])[0], '[0-5]'))
31 \ 'lnum': str2nr(l:match[2]),
32 \ 'col': str2nr(l:match[3]),
33 \ 'type': (l:severity < ale#Var(a:buffer, 'c_flawfinder_error_severity'))
35 \ 'text': s:RemoveUnicodeQuotes(join(split(l:match[4])[1:]) . ': ' . l:match[5]),
38 " If the filename is something like <stdin>, <nofile> or -, then
39 " this is an error for the file we checked.
40 if l:match[1] isnot# '-' && l:match[1][0] isnot# '<'
41 let l:item['filename'] = l:match[1]
44 call add(l:output, l:item)