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

feat(gitleaks): add initial support for gitleaks #4589

Open
wants to merge 1 commit 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
5 changes: 5 additions & 0 deletions ale_linters/ada/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for Ada files.

call ale#handlers#gitleaks#DefineLinter('ada')
5 changes: 5 additions & 0 deletions ale_linters/ansible/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for ansible files.

call ale#handlers#gitleaks#DefineLinter('ansible')
5 changes: 5 additions & 0 deletions ale_linters/asciidoc/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for ASCIIDoc files.

call ale#handlers#gitleaks#DefineLinter('asciidoc')
5 changes: 5 additions & 0 deletions ale_linters/c/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for C files.

call ale#handlers#gitleaks#DefineLinter('c')
5 changes: 5 additions & 0 deletions ale_linters/cpp/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for C++ files.

call ale#handlers#gitleaks#DefineLinter('cpp')
5 changes: 5 additions & 0 deletions ale_linters/cs/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for C# files.

call ale#handlers#gitleaks#DefineLinter('cs')
5 changes: 5 additions & 0 deletions ale_linters/css/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for CSS files.

call ale#handlers#gitleaks#DefineLinter('css')
5 changes: 5 additions & 0 deletions ale_linters/dockerfile/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for Dockerfiles.

call ale#handlers#gitleaks#DefineLinter('dockerfile')
5 changes: 5 additions & 0 deletions ale_linters/elixir/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for Elixir files.

call ale#handlers#gitleaks#DefineLinter('elixir')
5 changes: 5 additions & 0 deletions ale_linters/go/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for Go files.

call ale#handlers#gitleaks#DefineLinter('go')
5 changes: 5 additions & 0 deletions ale_linters/haskell/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for Haskell files.

call ale#handlers#gitleaks#DefineLinter('haskell')
5 changes: 5 additions & 0 deletions ale_linters/html/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for HTML files.

call ale#handlers#gitleaks#DefineLinter('html')
5 changes: 5 additions & 0 deletions ale_linters/java/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for Java files.

call ale#handlers#gitleaks#DefineLinter('java')
5 changes: 5 additions & 0 deletions ale_linters/javascript/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for JavaScript files.

call ale#handlers#gitleaks#DefineLinter('javascript')
5 changes: 5 additions & 0 deletions ale_linters/json/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for JSON files.

call ale#handlers#gitleaks#DefineLinter('json')
5 changes: 5 additions & 0 deletions ale_linters/lua/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for Lua files.

call ale#handlers#gitleaks#DefineLinter('lua')
5 changes: 5 additions & 0 deletions ale_linters/markdown/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for Markdown files.

call ale#handlers#gitleaks#DefineLinter('markdown')
5 changes: 5 additions & 0 deletions ale_linters/php/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for PHP files.

call ale#handlers#gitleaks#DefineLinter('php')
5 changes: 5 additions & 0 deletions ale_linters/powershell/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for PowerShell files.

call ale#handlers#gitleaks#DefineLinter('powershell')
5 changes: 5 additions & 0 deletions ale_linters/python/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for Python files.

call ale#handlers#gitleaks#DefineLinter('python')
4 changes: 4 additions & 0 deletions ale_linters/rego/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
scriptencoding utf-8
" Description: gitleaks support for rego files.

call ale#handlers#gitleaks#DefineLinter('rego')
5 changes: 5 additions & 0 deletions ale_linters/rst/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for ReStructuredText files.

call ale#handlers#gitleaks#DefineLinter('rst')
5 changes: 5 additions & 0 deletions ale_linters/ruby/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for Ruby files.

call ale#handlers#gitleaks#DefineLinter('ruby')
5 changes: 5 additions & 0 deletions ale_linters/rust/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for Rust files.

call ale#handlers#gitleaks#DefineLinter('rust')
5 changes: 5 additions & 0 deletions ale_linters/scala/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for Scala files.

call ale#handlers#gitleaks#DefineLinter('scala')
5 changes: 5 additions & 0 deletions ale_linters/sh/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for terraform files.

call ale#handlers#gitleaks#DefineLinter('sh')
5 changes: 5 additions & 0 deletions ale_linters/sql/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for SQL files.

call ale#handlers#gitleaks#DefineLinter('sql')
5 changes: 5 additions & 0 deletions ale_linters/swift/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for Swift files.

call ale#handlers#gitleaks#DefineLinter('swift')
5 changes: 5 additions & 0 deletions ale_linters/terraform/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for terraform files.

call ale#handlers#gitleaks#DefineLinter('terraform')
5 changes: 5 additions & 0 deletions ale_linters/tex/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for TeX files.

call ale#handlers#gitleaks#DefineLinter('tex')
5 changes: 5 additions & 0 deletions ale_linters/texinfo/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for TeXInfo files.

call ale#handlers#gitleaks#DefineLinter('texinfo')
5 changes: 5 additions & 0 deletions ale_linters/text/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for general text files.

call ale#handlers#gitleaks#DefineLinter('text')
5 changes: 5 additions & 0 deletions ale_linters/typescript/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for TypeScript files.

call ale#handlers#gitleaks#DefineLinter('typescript')
5 changes: 5 additions & 0 deletions ale_linters/vim/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for Vim files.

call ale#handlers#gitleaks#DefineLinter('vim')
5 changes: 5 additions & 0 deletions ale_linters/vue/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for Vue files.

call ale#handlers#gitleaks#DefineLinter('vue')
5 changes: 5 additions & 0 deletions ale_linters/xhtml/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for XHTML files.

call ale#handlers#gitleaks#DefineLinter('xhtml')
5 changes: 5 additions & 0 deletions ale_linters/yaml/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for YAML files.

call ale#handlers#gitleaks#DefineLinter('yaml')
5 changes: 5 additions & 0 deletions ale_linters/zig/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: gitleaks support for Zig files.

call ale#handlers#gitleaks#DefineLinter('zig')
49 changes: 49 additions & 0 deletions autoload/ale/handlers/gitleaks.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
scriptencoding utf-8
" Author: Peter Benjamin <https://github.com/pbnj>
" Description: Define a handler function for gitleaks

call ale#Set('gitleaks_executable', 'gitleaks')
call ale#Set('gitleaks_options', '')

function! ale#handlers#gitleaks#GetCommand(buffer) abort
return '%e'
\ . ' detect --no-git --no-color --no-banner --redact --verbose --source=%s'
\ . ale#Pad(ale#Var(a:buffer, 'gitleaks_options'))
endfunction

function! ale#handlers#gitleaks#Handle(buffer, lines) abort
" Look for lines like the following:
"
" Finding: ACCESS_KEY_ID=REDACTED
" Secret: REDACTED
" RuleID: generic-api-key
" Entropy: 3.546594
" File: tmp/env
" Line: 1
" Fingerprint: tmp/env:generic-api-key:1
let l:pattern = '\v^Fingerprint: .*:(.*):(\d+)$'
let l:output = []

for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[2] + 0,
\ 'text': l:match[1],
\ 'type': 'E',
\})
endfor

return l:output
endfunction

function! ale#handlers#gitleaks#DefineLinter(filetype) abort
call ale#Set('gitleaks_executable', 'gitleaks')
call ale#Set('gitleaks_options', '')

call ale#linter#Define(a:filetype, {
\ 'name': 'gitleaks',
\ 'executable': {b -> ale#Var(b, 'gitleaks_executable')},
\ 'command': function('ale#handlers#gitleaks#GetCommand'),
\ 'callback': 'ale#handlers#gitleaks#Handle',
\ 'lint_file': 1,
\})
endfunction
7 changes: 7 additions & 0 deletions doc/ale-ada.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ cspell *ale-ada-cspell*

See |ale-cspell-options|


===============================================================================
gcc *ale-ada-gcc*

Expand All @@ -26,6 +27,12 @@ g:ale_ada_gcc_options *g:ale_ada_gcc_options*
This variable can be set to pass additional options to gcc.


===============================================================================
gitleaks *ale-ada-gitleaks*

See |ale-gitleaks-options|


===============================================================================
gnatpp *ale-ada-gnatpp*

Expand Down
16 changes: 11 additions & 5 deletions doc/ale-ansible.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@
ALE Ansible Integration *ale-ansible-options*

===============================================================================
ansible-language-server *ale-ansible-language-server*
gitleaks *ale-ansible-gitleaks*

See |ale-gitleaks-options|

g:ale_ansible_language_server_executable *g:ale_ansible_language_server*
*b:ale_ansible_language_server*

===============================================================================
ansible-language-server *ale-ansible-language-server*


g:ale_ansible_language_server_executable *g:ale_ansible_language_server*
*b:ale_ansible_language_server*

Type: |String|
Default: 'ansible-language-server'

Variable can be used to modify the executable used for ansible language server.


g:ale_ansible_language_server_config *g:ale_ansible_language_server_config*
*b:ale_ansible_language_server_config*
g:ale_ansible_language_server_config *g:ale_ansible_language_server_config*
*b:ale_ansible_language_server_config*

Type: |Dictionary|
Default: '{}'
Expand Down
6 changes: 6 additions & 0 deletions doc/ale-asciidoc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ cspell *ale-asciidoc-cspell*
See |ale-cspell-options|


===============================================================================
gitleaks *ale-asciidoc-gitleaks*

See |ale-gitleaks-options|


===============================================================================
write-good *ale-asciidoc-write-good*

Expand Down
6 changes: 6 additions & 0 deletions doc/ale-c.txt
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,12 @@ g:ale_c_flawfinder_error_severity *g:ale_c_flawfinder_error_severity*
error. This setting also applies to flawfinder for c++.


===============================================================================
gitleaks *ale-c-gitleaks*

See |ale-gitleaks-options|


===============================================================================
uncrustify *ale-c-uncrustify*

Expand Down
6 changes: 6 additions & 0 deletions doc/ale-cpp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,12 @@ g:ale_cpp_flawfinder_options *g:ale-cpp-flawfinder*
This variable can be used to pass extra options into the flawfinder command.


===============================================================================
gitleaks *ale-cpp-gitleaks*

See |ale-gitleaks-options|


===============================================================================
uncrustify *ale-cpp-uncrustify*

Expand Down
6 changes: 6 additions & 0 deletions doc/ale-cs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ g:ale_cs_dotnet_format_options *g:ale_cs_dotnet_format_options*
fixer.


===============================================================================
gitleaks *ale-cs-gitleaks*

See |ale-gitleaks-options|


===============================================================================
mcs *ale-cs-mcs*

Expand Down
6 changes: 6 additions & 0 deletions doc/ale-dockerfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ dprint *ale-dockerfile-dprint*
See |ale-dprint-options| and https://dprint.dev/plugins/dockerfile


===============================================================================
gitleaks *ale-dockerfile-gitleaks*

See |ale-gitleaks-options|


===============================================================================
hadolint *ale-dockerfile-hadolint*

Expand Down
Loading
Loading