Skip to content

Sync Main (autogenerated) #197

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

Merged
merged 1,124 commits into from
Apr 9, 2025
Merged

Sync Main (autogenerated) #197

merged 1,124 commits into from
Apr 9, 2025

Conversation

dilanbhalla
Copy link
Collaborator

This PR syncs the latest changes from codeql-cli/latest into main.

redsun82 and others added 30 commits March 24, 2025 16:22
… query with a PrintAst name from QlRefInlineExpectations.
This allows the string of package feeds to be constructed once and used repeatedly in the parallel restore loop as well.
…us-id

Docs: add guidance for `previous-id` metadata
…stinlineexpect

QL4QL: Exclude PrintAst like tests from being reported as having missing InlineExpectations.
In particular for `postForm` `putForm` `patchForm` `getUri`.
Co-authored-by: Asger F <asgerf@github.com>
Co-authored-by: Michael Nebel <michaelnebel@github.com>
Paolo Tranquilli and others added 24 commits March 31, 2025 13:11
…rof-rewriting

Java buildless: add buildless-maven variant with a wildcard mirrorOf spec
…-swift

Misc: Add another path prefix to accept-expected-changes-from-ci.py
Rust: rename several entities to their more natural names
…e-bom-downloads

Java: add test exercising Gradle download pruning
Release preparation for version 2.21.0
Compatible with the latest released version of the CodeQL CLI
Comment on lines +821 to +845
if (nugetConfigs.Count > 0)
{
// We don't have to get the feeds from each of the folders from below, it would be enought to check the folders that recursively contain the others.
allFeeds = nugetConfigs
.Select(config =>
{
logger.LogWarning($"Failed to get directory of '{config}': {exc}");
}
return null;
})
.Where(folder => folder != null)
.SelectMany(folder => GetFeeds(() => dotnet.GetNugetFeedsFromFolder(folder!)))
.ToHashSet();
try
{
return new FileInfo(config).Directory?.FullName;
}
catch (Exception exc)
{
logger.LogWarning($"Failed to get directory of '{config}': {exc}");
}
return null;
})
.Where(folder => folder != null)
.SelectMany(folder => GetFeeds(() => dotnet.GetNugetFeedsFromFolder(folder!)))
.ToHashSet();
}
else
{
// If we haven't found any `nuget.config` files, then obtain a list of feeds from the root source directory.
allFeeds = GetFeeds(() => dotnet.GetNugetFeedsFromFolder(this.fileProvider.SourceDir.FullName)).ToHashSet();
}

Check notice

Code scanning / CodeQL

Missed ternary opportunity Note

Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.

Copilot Autofix

AI 4 months ago

To fix the problem, we will replace the if statement with a ternary operator to assign the value to the allFeeds variable. We will also move the logging statements outside the ternary operator to ensure they are executed appropriately based on the condition.

  • Replace the if statement on lines 821-845 with a ternary operator.
  • Move the logging statements to be executed based on the condition separately.
Suggested changeset 1
csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs
--- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs
+++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs
@@ -818,8 +818,4 @@
             // todo: this could be improved.
-            HashSet<string>? allFeeds = null;
-
-            if (nugetConfigs.Count > 0)
-            {
-                // We don't have to get the feeds from each of the folders from below, it would be enought to check the folders that recursively contain the others.
-                allFeeds = nugetConfigs
+            HashSet<string>? allFeeds = nugetConfigs.Count > 0
+                ? nugetConfigs
                     .Select(config =>
@@ -838,3 +834,8 @@
                     .SelectMany(folder => GetFeeds(() => dotnet.GetNugetFeedsFromFolder(folder!)))
-                    .ToHashSet();
+                    .ToHashSet()
+                : GetFeeds(() => dotnet.GetNugetFeedsFromFolder(this.fileProvider.SourceDir.FullName)).ToHashSet();
+
+            if (nugetConfigs.Count > 0)
+            {
+                logger.LogInfo($"Found {allFeeds.Count} Nuget feeds (with inherited ones) in nuget.config files: {string.Join(", ", allFeeds.OrderBy(f => f))}");
             }
@@ -842,8 +843,5 @@
             {
-                // If we haven't found any `nuget.config` files, then obtain a list of feeds from the root source directory.
-                allFeeds = GetFeeds(() => dotnet.GetNugetFeedsFromFolder(this.fileProvider.SourceDir.FullName)).ToHashSet();
+                logger.LogDebug("No Nuget feeds found in nuget.config files.");
             }
 
-            logger.LogInfo($"Found {allFeeds.Count} Nuget feeds (with inherited ones) in nuget.config files: {string.Join(", ", allFeeds.OrderBy(f => f))}");
-
             return (explicitFeeds, allFeeds);
EOF
@@ -818,8 +818,4 @@
// todo: this could be improved.
HashSet<string>? allFeeds = null;

if (nugetConfigs.Count > 0)
{
// We don't have to get the feeds from each of the folders from below, it would be enought to check the folders that recursively contain the others.
allFeeds = nugetConfigs
HashSet<string>? allFeeds = nugetConfigs.Count > 0
? nugetConfigs
.Select(config =>
@@ -838,3 +834,8 @@
.SelectMany(folder => GetFeeds(() => dotnet.GetNugetFeedsFromFolder(folder!)))
.ToHashSet();
.ToHashSet()
: GetFeeds(() => dotnet.GetNugetFeedsFromFolder(this.fileProvider.SourceDir.FullName)).ToHashSet();

if (nugetConfigs.Count > 0)
{
logger.LogInfo($"Found {allFeeds.Count} Nuget feeds (with inherited ones) in nuget.config files: {string.Join(", ", allFeeds.OrderBy(f => f))}");
}
@@ -842,8 +843,5 @@
{
// If we haven't found any `nuget.config` files, then obtain a list of feeds from the root source directory.
allFeeds = GetFeeds(() => dotnet.GetNugetFeedsFromFolder(this.fileProvider.SourceDir.FullName)).ToHashSet();
logger.LogDebug("No Nuget feeds found in nuget.config files.");
}

logger.LogInfo($"Found {allFeeds.Count} Nuget feeds (with inherited ones) in nuget.config files: {string.Join(", ", allFeeds.OrderBy(f => f))}");

return (explicitFeeds, allFeeds);
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +831 to +834
catch (Exception exc)
{
logger.LogWarning($"Failed to get directory of '{config}': {exc}");
}

Check notice

Code scanning / CodeQL

Generic catch clause Note

Generic catch clause.

Copilot Autofix

AI 4 months ago

To fix the problem, we should catch specific exceptions that are likely to occur during the operation of getting the directory of a file. The most relevant exceptions in this context are DirectoryNotFoundException, UnauthorizedAccessException, and IOException. By catching these specific exceptions, we can handle each case appropriately and avoid masking other potential issues.

  • Modify the catch block on line 831 to catch specific exceptions.
  • Ensure that the logging remains intact to help with diagnosing issues.
Suggested changeset 1
csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs
--- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs
+++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs
@@ -830,5 +830,13 @@
                         }
-                        catch (Exception exc)
+                        catch (DirectoryNotFoundException exc)
                         {
-                            logger.LogWarning($"Failed to get directory of '{config}': {exc}");
+                            logger.LogWarning($"Directory not found for '{config}': {exc}");
+                        }
+                        catch (UnauthorizedAccessException exc)
+                        {
+                            logger.LogWarning($"Unauthorized access to directory for '{config}': {exc}");
+                        }
+                        catch (IOException exc)
+                        {
+                            logger.LogWarning($"IO error while accessing directory for '{config}': {exc}");
                         }
EOF
@@ -830,5 +830,13 @@
}
catch (Exception exc)
catch (DirectoryNotFoundException exc)
{
logger.LogWarning($"Failed to get directory of '{config}': {exc}");
logger.LogWarning($"Directory not found for '{config}': {exc}");
}
catch (UnauthorizedAccessException exc)
{
logger.LogWarning($"Unauthorized access to directory for '{config}': {exc}");
}
catch (IOException exc)
{
logger.LogWarning($"IO error while accessing directory for '{config}': {exc}");
}
Copilot is powered by AI and may make mistakes. Always verify output.
@dilanbhalla dilanbhalla merged commit 89ddb30 into main Apr 9, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.