You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Step 1: Review and add dependencies using dependency graph
2
2
3
+
_Welcome to "Secure your repository's supply chain"! :wave:_
4
+
3
5
**What's the big deal about securing your repository's supply chain?**: With the accelerated use of open source, most projects depend on hundreds of open-source dependencies. This poses a security problem: what if the dependencies you're using are vulnerable? You could be putting your users at risk of a supply chain attack. One of the most important things you can do to protect your supply chain is to patch your vulnerable dependencies and replace any malware.
4
6
5
7
GitHub offers a range of features to help you understand the dependencies in your environment, know about vulnerabilities in those dependencies, and patch them. The supply chain features on GitHub are:
@@ -20,32 +22,28 @@ GitHub offers a range of features to help you understand the dependencies in you
20
22
21
23
**We recommend opening another browser tab to work through the following activities so you can keep these instructions open for reference.**
22
24
23
-
>[!NOTE]
24
-
> Dependency graph is enabled by default for all new public repositories.
25
+
Dependency graph is enabled by default for all new public repositories. If you're working in a public repository, you can go straight to "Activity 1.2: Add a new dependency and view your dependency graph." For private or internal repositories, you'll need to enable Dependency graph.
25
26
26
27
1. Navigate to the **Settings** tab.
27
-
1. Click **Advanced Security**.
28
-
1.Verify **Dependency Graph**is **Enabled**
28
+
1. Click **Code security and analysis**.
29
+
1.**Enable**"Dependency graph."
29
30
30
31
### :keyboard: Activity 1.2: Add a new dependency and view your dependency graph
31
32
32
33
1. Navigate to the **Code** tab and locate the `code/src/AttendeeSite` folder.
33
-
1. Commit the following content on the `main` branch to the `package-lock.json` file as the last item on the `dependencies` map _(after the third to last bracket `}` and before the last two brackets)_
34
-
35
-
> 🪧 **Note:** You can edit and commit the file on github.com directly or hit the `.` key to open the lightweight editor to edit and commit changes.
36
-
37
-
```json
38
-
,
34
+
1. Add the following content to the `package-lock.json` file after the third to last bracket `}` and before the last two brackets.
1. Select **Dependency graph** from the side navigation bar.
48
45
1. Review all the dependencies on the **Dependencies** tab.
49
46
1. Search for `follow-redirects` and review the new dependency you just added.
50
47

51
-
1. With the new dependency added, 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.
48
+
49
+
Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to display the next step.
Copy file name to clipboardExpand all lines: .github/steps/2-dependabot-alerts.md
+4-5Lines changed: 4 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,7 @@ _Nice work! :tada: You added and viewed a dependency using Dependency graph!_
4
4
5
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
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**.
7
+
**What are Dependabot alerts?**: 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
8
11
9
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.
1. Display the settings for **Advanced Security**.
27
+
1. Display the settings for **Code security and analysis**.
30
28
1.**Enable** Dependabot alerts.
31
29
1.**Wait about 60 seconds for Dependabot to check for alerts.**
32
30
1. Navigate to the **Security** tab.
@@ -44,4 +42,5 @@ Let's see how this would work by using Dependabot to create a pull request for o
44
42
1. Click the **Review security update** button to display the pull request.
45
43
- You can view the pull request and **Files changed** tab to review the update.
46
44
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.
45
+
46
+
Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to display the next step.
Copy file name to clipboardExpand all lines: .github/steps/3-dependabot-security.md
+6-8Lines changed: 6 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,17 +4,15 @@ _Nice work enabling, viewing, and creating Dependabot alerts :sparkles:_
4
4
5
5
Enabling Dependabot alerts on our repository was a great step toward improving our code security, but we still had to manually select an alert and then manually select the option to create the pull request. It would be nice to further improve the automation and maintenance of our dependencies! Well, with Dependabot security updates, we can do just that.
6
6
7
-
**What are Dependabot security updates?**
8
-
9
-
When this feature is enabled, Dependabot detects *and* fixes vulnerable dependencies for you by opening pull requests automatically to resolve Dependabot alerts.
7
+
**What are Dependabot security updates?**: When this feature is enabled, Dependabot detects *and* fixes vulnerable dependencies for you by opening pull requests automatically to resolve Dependabot alerts.
10
8
11
9
We manually created a pull request to fix the "Prototype Pollution in minimist" alert, but let's enable Dependabot security updates to automate this process for future alerts!
12
10
13
11
### :keyboard: Activity 3.1: Enable and trigger Dependabot security updates
14
12
15
-
1. Navigate to the **Settings** tab and select **Advanced Security**.
16
-
1. Enable **Dependabot security updates**. You may need to wait 30-60 seconds before you see any new pull requests.
17
-
1. Navigate to the **Pull requests** repository tab to view the what Dependabot has found.
18
-
1. Find the new pull request that requests to patch the **axios** dependency.
13
+
1. Navigate to the **Settings** tab and select **Code security and analysis**.
14
+
1. Enable Dependabot security updates. You may need to wait 30-60 seconds before you see any new pull requests.
15
+
1. Navigate to the **Pull requests** repository tab and select the newly created pull request that updates axios from version 0.21.1 to a patched version.
19
16
1. Review and merge the pull request.
20
-
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.
17
+
18
+
Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update this page to display the next step.
Copy file name to clipboardExpand all lines: .github/steps/4-dependabot-versions.md
+12-15Lines changed: 12 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,6 @@ _Nicely done!_ :partying_face:
4
4
5
5
You now have automated the process for Dependabot to alert you to vulnerabilities with your dependencies and to create pull requests to update them to secure versions! At this point, you only need to review the pull request and then merge it to stay on top of security problems with Dependencies.
6
6
7
-
> [!NOTE]
8
-
> Did you notice that there were several pull requests suggested by Dependabot? You only merged the one related to the **axios** dependency, but the others disappeared from the **Pull requests** panel. That's because the upgrade of the axios dependency triggered changes of other transitive dependencies, that might be either removed or updated to other versions. Whenever there is a change in your dependency graph, Dependabot will automatically review the existing pull requests and close the ones that are no longer relevant. So don't merge everything at once, let Dependabot do the job for you!
9
-
<img width="955" alt="Screenshot showing that the axios PR was merged and that the 2 others were closed" src="https://github.com/user-attachments/assets/6c97f90b-c6e2-4865-b1eb-dd7053383f07" />
10
-
11
-
12
7
The security updates feature helps automate the process to resolve alerts, but what about just keeping up-to-date with version updates? We can also automate pull request generation for updated versions of dependencies using the Dependabot version updates feature.
13
8
14
9
**What are Dependabot version updates?**: In addition to security alerts, Dependabot can also take the effort out of maintaining your dependencies. You can use it to ensure that your repository automatically keeps up with the latest releases of the packages and applications it depends on. Similar to security alerts, Dependabot will identify an outdated dependency and create a pull request to update the manifest to the latest version of the dependency.
@@ -17,11 +12,16 @@ Let's see how this works!
17
12
18
13
### :keyboard: Activity 4.1: Enable and trigger Dependabot version updates
19
14
20
-
1. Navigate to the **Settings** tab and select **Advanced Security**.
21
-
1. Locate **Dependabot version updates** and click **Configure** to open a new file editor with pre-poplulated contents. The file is called `dependabot.yml`.
15
+
1. Navigate to the **Settings** tab and select **Code security and analysis**.
16
+
1. Locate "Dependabot version updates" and click **Configure** to open a new file editor with pre-poplulated contents. The file is called `dependabot.yml`.
22
17
1. Notice that the file is prepopulated to update the GitHub actions in the repository, the `github-actions` package ecosystem.
23
-
1. Edit your `dependabot.yml` configuration file to include another entry. It should look like:
24
-
18
+
1. Copy the lines that define the GitHub actions updates and append them to the file.
19
+
1. Edit your copy of the content:
20
+
- Change the `package-ecosystem` to `nuget`.
21
+
- Change the `directory` to `/code/`.
22
+
- Change the `interval` to `weekly`.
23
+
24
+
The `dependabot.yml` file should now look like this.
25
25
```yaml
26
26
version: 2
27
27
updates:
@@ -33,14 +33,11 @@ Let's see how this works!
33
33
directory: "/code/"
34
34
schedule:
35
35
interval: "weekly"
36
-
```
37
-
38
-
> 💡 **Tip:** While, you can edit and commit a file directly on github.com, you can also press the period key `.` to open a lightweight VS Code editor directly in browser.
39
-
36
+
```
40
37
1. Commit your changes directly to the `main` branch.
41
-
1. With the configuration file updated, 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.
42
38
43
39
You have now configured Dependabot version updates to run and check for updates as follows:
44
-
45
40
- Check once a month for updates to GitHub Actions and create pull requests to update any that are out of date.
46
41
- Check once a week for updates to .NET packages and create pull requests to update any that are out of date. By default, this check runs on a Monday, to run the check on a different day, see [schedule.day](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#scheduleday).
42
+
43
+
Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to display the next step.
Here's a recap of all the tasks you've accomplished in your repository:
7
8
8
9
- You've learned how to view and use dependency graph.
@@ -21,6 +22,7 @@ Here's a recap of all the tasks you've accomplished in your repository:
21
22
### What's next?
22
23
23
24
- Learn more about securing your supply chain by reading: [Securing your supply chain](https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-supply-chain-security).
24
-
- Check out other security focused [GitHub Skills exercises](https://skills.github.com/#code-security-and-analysis).
25
+
-[We'd love to hear what you thought of this course](https://github.com/skills/.github/discussions).
26
+
-[Learn another GitHub skill](https://github.com/skills).
25
27
-[Read the Get started with GitHub docs](https://docs.github.com/en/get-started).
26
28
- To find projects to contribute to, check out [GitHub Explore](https://github.com/explore).
0 commit comments