diff --git a/Directory.Packages.props b/Directory.Packages.props index dd8034204..870401aed 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -46,7 +46,7 @@ - + diff --git a/src/Microsoft.ComponentDetection.Detectors/poetry/PoetryComponentDetector.cs b/src/Microsoft.ComponentDetection.Detectors/poetry/PoetryComponentDetector.cs index 554ef477c..0a7a98602 100644 --- a/src/Microsoft.ComponentDetection.Detectors/poetry/PoetryComponentDetector.cs +++ b/src/Microsoft.ComponentDetection.Detectors/poetry/PoetryComponentDetector.cs @@ -43,11 +43,7 @@ protected override async Task OnFileFoundAsync(ProcessRequest processRequest, ID this.Logger.LogDebug("Found Poetry lockfile {PoetryLockFile}", poetryLockFile); var reader = new StreamReader(poetryLockFile.Stream); - var options = new TomlModelOptions - { - IgnoreMissingProperties = true, - }; - var poetryLock = Toml.ToModel(await reader.ReadToEndAsync(cancellationToken), options: options); + var poetryLock = TomlSerializer.Deserialize(await reader.ReadToEndAsync(cancellationToken)); if (poetryLock.Metadata != null && poetryLock.Metadata.TryGetValue("lock-version", out var lockVersion)) { diff --git a/src/Microsoft.ComponentDetection.Detectors/rust/Parsers/RustCargoLockParser.cs b/src/Microsoft.ComponentDetection.Detectors/rust/Parsers/RustCargoLockParser.cs index 87eb1443d..61c05b522 100644 --- a/src/Microsoft.ComponentDetection.Detectors/rust/Parsers/RustCargoLockParser.cs +++ b/src/Microsoft.ComponentDetection.Detectors/rust/Parsers/RustCargoLockParser.cs @@ -25,11 +25,6 @@ internal class RustCargoLockParser : IRustCargoLockParser @"^(?[^ ]+)(?: (?[^ ]+))?(?: \((?[^()]*)\))?$", RegexOptions.Compiled); - private static readonly TomlModelOptions TomlOptions = new TomlModelOptions - { - IgnoreMissingProperties = true, - }; - private readonly ILogger logger; /// @@ -56,7 +51,7 @@ internal class RustCargoLockParser : IRustCargoLockParser { using var reader = new StreamReader(componentStream.Stream); var content = await reader.ReadToEndAsync(cancellationToken); - var cargoLock = Toml.ToModel(content, options: TomlOptions); + var cargoLock = TomlSerializer.Deserialize(content); this.ProcessCargoLock(cargoLock, singleFileComponentRecorder, componentStream); return cargoLock.Version; } diff --git a/src/Microsoft.ComponentDetection.Detectors/rust/RustSbomDetector.cs b/src/Microsoft.ComponentDetection.Detectors/rust/RustSbomDetector.cs index a37f47dd7..1252a47eb 100644 --- a/src/Microsoft.ComponentDetection.Detectors/rust/RustSbomDetector.cs +++ b/src/Microsoft.ComponentDetection.Detectors/rust/RustSbomDetector.cs @@ -26,11 +26,6 @@ internal class RustSbomDetector : FileComponentDetector private const string CargoTomlFileName = "Cargo.toml"; private const string CargoLockFileName = "Cargo.lock"; - private static readonly TomlModelOptions TomlOptions = new TomlModelOptions - { - IgnoreMissingProperties = true, - }; - private readonly IPathUtilityService pathUtilityService; private readonly IRustSbomParser sbomParser; private readonly IRustCliParser cliParser; @@ -561,7 +556,7 @@ private bool IsWorkspaceOnlyToml(string cargoTomlPath) try { var content = this.fileUtilityService.ReadAllText(cargoTomlPath); - var tomlTable = Toml.ToModel(content, options: TomlOptions); + var tomlTable = TomlSerializer.Deserialize(content); // Check if it has a [workspace] section but no [package] section var hasWorkspace = tomlTable.ContainsKey("workspace"); @@ -728,7 +723,7 @@ private void ProcessWorkspaceTables(string cargoTomlPath, string directory) try { var content = this.fileUtilityService.ReadAllText(cargoTomlPath); - var tomlTable = Toml.ToModel(content, options: TomlOptions); + var tomlTable = TomlSerializer.Deserialize(content); if (tomlTable.ContainsKey("workspace") && tomlTable["workspace"] is TomlTable workspaceTable) { diff --git a/src/Microsoft.ComponentDetection.Detectors/uv/UvLock.cs b/src/Microsoft.ComponentDetection.Detectors/uv/UvLock.cs index 61ec1b532..95b22686d 100644 --- a/src/Microsoft.ComponentDetection.Detectors/uv/UvLock.cs +++ b/src/Microsoft.ComponentDetection.Detectors/uv/UvLock.cs @@ -16,7 +16,7 @@ public static UvLock Parse(Stream tomlStream) { using var reader = new StreamReader(tomlStream); var tomlContent = reader.ReadToEnd(); - var model = Toml.ToModel(tomlContent); + var model = TomlSerializer.Deserialize(tomlContent); return new UvLock { Packages = ParsePackagesFromModel(model),