| | 1 | | using System.Diagnostics.CodeAnalysis; |
| | 2 | | using System.Text.Json.Serialization; |
| | 3 | | using Spdx3.Exceptions; |
| | 4 | | using Spdx3.Model.Core.Classes; |
| | 5 | | using Spdx3.Model.Core.Enums; |
| | 6 | | using Spdx3.Model.Security.Enums; |
| | 7 | | using Spdx3.Serialization; |
| | 8 | | using Spdx3.Utility; |
| | 9 | |
|
| | 10 | | namespace Spdx3.Model.Security.Classes; |
| | 11 | |
|
| | 12 | | /// <summary> |
| | 13 | | /// Links a vulnerability and one or more elements designating the latter as products not affected by the vulnerability. |
| | 14 | | /// See https://spdx.github.io/spdx-spec/v3.0.1/model/Security/Classes/VexNotAffectedVulnAssessmentRelationship/ |
| | 15 | | /// </summary> |
| | 16 | | public class VexNotAffectedVulnAssessmentRelationship : VexVulnAssessmentRelationship |
| | 17 | | { |
| | 18 | | [JsonPropertyName("security_impactStatement")] |
| | 19 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| 14 | 20 | | public string? ImpactStatement { get; set; } |
| | 21 | |
|
| | 22 | | [JsonPropertyName("security_impactStatementTime")] |
| | 23 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| 2 | 24 | | public DateTimeOffset? ImpactStatementTime { get; set; } |
| | 25 | |
|
| | 26 | | [JsonPropertyName("security_justificationType")] |
| | 27 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| 13 | 28 | | public VexJustificationType? JustificationType { get; set; } |
| | 29 | |
|
| | 30 | | // protected internal no-parm constructor required for deserialization |
| | 31 | | #pragma warning disable CS8618, CS9264 |
| 1 | 32 | | protected internal VexNotAffectedVulnAssessmentRelationship() |
| | 33 | | { |
| 1 | 34 | | } |
| | 35 | | #pragma warning restore CS8618, CS9264 |
| | 36 | |
|
| | 37 | | [SetsRequiredMembers] |
| | 38 | | public VexNotAffectedVulnAssessmentRelationship(Catalog catalog, CreationInfo creationInfo, Vulnerability from, |
| 3 | 39 | | List<Element> to) : base(catalog, creationInfo, RelationshipType.doesNotAffect, from, to) |
| | 40 | | { |
| 3 | 41 | | } |
| | 42 | |
|
| | 43 | |
|
| | 44 | | public override void Validate() |
| | 45 | | { |
| 6 | 46 | | base.Validate(); |
| | 47 | |
|
| | 48 | | /* |
| | 49 | | Both impactStatement and justificationType properties have a cardinality of 0..1 making them optional. |
| | 50 | | Nevertheless, to produce a valid VEX not_affected statement, one of them MUST be defined. |
| | 51 | | This is specified in the Minimum Elements for VEX. |
| | 52 | | */ |
| 6 | 53 | | if (ImpactStatement == null && JustificationType == null) |
| | 54 | | { |
| 1 | 55 | | throw new Spdx3ValidationException( |
| 1 | 56 | | "At least one of ImpactStatement and/or JustificationType must be specified."); |
| | 57 | | } |
| 5 | 58 | | } |
| | 59 | | } |