Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<PackageVersion Include="System.Runtime.Loader" Version="4.3.0" />
<PackageVersion Include="System.Text.Json" Version="9.0.13" />
<PackageVersion Include="System.Threading.Tasks.Dataflow" Version="8.0.1" />
<PackageVersion Include="Tomlyn.Signed" Version="0.20.0" />
<PackageVersion Include="Tomlyn.Signed" Version="1.1.1" />
<PackageVersion Include="yamldotnet" Version="16.3.0" />
<PackageVersion Include="Faker.net" Version="2.0.163" />
<PackageVersion Include="Valleysoft.DockerfileModel" Version="1.2.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PoetryLock>(await reader.ReadToEndAsync(cancellationToken), options: options);
var poetryLock = TomlSerializer.Deserialize<PoetryLock>(await reader.ReadToEndAsync(cancellationToken));

if (poetryLock.Metadata != null && poetryLock.Metadata.TryGetValue("lock-version", out var lockVersion))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ internal class RustCargoLockParser : IRustCargoLockParser
@"^(?<packageName>[^ ]+)(?: (?<version>[^ ]+))?(?: \((?<source>[^()]*)\))?$",
RegexOptions.Compiled);

private static readonly TomlModelOptions TomlOptions = new TomlModelOptions
{
IgnoreMissingProperties = true,
};

private readonly ILogger<RustCargoLockParser> logger;

/// <summary>
Expand All @@ -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<CargoLock>(content, options: TomlOptions);
var cargoLock = TomlSerializer.Deserialize<CargoLock>(content);
this.ProcessCargoLock(cargoLock, singleFileComponentRecorder, componentStream);
return cargoLock.Version;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<TomlTable>(content);

// Check if it has a [workspace] section but no [package] section
var hasWorkspace = tomlTable.ContainsKey("workspace");
Expand Down Expand Up @@ -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<TomlTable>(content);

if (tomlTable.ContainsKey("workspace") && tomlTable["workspace"] is TomlTable workspaceTable)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ComponentDetection.Detectors/uv/UvLock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TomlTable>(tomlContent);
return new UvLock
{
Packages = ParsePackagesFromModel(model),
Expand Down
Loading