Skip to content
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

BinSkim .NET Updates to version 9 #1024

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

AllDwarf
Copy link
Collaborator

[WIP] BinSkim .NET Updates to version 9

Overview

This pull request focuses on updating the BinSkim project to incorporate the latest .NET updates. The goal is to ensure compatibility with the newest .NET features and improve overall performance and security.

Changes

Updated the project to target the latest .NET version.

Benefits

Enhanced Compatibility: Ensures that the BinSkim project is compatible with the latest .NET version, taking advantage of new features and improvements.

Testing

Verified that the project builds successfully with the latest .NET version.
Ran all existing tests to ensure no regressions were introduced.
Conducted manual testing to confirm that the functionality remains intact.
Additional Notes
If you encounter any issues or have questions about these updates, please feel free to reach out.

@AllDwarf AllDwarf changed the title BinSkim .NET Updates to version 9 [WIP] BinSkim .NET Updates to version 9 Dec 19, 2024
@AllDwarf AllDwarf force-pushed the users/marekaldorf/BinSkim_dotnet_updates branch from 3d1696b to 990a79d Compare January 9, 2025 15:45
@AllDwarf AllDwarf force-pushed the users/marekaldorf/BinSkim_dotnet_updates branch 2 times, most recently from 8c0ae1d to c90c64e Compare January 21, 2025 10:43
@AllDwarf AllDwarf changed the title [WIP] BinSkim .NET Updates to version 9 BinSkim .NET Updates to version 9 Jan 21, 2025
@AllDwarf AllDwarf marked this pull request as ready for review January 21, 2025 10:46
@AllDwarf AllDwarf requested a review from a team as a code owner January 21, 2025 10:46
Comment on lines +132 to +135
catch (Exception ex)
{
throw new InvalidOperationException("Failed to read string from memory.", ex);
}

Check notice

Code scanning / CodeQL

Generic catch clause Note

Generic catch clause.
…and platform checks

Add static keyword to lambdas in AnalyzeCommandTests.cs

Modified lambda expressions in AnalyzeCommandTests.cs to be static.
This change ensures that the lambdas do not capture variables from
the enclosing scope, potentially improving performance and clarity.

Fixing version constant file

Refactor project to target .NET 9.0 and remove obsolete configurations

Update ADO build configuration to target .NET 9.0 and add .vscode to .gitignore

Update GitHub workflows to target .NET 9.0 and improve formatting steps

Update .gitignore and improve Build scripts for .NET 9.0 compatibility

Directory.Packages.props fixes
@AllDwarf AllDwarf force-pushed the users/marekaldorf/BinSkim_dotnet_updates branch from c72a5f2 to 0884878 Compare January 21, 2025 20:00
@AllDwarf AllDwarf added this to the Release v4.3.2 milestone Jan 24, 2025
Removed `using System.Runtime.Versioning;` and `[SupportedOSPlatform("windows")]` from `MSDiaComWrapper.cs` and `Pdb.cs`. Replaced `Marshal.GetObjectForIUnknown` with `ResourceReleaser.GetObjectForIUnknown` in `MSDiaComWrapper.cs`. Removed `OperatingSystem.IsWindows()` checks in `Pdb.cs` and ensured `PlatformSpecificHelpers.ThrowIfNotOnWindows()` still enforces Windows-only execution in `Init` methods. Simplified codebase by removing redundant platform checks.
echo public const string FileVersion = "%MAJOR%.%MINOR%.%PATCH%" + ".0";>> %VERSION_CONSTANTS%
echo public const string Version = AssemblyVersion + Prerelease;>> %VERSION_CONSTANTS%
echo }>> %VERSION_CONSTANTS%
echo }>> %VERSION_CONSTANTS%
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems there's an extra space at the start of the line here.

| **`--help`** | Table of argument information. |
| **`--version`** | BinSkim version details. |
| **`value pos. 0`** | One or more specifiers to a file, directory, or filter pattern that resolves to one or more binaries to analyze. |
| Argument (short form, long form) | Meaning |
Copy link
Collaborator

@mkacmar mkacmar Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any tooling in the repository that checks for correct indentation of Markdown? If not I suspect the indentation gets out of sync very quickly.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible - I'd suggest dealing with Markdown formatting outside of this PR.

Copy link
Collaborator

@mkacmar mkacmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some configs under .vscode/ you want to change too.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we no longer needs this?

@@ -121,13 +121,18 @@ public ulong ReadLength(out bool is64bit)
/// <summary>
/// Reads the string from the current position in the stream.
/// </summary>
[HandleProcessCorruptedStateExceptions]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be reading the docs wrong, but with HandleProcessCorruptedStateExceptions being removed - are you still trying to catch CSEs with the try-catch block?

@@ -212,6 +213,7 @@ public void PEBinary_IsDotNetNativeBootstrapExe()
}

[Fact]
[SupportedOSPlatform("windows")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me there are other places with a runtime check for PlatformSpecificHelpers.RunningOnWindows(), but without SupportedOSPlatform("windows") - do you want to make these more consistent?

@@ -237,7 +237,7 @@ public void MultithreadedAnalyzeCommand_InitializeGlobalContextFromOptions_Quiet
Assert.IsType<Sarif.Driver.AggregatingLogger>(context.Logger);

var aggregatingLogger = (Sarif.Driver.AggregatingLogger)context.Logger;
Assert.Equal(0, aggregatingLogger.Loggers.Count);
Assert.Empty(aggregatingLogger.Loggers);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's call it a nitpick, but unless this is required for the update itself, it would be great to tackle these type of changes in a separate PR.

@@ -16,8 +15,7 @@ function Build-Tool()
}


function Build-Baselines($sourceExtension)
{
function Build-Baselines($sourceExtension) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick - this is now inconsistent with GenerateTests.ps1, I'd perhaps leave the formatting for PowerShell scripts to a different PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems quite a lot of stuff got bundled into 7af574f - IMO if we're dropping Test.ConcurrencyTests altogether a separate PR would be great, but perhaps at least a separate commit with some reasoning why?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: It seems there's a mix of major, minor and patch updates - I assume not all of them are strictly .NET update related (I'd be surprised if some of these patch level updates would be). I think it's fine to update dependencies in general, but too many changes here make it a bit tricky to review these. Separate PR in a regular dependency update cycle would be great in the future.

| **`--help`** | Table of argument information. |
| **`--version`** | BinSkim version details. |
| **`value pos. 0`** | One or more specifiers to a file, directory, or filter pattern that resolves to one or more binaries to analyze. |
| Argument (short form, long form) | Meaning |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible - I'd suggest dealing with Markdown formatting outside of this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants