Skip to content

Commit

Permalink
New checker flawfinder for C/C++.
Browse files Browse the repository at this point in the history
  • Loading branch information
lcd047 committed Apr 25, 2017
1 parent 8e82ea7 commit 2cfb29d
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 21 deletions.
94 changes: 74 additions & 20 deletions doc/syntastic-checkers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,13 @@ The following checkers are available for C (filetype "c"):
4. Clang-Tidy...............|syntastic-c-clang_tidy|
5. Cppcheck.................|syntastic-c-cppcheck|
6. cppclean.................|syntastic-c-cppclean|
7. GCC......................|syntastic-c-gcc|
8. make.....................|syntastic-c-make|
9. OClint...................|syntastic-c-oclint|
10. PC-Lint.................|syntastic-c-pc_lint|
11. Sparse..................|syntastic-c-sparse|
12. Splint..................|syntastic-c-splint|
7. Flawfinder...............|syntastic-c-flawfinder|
8. GCC......................|syntastic-c-gcc|
9. make.....................|syntastic-c-make|
10. OClint..................|syntastic-c-oclint|
11. PC-Lint.................|syntastic-c-pc_lint|
12. Sparse..................|syntastic-c-sparse|
13. Splint..................|syntastic-c-splint|

------------------------------------------------------------------------------
1. AVR-GCC *syntastic-c-avrgcc*
Expand Down Expand Up @@ -719,7 +720,33 @@ accepts the standard options described at |syntastic-config-makeprg|.
See also: |syntastic-cpp-cppclean|.

------------------------------------------------------------------------------
7. GCC *syntastic-c-gcc*
7. Flawfinder *syntastic-c-flawfinder*

Name: flawfinder
Maintainer: LCD 47 <lcd047@gmail.com>

"Flawfinder" scans C/C++ source code for possible security weaknesses. See the
project's page for more information:

https://www.dwheeler.com/flawfinder

Checker options~

This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.

Additionally:

*'g:syntastic_c_flawfinder_thres'*
Type: integer
Default: 3
Error threshold. Policy violations with a severity above this value are
highlighted as errors, the others are considered warnings by syntastic.

See also: |syntastic-cpp-flawfinder|.

------------------------------------------------------------------------------
8. GCC *syntastic-c-gcc*

Name: gcc
Maintainer: Gregor Uhlenheuer <kongo2002@gmail.com>
Expand Down Expand Up @@ -816,7 +843,7 @@ executable.
See also: |syntastic-cpp-gcc|.

------------------------------------------------------------------------------
8. make *syntastic-c-make*
9. make *syntastic-c-make*

Name: make
Maintainer: Gregor Uhlenheuer <kongo2002@gmail.com>
Expand All @@ -827,7 +854,7 @@ This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.

------------------------------------------------------------------------------
9. OClint *syntastic-c-oclint*
10. OClint *syntastic-c-oclint*

Name: oclint
Maintainer: "UnCO" Lin <undercooled@lavabit.com>
Expand Down Expand Up @@ -866,7 +893,7 @@ Config files pointed to by 'g:syntastic_oclint_config_file' are then ignored.
See also: |syntastic-cpp-oclint|.

------------------------------------------------------------------------------
10. PC-Lint *syntastic-c-pc_lint*
11. PC-Lint *syntastic-c-pc_lint*

Name: pc_lint
Maintainer: Steve Bragg <steve@empresseffects.com>
Expand All @@ -893,7 +920,7 @@ current directory and in parent directories; first such file found is used.
See also: |syntastic-cpp-pc_lint|.

------------------------------------------------------------------------------
11. Sparse *syntastic-c-sparse*
12. Sparse *syntastic-c-sparse*

Name: sparse
Maintainer: Daniel Walker <dwalker@fifo99.com>
Expand Down Expand Up @@ -925,7 +952,7 @@ your vimrc: >
This allows "Sparse" to read "GCC"'s private include files.

------------------------------------------------------------------------------
12. Splint *syntastic-c-splint*
13. Splint *syntastic-c-splint*

Name: splint
Maintainer: LCD 47 <lcd047@gmail.com>
Expand Down Expand Up @@ -983,10 +1010,11 @@ The following checkers are available for C++ (filetype "cpp"):
4. Cppcheck.................|syntastic-cpp-cppcheck|
5. cppclean.................|syntastic-cpp-cppclean|
6. Cpplint..................|syntastic-cpp-cpplint|
7. GCC......................|syntastic-cpp-gcc|
8. OClint...................|syntastic-cpp-oclint|
9. PC-Lint..................|syntastic-cpp-pc_lint|
10. Vera++..................|syntastic-cpp-verapp|
7. Flawfinder...............|syntastic-cpp-flawfinder|
8. GCC......................|syntastic-cpp-gcc|
9. OClint...................|syntastic-cpp-oclint|
10. PC-Lint.................|syntastic-cpp-pc_lint|
11. Vera++..................|syntastic-cpp-verapp|

------------------------------------------------------------------------------
1. AVR-GCC *syntastic-cpp-avrgcc*
Expand Down Expand Up @@ -1190,7 +1218,33 @@ However, if your "cpplint" was installed with "pip", the script's name is
let g:syntastic_cpp_cpplint_exec = "cpplint"
<
------------------------------------------------------------------------------
7. GCC *syntastic-cpp-gcc*
7. Flawfinder *syntastic-cpp-flawfinder*

Name: flawfinder
Maintainer: LCD 47 <lcd047@gmail.com>

"Flawfinder" scans C/C++ source code for possible security weaknesses. See the
project's page for more information:

https://www.dwheeler.com/flawfinder

Checker options~

This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.

Additionally:

*'g:syntastic_cpp_flawfinder_thres'*
Type: integer
Default: 3
Error threshold. Policy violations with a severity above this value are
highlighted as errors, the others are considered warnings by syntastic.

See also: |syntastic-c-flawfinder|.

------------------------------------------------------------------------------
8. GCC *syntastic-cpp-gcc*

Name: gcc
Maintainer: Gregor Uhlenheuer <kongo2002@gmail.com>
Expand Down Expand Up @@ -1287,7 +1341,7 @@ executable.
See also: |syntastic-c-gcc|.

------------------------------------------------------------------------------
8. OClint *syntastic-cpp-oclint*
9. OClint *syntastic-cpp-oclint*

Name: oclint
Maintainer: "UnCO" Lin <undercooled@lavabit.com>
Expand Down Expand Up @@ -1327,7 +1381,7 @@ Config files pointed to by 'g:syntastic_oclint_config_file' are then ignored.
See also: |syntastic-c-oclint|.

------------------------------------------------------------------------------
9. PC-Lint *syntastic-cpp-pc_lint*
10. PC-Lint *syntastic-cpp-pc_lint*

Name: pc_lint
Maintainer: Steve Bragg <steve@empresseffects.com>
Expand All @@ -1354,7 +1408,7 @@ current directory and in parent directories; first such file found is used.
See also: |syntastic-c-pc_lint|.

------------------------------------------------------------------------------
10. Vera++ *syntastic-cpp-verapp*
11. Vera++ *syntastic-cpp-verapp*

Name: verapp
Maintainer: Lucas Verney <phyks@phyks.me>
Expand Down
2 changes: 1 addition & 1 deletion plugin/syntastic.vim
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START
endif

let g:_SYNTASTIC_VERSION = '3.8.0-49'
let g:_SYNTASTIC_VERSION = '3.8.0-50'
lockvar g:_SYNTASTIC_VERSION

" Sanity checks {{{1
Expand Down
61 changes: 61 additions & 0 deletions syntax_checkers/c/flawfinder.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"============================================================================
"File: flawfinder.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047 at gmail dot com>
"License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================

if exists('g:loaded_syntastic_c_flawfinder_checker')
finish
endif
let g:loaded_syntastic_c_flawfinder_checker = 1

if !exists('g:syntastic_c_flawfinder_sort')
let g:syntastic_c_flawfinder_sort = 1
endif

if !exists('g:syntastic_c_flawfinder_thres')
let g:syntastic_c_flawfinder_thres = 3
endif

let s:save_cpo = &cpo
set cpo&vim

function! SyntaxCheckers_c_flawfinder_GetHighlightRegex(item)
let term = matchstr(a:item['text'], '\m^(\S\+)\s\+\zs\S\+\ze:')
return term !=# '' ? '\V\<' . escape(term, '\') . '\>' : ''
endfunction

function! SyntaxCheckers_c_flawfinder_GetLocList() dict
let makeprg = self.makeprgBuild({
\ 'args_after': '--columns --dataonly --singleline --quiet' })

let errorformat = '%f:%l:%c: [%n] %m'

let loclist = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'subtype': 'Style',
\ 'returns': [0] })

for e in loclist
let e['type'] = e['nr'] < g:syntastic_{self.getFiletype()}_flawfinder_thres ? 'W' : 'E'
let e['nr'] = 0
endfor

return loclist
endfunction

call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'c',
\ 'name': 'flawfinder' })

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: set sw=4 sts=4 et fdm=marker:
26 changes: 26 additions & 0 deletions syntax_checkers/cpp/flawfinder.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"============================================================================
"File: flawfinder.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: Benjamin Bannier <bbannier at gmail dot com>
"License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"============================================================================

if exists('g:loaded_syntastic_cpp_flawfinder_checker')
finish
endif
let g:loaded_syntastic_cpp_flawfinder_checker = 1

if !exists('g:syntastic_cpp_flawfinder_thres')
let g:syntastic_cpp_flawfinder_thres = 3
endif

call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'cpp',
\ 'name': 'flawfinder',
\ 'redirect': 'c/flawfinder'})

" vim: set sw=4 sts=4 et fdm=marker:

0 comments on commit 2cfb29d

Please sign in to comment.