@cyclonedx/cyclonedx-library
Version:
Core functionality of CycloneDX for JavaScript (Node.js or WebBrowser).
95 lines (91 loc) • 3.62 kB
JavaScript
"use strict";
/*!
This file is part of CycloneDX JavaScript Library.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright (c) OWASP Foundation. All Rights Reserved.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.VulnerabilityRepository = exports.Vulnerability = void 0;
const sortable_1 = require("../../_helpers/sortable");
const cwe_1 = require("../../types/cwe");
const bomRef_1 = require("../bomRef");
const property_1 = require("../property");
const tool_1 = require("../tool");
const advisory_1 = require("./advisory");
const affect_1 = require("./affect");
const rating_1 = require("./rating");
const reference_1 = require("./reference");
class Vulnerability {
#bomRef;
id;
source;
references;
ratings;
cwes;
description;
detail;
recommendation;
advisories;
created;
published;
updated;
credits;
tools;
analysis;
affects;
properties;
constructor(op = {}) {
this.#bomRef = new bomRef_1.BomRef(op.bomRef);
this.id = op.id;
this.source = op.source;
this.references = op.references ?? new reference_1.ReferenceRepository();
this.ratings = op.ratings ?? new rating_1.RatingRepository();
this.cwes = op.cwes ?? new cwe_1.CweRepository();
this.description = op.description;
this.detail = op.detail;
this.recommendation = op.recommendation;
this.advisories = op.advisories ?? new advisory_1.AdvisoryRepository();
this.created = op.created;
this.published = op.published;
this.updated = op.updated;
this.credits = op.credits;
this.tools = op.tools ?? new tool_1.Tools();
this.analysis = op.analysis;
this.affects = op.affects ?? new affect_1.AffectRepository();
this.properties = op.properties ?? new property_1.PropertyRepository();
}
get bomRef() {
return this.#bomRef;
}
compare(other) {
const bomRefCompare = this.bomRef.compare(other.bomRef);
if (bomRefCompare !== 0) {
return bomRefCompare;
}
return (this.id ?? '').localeCompare(other.id ?? '') ||
(this.created?.getTime() ?? 0) - (other.created?.getTime() ?? 0) ||
(this.published?.getTime() ?? 0) - (other.published?.getTime() ?? 0) ||
(this.updated?.getTime() ?? 0) - (other.updated?.getTime() ?? 0) ||
this.ratings.compare(other.ratings) ||
this.cwes.compare(other.cwes) ||
(this.description ?? '').localeCompare(other.description ?? '') ||
(this.detail ?? '').localeCompare(other.detail ?? '') ||
(this.recommendation ?? '').localeCompare(other.recommendation ?? '') ||
(this.source && other.source ? this.source.compare(other.source) : 0) ||
this.properties.compare(other.properties);
}
}
exports.Vulnerability = Vulnerability;
class VulnerabilityRepository extends sortable_1.SortableComparables {
}
exports.VulnerabilityRepository = VulnerabilityRepository;
//# sourceMappingURL=vulnerability.js.map