File tree Expand file tree Collapse file tree 7 files changed +20
-7
lines changed
Microsoft.Sbom.Contracts/Contracts
Microsoft.Sbom.Extensions
Microsoft.Sbom.Parsers.Spdx22SbomParser/Parser
Microsoft.Sbom.Parsers.Spdx30SbomParser/Parser
Microsoft.Sbom.Parsers.Spdx22SbomParser.Tests/Parser
Microsoft.Sbom.Parsers.Spdx30SbomParser.Tests/Parser Expand file tree Collapse file tree 7 files changed +20
-7
lines changed Original file line number Diff line number Diff line change 1+ // Copyright (c) Microsoft. All rights reserved.
2+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+ namespace Microsoft . Sbom . Contracts ;
5+
6+ public class Spdx22Metadata : SpdxMetadata { }
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ public interface ISbomParser
2727 /// </summary>
2828 /// <param name="stream"></param>
2929 /// <returns></returns>
30- SpdxMetadata GetMetadata ( ) ;
30+ Spdx22Metadata GetMetadata ( ) ;
3131
3232 /// <summary>
3333 /// This function is called by the sbom tool upon initialization to get all the
Original file line number Diff line number Diff line change @@ -172,14 +172,14 @@ internal SPDXParser(
172172 return null ;
173173 }
174174
175- public SpdxMetadata GetMetadata ( )
175+ public Spdx22Metadata GetMetadata ( )
176176 {
177177 if ( ! this . parsingComplete )
178178 {
179179 throw new ParserException ( $ "{ nameof ( this . GetMetadata ) } can only be called after Parsing is complete to ensure that a whole object is returned.") ;
180180 }
181181
182- var spdxMetadata = new SpdxMetadata ( ) ;
182+ var spdxMetadata = new Spdx22Metadata ( ) ;
183183 foreach ( var kvp in this . metadata )
184184 {
185185 switch ( kvp . Key )
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ public class SPDX30Parser : ISbomParser
3535
3636 public ComplianceStandard ? RequiredComplianceStandard ;
3737 public IReadOnlyCollection < string > ? EntitiesToEnforceComplianceStandardsFor ;
38- public SpdxMetadata Metadata = new SpdxMetadata ( ) ;
38+ public Spdx22Metadata Metadata = new Spdx22Metadata ( ) ;
3939 private readonly LargeJsonParser parser ;
4040 private readonly IList < string > observedFieldNames = new List < string > ( ) ;
4141 private readonly bool requiredFieldsCheck = true ;
@@ -157,13 +157,14 @@ public SPDX30Parser(
157157 return null ;
158158 }
159159
160- public SpdxMetadata GetMetadata ( )
160+ public Spdx22Metadata GetMetadata ( )
161161 {
162162 if ( ! this . parsingComplete )
163163 {
164164 throw new ParserException ( $ "{ nameof ( this . GetMetadata ) } can only be called after Parsing is complete to ensure that a whole object is returned.") ;
165165 }
166166
167+ // TODO: Eventually this return type should be changed to SpdxMetadata to be consistent with naming.
167168 return this . Metadata ;
168169 }
169170
Original file line number Diff line number Diff line change 55using System . IO ;
66using System . Linq ;
77using System . Text ;
8+ using Microsoft . Sbom . Contracts ;
89using Microsoft . Sbom . JsonAsynchronousNodeKit . Exceptions ;
910using Microsoft . Sbom . Parser . Strings ;
1011using Microsoft . Sbom . Parsers . Spdx22SbomParser ;
@@ -41,6 +42,7 @@ public void MetadataPopulates()
4142 var metadata = parser . GetMetadata ( ) ;
4243
4344 Assert . IsNotNull ( metadata ) ;
45+ Assert . IsInstanceOfType ( metadata , typeof ( Spdx22Metadata ) ) ;
4446 Assert . IsNotNull ( metadata . CreationInfo ) ;
4547 var expectedTime = DateTime . Parse ( "2023-05-11T00:24:54Z" ) . ToUniversalTime ( ) ;
4648 Assert . AreEqual ( expectedTime , metadata . CreationInfo . Created ) ;
Original file line number Diff line number Diff line change 55using System . IO ;
66using System . Linq ;
77using System . Text ;
8+ using Microsoft . Sbom . Contracts ;
89using Microsoft . Sbom . JsonAsynchronousNodeKit . Exceptions ;
910using Microsoft . Sbom . Parser . JsonStrings ;
1011using Microsoft . Sbom . Parsers . Spdx30SbomParser ;
@@ -27,6 +28,7 @@ public void MetadataPopulates()
2728 Assert . AreEqual ( 5 , results . FormatEnforcedSPDX3Result . Graph . Count ( ) ) ;
2829
2930 var metadata = parser . GetMetadata ( ) ;
31+ Assert . IsInstanceOfType ( metadata , typeof ( Spdx22Metadata ) ) ;
3032 Assert . IsNotNull ( metadata ) ;
3133 Assert . IsNotNull ( metadata . DocumentNamespace ) ;
3234 Assert . AreEqual ( "spdx-doc-name" , metadata . Name ) ;
@@ -49,6 +51,7 @@ public void MetadataEmpty()
4951 var results = this . Parse ( parser ) ;
5052
5153 var metadata = parser . GetMetadata ( ) ;
54+ Assert . IsInstanceOfType ( metadata , typeof ( Spdx22Metadata ) ) ;
5255 Assert . IsNotNull ( metadata ) ;
5356 Assert . IsNull ( metadata . DocumentNamespace ) ;
5457 Assert . IsNull ( metadata . Name ) ;
Original file line number Diff line number Diff line change @@ -243,9 +243,10 @@ public void ValidateSbomPackagesForNTIA(List<Element> elementsList)
243243 /// Sets metadata based on parsed SBOM elements.
244244 /// </summary>
245245 /// <param name="result"></param>
246- public SpdxMetadata SetMetadata ( ParserResults result )
246+ public Spdx22Metadata SetMetadata ( ParserResults result )
247247 {
248- var metadata = new SpdxMetadata ( ) ;
248+ // TODO: Eventually this return type should be changed to SpdxMetadata to be consistent with naming.
249+ var metadata = new Spdx22Metadata ( ) ;
249250 var spdxDocumentElement = ( SpdxDocument ? ) result . FormatEnforcedSPDX3Result . Graph . FirstOrDefault ( element => element . Type == "SpdxDocument" ) ;
250251
251252 if ( spdxDocumentElement == null )
You can’t perform that action at this time.
0 commit comments