Skip to content

Commit

Permalink
feat(elbv2): add dropInvalidHeaderFields for elbv2 (#22466)
Browse files Browse the repository at this point in the history
Dropping invalid HTTP headers is recommended and also appears in Security Hub controls as [ELB.4](https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-standards-fsbp-controls.html#fsbp-elb-4)

Attribute document: 
https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_LoadBalancerAttribute.html

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
clueleaf authored Oct 19, 2022
1 parent 73c443a commit 91767f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ export interface ApplicationLoadBalancerProps extends BaseLoadBalancerProps {
* @default 60
*/
readonly idleTimeout?: Duration;

/**
* Indicates whether HTTP headers with invalid header fields are removed
* by the load balancer (true) or routed to targets (false)
*
* @default false
*/
readonly dropInvalidHeaderFields?: boolean;
}

/**
Expand Down Expand Up @@ -100,6 +108,7 @@ export class ApplicationLoadBalancer extends BaseLoadBalancer implements IApplic

if (props.http2Enabled === false) { this.setAttribute('routing.http2.enabled', 'false'); }
if (props.idleTimeout !== undefined) { this.setAttribute('idle_timeout.timeout_seconds', props.idleTimeout.toSeconds().toString()); }
if (props.dropInvalidHeaderFields) {this.setAttribute('routing.http.drop_invalid_header_fields.enabled', 'true'); }
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ describe('tests', () => {
deletionProtection: true,
http2Enabled: false,
idleTimeout: cdk.Duration.seconds(1000),
dropInvalidHeaderFields: true,
});

// THEN
Expand All @@ -98,6 +99,10 @@ describe('tests', () => {
Key: 'idle_timeout.timeout_seconds',
Value: '1000',
},
{
Key: 'routing.http.drop_invalid_header_fields.enabled',
Value: 'true',
},
],
});
});
Expand Down

0 comments on commit 91767f0

Please sign in to comment.