-
Notifications
You must be signed in to change notification settings - Fork 86
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
Fix ArgumentException
when recurse is enabled and two file target specifiers generates the same file paths
#2438
Fix ArgumentException
when recurse is enabled and two file target specifiers generates the same file paths
#2438
Conversation
…plicated file analysis
ArgumentException
when recurse is enabled and two file target specifiers generates the same file paths
@@ -1509,7 +1561,7 @@ private static IFileSystem CreateDefaultFileSystemForResultsCaching(IList<string | |||
mockFileSystem.Setup(x => x.FileReadAllText(It.Is<string>(f => f == fullyQualifiedName))).Returns(logFileContents); | |||
|
|||
mockFileSystem.Setup(x => x.FileOpenRead(It.Is<string>(f => f == fullyQualifiedName))) | |||
.Returns(new MemoryStream(Encoding.UTF8.GetBytes(generateSameInput ? logFileContents : fileNameWithoutExtension))); | |||
.Returns(new NonDisposingDelegatingStream(new MemoryStream(Encoding.UTF8.GetBytes(generateSameInput ? logFileContents : fileNameWithoutExtension)))); |
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.
src/ReleaseHistory.md
Outdated
@@ -6,6 +6,7 @@ | |||
* BUGFIX: Adjust Json Serialization field order for ReportingDescriptor and skip emit empty AutomationDetails node. [#2420](https://github.com/microsoft/sarif-sdk/pull/2420) | |||
* BREAKING: Fix `InvalidOperationException` when using PropertiesDictionary in a multithreaded application, and remove `[Serializable]` from it. Now use of BinaryFormatter on it will result in `SerializationException`: Type `PropertiesDictionary` is not marked as serializable. [#2415](https://github.com/microsoft/sarif-sdk/pull/2415) | |||
* BREAKING: `SarifLogger` now emits an artifacts table entry if `artifactLocation` is not null for tool configuration and tool execution notifications. [#2437](https://github.com/microsoft/sarif-sdk/pull/2437) | |||
* BUGFIX: Fix `ArgumentException` when recurse is enabled and two file target specifiers generates the same file path. [#2438](https://github.com/microsoft/sarif-sdk/pull/2438) |
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.
|
||
Action action = () => | ||
{ | ||
foreach (var testCase in testCases) |
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.
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.
done!
thanks for the suggestion!
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.
…pecifiers generates the same file paths (#2438) * Fixing ArgumentException when passing two filePaths that generates duplicated file analysis * Fixing dotnet-format issues and updating releasehistory * Removing comments * Addressing PR feedback * Addressing PR feedback
) * Add new visitor to get deterministic SARIF log by sorting results * Fix dotnet format issue * updating format * remove unnecessary using Format & minor fixes * Add Run Comparer to support sorting logs with multiple runs. * Add command argument unit tests fix dotnet format * use ContainsKey to avoid allocating variable * Fixing `AnalyzeCommandBase` and `MultithreadedAnalyzeCommandBase` artifacts generation (#2433) * Fixing multithreaded artifacts generation * Fixing tests and flags * Loosing precision. * Applying fix for AnalyzeCommandBase * Enabling tests * Updating test case and release history * Creating const to prevent magical numbers everywhere * Rebaselining tests * Creating Artifacts flag to keep previous behavior * Addressing PR feedback. * Rollback changes * Update SARIF2012.ProvideRuleProperties_Invalid.sarif * updating back * Ordering deprecated names * `SarifLogger` now emits an artifacts table entry if `artifactLocation` is not null for tool configuration and tool execution notifications. (#2437) * Fixing artifacts generation when logging notifications * Updating release history. * Updating ReleaseHistory * Fix `ArgumentException` when recurse is enabled and two file target specifiers generates the same file paths (#2438) * Fixing ArgumentException when passing two filePaths that generates duplicated file analysis * Fixing dotnet-format issues and updating releasehistory * Removing comments * Addressing PR feedback * Addressing PR feedback * Addressing PR review issues Add suppression support (#2435) * Add suppression support * Add incompatibility check and make suppressions non-null Co-authored-by: Eddy Nakamura <eddynaka@gmail.com> Update releasehistory fix couple test cases * Fix issues in PR review * Add xml comments * Fix test issues * fix dotnet format * Addressing review feedbacks * Fix tests * Update extension methods names * Change xml doc comments to normal comments Co-authored-by: Eddy Nakamura <eddynaka@gmail.com> Co-authored-by: Michael C. Fanning <michael.fanning@microsoft.com>
Description
If you pass two targets like
c:\path1\1.dll
,c:\path1\path2\1.dll
and recurse is enabled, theMultithreadedAnalyzeCommandBase
would generate the following searches:c:\path1\ -> search using recurse looking for 1.dll
c:\path1\path2\ -> search using recurse looking for 1.dll
This would generate path duplications, causing an ArgumentException when hashing:
Tests
Created a test where I'm passing two target specifiers that will list the same file. When that happens, no exception should occur since we will start checking if we already added the item to the
IDictionary
.