Skip to content

Commit ebb5d90

Browse files
pauld-msftCopilot
andauthored
Pauldorsch/public cd contract update (#1678)
* add non-required props to typed component * add another test * Update test/Microsoft.ComponentDetection.Contracts.Tests/ActorInfoTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/Microsoft.ComponentDetection.Contracts.Tests/TypedComponentSerializationTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * updated the component type id to include the optional props * updated othercomponent so it is backwards compatible * update manifest * remove non-required props * update pip generation in validation tests * Update src/Microsoft.ComponentDetection.Contracts/TypedComponent/TypedComponent.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * update actor info * pr feedback --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent e537f1d commit ebb5d90

28 files changed

+2679
-31
lines changed

.github/workflows/snapshot-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
run:
6464
dotnet run scan --Verbosity Verbose --SourceDirectory ${{ github.workspace }}/test/Microsoft.ComponentDetection.VerificationTests/resources --Output ${{ github.workspace }}/output
6565
--DockerImagesToScan "docker.io/library/debian@sha256:9b0e3056b8cd8630271825665a0613cc27829d6a24906dc0122b3b4834312f7d,mcr.microsoft.com/cbl-mariner/base/core@sha256:c1bc83a3d385eccbb2f7f7da43a726c697e22a996f693a407c35ac7b4387cd59,docker.io/library/alpine@sha256:1304f174557314a7ed9eddb4eab12fed12cb0cd9809e4c28f29af86979a3c870"
66-
--DetectorArgs DockerReference=EnableIfDefaultOff,SPDX22SBOM=EnableIfDefaultOff --DirectoryExclusionList "**/pip/parallel/**;**/pip/roots/**;**/pip/pre-generated/**"
66+
--DetectorArgs DockerReference=EnableIfDefaultOff,SPDX22SBOM=EnableIfDefaultOff --DirectoryExclusionList "**/pip/parallel/**;**/pip/roots/**;**/pip/pre-generated/**;**/pip/fallback/**;**/pip/index-removal/**;**/pip/simple-extras/**;**/pip/pytestresultpkg/**"
6767

6868
- name: Upload output folder
6969
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0

.github/workflows/snapshot-verify.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
run:
102102
dotnet run scan --Verbosity Verbose --SourceDirectory ${{ github.workspace }}/test/Microsoft.ComponentDetection.VerificationTests/resources --Output ${{ github.workspace }}/output
103103
--DockerImagesToScan "docker.io/library/debian@sha256:9b0e3056b8cd8630271825665a0613cc27829d6a24906dc0122b3b4834312f7d,mcr.microsoft.com/cbl-mariner/base/core@sha256:c1bc83a3d385eccbb2f7f7da43a726c697e22a996f693a407c35ac7b4387cd59,docker.io/library/alpine@sha256:1304f174557314a7ed9eddb4eab12fed12cb0cd9809e4c28f29af86979a3c870"
104-
--DetectorArgs DockerReference=EnableIfDefaultOff,SPDX22SBOM=EnableIfDefaultOff --MaxDetectionThreads 5 --DirectoryExclusionList "**/pip/parallel/**;**/pip/roots/**;**/pip/pre-generated/**"
104+
--DetectorArgs DockerReference=EnableIfDefaultOff,SPDX22SBOM=EnableIfDefaultOff --MaxDetectionThreads 5 --DirectoryExclusionList "**/pip/parallel/**;**/pip/roots/**;**/pip/pre-generated/**;**/pip/fallback/**;**/pip/index-removal/**;**/pip/simple-extras/**;**/pip/pytestresultpkg/**"
105105

106106
- name: Run Verification Tests
107107
working-directory: test/Microsoft.ComponentDetection.VerificationTests

docs/schema/manifest.schema.json

Lines changed: 109 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
{
22
"definitions": {
3+
"ActorInfo": {
4+
"type": [
5+
"object",
6+
"null"
7+
],
8+
"properties": {
9+
"name": {
10+
"type": [
11+
"string",
12+
"null"
13+
]
14+
},
15+
"email": {
16+
"type": [
17+
"string",
18+
"null"
19+
]
20+
},
21+
"url": {
22+
"type": [
23+
"string",
24+
"null"
25+
],
26+
"format": "uri"
27+
},
28+
"type": {
29+
"type": [
30+
"string",
31+
"null"
32+
]
33+
}
34+
}
35+
},
336
"ContainerDetails": {
437
"type": [
538
"object",
@@ -118,8 +151,10 @@
118151
"Spdx",
119152
"Vcpkg",
120153
"DockerReference",
154+
"Conan",
155+
"Swift",
121156
"DotNet",
122-
"Conan"
157+
"CppSdk"
123158
]
124159
}
125160
}
@@ -285,6 +320,15 @@
285320
"$ref": "#/definitions/TypedComponent"
286321
}
287322
},
323+
"ancestralReferrers": {
324+
"type": [
325+
"array",
326+
"null"
327+
],
328+
"items": {
329+
"$ref": "#/definitions/TypedComponent"
330+
}
331+
},
288332
"containerDetailIds": {
289333
"type": [
290334
"array",
@@ -308,6 +352,18 @@
308352
"type": "integer"
309353
}
310354
}
355+
},
356+
"targetFrameworks": {
357+
"type": [
358+
"array",
359+
"null"
360+
],
361+
"items": {
362+
"type": [
363+
"string",
364+
"null"
365+
]
366+
}
311367
}
312368
},
313369
"required": [
@@ -317,8 +373,10 @@
317373
"isDevelopmentDependency",
318374
"dependencyScope",
319375
"topLevelReferrers",
376+
"ancestralReferrers",
320377
"containerDetailIds",
321-
"containerLayerIds"
378+
"containerLayerIds",
379+
"targetFrameworks"
322380
]
323381
},
324382
"TypedComponent": {
@@ -346,8 +404,10 @@
346404
"Spdx",
347405
"Vcpkg",
348406
"DockerReference",
407+
"Conan",
408+
"Swift",
349409
"DotNet",
350-
"Conan"
410+
"CppSdk"
351411
]
352412
},
353413
"id": {
@@ -358,6 +418,41 @@
358418
},
359419
"packageUrl": {
360420
"$ref": "#/definitions/PackageURL"
421+
},
422+
"licenses": {
423+
"type": [
424+
"array",
425+
"null"
426+
],
427+
"items": {
428+
"type": [
429+
"string",
430+
"null"
431+
]
432+
}
433+
},
434+
"authorsInfo": {
435+
"type": [
436+
"array",
437+
"null"
438+
],
439+
"items": {
440+
"$ref": "#/definitions/ActorInfo"
441+
}
442+
},
443+
"downloadUrl": {
444+
"type": [
445+
"string",
446+
"null"
447+
],
448+
"format": "uri"
449+
},
450+
"sourceUrl": {
451+
"type": [
452+
"string",
453+
"null"
454+
],
455+
"format": "uri"
361456
}
362457
},
363458
"required": [
@@ -388,6 +483,15 @@
388483
"$ref": "#/definitions/Detector"
389484
}
390485
},
486+
"detectorsNotInScan": {
487+
"type": [
488+
"array",
489+
"null"
490+
],
491+
"items": {
492+
"$ref": "#/definitions/Detector"
493+
}
494+
},
391495
"containerDetailsMap": {
392496
"type": [
393497
"object",
@@ -417,8 +521,9 @@
417521
"required": [
418522
"componentsFound",
419523
"detectorsInScan",
524+
"detectorsNotInScan",
420525
"containerDetailsMap",
421526
"resultCode",
422527
"sourceDirectory"
423528
]
424-
}
529+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
2+
3+
using System;
4+
using Newtonsoft.Json;
5+
using Newtonsoft.Json.Serialization;
6+
using SystemTextJson = System.Text.Json.Serialization;
7+
8+
/// <summary>
9+
/// Represents an actor (person, organization, or software agent) involved with a component.
10+
/// At least one of <see cref="Name"/>, <see cref="Email"/>, or <see cref="Url"/> should be populated.
11+
/// Aligned with SPDX 3.0.1 Agent subclasses.
12+
/// </summary>
13+
[JsonObject(MemberSerialization.OptOut, NamingStrategyType = typeof(CamelCaseNamingStrategy))]
14+
public class ActorInfo
15+
{
16+
[SystemTextJson.JsonPropertyName("name")]
17+
[SystemTextJson.JsonIgnore(Condition = SystemTextJson.JsonIgnoreCondition.WhenWritingNull)]
18+
[JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)]
19+
public string? Name { get; set; }
20+
21+
[SystemTextJson.JsonPropertyName("email")]
22+
[SystemTextJson.JsonIgnore(Condition = SystemTextJson.JsonIgnoreCondition.WhenWritingNull)]
23+
[JsonProperty("email", NullValueHandling = NullValueHandling.Ignore)]
24+
public string? Email { get; set; }
25+
26+
[SystemTextJson.JsonPropertyName("url")]
27+
[SystemTextJson.JsonIgnore(Condition = SystemTextJson.JsonIgnoreCondition.WhenWritingNull)]
28+
[JsonProperty("url", NullValueHandling = NullValueHandling.Ignore)]
29+
public Uri? Url { get; set; }
30+
31+
/// <summary>
32+
/// The type of actor. One of: "Person", "Organization", or "SoftwareAgent".
33+
/// </summary>
34+
[SystemTextJson.JsonPropertyName("type")]
35+
[SystemTextJson.JsonIgnore(Condition = SystemTextJson.JsonIgnoreCondition.WhenWritingNull)]
36+
[JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)]
37+
public string? Type { get; set; }
38+
}

src/Microsoft.ComponentDetection.Contracts/TypedComponent/CargoComponent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ public CargoComponent(string name, string version, string author = null, string
4646
[JsonPropertyName("packageUrl")]
4747
public override PackageURL PackageUrl => new PackageURL("cargo", string.Empty, this.Name, this.Version, null, string.Empty);
4848

49-
protected override string ComputeId() => $"{this.Name} {this.Version} - {this.Type}";
49+
protected override string ComputeBaseId() => $"{this.Name} {this.Version} - {this.Type}";
5050
}

src/Microsoft.ComponentDetection.Contracts/TypedComponent/ConanComponent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ public ConanComponent(string name, string version, string previous, string packa
4040
[JsonPropertyName("packageUrl")]
4141
public override PackageURL PackageUrl => new PackageURL("conan", string.Empty, this.Name, this.Version, null, string.Empty);
4242

43-
protected override string ComputeId() => $"{this.Name} {this.Version} - {this.Type}";
43+
protected override string ComputeBaseId() => $"{this.Name} {this.Version} - {this.Type}";
4444
}

src/Microsoft.ComponentDetection.Contracts/TypedComponent/CondaComponent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ public CondaComponent()
4949
[JsonIgnore]
5050
public override ComponentType Type => ComponentType.Conda;
5151

52-
protected override string ComputeId() => $"{this.Name} {this.Version} {this.Build} {this.Channel} {this.Subdir} {this.Namespace} {this.Url} {this.MD5} - {this.Type}";
52+
protected override string ComputeBaseId() => $"{this.Name} {this.Version} {this.Build} {this.Channel} {this.Subdir} {this.Namespace} {this.Url} {this.MD5} - {this.Type}";
5353
}

src/Microsoft.ComponentDetection.Contracts/TypedComponent/CppSdkComponent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ public override PackageURL PackageUrl
5151
}
5252
}
5353

54-
protected override string ComputeId() => $"{this.Name} {this.Version} - {this.Type}";
54+
protected override string ComputeBaseId() => $"{this.Name} {this.Version} - {this.Type}";
5555
}

src/Microsoft.ComponentDetection.Contracts/TypedComponent/DockerImageComponent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ public DockerImageComponent(string hash, string name = null, string tag = null)
2929
[JsonIgnore]
3030
public override ComponentType Type => ComponentType.DockerImage;
3131

32-
protected override string ComputeId() => $"{this.Name} {this.Tag} {this.Digest}";
32+
protected override string ComputeBaseId() => $"{this.Name} {this.Tag} {this.Digest}";
3333
}

src/Microsoft.ComponentDetection.Contracts/TypedComponent/DockerReferenceComponent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ public DockerReference FullReference
4444
}
4545
}
4646

47-
protected override string ComputeId() => $"{this.Repository} {this.Tag} {this.Digest}";
47+
protected override string ComputeBaseId() => $"{this.Repository} {this.Tag} {this.Digest}";
4848
}

0 commit comments

Comments
 (0)