Skip to content

Commit fa32765

Browse files
author
Chris Howd
committed
updated instructions for the "Resolve GitHub Issues" exercise
1 parent 3df3824 commit fa32765

1 file changed

Lines changed: 181 additions & 44 deletions

File tree

Instructions/Labs/LAB_AK_11_resolve_github_issues.md

Lines changed: 181 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ Use the following steps to complete this task:
178178
179179
Understanding the structure and functionality of an existing codebase is essential before implementing security fixes. The ContosoShopEasy application follows a layered architecture typical of enterprise applications, with clear separation between models, services, data access, and security components. Reviewing the code structure and running the application helps establish a baseline for testing after implementing security improvements.
180180
181-
In this task, you clone the ContosoShopEasy repository, examine the project structure, and observe the application's current behavior.
181+
In this task, you clone the ContosoShopEasy repository, examine the project structure, observe the application's current behavior, and review security vulnerabilities.
182182

183183
Use the following steps to complete this task:
184184

@@ -226,142 +226,279 @@ Use the following steps to complete this task:
226226
dotnet run
227227
```
228228
229-
The application executes a complete e-commerce workflow simulation. It exposes multiple security vulnerabilities through detailed console logging. The application first runs a security audit that displays hardcoded admin credentials. It then demonstrates user registration, login attempts, and product searches with SQL injection patterns. The application also shows payment processing with full credit card logging and order management. Throughout this process, it outputs sensitive information to the console including passwords, credit card numbers, CVV codes, session tokens, and internal system details.
229+
The application runs an e-commerce workflow simulation that exposes security vulnerabilities through detailed console logging.
230230
231-
1. Review the console output to identify security-related logging.
231+
1. Review the console output.
232232
233233
Notice that the application logs sensitive information such as passwords, credit card numbers, admin credentials, and internal system details. This output provides clear evidence of the security issues that need to be addressed.
234234
235-
1. Take a few minutes to locate/read the code comments associated with the GitHub issues:
235+
> **NOTE**: Code logic and logging in this app are designed to expose security vulnerabilities. Although the implementation is contrived, the logs highlight security issues that are common in real-world applications.
236236
237-
- **Fix SQL Injection Vulnerability in Product Search**: Open the ProductService.cs file and scan the SearchProducts method.
237+
1. To begin a review process that identifies security vulnerabilities in the codebase, expand the **Models** folder, and then open the **Order.cs** file.
238238
239-
- **Replace MD5 Password Hashing with Secure Alternative**: Open the UserService.cs file and scan the GetMd5Hash method.
239+
1. Scroll down to find the **PaymentInfo** class.
240240
241-
- **Remove Sensitive Data from Debug Logging**: Open the UserService.cs and PaymentService.cs files and scan the registration/login/payment methods.
241+
Notice the comments regarding the CardNumber and CVV properties. This code is related to the "Fix Credit Card Data Storage Violations" issue.
242242
243-
- **Remove Hardcoded Admin Credentials**: Open the SecurityValidator.cs file and scan the admin credential constants (lines 7-9).
243+
1. Expand the **Security** folder and then open the **SecurityValidator.cs** file.
244244
245-
- **Fix Credit Card Data Storage Violations**: Open the Models/Order.cs file and scan the CardNumber and CVV properties.
245+
1. Take a minute to locate the following security issues:
246246
247-
- **Fix Input Validation Security Bypass**: Open the SecurityValidator.cs file and scan the ValidateInput method that always returns true.
247+
- Near the top of the file, notice the comment related to the admin credential constants (lines 7-9). This code is related to the "Remove Hardcoded Admin Credentials" issue.
248248
249-
- **Fix Predictable Session Token Generation**: Open the SecurityValidator.cs file and scan the GenerateSessionToken method.
249+
- Locate the ValidateInput method and review the comments describing security vulnerabilities. This code is related to the "Fix Input Validation Security Bypass" issue.
250250
251-
- **Improve Email Validation Security**: Open the SecurityValidator.cs file and scan the ValidateEmail method.
251+
- Locate the ValidateEmail method and review the comments describing security vulnerabilities. This code is related to the "Improve Email Validation Security" issue.
252252
253-
- **Strengthen Password Security Requirements**: Open the SecurityValidator.cs file and scan the ValidatePasswordStrength method.
253+
- Locate the ValidatePasswordStrength method and review the comments describing security vulnerabilities. This code is related to the "Strengthen Password Security Requirements" issue.
254254
255-
- **Reduce Information Disclosure in Error Messages**: There are multiple classes with verbose debug logging and security audit methods. For example, open the SecurityValidator.cs file and scan the RunSecurityAudit method.
255+
- Locate the GenerateSessionToken method and review the comments describing security vulnerabilities. This code is related to the "Fix Predictable Session Token Generation" issue.
256+
257+
- Locate the RunSecurityAudit method and review the comments describing security vulnerabilities. This code is related to the "Reduce Information Disclosure in Error Messages" issue.
258+
259+
1. Expand the **Services** folder and then open the **UserService.cs** file.
260+
261+
1. Take a minute to locate the following security issues:
262+
263+
- Locate the RegisterUser, LoginUser, and ValidateUserInput methods and review the comments describing security vulnerabilities. This code is related to the "Remove Sensitive Data from Debug Logging" issues.
264+
- Locate the GetMd5Hash method and review the comments describing security vulnerabilities. This code is related to the "Replace MD5 Password Hashing with Secure Alternative" issue.
265+
266+
1. Open the **PaymentService.cs** file.
267+
268+
1. Take a minute to review the comments describing security vulnerabilities.
269+
270+
This code is related to the "Remove Sensitive Data from Debug Logging" issue.
271+
272+
1. Open the **ProductService.cs** file.
273+
274+
1. Take a minute to review the SearchProducts method.
275+
276+
This code is related to the "Fix SQL Injection Vulnerability in Product Search" issue.
256277
257278
### Analyze issues using GitHub Copilot's Ask mode
258279

259280
GitHub Copilot's Ask mode provides intelligent code analysis capabilities that can help identify security vulnerabilities, understand their potential impact, and suggest remediation strategies. By systematically analyzing each security issue, you can develop a comprehensive understanding of the problems before implementing fixes. This approach ensures that solutions address root causes rather than just symptoms.
260281
261-
In this task, you use GitHub Copilot's Ask mode to systematically analyze the security vulnerabilities, starting with the most critical issues and working your way down by priority.
282+
In this task, you use GitHub Copilot's Ask mode to systematically analyze the security vulnerabilities.
262283

263284
Use the following steps to complete this task:
264285

265286
1. Open the GitHub Copilot Chat view and ensure that Ask mode is selected.
266287

267-
If the Chat view isn't already open, select the **Chat** icon at the top of the Visual Studio Code window. Verify that the chat mode is set to **Ask** and you're using the **GPT-4.1** model for complex security analysis.
288+
If the Chat view isn't already open, select the **Chat** icon at the top of the Visual Studio Code window. Verify that the chat mode is set to **Ask** and you're using the **GPT-4.1** model.
268289

269-
1. Begin with the SQL injection vulnerability analysis.
290+
1. Open the **ProductService.cs** file, and then locate the **SearchProducts** method.
270291

271-
Open the `ProductService.cs` file and locate the `SearchProducts` method. Select the entire method and add it to the Chat context using drag-and-drop or by right-clicking and selecting **Add to Chat**.
292+
1. In the code editor, select the entire **SearchProducts** method.
272293

273-
1. Ask GitHub Copilot to analyze the SQL injection vulnerability.
294+
Selecting code in the editor focuses the Chat context. GitHub Copilot uses the selected code to provide relevant analysis and recommendations.
274295

275-
Submit the following prompt to analyze the security issue:
296+
1. Ask GitHub Copilot to analyze the the code for SQL injection vulnerability.
297+
298+
For example, you can submit the following prompt:
276299

277300
```text
278301
Analyze the SearchProducts method for security vulnerabilities. What makes this code susceptible to SQL injection attacks, and what are the potential consequences if an attacker exploits this vulnerability?
279302
```
280303
281-
1. Review GitHub Copilot's analysis and ask for specific remediation guidance.
304+
1. Review GitHub Copilot's analysis and then ask for specific remediation guidance.
282305
283-
After reviewing the initial analysis, ask for specific fixes:
306+
For example, after reviewing the initial analysis, you can submit the following prompt:
284307
285308
```text
286309
How can I modify this method to prevent SQL injection attacks? What secure coding practices should I implement to safely handle user input in database queries?
287310
```
288311
289-
1. Analyze the weak password hashing vulnerability.
312+
1. Take a minute to review GitHub Copilot's remediation suggestions.
313+
314+
1. Open the **UserService.cs** file, and then locate the **GetMd5Hash** method.
315+
316+
1. In the code editor, select the entire **GetMd5Hash** method.
290317
291-
Open the `UserService.cs` file and locate the `GetMd5Hash` method. Add this method to the Chat context and submit the following prompt:
318+
1. Ask GitHub Copilot to analyze the weak password hashing vulnerability.
319+
320+
For example, you can submit the following prompt:
292321
293322
```text
294323
Why is MD5 hashing unsuitable for password storage? What are the security risks of using MD5 for passwords, and what stronger alternatives should I use instead?
295324
```
296325
297-
1. Ask for specific guidance on implementing secure password hashing.
326+
1. Review GitHub Copilot's analysis and then ask for specific remediation guidance.
327+
328+
For example, after reviewing the initial analysis, you can submit the following prompt:
298329
299330
```text
300331
Show me how to implement secure password hashing using bcrypt or PBKDF2. What additional security measures should I implement for password handling?
301332
```
302333
303-
1. Analyze the sensitive data logging issues (Issue #3).
334+
1. Take a minute to review GitHub Copilot's remediation suggestions.
304335
305-
Open the `PaymentService.cs` and `UserService.cs` files and locate methods that log sensitive information. Add relevant methods to the Chat context and ask:
336+
1. In the **UserService.cs** file, locate the **RegisterUser** and **LoginUser** methods.
337+
338+
These methods log user information. Logging sensitive information is a security vulnerability.
339+
340+
1. In the code editor, select both methods.
341+
342+
1. Ask GitHub Copilot to analyze the sensitive data logging vulnerability.
343+
344+
For example, you can submit the following prompt:
306345
307346
```text
308-
What sensitive information is being logged in the payment processing and user registration methods? Why is logging passwords, credit card numbers, and CVV codes a security risk?
347+
What sensitive information is being logged in the user registration and login methods? Why is logging passwords and user data a security risk?
309348
```
310349
311-
1. Examine the hardcoded credentials vulnerability (Issue #4).
350+
1. Review GitHub Copilot's analysis and then ask for specific remediation guidance.
312351
313-
Open the `SecurityValidator.cs` file and locate the admin credential constants around lines 7-9. Add the relevant code to the Chat context and ask:
352+
For example, after reviewing the initial analysis, you can submit the following prompt:
353+
354+
```text
355+
How can I modify these methods to prevent sensitive data logging? What secure logging practices should I implement to protect user information?
356+
```
357+
358+
1. Take a minute to review GitHub Copilot's remediation suggestions.
359+
360+
1. Open the **PaymentService.cs** file, and then locate the **ProcessPayment** method.
361+
362+
1. In the code editor, select the entire **ProcessPayment** method.
363+
364+
1. Ask GitHub Copilot to analyze the logging of sensitive payment data.
365+
366+
For example, you can submit the following prompt:
367+
368+
```text
369+
What sensitive payment information is being logged in this method? Why is logging credit card numbers and CVV codes a security risk?
370+
```
371+
372+
1. Open the **SecurityValidator.cs** file, and then locate the admin credential constants near the top of the file.
373+
374+
1. In the code editor, select the hardcoded admin credential constants.
375+
376+
1. Ask GitHub Copilot to analyze the hardcoded credentials vulnerability.
377+
378+
For example, you can submit the following prompt:
314379
315380
```text
316381
What security risks are created by hardcoding admin credentials in source code? How should application credentials be managed securely in production environments?
317382
```
318383
319-
1. Analyze the credit card data storage issues (Issue #5).
384+
1. Review GitHub Copilot's analysis and then ask for specific remediation guidance.
320385
321-
Open the `Models/Order.cs` file and examine the CardNumber and CVV properties. Add this code to the Chat context and ask:
386+
For example, after reviewing the initial analysis, you can submit the following prompt:
322387
323388
```text
324-
Why is storing full credit card numbers and CVV codes a PCI DSS compliance violation? What are the proper ways to handle payment card data securely?
389+
What are best practices for managing application credentials securely? How can I implement secure credential management in this application?
325390
```
326391
327-
1. Review the input validation bypass (Issue #6).
392+
1. Take a minute to review GitHub Copilot's remediation suggestions.
328393
329-
Focus on the `ValidateInput` method in `SecurityValidator.cs` that always returns true despite detecting threats. Ask:
394+
1. In the **SecurityValidator.cs** file, locate the **ValidateInput** method.
395+
396+
1. In the code editor, select the entire **ValidateInput** method.
397+
398+
1. Ask GitHub Copilot to analyze the input validation bypass vulnerability.
399+
400+
For example, you can submit the following prompt:
330401
331402
```text
332403
What makes this input validation method ineffective? Why does it detect dangerous input but still return true, and how should proper input validation work?
333404
```
334405
335-
1. Examine the predictable session token generation (Issue #7).
406+
1. Review GitHub Copilot's analysis and then ask for specific remediation guidance.
336407
337-
Focus on the `GenerateSessionToken` method in `SecurityValidator.cs` and ask:
408+
For example, after reviewing the initial analysis, you can submit the following prompt:
409+
410+
```text
411+
How can I modify this method to implement effective input validation? What secure coding practices should I follow to prevent input validation bypass vulnerabilities?
412+
```
413+
414+
1. Take a minute to review GitHub Copilot's remediation suggestions.
415+
416+
1. In the **SecurityValidator.cs** file, locate the **GenerateSessionToken** method.
417+
418+
1. In the code editor, select the entire **GenerateSessionToken** method.
419+
420+
1. Ask GitHub Copilot to analyze the predictable session token generation vulnerability.
421+
422+
For example, you can submit the following prompt:
338423
339424
```text
340425
Why are predictable session tokens based on username and timestamp a security risk? How should secure, unpredictable session tokens be generated?
341426
```
342427
343-
1. Analyze the weak email validation (Issue #8).
428+
1. Review GitHub Copilot's analysis and then ask for specific remediation guidance.
344429
345-
Review the `ValidateEmail` method in `SecurityValidator.cs` that only checks for "@" and "." characters. Ask:
430+
For example, after reviewing the initial analysis, you can submit the following prompt:
431+
432+
```text
433+
How can I modify this method to generate secure, unpredictable session tokens? What cryptographic techniques should I use to enhance session token security?
434+
```
435+
436+
1. Take a minute to review GitHub Copilot's remediation suggestions.
437+
438+
1. In the **SecurityValidator.cs** file, locate the **ValidateEmail** method.
439+
440+
1. In the code editor, select the entire **ValidateEmail** method.
441+
442+
1. Ask GitHub Copilot to analyze the weak email validation vulnerability.
443+
444+
For example, you can submit the following prompt:
346445
347446
```text
348447
What makes this email validation insufficient? What are the security risks of weak email validation, and how should proper email validation be implemented?
349448
```
350449
351-
1. Review the insufficient password requirements (Issue #9).
450+
1. Review GitHub Copilot's analysis and then ask for specific remediation guidance.
451+
452+
For example, after reviewing the initial analysis, you can submit the following prompt:
453+
454+
```text
455+
How can I modify this method to implement robust email validation? What techniques should I use to ensure email addresses are properly validated?
456+
```
457+
458+
1. In the **SecurityValidator.cs** file, locate the **ValidatePasswordStrength** method.
459+
460+
1. In the code editor, select the entire **ValidatePasswordStrength** method.
461+
462+
1. Ask GitHub Copilot to analyze the insufficient password requirements vulnerability.
352463
353-
Examine the `ValidatePasswordStrength` method in `SecurityValidator.cs` that only requires 4 characters. Ask:
464+
For example, you can submit the following prompt:
354465
355466
```text
356467
Why are these password requirements insufficient for security? What are proper password complexity requirements, and how should password strength be validated?
357468
```
358469
359-
1. Analyze the information disclosure issues (Issue #10).
470+
1. Review GitHub Copilot's analysis and then ask for specific remediation guidance.
471+
472+
For example, after reviewing the initial analysis, you can submit the following prompt:
473+
474+
```text
475+
How can I modify this method to enforce strong password requirements? What best practices should I follow for password strength validation?
476+
```
477+
478+
1. Take a minute to review GitHub Copilot's remediation suggestions.
479+
480+
1. Under the **Models** folder, open the **Order.cs** file, and then locate the **PaymentInfo** class.
481+
482+
1. In the code editor, select the **CardNumber** and **CVV** properties within the **PaymentInfo** class.
483+
484+
1. Ask GitHub Copilot to analyze the credit card data storage violations.
485+
486+
For example, you can submit the following prompt:
487+
488+
```text
489+
Why is storing full credit card numbers and CVV codes a PCI DSS compliance violation? What are the proper ways to handle payment card data securely?
490+
```
491+
492+
1. Return to the **SecurityValidator.cs** file, and then locate the **RunSecurityAudit** method.
493+
494+
1. In the code editor, select the entire **RunSecurityAudit** method.
495+
496+
1. Ask GitHub Copilot to analyze the information disclosure vulnerability.
360497
361-
Select the `RunSecurityAudit` method and other debug logging across different files and ask:
498+
For example, you can submit the following prompt:
362499
363500
```text
364-
How does the security audit method and excessive debug logging create information disclosure vulnerabilities? What information should never be exposed in logs or error messages?
501+
How does the security audit method create information disclosure vulnerabilities? What information should never be exposed in logs or error messages?
365502
```
366503
367504
1. Document the analysis results for reference during the remediation phase.

0 commit comments

Comments
 (0)