bridgecrewio / checkov

Prevent cloud misconfigurations and find vulnerabilities during build-time in infrastructure as code, container images and open source packages with Checkov by Bridgecrew.
https://www.checkov.io/
Apache License 2.0
7.02k stars 1.1k forks source link

Custom Checks in Python: Adding Guidelines and other metadata #6476

Open charles545587 opened 3 months ago

charles545587 commented 3 months ago

Describe the issue When creating custom checkov checks in YAML, you can add a guideline in the metadata. When trying to do the same in python it is not apparent how you can add a guideline. Can this either be added or documentation showing how to add this metadata.

Examples

In YAML.. there is a guideline in the metadata

metadata: name: "some name" id: "CKV_AWS_CUSTOM_1" category: "GENERAL_SECURITY" guideline: "some url"

In Python

def __init__(self) -> None:
    name = "some name"
    id = "CKV_AWS_CUSTOM_1"
    supported_resources = ["aws_instance"]
    categories = [CheckCategories.GENERAL_SECURITY]
    super().__init__(
        name=name,
        id=id,
        categories=categories,
        supported_resources=supported_resources,
    )

Version (please complete the following information):

Additional context I am sure this is possible, I have tried adding a guideline variable but it does not return the url and seems to return a generic url

gruebel commented 3 months ago

hey @charles545587 you can find an example here https://github.com/bridgecrewio/checkov/blob/main/docs/3.Custom%20Policies/Python%20Custom%20Policies.md#example under b. just pass guideline="xyz" to the super().__init__(...) call.

charles545587 commented 3 months ago

I have added this to my code, it runs without error, but does not return the text provided, instead it continues to return a url link to doc.prismacloud.io