Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions Angular-CLI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,17 @@ 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",
"type": "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/*"
}
},
{
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ 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)

## 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)
41 changes: 41 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.5 BLOCK -->

## 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).

<!-- END MICROSOFT SECURITY.MD BLOCK -->
1 change: 1 addition & 0 deletions debugging-jest-tests/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"name": "Jest Current File",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"--runTestsByPath",
"${relativeFile}",
"--config",
"jest.config.js"
Expand Down
3 changes: 2 additions & 1 deletion debugging-jest-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
],
Expand Down
74 changes: 74 additions & 0 deletions debugging-lambda-functions/README.md
Original file line number Diff line number Diff line change
@@ -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": ["<node_internals>/**"]
},
{
"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)
Binary file added debugging-lambda-functions/configure-launch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added debugging-lambda-functions/debug-session.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading