Add DevSecOps Demo 08 page with latest GHAS features and updates; upd…#114
Add DevSecOps Demo 08 page with latest GHAS features and updates; upd…#114
Conversation
…ate Index page to link to new demo
Dependency ReviewThe following issues were found:
Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Vulnerabilitiessrc/webapp01/webapp01.csproj
Only included vulnerabilities with severity moderate or higher. OpenSSF Scorecard
Scanned Files
|
1 similar comment
Dependency ReviewThe following issues were found:
Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Vulnerabilitiessrc/webapp01/webapp01.csproj
Only included vulnerabilities with severity moderate or higher. OpenSSF Scorecard
Scanned Files
|
There was a problem hiding this comment.
CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
There was a problem hiding this comment.
Pull request overview
This PR adds a new DevSecOps Demo 08 page showcasing the latest GitHub Advanced Security (GHAS) features and updates, specifically highlighting capabilities available as of December 2025. The page intentionally contains security vulnerabilities for demonstration and testing purposes.
Key Changes:
- Added comprehensive DevSecOps08 demo page with latest GHAS feature announcements and intentional security vulnerabilities
- Updated Index page to include navigation link to the new demo page
- Downgraded Newtonsoft.Json package from version 13.0.1 to 12.0.2
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 13 comments.
| File | Description |
|---|---|
| src/webapp01/webapp01.csproj | Downgrades Newtonsoft.Json package version from 13.0.1 to 12.0.2 |
| src/webapp01/Pages/Index.cshtml | Adds new navigation link and description for DevSecOps Demo 08 page |
| src/webapp01/Pages/DevSecOps08.cshtml.cs | Implements backend code with intentional security vulnerabilities for GHAS demonstration including SQL injection, log forging, insecure deserialization, and hard-coded credentials |
| src/webapp01/Pages/DevSecOps08.cshtml | Creates frontend view displaying GHAS feature announcements, impact statistics, and security vulnerability demonstrations |
| <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" /> | ||
| <PackageReference Include="System.Text.Json" Version="8.0.4" /> | ||
| <PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | ||
| <PackageReference Include="Newtonsoft.Json" Version="12.0.2" /> |
There was a problem hiding this comment.
This change downgrades Newtonsoft.Json from version 13.0.1 to 12.0.2. Downgrading package versions can introduce known security vulnerabilities and bugs that were fixed in later versions. Version 13.0.1 (released in 2021) includes important security fixes and improvements over 12.0.2 (released in 2019). Unless there's a specific compatibility requirement, it's recommended to keep the newer version or upgrade to the latest stable version.
| <PackageReference Include="Newtonsoft.Json" Version="12.0.2" /> | |
| <PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> |
| using System.Text.RegularExpressions; | ||
| using Microsoft.Data.SqlClient; | ||
| using Newtonsoft.Json; | ||
| using System.Text.Json; |
There was a problem hiding this comment.
Both Newtonsoft.Json (line 5) and System.Text.Json (line 6) namespaces are imported, but only Newtonsoft.Json is used in the code (line 136). Importing both JSON libraries can cause confusion about which serialization approach is being used. Consider removing the unused System.Text.Json import, or if this is intentional for demo purposes, add a comment explaining why both are imported.
| using System.Text.Json; |
| private const string DB_CONNECTION = "Server=myserver.database.windows.net;Database=ProductionDB;User Id=dbadmin;Password=P@ssw0rd123!;"; | ||
| private const string API_KEY = "ghp_1234567890abcdefghijklmnopqrstuvwxyz12"; | ||
|
|
||
| // VULNERABILITY: Vulnerable regex pattern susceptible to ReDoS (Regular Expression Denial of Service) |
There was a problem hiding this comment.
The comment "VULNERABILITY: Vulnerable regex pattern susceptible to ReDoS" contains redundancy with both "VULNERABILITY" and "Vulnerable" used together. Consider simplifying to "VULNERABILITY: Regex pattern susceptible to ReDoS" for better readability.
| // VULNERABILITY: Vulnerable regex pattern susceptible to ReDoS (Regular Expression Denial of Service) | |
| // VULNERABILITY: Regex pattern susceptible to ReDoS (Regular Expression Denial of Service) |
| catch (Exception ex) | ||
| { | ||
| // VULNERABILITY: Logging potentially sensitive exception details | ||
| _logger.LogError($"Database operation failed: {ex.ToString()}"); |
There was a problem hiding this comment.
Redundant call to 'ToString' on a String object.
| _logger.LogError($"Database operation failed: {ex.ToString()}"); | |
| _logger.LogError($"Database operation failed: {ex}"); |
| catch (Exception ex) | ||
| { | ||
| // VULNERABILITY: Exposing sensitive error details | ||
| _logger.LogError($"Command execution failed: {ex.ToString()}"); |
There was a problem hiding this comment.
Redundant call to 'ToString' on a String object.
| _logger.LogError($"Command execution failed: {ex.ToString()}"); | |
| _logger.LogError($"Command execution failed: {ex}"); |
| using var connection = new SqlConnection(DB_CONNECTION); | ||
|
|
||
| // VULNERABILITY: SQL Injection - constructing query with string concatenation | ||
| string userId = Request.Query.ContainsKey("userId") ? Request.Query["userId"].ToString() ?? "1" : "1"; |
There was a problem hiding this comment.
Inefficient use of 'ContainsKey' and indexer.
| string userId = Request.Query.ContainsKey("userId") ? Request.Query["userId"].ToString() ?? "1" : "1"; | |
| var userIdValue = Request.Query["userId"].ToString(); | |
| string userId = string.IsNullOrEmpty(userIdValue) ? "1" : userIdValue; |
| _logger.LogInformation($"Regex match result: {match} for pattern: {testInput}"); | ||
|
|
||
| // Another vulnerable regex pattern | ||
| string email = Request.Query.ContainsKey("email") ? Request.Query["email"].ToString() ?? "" : ""; |
| _logger.LogInformation("Demonstrating JSON deserialization..."); | ||
|
|
||
| // Get JSON from query parameter | ||
| string jsonInput = Request.Query.ContainsKey("json") ? Request.Query["json"].ToString() ?? "{}" : "{}"; |
There was a problem hiding this comment.
Inefficient use of 'ContainsKey' and indexer.
| string jsonInput = Request.Query.ContainsKey("json") ? Request.Query["json"].ToString() ?? "{}" : "{}"; | |
| string jsonInput = Request.Query.TryGetValue("json", out var jsonValue) ? jsonValue.ToString() ?? "{}" : "{}"; |
| }; | ||
|
|
||
| // This could lead to remote code execution if attacker controls the JSON | ||
| var deserializedObject = JsonConvert.DeserializeObject(jsonInput, settings); |
There was a problem hiding this comment.
This assignment to deserializedObject is useless, since its value is never read.
| var deserializedObject = JsonConvert.DeserializeObject(jsonInput, settings); | |
| JsonConvert.DeserializeObject(jsonInput, settings); |
…ate Index page to link to new demo