Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bandit maker #2557

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions autoload/neomake/makers/ft/python.vim
Original file line number Diff line number Diff line change
Expand Up @@ -470,3 +470,21 @@ function! neomake#makers#ft#python#py3kwarn() abort
\ 'errorformat': '%W%f:%l:%c: %m',
\ }
endfunction

function! neomake#makers#ft#python#bandit() abort
return {
\ 'args': [
\ '--silent',
\ '--format=custom',
\ '--msg-template="{relpath}:{line}:{col}: {msg} [{test_id}] ({confidence} confidence) ({severity} severity)"',
\ ],
\ 'output_stream': 'stdout',
\ 'errorformat': '%W"%f:%l:%c: %m"',
\ 'postprocess': function('neomake#makers#ft#python#BanditEntryProcess'),
\ }
endfunction

function! neomake#makers#ft#python#BanditEntryProcess(entry) abort
" Bandit uses 0-indexed columns, vim uses 1-indexed columns
let a:entry.col += 1
endfunction
File renamed without changes.
6 changes: 6 additions & 0 deletions tests/fixtures/python/password.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class User:
username:str
password:str

user = User()
user.password = "hardcoded"
25 changes: 22 additions & 3 deletions tests/ft_python.vader
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,40 @@ Include: include/setup.vader

Execute (python: errorformat):
new
e tests/fixtures/errors.py
e tests/fixtures/python/errors.py
call neomake#config#set('b:ft.python.python.exe', 'python3')
Neomake python
NeomakeTestsWaitForFinishedJobs

AssertEqualQf getloclist(0), [{
\ 'lnum': 1,
\ 'bufnr': bufnr('%'),
\ 'col': 16,
\ 'col': 15,
\ 'valid': 1,
\ 'vcol': 0,
\ 'nr': -1,
\ 'type': 'E',
\ 'pattern': '',
\ 'text': 'unexpected EOF while parsing'}]
\ 'text': '''('' was never closed'}]
bwipe

Execute (bandit: errorformat):
new
e tests/fixtures/python/password.py
call neomake#config#set('b:ft.python.python.exe', 'python3')
Neomake bandit
NeomakeTestsWaitForFinishedJobs

AssertEqualQf getloclist(0), [{
\ 'lnum': 6,
\ 'bufnr': bufnr('%'),
\ 'col': 17,
\ 'valid': 1,
\ 'vcol': 0,
\ 'nr': -1,
\ 'type': 'W',
\ 'pattern': '',
\ 'text': 'Possible hardcoded password: ''hardcoded'' [B105] (MEDIUM confidence) (LOW severity)'}]
bwipe

Execute (python: pylama: errorformat):
Expand Down