Created
March 1, 2022 19:10
-
-
Save schosterbarak/4d85fadfc91d7a847f6c56aeff1a7493 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from packaging import version as v | |
from checkov.common.models.enums import CheckResult | |
from checkov.terraform.checks.module.base_module_check import BaseModuleCheck | |
class S3ModuleVersionCheck(BaseModuleCheck): | |
def __init__(self): | |
name = "Ensure S3 module is from version 0.47.0" | |
id = "CKV_TF_MODULE_1" | |
supported_resources = ['module'] | |
categories = [] | |
super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources) | |
def scan_module_conf(self, conf): | |
""" | |
Some test for module source | |
:param conf: module call | |
:return: <CheckResult> | |
""" | |
version = conf.get('version', []) | |
if not version: | |
# latest version is used | |
return CheckResult.PASSED | |
else: | |
if v.parse(version[0]) <= v.parse("0.3.4"): | |
# misconfigured version is used | |
return CheckResult.FAILED | |
# good version is used | |
return CheckResult.PASSED | |
scanner = S3ModuleVersionCheck() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment