Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Microsoft.ComponentDetection.Contracts.BcdeModels;

using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

Expand All @@ -13,33 +14,41 @@ public class ContainerDetails
{
// Summary:
// ImageId for the docker container.
[JsonPropertyName("imageId")]
public string ImageId { get; set; }

// Summary:
// Unique id for the container.
[JsonPropertyName("id")]
public int Id { get; set; }

// Summary:
// Digests for the container
[JsonPropertyName("digests")]
public IEnumerable<string> Digests { get; set; }

// Summary:
// The Repository:Tag for the base image of the docker container
// ex: alpine:latest || alpine:v3.1 || mcr.microsoft.com/dotnet/sdk:5.0
[JsonPropertyName("baseImageRef")]
public string BaseImageRef { get; set; }

// Summary:
// The digest of the exact image used as the base image
// This is to avoid errors if there are ref updates between build time and scan time
[JsonPropertyName("baseImageDigest")]
public string BaseImageDigest { get; set; }

// Summary:
// The time the container was created
[JsonPropertyName("createdAt")]
public DateTime CreatedAt { get; set; }

// Summary:
// Tags for the container
[JsonPropertyName("tags")]
public IEnumerable<string> Tags { get; set; }

[JsonPropertyName("layers")]
public IEnumerable<DockerLayer> Layers { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#nullable disable
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;

using System.Text.Json.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

[JsonObject(MemberSerialization.OptOut, NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class DefaultGraphScanResult : ScanResult
{
[JsonPropertyName("dependencyGraphs")]
public DependencyGraphCollection DependencyGraphs { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;

using System.Collections.Generic;
using System.Text.Json.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

[JsonObject(MemberSerialization.OptOut, NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class DependencyGraphWithMetadata
{
[JsonPropertyName("graph")]
public DependencyGraph Graph { get; set; }

[JsonPropertyName("explicitlyReferencedComponentIds")]
public HashSet<string> ExplicitlyReferencedComponentIds { get; set; }

[JsonPropertyName("developmentDependencies")]
public HashSet<string> DevelopmentDependencies { get; set; }

[JsonPropertyName("dependencies")]
public HashSet<string> Dependencies { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;

using System.Text.Json.Serialization;

/// <summary>Used to communicate Dependency Scope of Component.
/// Currently only populated for Maven component.
/// The values are ordered in terms of priority, which is used to resolve the scope for duplicate component while merging them.
/// </summary>
[JsonConverter(typeof(JsonStringEnumConverter))]
public enum DependencyScope
{
/// <summary>default scope. dependencies are available in the project during all build tasks. propogated to dependent projects. </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;

using System.Collections.Generic;
using System.Text.Json.Serialization;
using Microsoft.ComponentDetection.Contracts.TypedComponent;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
Expand All @@ -10,12 +11,16 @@ namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
[JsonObject(MemberSerialization.OptOut, NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class Detector
{
[JsonPropertyName("detectorId")]
public string DetectorId { get; set; }

[JsonPropertyName("isExperimental")]
public bool IsExperimental { get; set; }

[JsonPropertyName("version")]
public int Version { get; set; }

[JsonProperty(ItemConverterType = typeof(StringEnumConverter))]
[JsonPropertyName("supportedComponentTypes")]
public IEnumerable<ComponentType> SupportedComponentTypes { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
#nullable disable
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;

using System.Text.Json.Serialization;

public class DockerLayer
{
// Summary:
// the command/script that was executed in order to create the layer.
[JsonPropertyName("createdBy")]
public string CreatedBy { get; set; }

// Summary:
// The Layer hash (docker inspect) that represents the changes between this layer and the previous layer
[JsonPropertyName("diffId")]
public string DiffId { get; set; }

// Summary:
// Whether or not this layer was found in the base image of the container
[JsonPropertyName("isBaseImage")]
public bool IsBaseImage { get; set; }

// Summary:
// 0-indexed monotonically increasing ID for the order of the layer in the container.
// Note: only includes non-empty layers
[JsonPropertyName("layerIndex")]
public int LayerIndex { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;

using System.Collections.Generic;
using System.Text.Json.Serialization;
using Microsoft.ComponentDetection.Contracts.TypedComponent;

/// <summary>
Expand All @@ -14,10 +15,12 @@ public class LayerMappedLinuxComponents
/// Gets or sets the components detected in this layer.
/// This can include system packages (LinuxComponent) as well as application-level packages (NpmComponent, PipComponent, etc.).
/// </summary>
[JsonPropertyName("components")]
public IEnumerable<TypedComponent> Components { get; set; }

/// <summary>
/// Gets or sets the Docker layer associated with these components.
/// </summary>
[JsonPropertyName("dockerLayer")]
public DockerLayer DockerLayer { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,30 @@
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;

using System.Collections.Generic;
using System.Text.Json.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;

[JsonObject(MemberSerialization.OptOut, NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class ScanResult
{
[JsonPropertyName("componentsFound")]
public IEnumerable<ScannedComponent> ComponentsFound { get; set; }

[JsonPropertyName("detectorsInScan")]
public IEnumerable<Detector> DetectorsInScan { get; set; }

[JsonPropertyName("detectorsNotInScan")]
public IEnumerable<Detector> DetectorsNotInScan { get; set; }

[JsonPropertyName("containerDetailsMap")]
public Dictionary<int, ContainerDetails> ContainerDetailsMap { get; set; }

[JsonConverter(typeof(StringEnumConverter))]
[Newtonsoft.Json.JsonConverter(typeof(StringEnumConverter))]
[JsonPropertyName("resultCode")]
public ProcessingResultCode ResultCode { get; set; }

[JsonPropertyName("sourceDirectory")]
public string SourceDirectory { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,42 @@
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;

using System.Collections.Generic;
using System.Text.Json.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;

[JsonObject(MemberSerialization.OptOut, NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class ScannedComponent
{
[JsonPropertyName("locationsFoundAt")]
public IEnumerable<string> LocationsFoundAt { get; set; }

[JsonPropertyName("component")]
public TypedComponent.TypedComponent Component { get; set; }

[JsonPropertyName("detectorId")]
public string DetectorId { get; set; }

[JsonPropertyName("isDevelopmentDependency")]
public bool? IsDevelopmentDependency { get; set; }

[JsonConverter(typeof(StringEnumConverter))]
[Newtonsoft.Json.JsonConverter(typeof(StringEnumConverter))]
[JsonPropertyName("dependencyScope")]
public DependencyScope? DependencyScope { get; set; }

[JsonPropertyName("topLevelReferrers")]
public IEnumerable<TypedComponent.TypedComponent> TopLevelReferrers { get; set; }

[JsonPropertyName("ancestralReferrers")]
public IEnumerable<TypedComponent.TypedComponent> AncestralReferrers { get; set; }

[JsonPropertyName("containerDetailIds")]
public IEnumerable<int> ContainerDetailIds { get; set; }

[JsonPropertyName("containerLayerIds")]
public IDictionary<int, IEnumerable<int>> ContainerLayerIds { get; set; }

[JsonPropertyName("targetFrameworks")]
public ISet<string> TargetFrameworks { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Microsoft.ComponentDetection.Contracts.Internal;

using System;
using System.Text.Json.Serialization;

public class NpmAuthor
{
Expand All @@ -11,7 +12,9 @@ public NpmAuthor(string name, string email = null)
this.Email = string.IsNullOrEmpty(email) ? null : email;
}

[JsonPropertyName("name")]
public string Name { get; set; }

[JsonPropertyName("email")]
public string Email { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
namespace Microsoft.ComponentDetection.Contracts;

using System.Text.Json.Serialization;

/// <summary>Code used to communicate the state of a scan after completion.</summary>
[JsonConverter(typeof(JsonStringEnumConverter))]
public enum ProcessingResultCode
{
/// <summary>The scan was completely successful.</summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#nullable disable
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;

using System.Text.Json.Serialization;
using Newtonsoft.Json;
using PackageUrl;

Expand All @@ -20,18 +21,26 @@ public CargoComponent(string name, string version, string author = null, string
this.Source = source;
}

[JsonPropertyName("name")]
public string Name { get; set; }

[JsonPropertyName("version")]
public string Version { get; set; }

#nullable enable
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] // Newtonsoft.Json
[System.Text.Json.Serialization.JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] // System.Text.Json
[JsonPropertyName("author")]
public string? Author { get; set; }

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] // Newtonsoft.Json
[System.Text.Json.Serialization.JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] // System.Text.Json
[JsonPropertyName("license")]
public string? License { get; set; }

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] // Newtonsoft.Json
[System.Text.Json.Serialization.JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] // System.Text.Json
[JsonPropertyName("source")]
public string? Source { get; set; }
#nullable disable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;

using System.Runtime.Serialization;
using System.Text.Json.Serialization;

// This is used in BcdeModels as well
[DataContract]
[JsonConverter(typeof(JsonStringEnumConverter))]
public enum ComponentType : byte
{
[EnumMember]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#nullable disable
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;

using System.Text.Json.Serialization;
using PackageUrl;

public class ConanComponent : TypedComponent
Expand All @@ -18,14 +19,19 @@ public ConanComponent(string name, string version, string previous, string packa
this.Sha1Hash = this.ValidateRequiredInput(packageId, nameof(this.Sha1Hash), nameof(ComponentType.Conan));
}

[JsonPropertyName("name")]
public string Name { get; set; }

[JsonPropertyName("version")]
public string Version { get; set; }

[JsonPropertyName("md5Hash")]
public string Md5Hash { get; set; }

[JsonPropertyName("sha1Hash")]
public string Sha1Hash { get; set; }

[JsonPropertyName("packageSourceURL")]
public string PackageSourceURL => $"https://conan.io/center/recipes/{this.Name}?version={this.Version}";

public override ComponentType Type => ComponentType.Conan;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#nullable disable
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;

using System.Text.Json.Serialization;

public class CondaComponent : TypedComponent
{
public CondaComponent(string name, string version, string build, string channel, string subdir, string @namespace, string url, string md5)
Expand All @@ -20,20 +22,28 @@ private CondaComponent()
/* Reserved for deserialization */
}

[JsonPropertyName("build")]
public string Build { get; set; }

[JsonPropertyName("channel")]
public string Channel { get; set; }

[JsonPropertyName("name")]
public string Name { get; set; }

[JsonPropertyName("namespace")]
public string Namespace { get; set; }

[JsonPropertyName("subdir")]
public string Subdir { get; set; }

[JsonPropertyName("version")]
public string Version { get; set; }

[JsonPropertyName("url")]
public string Url { get; set; }

[JsonPropertyName("mD5")]
public string MD5 { get; set; }

public override ComponentType Type => ComponentType.Conda;
Expand Down
Loading
Loading