-
Notifications
You must be signed in to change notification settings - Fork 598
/
RuleCondition.py
41 lines (33 loc) · 1.32 KB
/
RuleCondition.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0
"""
from __future__ import annotations
from typing import Any
from cfnlint.helpers import FUNCTION_RULES
from cfnlint.jsonschema import ValidationResult, Validator
from cfnlint.rules.jsonschema.CfnLintJsonSchema import CfnLintJsonSchema
class RuleCondition(CfnLintJsonSchema):
id = "E1702"
shortdesc = "Validate the configuration of Rules RuleCondition"
description = "Make sure the RuleCondition in a Rule is properly configured"
source_url = "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/rules-section-structure.html"
tags = ["rules"]
def __init__(self):
super().__init__(
keywords=["Rules/*/RuleCondition"],
all_matches=True,
)
def validate(
self, validator: Validator, keywords: Any, instance: Any, schema: dict[str, Any]
) -> ValidationResult:
validator = validator.evolve(
context=validator.context.evolve(
functions=list(FUNCTION_RULES) + ["Condition"],
),
function_filter=validator.function_filter.evolve(
add_cfn_lint_keyword=False,
),
schema={"type": "boolean"},
)
yield from self._iter_errors(validator, instance)