-
Notifications
You must be signed in to change notification settings - Fork 655
fix: #1218 Proxy implementation for Lambdas (basic UT for aws-sdk v2) #1256
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
Closed
Closed
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
b1f94be
Fix #1218 : Proxy implementation for Lambdas
axel3rd d622546
PR review updates
axel3rd d813dde
Merge branch 'develop' into lambda-http-proxy
axel3rd 326f7a0
Merge branch 'develop' into lambda-http-proxy
axel3rd 5b43dc1
Merge branch 'develop' into lambda-http-proxy
axel3rd 0c8559b
Merge branch 'develop' into lambda-http-proxy
axel3rd b1f4993
Merge branch 'develop' into lambda-http-proxy
axel3rd cf2d682
Merge branch 'develop' into lambda-http-proxy
axel3rd ee8126d
Merge branch 'develop' into lambda-http-proxy
axel3rd c890c84
Add all generated js files in runners dist (replace 'contextify.js')
axel3rd 9fc0da3
Merge branch 'develop' into lambda-http-proxy
axel3rd cdd5e9d
Merge branch 'develop' into lambda-http-proxy
axel3rd 522bea0
Merge branch 'develop' into lambda-http-proxy
axel3rd cf8e831
Merge branch 'develop' into lambda-http-proxy
axel3rd 5e808e1
Merge branch 'develop' into lambda-http-proxy
axel3rd f8c729a
Merge branch 'develop' into lambda-http-proxy
axel3rd 5c20202
Merge branch 'develop' into lambda-http-proxy
axel3rd 20c6dc1
Merge branch 'develop' into lambda-http-proxy
axel3rd eefc4f5
Merge branch 'develop' into lambda-http-proxy
axel3rd 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ secrets.auto.tfvars | |
*.tgz | ||
*.env* | ||
.vscode | ||
.project | ||
.settings/ | ||
|
||
**/coverage/* | ||
|
||
|
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
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 |
---|---|---|
@@ -1,6 +1,22 @@ | ||
import { SSM } from '@aws-sdk/client-ssm'; | ||
import { NodeHttpHandler } from '@aws-sdk/node-http-handler'; | ||
import proxy from 'proxy-agent'; | ||
|
||
import { logger } from '../logger'; | ||
import { hideUrlPassword } from '../utils/url'; | ||
|
||
export async function getParameterValue(parameter_name: string): Promise<string> { | ||
const client = new SSM({ region: process.env.AWS_REGION }); | ||
// Proxy with aws-sdk v3 | ||
// Configured by client (global configuration like v2 doesn't work) | ||
// https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-proxies.html | ||
let rh; | ||
const httpsProxy = process.env.HTTPS_PROXY; | ||
if (httpsProxy?.startsWith('http')) { | ||
logger.debug('Http proxy used for AWS SSM SDK (v3): ' + hideUrlPassword(httpsProxy)); | ||
rh = new NodeHttpHandler({ | ||
httpsAgent: new proxy(httpsProxy), | ||
}); | ||
} | ||
const client = new SSM({ region: process.env.AWS_REGION, requestHandler: rh }); | ||
return (await client.getParameter({ Name: parameter_name, WithDecryption: true })).Parameter?.Value as string; | ||
} |
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
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,12 @@ | ||
import { hideUrlPassword } from './url'; | ||
|
||
describe('Test URL proxy validation', () => { | ||
test('URL credentials port 80', async () => { | ||
const url = hideUrlPassword('http://foo:[email protected]:80'); | ||
expect(url).toBe('http://foo:*****@proxy.company.com/'); | ||
}); | ||
test('URL port 8080', async () => { | ||
const url = hideUrlPassword('http://proxy.company.com:8080'); | ||
expect(url).toBe('http://proxy.company.com:8080/'); | ||
}); | ||
}); |
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,7 @@ | ||
export function hideUrlPassword(url: string): string { | ||
const urlProxy = new URL(url); | ||
if (urlProxy.password) { | ||
urlProxy.password = '*****'; | ||
} | ||
return urlProxy.toString(); | ||
} |
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked the library, tiny but last half year not maintained https://www.npmjs.com/package/proxy-agent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, but wide used. Not sure to have another better solution 😢.