|
| 1 | +## Step 2: Enable and view Dependabot alerts |
| 2 | + |
| 3 | +_Nice work! :tada: You added and viewed a dependency using Dependency graph!_ |
| 4 | + |
| 5 | +Given how many dependencies our repository uses, maintaining them needs to become an automated task. Keeping our code secure is a top priority, so the first thing we need to do is set up a way to be notified when a dependency we are using is vulnerable or malware. We can do this by enabling Dependabot alerts. |
| 6 | + |
| 7 | +**What are Dependabot alerts?** |
| 8 | + |
| 9 | +Dependabot alerts tell you that your code depends on a package that is insecure. These Dependabot alerts reference the [GitHub Advisory Database](https://github.com/advisories), which contains a list of known security vulnerabilities and malware, grouped in two categories: **GitHub reviewed advisories** and **unreviewed advisories**. |
| 10 | + |
| 11 | +If your code depends on a package that has a security vulnerability, this can cause a range of problems for your project or the people who use it. You should upgrade to a secure version of the package as soon as possible. If your code uses malware, you need to replace the package with a secure alternative. |
| 12 | + |
| 13 | +Let's try this out with our newly added `follow-redirects` dependency! |
| 14 | + |
| 15 | +### :keyboard: Activity 2.1: View security advisories in the GitHub Advisory Database |
| 16 | + |
| 17 | +1. Navigate to [GitHub Advisory Database](https://github.com/advisories). |
| 18 | +1. Type or paste `follow-redirects` into the advisory search box. |
| 19 | +1. Click on any of the advisories that were found to see more information. |
| 20 | +1. You'll see the packages, impact, patches, workaround, and references for the advisory. |
| 21 | + |
| 22 | +Notice the long list of advisories for our dependency! This can look scary but it's actually a good thing. It means that our dependency is actively being maintained and patches are being pushed to remove the vulnerability. If we had Dependabot alerts enabled, we could receive alerts when we need to update a dependency and act promptly to secure them. |
| 23 | + |
| 24 | +Let's enable Dependabot alerts on our repository! |
| 25 | + |
| 26 | +### :keyboard: Activity 2.2: Enable Dependabot alerts |
| 27 | + |
| 28 | +1. Navigate to the **Settings** tab. |
| 29 | +1. Display the settings for **Advanced Security**. |
| 30 | +1. **Enable** Dependabot alerts. |
| 31 | +1. **Wait about 60 seconds for Dependabot to check for alerts.** |
| 32 | +1. Navigate to the **Security** tab. |
| 33 | +1. Under "Vulnerability alerts" in the side bar, select **Dependabot** to view a list of the Dependabot alerts for the default branch. |
| 34 | + |
| 35 | +Dependabot has alerted us to vulnerabilities in the dependencies that we use. We can also use Dependabot to help us address these vulnerabilities by creating pull requests to update the dependency to a safe version. |
| 36 | + |
| 37 | +Let's see how this would work by using Dependabot to create a pull request for one of the alerts! |
| 38 | + |
| 39 | +### :keyboard: Activity 2.3: Create a pull request based on a Dependabot alert |
| 40 | + |
| 41 | +1. In the list of Dependabot alerts, click the "Prototype Pollution in minimist" to display more information. |
| 42 | +1. Click the **Create Dependabot security update** button to create a pull request to update the dependency. This could take up to 2 minutes. |
| 43 | +1. When the pull request is open, the alert page is updated to show a **Review security update** button. |
| 44 | +1. Click the **Review security update** button to display the pull request. |
| 45 | + - You can view the pull request and **Files changed** tab to review the update. |
| 46 | +1. Navigate back to the **Conversation** tab and merge the pull request. |
| 47 | +1. With the pull request merged, Mona should already be busy checking your work. Give her a moment and keep watch in the comments. You will see her respond with progress info and the next lesson. |
0 commit comments