UNPKG

@cyclonedx/cyclonedx-library

Version:

Core functionality of CycloneDX for JavaScript (Node.js or WebBrowser).

273 lines (269 loc) 8.26 kB
/*! 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. */ import type * as Enums from '../../enums'; import type { HashContent } from '../../models'; import type { SpdxId } from '../../spdx'; import type { CPE, CWE, Integer } from '../../types'; export declare namespace JsonSchema { /** * @see {@link isIriReference} */ type IriReference = string; /** * Test whether format is JSON::iri-reference - best-effort. * * @see {@link https://datatracker.ietf.org/doc/html/rfc3987 | RFC 3987} * * @TODO add more validation according to spec */ function isIriReference(value: IriReference | any): value is IriReference; /** * @see {@link isIdnEmail} */ type IdnEmail = string; /** * Test whether format is JSON::idn-email - best-effort. * * @see {@link https://datatracker.ietf.org/doc/html/rfc6531 | RFC 6531} * * @TODO add more validation according to spec */ function isIdnEmail(value: IdnEmail | any): value is IdnEmail; type DateTime = string; } export declare namespace Normalized { type RefType = string; type RefLinkType = RefType; type BomLinkDocumentType = string; type BomLinkElementType = string; type BomLink = BomLinkDocumentType | BomLinkElementType; interface Bom { $schema?: string; bomFormat: 'CycloneDX'; specVersion: string; version: Integer; serialNumber?: string; metadata?: Metadata; components?: Component[]; services?: Service[]; externalReferences?: ExternalReference[]; dependencies?: Dependency[]; vulnerabilities?: Vulnerability[]; } interface Metadata { timestamp?: JsonSchema.DateTime; lifecycles?: Lifecycle[]; tools?: ToolsType; authors?: OrganizationalContact[]; component?: Component; manufacture?: OrganizationalEntity; supplier?: OrganizationalEntity; licenses?: License[]; properties?: Property[]; } interface LifecyclePhase { phase: Enums.LifecyclePhase; } interface NamedLifecycle { name: string; description?: string; } type Lifecycle = LifecyclePhase | NamedLifecycle; interface Tool { vendor?: string; name?: string; version?: string; hashes?: Hash[]; externalReferences?: ExternalReference[]; } /** since CDX 1.5 */ interface Tools { components?: Component[]; services?: Service[]; } type ToolsType = Tools | Tool[]; interface OrganizationalContact { name?: string; email?: JsonSchema.IdnEmail; phone?: string; } interface OrganizationalEntity { name?: string; url?: JsonSchema.IriReference[]; contact?: OrganizationalContact[]; } interface Hash { alg: Enums.HashAlgorithm; content: HashContent; } interface Component { type: Enums.ComponentType; name: string; 'mime-type'?: string; 'bom-ref'?: RefType; supplier?: OrganizationalEntity; author?: string; publisher?: string; group?: string; version?: string; description?: string; scope?: Enums.ComponentScope; hashes?: Hash[]; licenses?: License[]; copyright?: string; cpe?: CPE; purl?: string; swid?: SWID; modified?: boolean; externalReferences?: ExternalReference[]; components?: Component[]; evidence?: ComponentEvidence; properties?: Property[]; } interface Service { 'bom-ref'?: RefType; provider?: OrganizationalEntity; group?: string; name: string; version?: string; description?: string; licenses?: License[]; externalReferences?: ExternalReference[]; services?: Service[]; properties?: Property[]; } interface ComponentEvidence { licenses?: License[]; copyright?: Copyright[]; } interface Copyright { text: string; } interface NamedLicense { license: { name: string; acknowledgement?: Enums.LicenseAcknowledgement; text?: Attachment; url?: string; }; } interface SpdxLicense { license: { id: SpdxId; acknowledgement?: Enums.LicenseAcknowledgement; text?: Attachment; url?: string; }; } interface LicenseExpression { expression: string; acknowledgement?: Enums.LicenseAcknowledgement; } type License = NamedLicense | SpdxLicense | LicenseExpression; interface SWID { tagId: string; name: string; version?: string; tagVersion?: Integer; patch?: boolean; text?: Attachment; url?: JsonSchema.IriReference; } interface ExternalReference { url: JsonSchema.IriReference | BomLink; type: Enums.ExternalReferenceType; hashes?: Hash[]; comment?: string; } interface Attachment { content?: string; contentType?: string; encoding?: Enums.AttachmentEncoding; } interface Property { name?: string; value?: string; } interface Dependency { ref: RefLinkType; dependsOn?: RefLinkType[]; } interface Vulnerability { 'bom-ref'?: RefType; id?: string; source?: Vulnerability.Source; references?: Vulnerability.Reference[]; ratings?: Vulnerability.Rating[]; cwes?: CWE[]; description?: string; detail?: string; recommendation?: string; advisories?: Vulnerability.Advisory[]; created?: JsonSchema.DateTime; published?: JsonSchema.DateTime; updated?: JsonSchema.DateTime; credits?: Vulnerability.Credits; tools?: ToolsType; analysis?: Vulnerability.Analysis; affects?: Vulnerability.Affect[]; properties?: Property[]; } namespace Vulnerability { interface Source { name?: string; url?: string; } interface Reference { id: string; source: Source; } interface Rating { source?: Source; score?: number; severity?: Enums.Vulnerability.Severity; method?: Enums.Vulnerability.RatingMethod; vector?: string; justification?: string; } interface Advisory { title?: string; url: JsonSchema.IriReference; } interface Credits { organizations?: OrganizationalEntity[]; individuals?: OrganizationalContact[]; } interface Analysis { state?: Enums.Vulnerability.AnalysisState; justification?: Enums.Vulnerability.AnalysisJustification; response?: Enums.Vulnerability.AnalysisResponse[]; detail?: string; } interface Affect { ref: RefLinkType | BomLinkElementType; versions?: AffectedVersion[]; } interface AffectedSingleVersion { version: string; status?: Enums.Vulnerability.AffectStatus; } interface AffectedVersionRange { range: string; status?: Enums.Vulnerability.AffectStatus; } type AffectedVersion = AffectedSingleVersion | AffectedVersionRange; } } //# sourceMappingURL=types.d.ts.map