Add a mechanism for handling checkers disabled for security.
This commit is contained in:
parent
d75f3e5e8e
commit
4708cdd122
@ -19,7 +19,7 @@ if has('reltime')
|
||||
lockvar! g:_SYNTASTIC_START
|
||||
endif
|
||||
|
||||
let g:_SYNTASTIC_VERSION = '3.6.0-114'
|
||||
let g:_SYNTASTIC_VERSION = '3.6.0-115'
|
||||
lockvar g:_SYNTASTIC_VERSION
|
||||
|
||||
" Sanity checks {{{1
|
||||
|
@ -25,6 +25,10 @@ function! g:SyntasticChecker.New(args) abort " {{{2
|
||||
let prefix = 'SyntaxCheckers_' . newObj._filetype . '_' . newObj._name . '_'
|
||||
endif
|
||||
|
||||
if has_key(a:args, 'enable')
|
||||
let newObj._enable = a:args['enable']
|
||||
endif
|
||||
|
||||
let newObj._locListFunc = function(prefix . 'GetLocList')
|
||||
|
||||
if exists('*' . prefix . 'IsAvailable')
|
||||
@ -78,6 +82,21 @@ endfunction " }}}2
|
||||
|
||||
function! g:SyntasticChecker.getLocListRaw() abort " {{{2
|
||||
let name = self._filetype . '/' . self._name
|
||||
|
||||
if has_key(self, '_enable')
|
||||
let status = syntastic#util#var(self._enable, -1)
|
||||
if status < 0
|
||||
call syntastic#log#error('checker ' . name . ': checks disabled for security reasons; ' .
|
||||
\ 'set g:syntastic_' . self._enable . ' to 1 to override')
|
||||
endif
|
||||
if status <= 0
|
||||
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'getLocList: checker ' . name . ' enabled but not forced')
|
||||
return []
|
||||
else
|
||||
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'getLocList: checker ' . name . ' forced')
|
||||
endif
|
||||
endif
|
||||
|
||||
try
|
||||
let list = self._locListFunc()
|
||||
if self._exec !=# ''
|
||||
@ -152,6 +171,10 @@ function! g:SyntasticChecker.isAvailable() abort " {{{2
|
||||
return self._available
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticChecker.isDisabled() abort " {{{2
|
||||
return has_key(self, '_enable') && syntastic#util#var(self._enable, -1) <= 0
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticChecker.wantSort() abort " {{{2
|
||||
return syntastic#util#var(self._filetype . '_' . self._name . '_sort', 0)
|
||||
endfunction " }}}2
|
||||
|
@ -181,12 +181,18 @@ function! g:SyntasticRegistry.getCheckers(ftalias, hints_list) abort " {{{2
|
||||
\ self._filterCheckersByName(checkers_map, names) : [checkers_map[keys(checkers_map)[0]]]
|
||||
endfunction " }}}2
|
||||
|
||||
" Same as getCheckers(), but keep only the checkers available. This runs the
|
||||
" Same as getCheckers(), but keep only the available checkers. This runs the
|
||||
" corresponding IsAvailable() functions for all checkers.
|
||||
function! g:SyntasticRegistry.getCheckersAvailable(ftalias, hints_list) abort " {{{2
|
||||
return filter(self.getCheckers(a:ftalias, a:hints_list), 'v:val.isAvailable()')
|
||||
endfunction " }}}2
|
||||
|
||||
" Same as getCheckers(), but keep only the checkers tyhat are available and
|
||||
" disabled. This runs the corresponding IsAvailable() functions for all checkers.
|
||||
function! g:SyntasticRegistry.getCheckersDisabled(ftalias, hints_list) abort " {{{2
|
||||
return filter(self.getCheckers(a:ftalias, a:hints_list), 'v:val.isDisabled() && v:val.isAvailable()')
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticRegistry.getKnownFiletypes() abort " {{{2
|
||||
let types = keys(s:_DEFAULT_CHECKERS)
|
||||
|
||||
@ -214,15 +220,18 @@ function! g:SyntasticRegistry.echoInfoFor(ftalias_list) abort " {{{2
|
||||
if len(ft_list) != 1
|
||||
let available = []
|
||||
let active = []
|
||||
let disabled = []
|
||||
|
||||
for ft in ft_list
|
||||
call extend(available, map( self.getNamesOfAvailableCheckers(ft), 'ft . "/" . v:val' ))
|
||||
call extend(active, map( self.getCheckersAvailable(ft, []), 'ft . "/" . v:val.getName()' ))
|
||||
call extend(disabled, map( self.getCheckersDisabled(ft, []), 'ft . "/" . v:val.getName()' ))
|
||||
endfor
|
||||
else
|
||||
let ft = ft_list[0]
|
||||
let available = self.getNamesOfAvailableCheckers(ft)
|
||||
let active = map(self.getCheckersAvailable(ft, []), 'v:val.getName()')
|
||||
let disabled = map(self.getCheckersDisabled(ft, []), 'v:val.getName()')
|
||||
endif
|
||||
|
||||
let cnt = len(available)
|
||||
@ -235,6 +244,13 @@ function! g:SyntasticRegistry.echoInfoFor(ftalias_list) abort " {{{2
|
||||
let cklist = cnt ? join(active) : '-'
|
||||
echomsg 'Currently enabled checker' . plural . ': ' . cklist
|
||||
|
||||
let cnt = len(disabled)
|
||||
let plural = cnt != 1 ? 's' : ''
|
||||
if len(disabled)
|
||||
let cklist = join(sort(disabled))
|
||||
echomsg 'Checker' . plural . ' disabled for security reasons: ' . cklist
|
||||
endif
|
||||
|
||||
" Eclim feels entitled to mess with syntastic's variables {{{3
|
||||
if exists(':EclimValidate') && get(g:, 'EclimFileTypeValidate', 1)
|
||||
let disabled = filter(copy(ft_list), 's:_disabled_by_eclim(v:val)')
|
||||
|
@ -27,12 +27,6 @@ function! SyntaxCheckers_elixir_elixir_IsAvailable() dict
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_elixir_elixir_GetLocList() dict
|
||||
if !syntastic#util#var('enable_elixir_checker', 0)
|
||||
call syntastic#log#error('checker elixir/elixir: checks disabled for security reasons; ' .
|
||||
\ 'set g:syntastic_enable_elixir_checker to 1 to override')
|
||||
return []
|
||||
endif
|
||||
|
||||
let make_options = {}
|
||||
let compile_command = 'elixir'
|
||||
let mix_file = syntastic#util#findFileInParent('mix.exs', expand('%:p:h', 1))
|
||||
@ -53,7 +47,8 @@ endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'elixir',
|
||||
\ 'name': 'elixir'})
|
||||
\ 'name': 'elixir',
|
||||
\ 'enable': 'enable_elixir_checker'})
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
@ -51,12 +51,6 @@ function! SyntaxCheckers_perl_perl_IsAvailable() dict
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_perl_perl_GetLocList() dict
|
||||
if !syntastic#util#var('enable_perl_checker', 0)
|
||||
call syntastic#log#error('checker perl/perl: checks disabled for security reasons; ' .
|
||||
\ 'set g:syntastic_enable_perl_checker to 1 to override')
|
||||
return []
|
||||
endif
|
||||
|
||||
if type(g:syntastic_perl_lib_path) == type('')
|
||||
call syntastic#log#oneTimeWarn('variable g:syntastic_perl_lib_path should be a list')
|
||||
let includes = split(g:syntastic_perl_lib_path, ',')
|
||||
@ -91,7 +85,8 @@ endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'perl',
|
||||
\ 'name': 'perl'})
|
||||
\ 'name': 'perl',
|
||||
\ 'enable': 'enable_perl_checker'})
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
@ -46,11 +46,6 @@ function! SyntaxCheckers_r_svtools_IsAvailable() dict
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_r_svtools_GetLocList() dict
|
||||
if !syntastic#util#var('enable_r_svtools_checker', 0)
|
||||
call syntastic#log#error('checker r/svtools: checks disabled for security reasons; set g:syntastic_enable_r_svtools_checker to 1 to override')
|
||||
return []
|
||||
endif
|
||||
|
||||
let setwd = syntastic#util#isRunningWindows() ? 'setwd("' . escape(getcwd(), '"\') . '"); ' : ''
|
||||
let makeprg = self.getExecEscaped() . ' --slave --restore --no-save' .
|
||||
\ ' -e ' . syntastic#util#shescape(setwd . 'library(svTools); ' .
|
||||
@ -70,7 +65,8 @@ endfunction
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'r',
|
||||
\ 'name': 'svtools',
|
||||
\ 'exec': 'R' })
|
||||
\ 'exec': 'R',
|
||||
\ 'enable': 'enable_r_svtools_checker'})
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
Loading…
x
Reference in New Issue
Block a user