-
-
Notifications
You must be signed in to change notification settings - Fork 2
fix: resolve 5 CodeQL source alerts and suppress 1 intentional obsolete call #428
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 |
|---|---|---|
|
|
@@ -402,11 +402,8 @@ private static bool IsUnderTrustedDirectory(string fullPath) | |
| Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) | ||
| }; | ||
|
|
||
| foreach (var dir in trustedDirs) | ||
| { | ||
| if (!string.IsNullOrEmpty(dir) && fullPath.StartsWith(dir, StringComparison.OrdinalIgnoreCase)) | ||
| return true; | ||
| } | ||
| return false; | ||
| return trustedDirs.Any(dir => | ||
| !string.IsNullOrEmpty(dir) && | ||
| fullPath.StartsWith(dir, StringComparison.OrdinalIgnoreCase)); | ||
|
Comment on lines
+405
to
+407
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Harden trusted-directory matching to avoid prefix bypass. This check trusts paths that only start with a trusted prefix, which can be bypassed by sibling paths (for example, Proposed fix- return trustedDirs.Any(dir =>
- !string.IsNullOrEmpty(dir) &&
- fullPath.StartsWith(dir, StringComparison.OrdinalIgnoreCase));
+ var normalizedPath = System.IO.Path.GetFullPath(fullPath)
+ .TrimEnd(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar);
+
+ return trustedDirs.Any(dir =>
+ {
+ if (string.IsNullOrWhiteSpace(dir)) return false;
+ var normalizedDir = System.IO.Path.GetFullPath(dir)
+ .TrimEnd(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar);
+
+ return normalizedPath.Equals(normalizedDir, StringComparison.OrdinalIgnoreCase)
+ || normalizedPath.StartsWith(
+ normalizedDir + System.IO.Path.DirectorySeparatorChar,
+ StringComparison.OrdinalIgnoreCase)
+ || normalizedPath.StartsWith(
+ normalizedDir + System.IO.Path.AltDirectorySeparatorChar,
+ StringComparison.OrdinalIgnoreCase);
+ });🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,9 +31,25 @@ protected static async void InitializeAsync(Func<Task> asyncAction, [System.Runt | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Expected during shutdown — no action needed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| catch (Exception ex) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| catch (InvalidOperationException ex) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Log.Error(ex, "Unhandled exception in async initialization of {Caller}", callerName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Log.Error(ex, "Invalid operation in async initialization of {Caller}", callerName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| catch (UnauthorizedAccessException ex) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Log.Error(ex, "Access denied in async initialization of {Caller}", callerName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| catch (System.IO.IOException ex) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Log.Error(ex, "I/O error in async initialization of {Caller}", callerName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| catch (System.Net.Http.HttpRequestException ex) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Log.Error(ex, "Network error in async initialization of {Caller}", callerName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| catch (TimeoutException ex) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Log.Error(ex, "Timeout in async initialization of {Caller}", callerName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+34
to
53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unhandled exception gap reintroduced in Line 34 onward narrows catches, but without a final fallback, Suggested patch catch (TimeoutException ex)
{
Log.Error(ex, "Timeout in async initialization of {Caller}", callerName);
}
+ catch (Exception ex)
+ {
+ Log.Error(ex, "Unexpected error in async initialization of {Caller}", callerName);
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
🧩 Analysis chain
🌐 Web query:
In GitHub CodeQLcodeql-config.yml, doesquery-filters.excludesupport apathfield? Please list the officially supported fields forquery-filtersand whether unsupported keys are ignored or rejected.💡 Result:
In GitHub CodeQL configuration files (codeql-config.yml), the query-filters.exclude block does not support a path field [1][2]. The query-filters mechanism is designed to filter queries based on their metadata properties (such as id, tags, or severity) rather than file paths [1][2]. To exclude specific files or directories from CodeQL analysis, you should use the top-level paths-ignore field in your codeql-config.yml file instead [3][2][4]. Officially supported fields for query-filters The query-filters section supports include and exclude blocks [2]. Within these blocks, you can filter queries using any valid CodeQL query metadata property [1]. Common examples include: - id: The unique identifier of the query [5][1][2]. - tags: The tags associated with the query [2]. - kind: The kind of query (e.g., problem, path-problem, table) [5][2]. - problem.severity: The severity level of the query (e.g., warning, recommendation) [2]. Handling of unsupported keys In GitHub Actions, providing unsupported keys in the codeql-config.yml file typically results in a warning or the key being ignored by the CodeQL action [6]. If you provide an invalid property at the top level of the configuration file or within specific blocks, the action may log a warning indicating that the property is not a valid input or is being ignored [6]. It is recommended to strictly follow the documented schema to ensure your configuration is applied correctly [2].
Citations:
🏁 Script executed:
Repository: laurentiu021/SystemManager
Length of output: 822
Remove
pathfromquery-filters.exclude—it's unsupported and causes the suppression to be globalquery-filters.excludedoes not support apathfield. Unsupported fields are ignored, so theid: cs/call-to-obsolete-methodexclusion will suppress this rule across the entire repository, not justUpdateService.cs. Since bothUpdateService.csandSpeedTestService.csalready use local#pragma warning disable SYSLIB0057pragmas at the call sites (which is the correct approach), remove the ineffective CodeQL config line entirely.🤖 Prompt for AI Agents