Skip to content
This repository was archived by the owner on May 29, 2024. It is now read-only.

Commit 3d46a87

Browse files
authored
Update .travis.yml environment role (#17)
* Update .travis.yml environment role + add build status to role + add cfn-lint checks + update publisher role + clean up code as per pre-commit rules * Removed unused mappings and condition parameters
1 parent 0494571 commit 3d46a87

File tree

13 files changed

+26
-31
lines changed

13 files changed

+26
-31
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.idea
1+
.idea

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ before_script:
88
- pip install -r requirements.txt
99

1010
script:
11+
- cfn-lint templates/main.template
1112
- |
1213
if [ $TRAVIS_PULL_REQUEST == true ] && [ $TRAVIS_BRANCH != "master" ]; then
1314
VERSION="v$(cat templates/main.template | shyaml get-value Metadata.Version)"
1415
git tag $VERSION
1516
fi
1617
1718
before_deploy:
19+
- mkdir -p ~/.aws
20+
- cat >> ~/.aws/config <<<"[profile publisher]"$'\n'"credential_source=Environment"$'\n'"role_arn=${ROLE_ARN}"$'\n'"duration_seconds=900"
1821
- VERSION="v$(cat templates/main.template | shyaml get-value Metadata.Version)"
1922
- if [ -z "$TRAVIS_TAG" ]; then git tag $VERSION; fi
2023
- zip -r "$VERSION.zip" -@ < ci/include.lst
@@ -29,7 +32,7 @@ deploy:
2932
branch: master
3033
condition: type != pull_request
3134
- provider: script
32-
script: aws s3 cp ./$VERSION.zip s3://$CFN_BUCKET/aws-waf-workshop/$VERSION/aws-waf-workshop.zip
35+
script: aws s3 --profile publisher cp ./$VERSION.zip s3://$CFN_BUCKET/aws-waf-workshop/$VERSION/aws-waf-workshop.zip > /dev/null 2>&1
3336
skip_cleanup: true
3437
on:
3538
tags: true

LICENSE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
1212
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
1313
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1414
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15-

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# AWS WAF workshop
22

3+
[![Build Status](https://travis-ci.org/aws-samples/aws-waf-classic-workshop.svg?branch=master)](https://travis-ci.org/aws-samples/aws-waf-classic-workshop)
4+
35
> :warning: **This workshop uses AWS WAF Classic**
46
57
A workshop about [AWS WAF](https://aws.amazon.com/waf/) and the [WAF Security Automations Solution](https://aws.amazon.com/solutions/aws-waf-security-automations/)
@@ -9,7 +11,7 @@ A workshop about [AWS WAF](https://aws.amazon.com/waf/) and the [WAF Security Au
911

1012
This workshop introduces AWS WAF and the AWS WAF Security Automations solution.
1113

12-
The AWS WAF enables customers to create rules to block common attack patterns, administered via APIs.
14+
The AWS WAF enables customers to create rules to block common attack patterns, administered via APIs.
1315
The Security Automation Solution extends WAF by deploying a set of preconfigured rules to protect applications. These rules can be customised for your application.
1416

1517
## Learning Objectives
@@ -21,7 +23,7 @@ The Security Automation Solution extends WAF by deploying a set of preconfigured
2123
## Prerequisites
2224

2325
To complete this workshop you will require the following:
24-
* An AWS Account.
26+
* An AWS Account.
2527
* If you don’t already have an AWS account, create one at <https://aws.amazon.com> by following the on-screen instructions
2628
* Your access to the AWS account must have IAM permissions to launch AWS CloudFormation templates that create IAM roles.
2729

docs/step-0.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ In this step, you will deploy two CloudFormation templates required for the work
44

55
You will deploy the [WAF Security Automations Solution](https://aws.amazon.com/solutions/aws-waf-security-automations/) and a sample Web Application. The Sample Web Application template contains an EC2 instance containing the [OWASP Juice Shop](https://www2.owasp.org/www-project-juice-shop/). It is exposed by an Application Load Balancer. The sample Web Application will be protected by the WAF. The OWASP Juice Shop is an example web application containing many common vulnerabilities found in Web Applications.
66

7-
> **Note**
7+
> **Note**
88
You are responsible for the cost of the AWS services used while running these CloudFormation stacks. There is no additional cost for using them. For full details, see the pricing pages for each AWS service you will be using in these CloudFormation stacks. Prices are subject to change.
99

1010
## Deploy the WAF Security Automations Solution
@@ -23,7 +23,7 @@ Step by step instructions:
2323
* Leave all other parameters set to their default values.
2424
* Check the box at the bottom allowing AWS CloudFormation to create IAM resources with custom names.
2525
* Click the orange "Create stack" button at the bottom-right of the page to deploy the stack into your account.
26-
26+
2727
## Deploy the sample Web App
2828

2929
|Region|Launch Template|
@@ -40,4 +40,4 @@ Step by step instructions:
4040
* On the final page, check the box at the bottom allowing AWS CloudFormation to create IAM resources with custom names.
4141
* Click the orange "Create stack" button at the bottom-right of the page to deploy the stack into your account.
4242

43-
# [Next step](step-1.md)
43+
# [Next step](step-1.md)

docs/step-1.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ SQL Injection and XSS are two common attacks. The AWS WAF Security Automation So
2727

2828
Access the `site-url` endpoint and include bad signatures to the requests. You can use, for example:
2929

30-
* SQL Injection: `<your-endpoint>/?username=1'%20or%20'1'%20=%20'1&password=1'%20or%20'1'%20=%20'1'`
30+
* SQL Injection: `<your-endpoint>/?username=1'%20or%20'1'%20=%20'1&password=1'%20or%20'1'%20=%20'1'` <!-- pragma: allowlist secret -->
3131
* XSS: `<your-endpoint>/?<SCRIPT>alert(“Cookie”+document.cookie)</SCRIPT>`
3232

3333
Optional Extension - Try and find an input form on the juice site to perform a XSS attack. See if your WAF blocks the malicious request.
@@ -38,7 +38,7 @@ If you bypass the WAF by accessing the EC2 instance directly, you will see the a
3838
HTTP floods are a type of denial-of-service attack where an application receives a large volume of requests intended to exhaust the resources of an application, preventing it from handling requests from legitimate users.
3939
We will demonstrate functionality provided by the Security Automation Solution to detect this type of attack and block the responsible IP address in AWS WAF.
4040

41-
Rather than execute an HTTP Flood attack on our sample application, we can simulate one by providing an example log file. This will be processed by the Security Automation Solution.
41+
Rather than execute an HTTP Flood attack on our sample application, we can simulate one by providing an example log file. This will be processed by the Security Automation Solution.
4242

4343
* Go to the CloudFormation Console, and inspect the WAF Automation stack's `Outputs` tab to find the value defined for `WafLogBucket`. Note this name. You will need it next.
4444
* Download [this file](files/waf-access-log-sample.gz) to your machine.
@@ -51,7 +51,7 @@ Rather than execute an HTTP Flood attack on our sample application, we can simul
5151
* To upload the file to the S3 bucket via the console, navigate to the [S3 Console page](https://s3.console.aws.amazon.com/s3/)
5252
* Select the bucket you noted in the previous step.
5353
* Select `upload`, then select the `waf-access-log-sample.gz` file.
54-
* The lambda function is triggered by the creation of a new file in the S3 Bucket. Wait a few seconds while the log parser function processes the new WAF log file.
54+
* The lambda function is triggered by the creation of a new file in the S3 Bucket. Wait a few seconds while the log parser function processes the new WAF log file.
5555
* Check if the file `<stack_name>-waf_log_out.json` was added to the same bucket
5656
* Check the [AWS WAF console](https://console.aws.amazon.com/wafv2/home?#/webacls) (you may need to change the filter to WAF resources in your chosen region) to see if `HTTP Flood` rule contains any IP listed.
5757

docs/step-2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The HTTP Flood log parser comes with some extensions points, they are:
1414
* Ignored Suffixes: requests accessing this type of resource will not count to request threshold. By default, this list is empty.
1515
* URI List: use this to define a custom request threshold and block period for specifics URLs. By default, this list is empty.
1616

17-
The goal now is to apply customisations and check how it affects the log parser behavior.
17+
The goal now is to apply customisations and check how it affects the log parser behavior.
1818

1919

2020
### 2.1.2 Customising the HTTP Log Parser

docs/step-3.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
* Create an automation ([like this one](https://www.imperva.com/blog/imperva-integration-with-aws-security-hub-expanding-customer-security-visibility/)) to ingest AWS WAF Alert to AWS Security Hub. More info about AWS Security Hub custom providers [here](https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-custom-providers.html)
77

88

9-
## 3.2 Play with the OWASP Juice Shop.
9+
## 3.2 Play with the OWASP Juice Shop.
1010

11-
* The sample application you deployed is the OWASP Juice Shop. It intentionally contains common web vulnerabilities. WAF automatically protects against some of these vulnerabilities, such as SQL Injection and Cross Site Scriptting. There is an [accompanying book by Ben Kimminitch](https://bkimminich.gitbooks.io/pwning-owasp-juice-shop/) that explains further. Try exploring the site to test out some other vulnerabilities. Access your EC2 resource directly (bypassing the ALB) to test your attacks without the WAF protection.
11+
* The sample application you deployed is the OWASP Juice Shop. It intentionally contains common web vulnerabilities. WAF automatically protects against some of these vulnerabilities, such as SQL Injection and Cross Site Scriptting. There is an [accompanying book by Ben Kimminitch](https://bkimminich.gitbooks.io/pwning-owasp-juice-shop/) that explains further. Try exploring the site to test out some other vulnerabilities. Access your EC2 resource directly (bypassing the ALB) to test your attacks without the WAF protection.

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
awscli>=1.16.244
22
shyaml==0.6.1
3+
cfn-lint==0.29.0

templates/instance.template

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Description: set up a launch configuration and attach to ASG
33
Metadata: {}
44
Parameters:
55
TheAmi:
6-
Type: String
6+
Type: AWS::EC2::Image::Id
77
WebSecurityGroup:
88
Type: String
99
ALBSecurityGroup:
@@ -16,8 +16,6 @@ Parameters:
1616
Type: String
1717
TheWebPort:
1818
Type: Number
19-
Mappings: {}
20-
Conditions: {}
2119
Resources:
2220
TheRolePolicies:
2321
Type: AWS::IAM::Policy

0 commit comments

Comments
 (0)