-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Write base docs in mkdocs * Add docs requirements * Add readthedocs config file * Fix docs url * Automatic Rule documentation * Remove unneded files * Improve rule formatting * Linter fix * Add noqa to * imports handled by __all__ * Linter fixes * More linter fixes * Update README.md * Update README.md
- Loading branch information
1 parent
0ab81d3
commit 7cd15dc
Showing
33 changed files
with
260 additions
and
90 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# .readthedocs.yml | ||
# Read the Docs configuration file | ||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details | ||
|
||
# Required | ||
version: 2 | ||
|
||
# Build documentation with MkDocs | ||
mkdocs: | ||
configuration: mkdocs.yml | ||
|
||
# Optionally build your docs in additional formats such as PDF and ePub | ||
formats: all | ||
|
||
# Optionally set the version of Python and requirements required to build your docs | ||
python: | ||
version: 3.7 | ||
install: | ||
- requirements: docs/requirements.txt |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,10 @@ | ||
<img src="docs/images/logo.png" width="200"> | ||
<img src="docs/img/logo.png" width="200"> | ||
|
||
# CFripper | ||
|
||
[![Build Status](https://travis-ci.org/Skyscanner/cfripper.svg?branch=master)](https://travis-ci.org/Skyscanner/cfripper) | ||
[![PyPI version](https://badge.fury.io/py/cfripper.svg)](https://badge.fury.io/py/cfripper) | ||
|
||
Lambda function to "rip apart" a CloudFormation template and check it for security compliance. | ||
Library designed to be used as part of a Lambda function to "rip apart" a CloudFormation template and check it for security compliance. | ||
|
||
## Sample pipeline with CFripper | ||
|
||
CFripper is a Python tool that aims to prevent vulnerabilities from getting to production infrastructure through vulnerable CloudFormation scripts. As with the other security tools that we use at Skyscanner, CFripper is part of the CI/CD pipeline. It runs just before a CloudFormation stack is deployed or updated and if the CloudFormation script fails to pass the security check it fails the deployment and notifies the team that owns the stack. This is an example of how you might set up CFripper as an AWS Lambda: | ||
![CFripperPipeline](docs/images/cfripper.png) | ||
|
||
Another approach that we use at Skyscanner is the Infrastructure as Code pipeline. Code is built and tested using drone and then our internal CD tool deals with calling CFripper to validate the script and then trigger the deployment of the infrastructure provided that the CloudFormation script is valid: | ||
![CFripperPipeline](docs/images/cfripper2.png) | ||
|
||
## Lambda Installation | ||
|
||
To install the lambda first generate the zip package using `make lambda.zip`. | ||
The runtime of the environment should be `Python 3.7` and the handler `cfripper.main.handler`. | ||
|
||
## Developing | ||
|
||
The project comes with a set of commands you can use to run common operations: | ||
|
||
- `make install`: Installs run time dependencies. | ||
- `make install-dev`: Installs dev dependencies together with run time dependencies. | ||
- `make freeze`: Freezes dependencies from `setup.py` to `requirements.txt` (including transitive ones). | ||
- `make lint`: Runs static analysis. | ||
- `make coverage`: Runs all tests collecting coverage. | ||
- `make test`: Runs `lint` and `component`. | ||
|
||
|
||
## Running the simulator | ||
|
||
To run the simulator make sure you have the dependencies installed using `make install-dev` and run `python simulator/simulator.py` | ||
You can add more scripts to the test set in `simulator/test_cf_scripts`. | ||
Be sure to also add them in the `scripts` dictionary with their name, service name and project so that the simulator can pick them up. | ||
|
||
## Custom Rules | ||
|
||
To add custom rules first extend the [Rule](cfripper/rule_processor.py) class. Then implement the `invoke` method by adding your logic. | ||
|
||
CFripper uses [pycfmodel](https://github.com/Skyscanner/pycfmodel) to create a Python model of the CloudFormation script. This model is passed to the `invoke` function as the `resources` parameter. You can use the model's iterate through the resources and other objects of the model and use the helper functions to perform various checks. Look at the [current rules](cfripper/rules) for examples. | ||
|
||
![CFripperRule](docs/images/rule.png) | ||
|
||
## Monitor Mode | ||
By default, each rule has `MONITOR_MODE` set to false. Monitor model will return the failed rules in another field in the response, instead in the main "failed rules". This way new rules can be tested before they are removed from monitor mode and start triggering alarms. | ||
|
||
## Contributing | ||
|
||
See [CONTRIBUTING.md](CONTRIBUTING.md) file to add a contribution. | ||
|
||
## Attribution | ||
Some of our rules were inspired by [cfn-nag](https://github.com/stelligent/cfn_nag). We also use their example scripts in our test cases. | ||
Docs available in https://cfripper.readthedocs.io/ |
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../CODE_OF_CONDUCT.md |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../CONTRIBUTING.md |
Binary file not shown.
Binary file not shown.
File renamed without changes
File renamed without changes
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<img src="img/logo.png" width="200"> | ||
|
||
# CFripper | ||
|
||
[![Build Status](https://travis-ci.org/Skyscanner/cfripper.svg?branch=master)](https://travis-ci.org/Skyscanner/cfripper) | ||
[![PyPI version](https://badge.fury.io/py/cfripper.svg)](https://badge.fury.io/py/cfripper) | ||
|
||
Lambda function to "rip apart" a CloudFormation template and check it for security compliance. | ||
|
||
## Sample pipeline with CFripper | ||
|
||
CFripper is a Python tool that aims to prevent vulnerabilities from getting to production infrastructure through vulnerable CloudFormation scripts. As with the other security tools that we use at Skyscanner, CFripper is part of the CI/CD pipeline. It runs just before a CloudFormation stack is deployed or updated and if the CloudFormation script fails to pass the security check it fails the deployment and notifies the team that owns the stack. This is an example of how you might set up CFripper as an AWS Lambda: | ||
![CFripperPipeline](img/cfripper.png) | ||
|
||
Another approach that we use at Skyscanner is the Infrastructure as Code pipeline. Code is built and tested using drone and then our internal CD tool deals with calling CFripper to validate the script and then trigger the deployment of the infrastructure provided that the CloudFormation script is valid: | ||
![CFripperPipeline](img/cfripper2.png) | ||
|
||
## Lambda Installation | ||
|
||
To install the lambda first generate the zip package using `make lambda.zip`. | ||
The runtime of the environment should be `Python 3.7` and the handler `cfripper.main.handler`. | ||
|
||
## Developing | ||
|
||
The project comes with a set of commands you can use to run common operations: | ||
|
||
- `make install`: Installs run time dependencies. | ||
- `make install-dev`: Installs dev dependencies together with run time dependencies. | ||
- `make freeze`: Freezes dependencies from `setup.py` to `requirements.txt` (including transitive ones). | ||
- `make lint`: Runs static analysis. | ||
- `make coverage`: Runs all tests collecting coverage. | ||
- `make test`: Runs `lint` and `component`. | ||
|
||
|
||
## Running the simulator | ||
|
||
To run the simulator make sure you have the dependencies installed using `make install-dev` and run `python simulator/simulator.py` | ||
You can add more scripts to the test set in `simulator/test_cf_scripts`. | ||
Be sure to also add them in the `scripts` dictionary with their name, service name and project so that the simulator can pick them up. | ||
|
||
|
||
## Contributing | ||
|
||
See [CONTRIBUTING.md](https://github.com/Skyscanner/cfripper/blob/master/CONTRIBUTING.md) file to add a contribution. | ||
|
||
## Attribution | ||
Some of our rules were inspired by [cfn-nag](https://github.com/stelligent/cfn_nag). We also use their example scripts in our test cases. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import inspect | ||
|
||
from cfripper import rules | ||
|
||
|
||
def define_env(env): | ||
@env.macro | ||
def cfripper_rules(): | ||
rules_inspection = inspect.getmembers(rules, inspect.isclass) | ||
results = [] | ||
for _, klass in rules_inspection: | ||
doc = inspect.getdoc(klass) | ||
# Remove ABCMeta default docstring | ||
if not doc.startswith("Helper class that"): | ||
results.append((klass.__name__, doc)) | ||
else: | ||
results.append((klass.__name__, None)) | ||
return sorted(results) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
ansi2html==1.5.2 | ||
click==7.0 # via mkdocs | ||
htmlmin==0.1.12 # via mkdocs-minify-plugin | ||
jinja2==2.10.3 # via mkdocs, mkdocs-macros-plugin | ||
jsmin==2.2.2 # via mkdocs-minify-plugin | ||
livereload==2.6.1 # via mkdocs | ||
markdown-include==0.5.1 | ||
markdown==3.1.1 # via markdown-include, mkdocs, mkdocs-material, pymdown-extensions | ||
markupsafe==1.1.1 # via jinja2 | ||
mkdocs-exclude==1.0.2 | ||
mkdocs-macros-plugin==0.3.2 | ||
mkdocs-material==4.5.1 | ||
mkdocs-minify-plugin==0.2.1 # via mkdocs-material | ||
mkdocs==1.0.4 | ||
pep562==1.0 # via pymdown-extensions | ||
pygments==2.5.2 | ||
pymdown-extensions==6.2 # via mkdocs-material | ||
pyyaml==5.2 # via mkdocs, mkdocs-macros-plugin | ||
repackage==0.7.3 # via mkdocs-macros-plugin | ||
six==1.13.0 # via ansi2html, livereload | ||
termcolor==1.1.0 # via mkdocs-macros-plugin | ||
tornado==6.0.3 # via livereload, mkdocs | ||
|
||
. # CFRipper in the current version |
Oops, something went wrong.