diff --git a/Angular-CLI/README.md b/Angular-CLI/README.md index 874fe7c..4e272e9 100644 --- a/Angular-CLI/README.md +++ b/Angular-CLI/README.md @@ -47,15 +47,8 @@ Then click on the gear icon to configure a launch.json file, selecting **Chrome* "type": "chrome", "request": "launch", "preLaunchTask": "npm: start", - "url": "http://localhost:4200/#", - "webRoot": "${workspaceFolder}", - "sourceMapPathOverrides": { - "webpack:/*": "${webRoot}/*", - "/./*": "${webRoot}/*", - "/src/*": "${webRoot}/*", - "/*": "*", - "/./~/*": "${webRoot}/node_modules/*" - } + "url": "http://localhost:4200", + "webRoot": "${workspaceFolder}" }, { "name": "ng test", @@ -63,13 +56,8 @@ Then click on the gear icon to configure a launch.json file, selecting **Chrome* "request": "launch", "url": "http://localhost:9876/debug.html", "webRoot": "${workspaceFolder}", - "sourceMaps": true, "sourceMapPathOverrides": { - "webpack:/*": "${webRoot}/*", - "/./*": "${webRoot}/*", - "/src/*": "${webRoot}/*", - "/*": "*", - "/./~/*": "${webRoot}/node_modules/*" + "./src/*": "${workspaceFolder}/src/*" } }, { diff --git a/README.md b/README.md index 4e73a1b..3419cba 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,6 @@ A collection of recipes for using VS Code with particular technologies. - [Debugging Python](https://github.com/Microsoft/vscode-recipes/tree/master/debugging%20python) -## Container Technology - -- [Debugging TypeScript in a Docker Container](https://github.com/weinand/vscode-recipes/tree/master/Docker-TypeScript) - ## Runtimes - [Debugging Electron Main and Renderer processes](https://github.com/Microsoft/vscode-recipes/blob/master/Electron) @@ -45,3 +41,7 @@ A collection of recipes for using VS Code with particular technologies. ## Emscripten - [Debug Emscripten translated C/C++](https://github.com/weinand/vscode-recipes/issues/20) + +## AWS Lambda + +- [Debugging Lambda functions](https://github.com/Microsoft/vscode-recipes/tree/main/debugging-lambda-functions) diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..a050f36 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,41 @@ + + +## Security + +Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). + +If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below. + +## Reporting Security Issues + +**Please do not report security vulnerabilities through public GitHub issues.** + +Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). + +If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc). + +You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). + +Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: + + * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) + * Full paths of source file(s) related to the manifestation of the issue + * The location of the affected source code (tag/branch/commit or direct URL) + * Any special configuration required to reproduce the issue + * Step-by-step instructions to reproduce the issue + * Proof-of-concept or exploit code (if possible) + * Impact of the issue, including how an attacker might exploit the issue + +This information will help us triage your report more quickly. + +If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs. + +## Preferred Languages + +We prefer all communications to be in English. + +## Policy + +Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd). + + diff --git a/debugging-jest-tests/.vscode/launch.json b/debugging-jest-tests/.vscode/launch.json index 905f6e7..a19a5bb 100644 --- a/debugging-jest-tests/.vscode/launch.json +++ b/debugging-jest-tests/.vscode/launch.json @@ -20,6 +20,7 @@ "name": "Jest Current File", "program": "${workspaceFolder}/node_modules/.bin/jest", "args": [ + "--runTestsByPath", "${relativeFile}", "--config", "jest.config.js" diff --git a/debugging-jest-tests/README.md b/debugging-jest-tests/README.md index 33a2e9b..623c11c 100644 --- a/debugging-jest-tests/README.md +++ b/debugging-jest-tests/README.md @@ -42,7 +42,8 @@ To try the example you'll need to install dependencies by running: "name": "Jest Current File", "program": "${workspaceFolder}/node_modules/.bin/jest", "args": [ - "${fileBasenameNoExtension}", + "--runTestsByPath", + "${relativeFile}", "--config", "jest.config.js" ], diff --git a/debugging-lambda-functions/README.md b/debugging-lambda-functions/README.md new file mode 100644 index 0000000..82de0e6 --- /dev/null +++ b/debugging-lambda-functions/README.md @@ -0,0 +1,74 @@ +# Debugging AWS Lambda functions with SST + +by [Jay V (@jayair)](https://github.com/jayair) + +[SST](https://github.com/serverless-stack/serverless-stack) is a framework for building serverless applications. It allows you to [test and debug your Lambda functions locally](https://docs.serverless-stack.com/live-lambda-development) without having to redeploy your changes. It does this by streaming the Lambda function requests from AWS to your local client and running it locally. So for Node.js Lambda functions, you **can set breakpoints locally** and they'll reflect the event and context of the deployed Lambda function. + +This guide will help you configure VS Code to support setting breakpoints and debugging your Lambda functions. + +## Getting started + +### Requirements + +1. The latest version of VS Code installed. +2. A project initialized with the [SST CLI](https://docs.serverless-stack.com/installation). + +## Configure `launch.json` file + +1. Open your project folder in VS Code. +2. Click on the **Debug** icon in the Activity Bar to switch to the Debug view. +3. Under **Run and Debug** click on **create a launch.json file**. +4. In the **Select environment** input, select **Node.js**. + + ![VS Code Debug view](./configure-launch.png) + +5. Replace the content of the generated `launch.json` file with the following configuration: + + ```json + { + "version": "0.2.0", + "configurations": [ + { + "name": "Debug SST Start", + "type": "node", + "request": "launch", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst", + "runtimeArgs": ["start", "--increase-timeout"], + "console": "integratedTerminal", + "skipFiles": ["/**"] + }, + { + "name": "Debug SST Tests", + "type": "node", + "request": "launch", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst", + "args": ["test", "--runInBand", "--no-cache", "--watchAll=false"], + "cwd": "${workspaceRoot}", + "protocol": "inspector", + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen", + "env": { "CI": "true" }, + "disableOptimisticBPs": true + } + ] + } + ``` + +> This JSON file defines two configurations, one for the `sst start` command; to debug your Lambda functions. And another for the `sst test` command; to debug your tests. + +## Debugging your Lambda functions + +SST runs your Lambda functions locally and streams the requests back to AWS. So your functions can be debugged like any other Node.js application. + +1. Open a Lambda function inside the `src/` directory. +2. Put a **breakpoint** 🔴 anywhere in the function. +3. Switch to the Debug view and select "**Debug SST Start**". +4. Press `F5` or click on **Start debugging**. +5. Tadaa! 🎉 Your breakpoint should be hit, and now you have full access to the event and context of the deployed Lambda function. + +![VS Code Debug session running](./debug-session.png) + +## Additional resources + +* [Live Lambda Development](https://docs.serverless-stack.com/live-lambda-development) +* [How to debug Lambda functions with Visual Studio Code](https://serverless-stack.com/examples/how-to-debug-lambda-functions-with-visual-studio-code.html) diff --git a/debugging-lambda-functions/configure-launch.png b/debugging-lambda-functions/configure-launch.png new file mode 100644 index 0000000..af1631c Binary files /dev/null and b/debugging-lambda-functions/configure-launch.png differ diff --git a/debugging-lambda-functions/debug-session.png b/debugging-lambda-functions/debug-session.png new file mode 100644 index 0000000..b5218a5 Binary files /dev/null and b/debugging-lambda-functions/debug-session.png differ