mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
Add checkov linter for cloudformation
Co-Authored-By: jhandsel <64368631+jhandsel@users.noreply.github.com>
This commit is contained in:
86
test/handler/test_cloudformation_checkov_handler.vader
Normal file
86
test/handler/test_cloudformation_checkov_handler.vader
Normal file
@@ -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"',
|
||||
\' }',
|
||||
\' ]',
|
||||
\' }',
|
||||
\'}'
|
||||
\ ])
|
||||
15
test/linter/test_cloudformation_checkov.vader
Normal file
15
test/linter/test_cloudformation_checkov.vader
Normal file
@@ -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 '
|
||||
|
||||
Reference in New Issue
Block a user