Skip to content

Commit 18d17aa

Browse files
authored
Initial commit
0 parents  commit 18d17aa

31 files changed

+1379
-0
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
## Step 1: Review and add dependencies using dependency graph
2+
3+
**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+
5+
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:
6+
7+
- Dependency graph
8+
- Dependency review
9+
- Dependabot alerts
10+
- Dependabot updates
11+
- Dependabot security updates
12+
- Dependabot version updates
13+
14+
**What is a dependency graph**: The dependency graph is a summary of the manifest and lock files stored in a repository and any dependencies that are submitted for the repository using the dependency submission API (beta). For each repository, it shows:
15+
16+
- Dependencies, the ecosystems and packages it depends on
17+
- Dependents, the repositories and packages that depend on it
18+
19+
### :keyboard: Activity 1.1: Verify that dependency graph is enabled
20+
21+
**We recommend opening another browser tab to work through the following activities so you can keep these instructions open for reference.**
22+
23+
>[!NOTE]
24+
> Dependency graph is enabled by default for all new public repositories.
25+
26+
1. Navigate to the **Settings** tab.
27+
1. Click **Advanced Security**.
28+
1. Verify **Dependency Graph** is **Enabled**
29+
30+
### :keyboard: Activity 1.2: Add a new dependency and view your dependency graph
31+
32+
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+
,
39+
"follow-redirects": {
40+
"version": "1.14.1",
41+
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.1.tgz",
42+
"integrity": "sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg=="
43+
}
44+
```
45+
46+
1. Navigate to the **Insights** tab.
47+
1. Select **Dependency graph** from the side navigation bar.
48+
1. Review all the dependencies on the **Dependencies** tab.
49+
1. Search for `follow-redirects` and review the new dependency you just added.
50+
![Screen Shot showing the "follow-redirects" dependency.](https://user-images.githubusercontent.com/6351798/196288729-734e3319-c5d7-4f35-a19c-676c12f0e27d.png)
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.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## Step 3: Enable and trigger Dependabot security updates
2+
3+
_Nice work enabling, viewing, and creating Dependabot alerts :sparkles:_
4+
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+
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.
10+
11+
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+
13+
### :keyboard: Activity 3.1: Enable and trigger Dependabot security updates
14+
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.
19+
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.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## Step 4: Enable and trigger Dependabot version updates
2+
3+
_Nicely done!_ :partying_face:
4+
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+
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+
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+
14+
**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.
15+
16+
Let's see how this works!
17+
18+
### :keyboard: Activity 4.1: Enable and trigger Dependabot version updates
19+
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`.
22+
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+
25+
```yaml
26+
version: 2
27+
updates:
28+
- package-ecosystem: "github-actions"
29+
directory: "/"
30+
schedule:
31+
interval: "monthly"
32+
- package-ecosystem: "nuget"
33+
directory: "/code/"
34+
schedule:
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+
40+
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+
43+
You have now configured Dependabot version updates to run and check for updates as follows:
44+
45+
- Check once a month for updates to GitHub Actions and create pull requests to update any that are out of date.
46+
- 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).

.github/steps/x-review.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Review
2+
3+
_Congratulations, you've completed this exercise and learned a lot securing your supply chain!_
4+
5+
<img src="https://octodex.github.com/images/jetpacktocat.png" alt="celebrate" width=200 align=right>
6+
Here's a recap of all the tasks you've accomplished in your repository:
7+
8+
- You've learned how to view and use dependency graph.
9+
- You've learned how to enable and use Dependabot alerts.
10+
- You've learned how to enable and use Dependabot security updates.
11+
- You've learned how to enable and use Dependabot version updates.
12+
13+
### Additional learning and resources
14+
15+
- [Dependency graph](https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-the-dependency-graph)
16+
- [Exploring the dependencies of a repository](https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/exploring-the-dependencies-of-a-repository)
17+
- [About supply chain security](https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-supply-chain-security)
18+
- [Dependabot alerts](https://docs.github.com/en/code-security/dependabot/dependabot-alerts/about-dependabot-alerts)
19+
- [GitHub Advisory Database](https://docs.github.com/en/code-security/dependabot/dependabot-alerts/browsing-security-advisories-in-the-github-advisory-database)
20+
21+
### What's next?
22+
23+
- 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://learn.github.com/skills).
25+
- [Read the Get started with GitHub docs](https://docs.github.com/en/get-started).
26+
- To find projects to contribute to, check out [GitHub Explore](https://github.com/explore).
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Step 0 # Start Exercise
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
actions: write
11+
issues: write
12+
13+
env:
14+
STEP_1_FILE: ".github/steps/1-dependency-graph.md"
15+
16+
jobs:
17+
start_exercise:
18+
if: |
19+
!github.event.repository.is_template
20+
name: Start Exercise
21+
uses: skills/exercise-toolkit/.github/workflows/[email protected]
22+
with:
23+
exercise-title: "Secure your Repository's Supply Chain"
24+
intro-message: "Let's explore how to secure your repository's supply chain, understand dependencies in your environment, and find vulnerabilities in those dependencies and patch them. 💻✨"
25+
26+
post_next_step_content:
27+
name: Post next step content
28+
runs-on: ubuntu-latest
29+
needs: [start_exercise]
30+
env:
31+
ISSUE_REPOSITORY: ${{ github.repository }}
32+
ISSUE_NUMBER: ${{ needs.start_exercise.outputs.issue-number }}
33+
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v6
37+
38+
- name: Get response templates
39+
uses: actions/checkout@v6
40+
with:
41+
repository: skills/exercise-toolkit
42+
path: exercise-toolkit
43+
ref: v0.7.3
44+
45+
- name: Create comment - add step content
46+
uses: GrantBirki/[email protected]
47+
with:
48+
repository: ${{ env.ISSUE_REPOSITORY }}
49+
issue-number: ${{ env.ISSUE_NUMBER }}
50+
file: ${{ env.STEP_1_FILE }}
51+
52+
- name: Create comment - watching for progress
53+
uses: GrantBirki/[email protected]
54+
with:
55+
repository: ${{ env.ISSUE_REPOSITORY }}
56+
issue-number: ${{ env.ISSUE_NUMBER }}
57+
file: exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md
58+
59+
- name: Enable next step workflow
60+
run: |
61+
gh workflow enable "Step 1"
62+
env:
63+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)