Compare commits

...
5 Commits
Author SHA1 Message Date
w0rp 9acafa8018 Close #5019 - Mention Sponsorship page
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
2025-08-14 20:26:42 +01:00
w0rp 11cbd96667 Stop oelint_adv functions possibly conflicting 2025-08-14 20:21:50 +01:00
offa ce1ee7c598 Update oelint pattern (#5016)
* Update oelint pattern
* Handle optional branch output
2025-08-14 20:18:00 +01:00
rymdbarandcos a083d58c7f Fix lua_language_server_config variable name (#5025)
Since added in commit f2a21c9, the implementation and documentation has
differed in their naming. The latter has had an additional lua_-prefix.

With this fix, setting the variable as documented actually results in a
'workspace/didChangeConfiguration' method being executed on the luals.

Adding a reference to the documentation of which configurations the lsp
supports doesn't hurt, so that's done too.

Co-authored-by: cos <cos>
2025-08-14 20:16:18 +01:00
w0rpandjhandsel 3539f39d4d Add checkov linter for cloudformation
Co-Authored-By: jhandsel <64368631+jhandsel@users.noreply.github.com>
2025-08-14 17:34:25 +01:00
11 changed files with 248 additions and 16 deletions

No files matched your search

+8
View File
@@ -61,6 +61,14 @@ linting and fixing of code in Vim. ALE offers the following.
* Windows support * Windows support
* Well-integrated with other plugins * Well-integrated with other plugins
## Sponsorship
If you would like to donate to Dense Analysis to say thank you for ALE, please
consider visiting our [Sponsorship page](https://denseanalysis.org/sponsors/).
Funds will be used to pay for our hosting fees and research. Whilst visiting our
site, please feel free to make use of our educational resources and other
recommended tools.
## Supported Languages and Tools ## Supported Languages and Tools
ALE supports a wide variety of languages and tools. See the ALE supports a wide variety of languages and tools. See the
+18 -11
View File
@@ -5,6 +5,14 @@ call ale#Set('bitbake_oelint_adv_executable', 'oelint-adv')
call ale#Set('bitbake_oelint_adv_options', '') call ale#Set('bitbake_oelint_adv_options', '')
call ale#Set('bitbake_oelint_adv_config', '.oelint.cfg') call ale#Set('bitbake_oelint_adv_config', '.oelint.cfg')
function! ale_linters#bitbake#oelint_adv#StripAnsiCodes(line) abort
return substitute(a:line, '\e\[[0-9;]\+[mK]', '', 'g')
endfunction
function! ale_linters#bitbake#oelint_adv#RemoveBranch(line) abort
return substitute(a:line, ' \[branch:.*', '', 'g')
endfunction
function! ale_linters#bitbake#oelint_adv#Command(buffer) abort function! ale_linters#bitbake#oelint_adv#Command(buffer) abort
let l:config_file = ale#path#FindNearestFile(a:buffer, let l:config_file = ale#path#FindNearestFile(a:buffer,
\ ale#Var(a:buffer, 'bitbake_oelint_adv_config')) \ ale#Var(a:buffer, 'bitbake_oelint_adv_config'))
@@ -17,26 +25,25 @@ function! ale_linters#bitbake#oelint_adv#Command(buffer) abort
endfunction endfunction
function! ale_linters#bitbake#oelint_adv#Handle(buffer, lines) abort function! ale_linters#bitbake#oelint_adv#Handle(buffer, lines) abort
let l:pattern = '\v^(.+):(.+):(.+):(.+):(.+)$' let l:pattern = '\v^(.{-}):(.{-}):(.{-}):(.{-}):(.{-})$'
let l:output = [] let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern) for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, { call add(l:output, {
\ 'lnum': str2nr(l:match[2]), \ 'lnum': str2nr(l:match[2]),
\ 'type': l:match[3] is# 'error' \ 'type': l:match[3] is# 'error'
\ ? 'E' : (l:match[3] is# 'warning' ? 'W' : 'I'), \ ? 'E'
\ 'text': StripAnsiCodes(l:match[5]), \ : (l:match[3] is# 'warning' ? 'W' : 'I'),
\ 'code': l:match[4] \ 'text': ale_linters#bitbake#oelint_adv#RemoveBranch(
\ }) \ ale_linters#bitbake#oelint_adv#StripAnsiCodes(l:match[5])
\ ),
\ 'code': l:match[4],
\})
endfor endfor
return l:output return l:output
endfunction endfunction
function! StripAnsiCodes(line) abort
return substitute(a:line, '\e\[[0-9;]\+[mK]', '', 'g')
endfunction
call ale#linter#Define('bitbake', { call ale#linter#Define('bitbake', {
\ 'name': 'oelint_adv', \ 'name': 'oelint_adv',
\ 'output_stream': 'both', \ 'output_stream': 'both',
+41
View File
@@ -0,0 +1,41 @@
" Author: J. Handsel <jennpbc@posteo.net>, Thyme-87 <thyme-87@posteo.me>
" Description: use checkov for providing warnings for cloudformation via ale
call ale#Set('cloudformation_checkov_executable', 'checkov')
call ale#Set('cloudformation_checkov_options', '')
function! ale_linters#cloudformation#checkov#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'cloudformation_checkov_executable')
endfunction
function! ale_linters#cloudformation#checkov#GetCommand(buffer) abort
return '%e ' . '-f %t -o json --quiet --framework cloudformation ' . ale#Var(a:buffer, 'cloudformation_checkov_options')
endfunction
function! ale_linters#cloudformation#checkov#Handle(buffer, lines) abort
let l:output = []
let l:results = get(get(ale#util#FuzzyJSONDecode(a:lines, {}), 'results', []), 'failed_checks', [])
for l:violation in l:results
call add(l:output, {
\ 'filename': l:violation['file_path'],
\ 'lnum': l:violation['file_line_range'][0],
\ 'end_lnum': l:violation['file_line_range'][1],
\ 'text': l:violation['check_name'] . ' [' . l:violation['check_id'] . ']',
\ 'detail': l:violation['check_id'] . ': ' . l:violation['check_name'] . "\n" .
\ 'For more information, see: '. l:violation['guideline'],
\ 'type': 'W',
\ })
endfor
return l:output
endfunction
call ale#linter#Define('cloudformation', {
\ 'name': 'checkov',
\ 'output_stream': 'stdout',
\ 'executable': function('ale_linters#cloudformation#checkov#GetExecutable'),
\ 'command': function('ale_linters#cloudformation#checkov#GetCommand'),
\ 'callback': 'ale_linters#cloudformation#checkov#Handle',
\})
+46
View File
@@ -41,5 +41,51 @@ Just put the following in `ftdetect/cloudformation.vim`: >
This will get both cloudformation and yaml linters to work on any file with This will get both cloudformation and yaml linters to work on any file with
`.template.yaml` extension. `.template.yaml` extension.
===============================================================================
checkov *ale-cloudformation-checkov*
*ale-options.cloudformation_checkov_executable*
*g:ale_cloudformation_checkov_executable*
*b:ale_cloudformation_checkov_executable*
cloudformation_checkov_executable
g:ale_cloudformation_checkov_executable
Type: |String|
Default: `'checkov'`
This variable can be changed to use a different executable for checkov.
*ale-options.cloudformation_checkov_options*
*g:ale_cloudformation_checkov_options*
*b:ale_cloudformation_checkov_options*
cloudformation_checkov_options
g:ale_cloudformation_checkov_options
Type: |String|
Default: `''`
This variable can be changed to set additional options for checkov.
-------------------------------------------------------------------------------
Configuration
To get chekov to work with cloudformation files (rather than general yaml
files) we must set the buffer |filetype| to `yaml.cloudformation`. This
causes ALE to lint the file with linters configured for cloudformation and
YAML files.
One option is to put the following in `ftdetect/cloudformation.vim`: >
au BufRead,BufNewFile *.template.yaml set filetype=yaml.cloudformation
This will get both cloudformation and yaml linters to work on any file with
`.template.yaml` extension.
Another option is to check for the presence of 'AWSTemplateFormatVersion' in
the yaml file: >
au BufRead,BufNewFile *.yaml,*.yml if search('AWSTemplateFormatVersion', 'nw') | set filetype=yaml.cloudformation | endif
<
=============================================================================== ===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
+10 -5
View File
@@ -49,17 +49,22 @@ g:ale_lua_language_server_executable
If you have compiled the language server yourself in `/some/path`, the path If you have compiled the language server yourself in `/some/path`, the path
will be `'/some/path/bin/lua-language-server'`. will be `'/some/path/bin/lua-language-server'`.
*ale-options.lua_lua_language_server_config* *ale-options.lua_language_server_config*
*g:ale_lua_lua_language_server_config* *g:ale_lua_language_server_config*
*b:ale_lua_lua_language_server_config* *b:ale_lua_language_server_config*
lua_lua_language_server_config lua_language_server_config
g:ale_lua_lua_language_server_config g:ale_lua_language_server_config
Type: |Dictionary| Type: |Dictionary|
Default: `{}` Default: `{}`
Dictionary containing configuration settings that will be passed to the Dictionary containing configuration settings that will be passed to the
language server. language server.
For available configuration parameters, see `Settings` on the luals wiki:
https://luals.github.io/wiki/settings/
=============================================================================== ===============================================================================
luac *ale-lua-luac* luac *ale-lua-luac*
@@ -121,6 +121,7 @@ Notes:
* `joker` * `joker`
* CloudFormation * CloudFormation
* `cfn-python-lint` * `cfn-python-lint`
* `checkov`
* CMake * CMake
* `cmake-format` * `cmake-format`
* `cmake-lint` * `cmake-lint`
+1
View File
@@ -3419,6 +3419,7 @@ documented in additional help files.
joker.................................|ale-clojure-joker| joker.................................|ale-clojure-joker|
cloudformation..........................|ale-cloudformation-options| cloudformation..........................|ale-cloudformation-options|
cfn-python-lint.......................|ale-cloudformation-cfn-python-lint| cfn-python-lint.......................|ale-cloudformation-cfn-python-lint|
checkov...............................|ale-cloudformation-checkov|
cmake...................................|ale-cmake-options| cmake...................................|ale-cmake-options|
cmakelint.............................|ale-cmake-cmakelint| cmakelint.............................|ale-cmake-cmakelint|
cmake-lint............................|ale-cmake-cmake-lint| cmake-lint............................|ale-cmake-cmake-lint|
+1
View File
@@ -131,6 +131,7 @@ formatting.
* [joker](https://github.com/candid82/joker) * [joker](https://github.com/candid82/joker)
* CloudFormation * CloudFormation
* [cfn-python-lint](https://github.com/awslabs/cfn-python-lint) * [cfn-python-lint](https://github.com/awslabs/cfn-python-lint)
* [checkov](https://github.com/bridgecrewio/checkov)
* CMake * CMake
* [cmake-format](https://github.com/cheshirekow/cmake_format) * [cmake-format](https://github.com/cheshirekow/cmake_format)
* [cmake-lint](https://github.com/cheshirekow/cmake_format) * [cmake-lint](https://github.com/cheshirekow/cmake_format)
@@ -7,6 +7,27 @@ After:
call ale#linter#Reset() call ale#linter#Reset()
Execute(The oelint_adv handler should handle warnings): Execute(The oelint_adv handler should handle warnings):
AssertEqual
\ [
\ {
\ 'lnum': 1234,
\ 'type': 'I',
\ 'code': 'oelint.var.suggestedvar.BUGTRACKER',
\ 'text': 'Variable ''BUGTRACKER'' should be set',
\ },
\ {
\ 'lnum': 17,
\ 'type': 'E',
\ 'code': 'oelint.var.mandatoryvar.DESCRIPTION',
\ 'text': 'Variable ''DESCRIPTION'' should be set',
\ },
\ ],
\ ale_linters#bitbake#oelint_adv#Handle(1, [
\ '/meta-x/recipes-y/example/example_1.0.bb:1234:info:oelint.var.suggestedvar.BUGTRACKER:Variable ''BUGTRACKER'' should be set [branch:true]',
\ 'example2_1.1.bb:17:error:oelint.var.mandatoryvar.DESCRIPTION:Variable ''DESCRIPTION'' should be set [branch:true]',
\ ])
Execute(The oelint_adv handler should handle warnings without branch message):
AssertEqual AssertEqual
\ [ \ [
\ { \ {
@@ -0,0 +1,86 @@
Before:
runtime ale_linters/cloudformation/checkov.vim
call ale#test#SetFilename('sample.template.yaml')
After:
call ale#linter#Reset()
Execute(Handle output for no findings correctly):
AssertEqual
\ [],
\ ale_linters#cloudformation#checkov#Handle(bufnr(''), [
\'{',
\' "passed": 0,',
\' "failed": 0,',
\' "skipped": 0,',
\' "parsing_errors": 0,',
\' "resource_count": 0,',
\' "checkov_version": "3.2.415"',
\'}'
\])
Execute(Handle output for all tests passed):
AssertEqual
\ [],
\ ale_linters#cloudformation#checkov#Handle(bufnr(''), [
\'{',
\' "check_type": "cloudformation",',
\' "results": {',
\' "failed_checks": []',
\' },',
\' "summary": {',
\' "passed": 18,',
\' "failed": 0,',
\' "skipped": 0,',
\' "parsing_errors": 0,',
\' "resource_count": 3,',
\' "checkov_version": "3.2.415"',
\' }',
\'}'
\])
Execute(The JSON output of checkov should be handled correctly):
AssertEqual
\ [
\ {
\ 'filename': '/sample.template.yaml',
\ 'lnum': 57,
\ 'end_lnum': 79,
\ 'text': 'Ensure that AWS Lambda function is configured for a Dead Letter Queue(DLQ) [CKV_AWS_116]',
\ 'detail': "CKV_AWS_116: Ensure that AWS Lambda function is configured for a Dead Letter Queue(DLQ)\n" .
\ 'For more information, see: https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/ensure-that-aws-lambda-function-is-configured-for-a-dead-letter-queue-dlq',
\ 'type': 'W',
\ }
\ ],
\ ale_linters#cloudformation#checkov#Handle(bufnr(''), [
\'{',
\' "check_type": "cloudformation",',
\' "results": {',
\' "failed_checks": [',
\' {',
\' "check_id": "CKV_AWS_116",',
\' "bc_check_id": "BC_AWS_GENERAL_64",',
\' "check_name": "Ensure that AWS Lambda function is configured for a Dead Letter Queue(DLQ)",',
\' "check_result": {',
\' "result": "FAILED",',
\' "evaluated_keys": [',
\' "Properties/DeadLetterQueue/TargetArn"',
\' ]',
\' },',
\' "file_path": "/sample.template.yaml",',
\' "repo_file_path": "/sample.template.yaml",',
\' "file_line_range": [',
\' 57,',
\' 79',
\' ],',
\' "resource": "AWS::Serverless::Function.FunctionName",',
\' "evaluations": {},',
\' "check_class": "checkov.cloudformation.checks.resource.aws.LambdaDLQConfigured",',
\' "entity_tags": null,',
\' "resource_address": null,',
\' "guideline": "https://docs.prismacloud.io/en/enterprise-edition/policy-reference/aws-policies/aws-general-policies/ensure-that-aws-lambda-function-is-configured-for-a-dead-letter-queue-dlq"',
\' }',
\' ]',
\' }',
\'}'
\ ])
@@ -0,0 +1,15 @@
Before:
call ale#assert#SetUpLinterTest('cloudformation', 'checkov')
After:
call ale#assert#TearDownLinterTest()
Execute(The default command should be direct):
AssertLinter 'checkov',
\ ale#Escape('checkov') . ' -f %t -o json --quiet --framework cloudformation '
Execute(It should be possible to override the default command):
let b:ale_cloudformation_checkov_executable = '/bin/other/checkov'
AssertLinter '/bin/other/checkov',
\ ale#Escape('/bin/other/checkov') . ' -f %t -o json --quiet --framework cloudformation '