Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: andreas hilti <69210561+andreas-hilti@users.noreply.github.com>
  • Loading branch information
andreas-hilti committed Sep 13, 2024
1 parent dbb4307 commit 4216c55
Show file tree
Hide file tree
Showing 19 changed files with 60 additions and 23 deletions.
8 changes: 5 additions & 3 deletions src/CycloneDX.Core/Models/Algorithms/AlgorithmProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ public bool ShouldSerializePrimitive_XML()
[XmlElement("parameterSetIdentifier")]
[ProtoMember(2)]
public string ParameterSetIdentifier { get; set; }

[XmlElement("curve")]
[ProtoMember(3)]
public string Curve { get; set; }
//[XmlIgnore]

[XmlElement("executionEnvironment")]
[ProtoMember(4)]
public ExecutionEnvironment? ExecutionEnvironment { get; set; }
Expand All @@ -64,9 +65,10 @@ public bool ShouldSerializePrimitive_XML()

[XmlElement("certificationLevel")]
public List<CertificationLevel> CertificationLevel { get; set; }
[ProtoMember(6)]

[XmlIgnore]
[JsonIgnore]
[ProtoMember(6)]
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public List<string> CertificationLevel_Protobuf
{
Expand Down Expand Up @@ -122,10 +124,10 @@ public PaddingScheme Padding_XML
[XmlElement("classicalSecurityLevel")]
[ProtoMember(10)]
public int ClassicalSecurityLevel { get; set; }

[XmlElement("nistQuantumSecurityLevel")]
[ProtoMember(11)]
public int NistQuantumSecurityLevel { get; set; }


}
}
6 changes: 3 additions & 3 deletions src/CycloneDX.Core/Models/Algorithms/CertificationLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ public enum CertificationLevel
CC_EAL4plus,
[XmlEnum("cc-eal5")]
CC_EAL5,
[EnumMember(Value = "cc-eal5+")]
[XmlEnum("cc-eal5+")]
[EnumMember(Value = "cc-eal5+")]
CC_EAL5plus,
[XmlEnum("cc-eal6")]
CC_EAL6,
[EnumMember(Value = "cc-eal6+")]
[XmlEnum("cc-eal6+")]
[EnumMember(Value = "cc-eal6+")]
CC_EAL6plus,
[XmlEnum("cc-eal7")]
CC_EAL7,
[EnumMember(Value = "cc-eal7+")]
[XmlEnum("cc-eal7+")]
[EnumMember(Value = "cc-eal7+")]
CC_EAL7plus,
[XmlEnum("other")]
Other,
Expand Down
7 changes: 7 additions & 0 deletions src/CycloneDX.Core/Models/Crypto/CertificateProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,31 @@ public class CertificateProperties
[XmlElement("subjectName")]
[ProtoMember(1)]
public string SubjectName { get; set; }

[XmlElement("issuerName")]
[ProtoMember(2)]
public string IssuerName { get; set; }

[XmlElement("notValidBefore")]
[ProtoMember(3)]
public DateTime NotValidBefore { get; set; }

[XmlElement("notValidAfter")]
[ProtoMember(4)]
public DateTime NotValidAfter { get; set; }

[XmlElement("signatureAlgorithmRef")]
[ProtoMember(5)]
public string SignatureAlgorithmRef { get; set; }

[XmlElement("subjectPublicKeyRef")]
[ProtoMember(6)]
public string SubjectPublicKeyRef { get; set; }

[XmlElement("certificateFormat")]
[ProtoMember(7)]
public string CertificateFormat { get; set; }

[XmlElement("certificateExtension")]
[ProtoMember(8)]
public string CertificateExtension { get; set; }
Expand Down
1 change: 0 additions & 1 deletion src/CycloneDX.Core/Models/Crypto/CipherSuite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class CipherSuite
[ProtoMember(1)]
public string Name { get; set; }


[XmlArray("algorithms")]
[XmlArrayItem("algorithm")]
[ProtoMember(2)]
Expand Down
5 changes: 5 additions & 0 deletions src/CycloneDX.Core/Models/Crypto/CryptoProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,24 @@ public class CryptoProperties
[XmlElement("assetType")]
[ProtoMember(1)]
public AssetType AssetType { get; set; }

[XmlElement("algorithmProperties")]
[ProtoMember(2)]
public AlgorithmProperties AlgorithmProperties { get; set; }

[XmlElement("certificateProperties")]
[ProtoMember(3)]

public CertificateProperties CertificateProperties { get; set; }

[XmlElement("relatedCryptoMaterialProperties")]
[ProtoMember(4)]
public RelatedCryptoMaterialProperties RelatedCryptoMaterialProperties { get; set; }

[XmlElement("protocolProperties")]
[ProtoMember(5)]
public ProtocolProperties ProtocolProperties { get; set; }

[XmlElement("oid")]
[JsonPropertyName("oid")]
[ProtoMember(6)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,47 @@ public class RelatedCryptoMaterialProperties
[XmlElement("type")]
[ProtoMember(1)]
public RelatedCryptoMaterialType Type { get; set; }

[XmlElement("id")]
[ProtoMember(2)]
public string Id { get; set; }

[XmlElement("state")]
[ProtoMember(3)]
public KeyState State { get; set; }

[XmlElement("algorithmRef")]
[ProtoMember(4)]
public string AlgorithmRef { get; set; }

[XmlElement("creationDate")]
[ProtoMember(5)]
public DateTime CreationDate { get; set; }

[XmlElement("activationDate")]
[ProtoMember(6)]
public DateTime ActivationDate { get; set; }

[XmlElement("updateDate")]
[ProtoMember(7)]
public DateTime UpdateDate { get; set; }

[XmlElement("expirationDate")]
[ProtoMember(8)]
public DateTime ExpirationDate { get; set; }

[XmlElement("value")]
[ProtoMember(9)]
public string Value { get; set; }

[XmlElement("size")]
[ProtoMember(10)]
public int Size { get; set; }

[XmlElement("format")]
[ProtoMember(11)]
public string Format { get; set; }

[XmlElement("securedBy")]
[ProtoMember(12)]
public SecuredBy SecuredBy { get; set; }
Expand Down
4 changes: 1 addition & 3 deletions src/CycloneDX.Core/Models/Crypto/SecuredBy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ public class SecuredBy
{
[XmlElement("mechanism")]
[ProtoMember(1)]

public string Mechanism { get; set; }

[XmlElement("algorithmRef")]
[ProtoMember(2)]

public string AlgorithmRef { get; set; }


}


Expand Down
1 change: 1 addition & 0 deletions src/CycloneDX.Core/Models/Declarations/Affirmation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class Affirmation
[XmlAnyElement("Signature", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
[JsonIgnore]
public XmlElement XmlSignature { get; set; }

[XmlIgnore]
public Signature Signature { get; set; }

Expand Down
1 change: 1 addition & 0 deletions src/CycloneDX.Core/Models/Declarations/Assessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class Assessor : IEquatable<Assessor>, IHasBomRef
[JsonPropertyName("bom-ref")]
[ProtoMember(1)]
public string BomRef { get; set; }

[XmlElement("thirdParty")]
[ProtoMember(2)]
public bool ThirdParty { get; set; }
Expand Down
1 change: 1 addition & 0 deletions src/CycloneDX.Core/Models/Declarations/Claim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class Claim : IEquatable<Claim>, IHasBomRef
[XmlAnyElement("Signature", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
[JsonIgnore]
public XmlElement XmlSignature { get; set; }

[XmlIgnore]
public Signature Signature { get; set; }

Expand Down
5 changes: 3 additions & 2 deletions src/CycloneDX.Core/Models/Declarations/Conformance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ public class Conformance
[XmlElement("score")]
[ProtoMember(1)]
public double Score { get; set; }

[XmlElement("rationale")]
[ProtoMember(2)]
public string Rationale { get; set; }
[ProtoMember(3)]


[XmlArray("mitigationStrategies")]
[XmlArrayItem("mitigationStrategy")]
[ProtoMember(3)]
public List<string> MitigationStrategies { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/CycloneDX.Core/Models/Declarations/DeclarationData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,19 @@ public class DeclarationData
[XmlElement("name")]
[ProtoMember(1)]
public string Name { get; set; }

[XmlElement("contents")]
[ProtoMember(2)]
public DeclarationDataContents Contents { get; set; }

[XmlElement("classification")]
[ProtoMember(3)]
public string Classification { get; set; }

[XmlElement("sensitiveData")]
[ProtoMember(4)]
public List<string> SensitiveData { get; set; }

[XmlElement("governance")]
[ProtoMember(5)]
public DataGovernance Governance { get; set; }
Expand Down
5 changes: 3 additions & 2 deletions src/CycloneDX.Core/Models/Declarations/Declarations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,26 @@ public class Declarations

[XmlArray("claims")]
[XmlArrayItem("claim")]

[ProtoMember(3)]
public List<Claim> Claims { get; set; }

[XmlArray("evidence")]
[XmlArrayItem("evidence")]
[ProtoMember(4)]
public List<DeclarationsEvidence> Evidence { get; set; }

[XmlElement("targets")]
[ProtoMember(5)]
public Targets Targets { get; set; }
[XmlElement("affirmation")]

[XmlElement("affirmation")]
[ProtoMember(6)]
public Affirmation Affirmation { get; set; }

[XmlAnyElement("Signature", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
[JsonIgnore]
public XmlElement XmlSignature { get; set; }

[XmlIgnore]
public Signature Signature { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ public class DeclarationsEvidence : IHasBomRef
[JsonPropertyName("bom-ref")]
[ProtoMember(1)]
public string BomRef { get; set; }

[XmlElement("propertyName")]
[ProtoMember(2)]
public string PropertyName { get; set; }

[XmlElement("description")]
[ProtoMember(3)]
public string Description { get; set; }
Expand Down Expand Up @@ -62,16 +64,19 @@ public DateTime? Expires
get => _expires;
set { _expires = BomUtils.UtcifyDateTime(value); }
}

[XmlElement("author")]
[ProtoMember(7)]
public OrganizationalContact Author { get; set; }

[XmlElement("reviewer")]
[ProtoMember(8)]
public OrganizationalContact Reviewer { get; set; }

[XmlAnyElement("Signature", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
[JsonIgnore]
public XmlElement XmlSignature { get; set; }

[XmlIgnore]
public Signature Signature { get; set; }

Expand Down
6 changes: 2 additions & 4 deletions src/CycloneDX.Core/Models/Declarations/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,19 @@ public class Map

[XmlArray("claims")]
[XmlArrayItem("claim")]

[ProtoMember(2)]
public List<string> Claims { get; set; }

[XmlArray("counterClaims")]
[XmlArrayItem("counterClaim")]

[ProtoMember(3)]
public List<string> CounterClaims { get; set; }
[XmlElement("conformance")]

[XmlElement("conformance")]
[ProtoMember(4)]
public Conformance Conformance { get; set; }
[XmlElement("confidence")]

[XmlElement("confidence")]
[ProtoMember(5)]
public Confidence Confidence { get; set; }
}
Expand Down
5 changes: 5 additions & 0 deletions src/CycloneDX.Core/Models/Declarations/Signatory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,23 @@ public class Signatory
[XmlElement("name")]
[ProtoMember(1)]
public string Name { get; set; }

[XmlElement("role")]
[ProtoMember(2)]
public string Role { get; set; }

[XmlElement("organization")]
[ProtoMember(3)]
public OrganizationalEntity Organization { get; set; }

[XmlElement("externalReference")]
[ProtoMember(4)]
public ExternalReference ExternalReference { get; set; }

[XmlAnyElement("Signature", Namespace = "http://www.w3.org/2000/09/xmldsig#")]
[JsonIgnore]
public XmlElement XmlSignature { get; set; }

[XmlIgnore]
public Signature Signature { get; set; }
}
Expand Down
1 change: 0 additions & 1 deletion src/CycloneDX.Core/Xml/Serializer.Serialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
using System.Xml;
using System.Xml.Serialization;
using CycloneDX.Models;
using ProtoBuf;

namespace CycloneDX.Xml
{
Expand Down
6 changes: 3 additions & 3 deletions src/CycloneDX.Utils/Merge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,21 +286,21 @@ public static Bom HierarchicalMerge(IEnumerable<Bom> boms, Component bomSubject)
result.Compositions = new List<Composition>();
result.Vulnerabilities = new List<Vulnerability>();

result.Declarations = new Declarations()
result.Declarations = new Declarations
{
Assessors = new List<Assessor>(),
Attestations = new List<Attestation>(),
Claims = new List<Claim>(),
Evidence = new List<DeclarationsEvidence>(),
Targets = new Targets()
Targets = new Targets
{
Components = new List<Component>(),
Organizations = new List<OrganizationalEntity>(),
Services = new List<Service>()
}
};

result.Definitions = new Definitions()
result.Definitions = new Definitions
{
Standards = new List<Standard>()
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void ValidProtobufTest(string filename)
var protoBom = stream.ToArray();

var runner = new ProtocRunner();
var result = runner.Run(tempDir.DirectoryPath, protoBom, new string[]
var result = runner.Run(tempDir.DirectoryPath, protoBom, new []
{
"--proto_path=./",
"--decode=cyclonedx.v1_6.Bom",
Expand Down

0 comments on commit 4216c55

Please sign in to comment.