-
Notifications
You must be signed in to change notification settings - Fork 0
Fix CodeQL security vulnerabilities in CORS, JWT, logging, and GitHub Actions #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -58,7 +58,9 @@ public static void Main(string[] args) | |||||
| }) | ||||||
| .AddJwtBearer(options => | ||||||
| { | ||||||
| options.RequireHttpsMetadata = false; // enable HTTPS in production | ||||||
| // WARNING: RequireHttpsMetadata should be true in production environments | ||||||
| // Set to false only for local development | ||||||
| options.RequireHttpsMetadata = builder.Environment.IsDevelopment() == false; | ||||||
|
||||||
| options.RequireHttpsMetadata = builder.Environment.IsDevelopment() == false; | |
| options.RequireHttpsMetadata = !builder.Environment.IsDevelopment(); |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |||||||||||||||||||||||||||||||||||||||||
| using System.Text; | ||||||||||||||||||||||||||||||||||||||||||
| using CsvHelper; | ||||||||||||||||||||||||||||||||||||||||||
| using CsvHelper.Configuration; | ||||||||||||||||||||||||||||||||||||||||||
| using Microsoft.Extensions.Logging; | ||||||||||||||||||||||||||||||||||||||||||
| using OfficeOpenXml; | ||||||||||||||||||||||||||||||||||||||||||
| using PhantomDave.BankTracking.Api.Types.ObjectTypes; | ||||||||||||||||||||||||||||||||||||||||||
| using PhantomDave.BankTracking.Library.Models; | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -24,8 +25,10 @@ public class ParsedFileData | |||||||||||||||||||||||||||||||||||||||||
| public FileType FileTypeExt { get; set; } = FileType.Xlsx; | ||||||||||||||||||||||||||||||||||||||||||
| public int HeaderRowIndex { get; set; } = 1; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| public class FileImportService | ||||||||||||||||||||||||||||||||||||||||||
| public class FileImportService(ILogger<FileImportService> logger) | ||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||
| private readonly ILogger<FileImportService> _logger = logger; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| public async Task<ParsedFileData> ParseFileAsync(IFile file) | ||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||
| await using var reader = file.OpenReadStream(); | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -239,8 +242,9 @@ private static Encoding DetectEncoding(Stream stream) | |||||||||||||||||||||||||||||||||||||||||
| Encoding.UTF8.GetString(buffer, 0, bytesRead); | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
| Encoding.UTF8.GetString(buffer, 0, bytesRead); | |
| var strictUtf8 = Encoding.GetEncoding("UTF-8", new EncoderExceptionFallback(), new DecoderExceptionFallback()); | |
| strictUtf8.GetString(buffer, 0, bytesRead); |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generic catch clause.
| catch (Exception ex) | |
| { | |
| failedCount++; | |
| _logger.LogWarning(ex, "Failed to parse row {RowIndex} during import", records.Count + failedCount); | |
| } | |
| catch (FormatException ex) | |
| { | |
| failedCount++; | |
| _logger.LogWarning(ex, "Failed to parse row {RowIndex} due to format error during import", records.Count + failedCount); | |
| } | |
| catch (KeyNotFoundException ex) | |
| { | |
| failedCount++; | |
| _logger.LogWarning(ex, "Failed to parse row {RowIndex} due to missing column during import", records.Count + failedCount); | |
| } | |
| catch (InvalidCastException ex) | |
| { | |
| failedCount++; | |
| _logger.LogWarning(ex, "Failed to parse row {RowIndex} due to invalid cast during import", records.Count + failedCount); | |
| } |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The debug log is being written inside the loop for every row, which could generate excessive log output. This should be moved outside the foreach loop to log the final count only once after all rows have been processed.
| _logger.LogDebug("Processed {ProcessedRows} / {TotalRows}, Failed: {FailedRows}", | |
| records.Count + failedCount, parsedData.Rows.Count, failedCount); | |
| } | |
| } | |
| _logger.LogDebug("Processed {ProcessedRows} / {TotalRows}, Failed: {FailedRows}", | |
| records.Count + failedCount, parsedData.Rows.Count, failedCount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says "Set to false only for local development" but the code
builder.Environment.IsDevelopment() == falseevaluates totruein production (not development) andfalsein development. Consider rephrasing the comment to be clearer:// RequireHttpsMetadata is disabled in development and enabled in production