Fix awk linter and security concerns. (#1411)

* Fixed (g)awk linter

 * Made it secure, albeit less useful.
 * Added gawk handler; the cpplint one was not working?
 * Added gawk handler test.
 * added warning to gawk handler.
 * added gawk command callback test
 * added comment about --source

* added back optional commandline option
This commit is contained in:
Anthony DeDominic
2018-03-14 13:46:57 -04:00
committed by w0rp
parent 05d39bc1a9
commit 92e6e4d1ba
4 changed files with 109 additions and 1 deletions

View File

@@ -12,7 +12,11 @@ function! ale_linters#awk#gawk#GetExecutable(buffer) abort
endfunction
function! ale_linters#awk#gawk#GetCommand(buffer) abort
" note the --source 'BEGIN ...' is to prevent
" gawk from attempting to execute the body of the script
" it is linting.
return ale_linters#awk#gawk#GetExecutable(a:buffer)
\ . " --source 'BEGIN { exit } END { exit 1 }'"
\ . ' ' . ale#Var(a:buffer, 'awk_gawk_options')
\ . ' ' . '-f %t --lint /dev/null'
endfunction
@@ -21,6 +25,6 @@ call ale#linter#Define('awk', {
\ 'name': 'gawk',
\ 'executable_callback': 'ale_linters#awk#gawk#GetExecutable',
\ 'command_callback': 'ale_linters#awk#gawk#GetCommand',
\ 'callback': 'ale#handlers#cpplint#HandleCppLintFormat',
\ 'callback': 'ale#handlers#gawk#HandleGawkFormat',
\ 'output_stream': 'both'
\})