Skip to content

Commit a350ca9

Browse files
committed
fix(quality): close remaining CodeQL findings on touched files
Aligns the lines already modified in this branch with the closure work done on codeql/3-correctness so the two branches do not conflict on merge. - CMSFile.cs: seal the class to close cs/virtual-call-in-constructor (no inheritor in C#, no mocking, no UseLazyLoadingProxies). - CompetencyController.UpdateComptency: drop the now-dead `CompetencyId <= 0` check. The preceding FindAsync already returns NotFound when the row is missing; an existing row's identity column is always a positive int. - Program.cs SetAwsCredentials: trim the RegionEndpoint value, look it up with BindingFlags.IgnoreCase, and fall back to USWest1 when the name is non-empty but does not match any known region. The previous ternary could leave profile.Region as null on unknown region names.
1 parent 918ce04 commit a350ca9

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

web/Areas/CMS/Models/CMSFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Viper.Areas.CMS.Models
44
{
5-
public class CMSFile : File
5+
public sealed class CMSFile : File
66
{
77
public string FriendlyURL { get; set; }
88

web/Areas/CTS/Controllers/CompetencyController.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,6 @@ public async Task<ActionResult<CompetencyDto>> UpdateComptency(int competencyId,
136136
return NotFound();
137137
}
138138

139-
if (competency.CompetencyId <= 0)
140-
{
141-
return BadRequest("CompetencyId is required.");
142-
}
143139
if (competency.Name.Length < 2 || competency.Number.Length < 1)
144140
{
145141
return BadRequest("Name and Number are required.");

web/Program.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Net;
2+
using System.Reflection;
23
using System.Security.Claims;
34
using System.Text.Json.Serialization;
45
using System.Text.RegularExpressions;
@@ -561,10 +562,17 @@ void SetAwsCredentials(Logger logger)
561562

562563
var profile = new CredentialProfile("default", options);
563564
// if a region was specified in the xml then use the specified region else default to USWest1
564-
var regionFieldName = xAwsCredentials.Element("RegionEndpoint")?.Value;
565-
profile.Region = !string.IsNullOrWhiteSpace(regionFieldName)
566-
? typeof(RegionEndpoint).GetField(regionFieldName)?.GetValue(null) as RegionEndpoint
567-
: RegionEndpoint.USWest1;
565+
var regionValue = xAwsCredentials.Element("RegionEndpoint")?.Value.Trim();
566+
if (!string.IsNullOrWhiteSpace(regionValue))
567+
{
568+
const BindingFlags regionFieldFlags = BindingFlags.Public | BindingFlags.Static | BindingFlags.IgnoreCase;
569+
profile.Region = typeof(RegionEndpoint).GetField(regionValue, regionFieldFlags)?.GetValue(null) as RegionEndpoint
570+
?? RegionEndpoint.USWest1;
571+
}
572+
else
573+
{
574+
profile.Region = RegionEndpoint.USWest1;
575+
}
568576
var netSDKFile = new NetSDKCredentialsFile();
569577
netSDKFile.RegisterProfile(profile);
570578

0 commit comments

Comments
 (0)