-
Notifications
You must be signed in to change notification settings - Fork 40
fix(appsec): send the normalized status code on end-invocation #817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
CarlesDD
merged 8 commits into
main
from
ccapell/APPSEC-68818/fix-appsec-end-invocation-status-code
Aug 31, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6485910
fix(appsec): send the normalized status code on end-invocation
CarlesDD 3ec4f0b
refactor(appsec): move normalizeHeaders
CarlesDD 32eb9a5
fix(appsec): normalize the response headers sent on end-invocation
CarlesDD 52ea36f
doc(appsec): fix comment on reordering in onEndingInvocation
CarlesDD 144f1ab
fix(appsec): drop the status code fallback on end invocation
CarlesDD 7dae173
doc(appsec): clean comments
CarlesDD d19ad38
fix(appsec): harden response header normalization
CarlesDD b868f0f
Merge branch 'main' into ccapell/APPSEC-68818/fix-appsec-end-invocati…
CarlesDD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,35 @@ | ||
| /** | ||
| * Normalizes header names to lowercase and collapses multi-value headers into a single | ||
| * comma-separated value, which is the shape the WAF expects. When a name appears in both maps the | ||
| * multi-value one wins. | ||
| * | ||
| * API Gateway v1 and application load balancer payloads carry `headers` and `multiValueHeaders`, | ||
| * both on the request event and on the handler result. | ||
| */ | ||
| export function normalizeHeaders( | ||
| headers?: Record<string, unknown>, | ||
| multiValueHeaders?: Record<string, unknown[]>, | ||
| ): Record<string, string> { | ||
| if (!headers && !multiValueHeaders) return {}; | ||
|
|
||
| const result: Record<string, string> = {}; | ||
|
|
||
| if (multiValueHeaders) { | ||
| for (const [key, values] of Object.entries(multiValueHeaders)) { | ||
| if (Array.isArray(values) && values.length > 0) { | ||
| result[key.toLowerCase()] = values.join(", "); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (headers) { | ||
| for (const [key, value] of Object.entries(headers)) { | ||
| const lowerKey = key.toLowerCase(); | ||
| if (!(lowerKey in result) && value !== undefined && value !== null) { | ||
| result[lowerKey] = String(value); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return result; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.