Repository: bridgecrewio/checkov

Issue:
"checkov --add-check" failing due to missing templates directory in setup.py
When running `checkov --add-check`, you get an error due to the templates not being installed properly

```
gitpod /workspace/checkov $ checkov --add-check

       _               _              
   ___| |__   ___  ___| | _______   __
  / __| '_ \ / _ \/ __| |/ / _ \ \ / /
 | (__| | | |  __/ (__|   < (_) \ V / 
  \___|_| |_|\___|\___|_|\_\___/ \_/  
                                      
By bridgecrew.io | version: 2.0.744 
What action would you like to take? (add) [add]: 

Enter the title of your new check (without a .py) [MyNewTest]: 

Select a category for this check (application_security, backup_and_recoveryconvention, encryption, general_security, iam, kubernetes, logging, networking, secrets) [iam]: 

Describe what this check does [Ensure that X does Y...]: 

What kind of check would you like to add? (terraform) [terraform]: 

Select the cloud provider this will run on (azure, aws, gcp) [aws]: 

Select a terraform object for this check (data, provider, resource) [resource]: 

Enter the terraform object type [aws_iam_policy]: 

Please ensure you are at the root of the Checkov repository before completing this prompt
Traceback (most recent call last):
  File "/home/gitpod/.pyenv/versions/3.8.12/bin/checkov", line 9, in <module>
    sys.exit(run())
  File "/home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/main.py", line 77, in run
    check.action()
  File "/home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/common/util/prompt.py", line 184, in action
    getattr(self, self.chosen_action)()
  File "/home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/common/util/prompt.py", line 189, in add
    self.populate_templates()
  File "/home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/common/util/prompt.py", line 196, in populate_templates
    tf_unit_test_template = self.template_env().get_template("unittest-terraform.jinja2")
  File "/home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/common/util/prompt.py", line 167, in template_env
    print("jinja2.list_templates: %s" % jinja2.list_templates())
AttributeError: module 'jinja2' has no attribute 'list_templates'
gitpod /workspace/checkov $ 
```
The problem occurs on Mac, regardless of whether checkov is installed using `pip3 install checkov` or `brew install checkov`. I think it will probably occur in other environments as well.

The fix inside checkov's gitpod environment seems to be fairly simple - just copy the template files from the repo into the installed package:
```
gitpod /workspace/checkov $ ls /home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/common/util/templates/
__init__.py  __pycache__
gitpod /workspace/checkov $ cp checkov/common/util/templates/*.jinja2 /home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/site-packages/checkov/common/util/templates/
gitpod /workspace/checkov $ checkov --add-check
       _               _              
   ___| |__   ___  ___| | _______   __
  / __| '_ \ / _ \/ __| |/ / _ \ \ / /
 | (__| | | |  __/ (__|   < (_) \ V / 
  \___|_| |_|\___|\___|_|\_\___/ \_/  
                                      
By bridgecrew.io | version: 2.0.744 
What action would you like to take? (add) [add]: 

Enter the title of your new check (without a .py) [MyNewTest]: 

Select a category for this check (application_security, backup_and_recoveryconvention, encryption, general_security, iam, kubernetes, logging, networking, secrets) [iam]: 

Describe what this check does [Ensure that X does Y...]: 

What kind of check would you like to add? (terraform) [terraform]: 

Select the cloud provider this will run on (azure, aws, gcp) [aws]: 

Select a terraform object for this check (data, provider, resource) [resource]: 

Enter the terraform object type [aws_iam_policy]: 

Please ensure you are at the root of the Checkov repository before completing this prompt
Creating Check MyNewTest.py in /workspace/checkov/checkov/terraform/checks/resource/aws
        Successfully created /workspace/checkov/checkov/terraform/checks/resource/aws/MyNewTest.py
Creating Unit Test Stubs for MyNewTest in /workspace/checkov/tests/terraform/checks/resource/aws
        Successfully created /workspace/checkov/tests/terraform/checks/resource/aws/example_MyNewTest/MyNewTest.tf
        Successfully created /workspace/checkov/tests/terraform/checks/resource/aws/test_MyNewTest.py

Next steps:
        1) Edit your new check located in the checks/ directory listed above
        2) Add both a PASS and FAIL unit test to the newly created unit test under the tests/ directory to show others how to fix failures

gitpod /workspace/checkov $ 
```

I _think_ the problem is simply due to the template files being inadvertently left out of checkov's `setup.py`, and that adding them into the `package_dir` section as below should probably fix things:
```
    package_dir={
        "checkov.terraform.checks.graph_checks": "checkov/terraform/checks/graph_checks",
        "checkov.common.util.templates": "checkov.common.util.templates"
    },
```

However there's a number of directories under `checkov.common` that maybe should also be added to checkov's `setup.py`, and I'm not familiar enough with all of checkov's use cases to know which ones are important


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -84,6 +84,9 @@
             "aws/*.yaml",
             "gcp/*.yaml",
             "azure/*.yaml",
+        ],
+        "checkov.common.util.templates": [
+            "*.jinja2"
         ]
     },
     scripts=["bin/checkov", "bin/checkov.cmd"],


Test patch: