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
Copy file name to clipboardExpand all lines: docs/04_make_things_secure/0401.md
+15-24Lines changed: 15 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,20 +17,19 @@ In addition to these manual processes, GitHub also provides automated tools for
17
17
18
18
## Description
19
19
20
-
In this task, you will improve the security of your repository using some of GitHub's built-in tools.
20
+
In this task, you will enable some of GitHub's built-in tools for securing code in repositories.
21
21
22
22
1. Ask GitHub Copilot, "What do I need in a GitHub repository's security file?"
23
-
2. Find the repository's Security policy. If there is an existing policy, make an edit and merge your change back into the main branch. Otherwise, create a policy using the template provided. GitHub Security policies are Markdown documents that indicate the preferred way to report security vulnerabilities for the repository.
23
+
2. Find the repository's Security policy. If there is an existing policy, make an edit using GithUb Copilot and merge your change back into the main branch. Otherwise, create a policy using the template provided and GitHub Copilot. GitHub Security policies are Markdown documents that indicate the preferred way to report security vulnerabilities for the repository.
24
24
3. Ask GitHub Copilot, "How do I enable Dependabot alerts on a GitHub repository?" Then, enable Dependabot alerts for the repository. Dependabot is an automated tool that creates a pull request when any dependencies in the code base has a known vulnerability.
25
25
4. Ask GitHub Copilot, "How do I create a code scanning workflow in a GitHub repository?" After that, set up and run a Code scanning workflow for the repository using GitHub's 'CodeQL Analysis.' This workflow can run either on each pull request or on a schedule, and it checks your code for common vulnerabilities or errors.
26
-
5. Ask GitHub Copilot, "How can I view the results of a CodeQL analysis in GitHub?" Then, navigate to the results.
27
-
6.You should have one security issue from code scanning. Review the security issue and read up on how to correct the issue. Create a new GitHub Issue and feature branch. Then, resolve the issue, using GitHub Copilot to assist you.
26
+
5. Ask GitHub Copilot, "How can I view the results of a CodeQL analysis in GitHub?" Then, navigate to the results. The next task will cover reviewing and correcting any issues you find.
27
+
6.Ask GitHub Copilot, "How do I enable secret scanningon a GitHub repository?" Then, enable secret scanning and push protection on the repository.
28
28
29
29
## Success Criteria
30
30
31
-
- In GitHub, you should be able to view the 'closed' pull request which either created or updated the Security policy (SECURITY.md file).
32
-
- Additionally, you should be able to view a new 'open' pull request created by Dependabot requesting an update of a dependency.
33
-
- Finally, you should be able to view the results of the CodeQL Analysis in the Security tab.
31
+
- The **Security** page for your GitHub repository shows that Dependabot alerts, Code scanning alerts, and Secret scanning alerts are all enabled.
32
+
- You have one Dependabot alert, one Code scanning alert, and one Secret scanning alert.
34
33
35
34
## Learning Resources
36
35
@@ -40,7 +39,7 @@ In this task, you will improve the security of your repository using some of Git
40
39
41
40
## Tips
42
41
43
-
- If you are stuck, check out the 'Security' tab of your repository on GitHub.
42
+
- If you are stuck, check out the **Security** tab of your repository on GitHub.
44
43
45
44
## Solution
46
45
@@ -70,7 +69,7 @@ In this task, you will improve the security of your repository using some of Git
70
69
71
70

72
71
73
-
8. By choosing the advanced option, you can see the YAML for the pipeline that actually performs the code check. We don't need to make any changes here, but it's something you should be familiar with. An easy change to make in this file would be if you want to adjust the schedule of when the scan runs.
72
+
8. By choosing the advanced option, you can see the YAML for the pipeline that actually performs the code check. We don't need to make any changes here, but it's something you should be familiar with. An easy change to make in this file would be if you want to adjust the schedule of when the scan runs. Use GitHub Copilot to assist you with making any change.
74
73
75
74

76
75
@@ -93,20 +92,12 @@ In this task, you will improve the security of your repository using some of Git
12. Select the alert and then choose "Show more" to view details on the security issue. It turns out that an attacker could traverse to an arbitrary directory based on the way the MP&P staff wrote this function. In order to correct the function and prevent a directory traversal attack, replace `WriteToDirectory()` with the following code:
thrownewSystem.InvalidOperationException("Entry is outside the target dir: "+destFileName);
105
-
}
106
-
entry.ExtractToFile(destFileName);
107
-
}
108
-
```
109
-
110
-
Committhecodeandcreateapullrequesttothemainbranch. YoushouldthenseeaCodeQLscanfor the pull request, and after it succeeds, complete the pull request. Then, return to the code scanning results view and confirm that no issues remain on the list.
95
+
12. Return to the **Settings** menu and select **Code security and analysis**. Navigate to the bottom of the page and select the **Enable** button for Secret scanning.
The Munson's Pickles and Preserves Team Messaging System is up and running! They even have a proper Git Flow to protect against unintended changes to the main branch, and are recording application telemetry into App Insights. Before we are truly production-ready, though, there is one topic we have to cover: security.
13
-
14
-
One good DevOps practice is to enable protections against code-level vulnerabilities, and GitHub provides a number of useful features in this area. First, there are Issues, which allow developers or users to open 'tickets' indicating bugs to be fixed or potential vulnerabilities. If your organization prefers security flaws to be reported in a location other than GitHub, you have the option to provide a custom Security policy which describes the process for reporting.
15
-
16
-
In addition to these manual processes, GitHub also provides automated tools for scanning code for common errors. In this task, you will utilize the built-in Dependabot, which provides alerts if your repository contains libraries, packages, or external dependencies with known vulnerabilities. You will also set up a workflow with CodeQL, which can scan your source code for common coding errors or basic security flaws. This will help to ensure that the Team Messaging System contains code without any known vulnerabilities.
10
+
Now that the Munson's Pickles and Preserves team has GitHub Advanced Security in place, they would like your assistance in resolving the issues the tool has found. They see a variety of issues, from vulnerable dependencies to secrets exposed in code, and even coding practices that may be dangerous.
17
11
18
12
## Description
19
13
20
14
In this task, you will improve the security of your repository using some of GitHub's built-in tools.
21
15
22
-
1. Ask GitHub Copilot, "What do I need in a GitHub repository's security file?"
23
-
2. Find the repository's Security policy. If there is an existing policy, make an edit and merge your change back into the main branch. Otherwise, create a policy using the template provided. GitHub Security policies are Markdown documents that indicate the preferred way to report security vulnerabilities for the repository.
24
-
3. Ask GitHub Copilot, "How do I enable Dependabot alerts on a GitHub repository?" Then, enable Dependabot alerts for the repository. Dependabot is an automated tool that creates a pull request when any dependencies in the code base has a known vulnerability.
25
-
4. Ask GitHub Copilot, "How do I create a code scanning workflow in a GitHub repository?" After that, set up and run a Code scanning workflow for the repository using GitHub's 'CodeQL Analysis.' This workflow can run either on each pull request or on a schedule, and it checks your code for common vulnerabilities or errors.
26
-
5. Ask GitHub Copilot, "How can I view the results of a CodeQL analysis in GitHub?" Then, navigate to the results.
27
-
6. You should have one security issue from code scanning. Review the security issue and read up on how to correct the issue. Create a new GitHub Issue and feature branch. Then, resolve the issue, using GitHub Copilot to assist you.
16
+
1. You should have one security issue from code scanning. Review the security issue and read up on how to correct the issue. Create a new GitHub Issue from the code scanning alert.
17
+
2. You should have one security issue from secret scanning. Create a separate GitHub Issue from the security alert. In reviewing this alert, one of the developers informs you that this secret is part of a local configuration file and that file should not be checked into source control at all.
18
+
3. You should have one Dependabot alert due to a vulnerable version of a library. Try to use Dependabot to fix this package version and create a new pull request with the change. If it does not work, create a GitHub Issue for this Dependabot alert.
19
+
4. Create a new feature branch. Then, use GitHub Copilot to assist you in resolving all of the outstanding security issues.
20
+
5. Create a pull request, closing out the issues that you've resolved. Use GitHub Copilot Enterprise to generate a meaningful pull request message and have another learner review your code changes. Merge your code into the main branch of your repository.
28
21
29
22
## Success Criteria
30
23
31
-
- In GitHub, you should be able to view the 'closed' pull request which either created or updated the Security policy (SECURITY.md file).
32
-
- Additionally, you should be able to view a new 'open' pull request created by Dependabot requesting an update of a dependency.
33
-
- Finally, you should be able to view the results of the CodeQL Analysis in the Security tab.
24
+
- In GitHub, you should be able to view the 'closed' pull request with your changes.
25
+
- The **Security** tab shows no outstanding alerts for Dependabot, Code scanning, or Secret scanning.
34
26
35
27
## Learning Resources
36
28
@@ -40,60 +32,20 @@ In this task, you will improve the security of your repository using some of Git
40
32
41
33
## Tips
42
34
43
-
- If you are stuck, check out the 'Security' tab of your repository on GitHub.
35
+
- If you are stuck, review the details provided for each of the vulnerability alerts. This may include sample code to cause and fix a security issue, as well as links to additional resources.
44
36
45
37
## Solution
46
38
47
39
<detailsmarkdown="block">
48
40
<summary>Expand this section to view the solution</summary>
49
41
50
-
1. Select **Settings** in your repo, then **Code security and analysis**. Select **Enable** on "Dependabot alerts" and "Dependabot security updates."
51
-
52
-

53
-
54
-
**Note** This will also automatically enable "Dependency graph."
55
-
2. Navigate to [https://github.com/electron/electron/blob/main/SECURITY.md](https://github.com/electron/electron/blob/main/SECURITY.md) for information about security policies. This is an example of a sample security policy that you could use for this exercise.
56
-
3. In your GitHub repo, select **Security**, **Policy**, and **Start setup**
57
-
58
-

59
-
60
-
4. Paste the security policy into the Markdown file (you can overwrite what is there now) and update it for the Munson's Pickles and Preserves Team Messaging System and the GitHub repo your code is in. Then, commit the changes to the main branch.
61
-
62
-

63
-
64
-
5. Next, we need to enable CodeQL. Select **Settings** and then **Code security and analysis**.
65
-
6. Scroll down if needed and select **Set up** in "Code scanning" for "CodeQL analysis."
7. If you select "Default", the code scan will immediately be run. For this exercise, select **Advanced**.
70
-
71
-

72
-
73
-
8. By choosing the advanced option, you can see the YAML for the pipeline that actually performs the code check. We don't need to make any changes here, but it's something you should be familiar with. An easy change to make in this file would be if you want to adjust the schedule of when the scan runs.
74
-
75
-

76
-
77
-
After you've reviewed the YAML, commit the change to main.
78
-
79
-

80
-
81
-
9. After you've committed the change, select **Actions** and you should see your CodeQL Scan workflow running.
11. After it's complete, go back to **Settings** and **Code security and analysis**. Then, select the ellipsis **...** next to the "Set up" menu. From the ellipsis dropdown, explore each of the first two options: "View last scan log" and "View Code Scanning alerts." You will find one High-risk vulnerability around arbitrary file access during archive extraction.
90
-
91
-
{: .note }
92
-
> This page will still show "Set up" because we chose the Advanced option instead of Basic.
1. Select **Security** in your repo, then **Code scanning**. Select the 'Arbitrary file access during archive extraction ("Zip Slip")' code issue. Select **Create issue** to create a GitHub issue around this code scanning alert.
43
+
2. After creating an issue for the code scanning alert, navigate back to **Security** and then select **Secret scanning**. TODO: continue this!
44
+
3. After creating an issue for the secret scanning alert, navigate back to the **Security** page and then select **Dependabot**. Select the 'Improper Handling of Exceptional Conditions in Newtonsoft.Json' alert. Then, select **Create Dependabot security update** to have Dependabot try to fix this issue. TODO: continue this!
45
+
4. Create a new feature branch and give it a name like 'security-fixes'. Fetch changes from your machine and then check out and pull the new branch using the Git command line, Visual Studio Code, or your tool of choice.
46
+
5. In GitHub, navigate back to the **Security** page and then select **Code scanning**. Select the code issue once again. Choose "Show more" to view details on the security issue. It turns out that an attacker could traverse to an arbitrary directory based on the way the MP&P staff wrote this function. In order to correct the function and prevent a directory traversal attack, update the `WriteToDirectory()` function. You can highlight the function, strike `Ctrl+i` or `Command+i`, and use a prompt like "Please update this function to prevent a directory traversal attack."
95
47
96
-
12. Select the alert and then choose "Show more" to view details on the security issue. It turns out that an attacker could traverse to an arbitrary directory based on the way the MP&P staff wrote this function. In order to correct the function and prevent a directory traversal attack, replace `WriteToDirectory()` with the following code:
48
+
For comparison, the following code will not be vulnerable to a directory traversal attack:
@@ -107,6 +59,10 @@ In this task, you will improve the security of your repository using some of Git
107
59
}
108
60
```
109
61
110
-
Committhecodeandcreateapullrequesttothemainbranch. YoushouldthenseeaCodeQLscanfor the pull request, and after it succeeds, complete the pull request. Then, return to the code scanning results view and confirm that no issues remain on the list.
Copy file name to clipboardExpand all lines: docs/04_make_things_secure/0403.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ parent: 'Exercise 04: Make things secure'
9
9
10
10
## Introduction
11
11
12
-
To wrap up the DevOps journey, Munson's Pickles and Preserves would like to understand what is happening in their deployed environments. By the time users complain about a problem, it is already too late. It is also imperative to know not only about the performance of the site, but also the impact--positive or negative--a feature has had on the users. Please take a moment to review the articles in the **Learning Resources** section to gain a better understanding of the importance of monitoring, as well as Application Insights, one of the tools available in Azure to make monitoring easy.
12
+
To reach the next step of their DevOps journey, Munson's Pickles and Preserves would like to understand what is happening in their deployed environments. By the time users complain about a problem, it is already too late. It is also imperative to know not only about the performance of the site, but also the impact--positive or negative--a feature has had on the users. Please take a moment to review the articles in the **Learning Resources** section to gain a better understanding of the importance of monitoring, as well as Application Insights, one of the tools available in Azure to make monitoring easy.
Copy file name to clipboardExpand all lines: index.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,4 +27,7 @@ For running this lab you will need:
27
27
* An AAD tenant where you are a global admin. and an Azure subscription in that same tenant.
28
28
* M365 E5 licenses (or a trial for these licenses configured) in that same tenant.
29
29
30
-
**[MCAPS non-prod subscriptions](https://dev.azure.com/OneCommercial/NoCode/_wiki/wikis/NoCode.wiki/12/Hybrid-Subscription) are the most convenient way for you to meet all these prerequisites**, and the lab activities assume that you have configured an external subscription via [https://aka.ms/MCAPSNewAzureSub](https://aka.ms/MCAPSNewAzureSub).
30
+
**[MCAPS non-prod subscriptions](https://dev.azure.com/OneCommercial/NoCode/_wiki/wikis/NoCode.wiki/12/Hybrid-Subscription) are the most convenient way for you to meet all these prerequisites**, and the lab activities assume that you have configured an external subscription via [https://aka.ms/MCAPSNewAzureSub](https://aka.ms/MCAPSNewAzureSub). Note that this must be an **external** MCAPS subscription and not a hybrid subscription.
31
+
32
+
{: .note }
33
+
> If you requested an external MCAPS subscription prior to April of 2024, you might have an obsolete MCAPS subscription. In that case, you will need to delete the subscription, delete the tenant, and re-request the external MCAPS subscription in the new system **before** beginning these labs. The link above will allow you to request a subscription in the new system. Obsolete external MCAPS subscriptions will be eliminated in September of 2024.
0 commit comments