@mitre/hdf-converters 3.6.0-rc.3 → 3.6.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +260 -266
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as detectFormat, r as detectConverter, t as registerAllFingerprints } from "./register-all-CDfYvwQF.js";
|
|
2
2
|
import { flattenOverlays } from "@mitre/hdf-parsers";
|
|
3
|
-
import { buildCsv, buildXml, canonicalJson, computeCvssScore, computeEffectiveStatus, cvssScoreToSeverity, formatTimestamp, formatTimestampSeconds, governingStatusOverride, impactToSeverity, isUnratedSeverity, normalizeHdfTimestamps, parseCsv, parseJSON, parsePurl, parseTimestamp, parseXml, parseXmlWithArrays, replaceHtmlTags, roundImpact, severityToImpact, severityToImpactWithAliases, sha256, stripHtml, stripHtml as stripHTML, trimUtcFraction, worstStatus, xmlSafeText } from "@mitre/hdf-utilities";
|
|
3
|
+
import { DEFAULT_MAX_INPUT_SIZE, buildCsv, buildXml, canonicalJson, computeCvssScore, computeEffectiveStatus, cvssScoreToSeverity, encodeBase64Utf8, formatJsonNumber, formatTimestamp, formatTimestampSeconds, governingStatusOverride, impactToSeverity, isUnratedSeverity, normalizeHdfTimestamps, parseCsv, parseJSON, parsePurl, parseTimestamp, parseXml, parseXmlWithArrays, replaceHtmlTags, roundImpact, severityToImpact, severityToImpactWithAliases, sha256, stripHtml, stripHtml as stripHTML, trimUtcFraction, validateInputSize, worstStatus, xmlSafeText } from "@mitre/hdf-utilities";
|
|
4
4
|
import { Applicability, AuthorizationStatus, CVSSSeverity, CategorizationLevel, ControlType, Ecosystem, EvidenceType, HashAlgorithm, IdentityType, Justification, MilestoneStatus, OverrideType, PlanType, ResultStatus, Severity, TargetType, VerificationMethodEnum, Version, affectedPackageSchema, amendmentsSchema, bomSchema, commonSchema, comparisonSchema, componentSchema, createDescription, createMinimalBaseline, createRequirement, createResult, cvssSchema, dataFlowSchema, epssSchema, eventsSchema, extensionsSchema, hdfAmendmentsSchema, hdfBaselineSchema, hdfComparisonSchema, hdfEvidencePackageSchema, hdfPlanSchema, hdfRequirementChangeEventSchema, hdfResultsSchema, hdfSystemSchema, kevSchema, parameterSchema, planSchema, platformSchema, resultSchema, runnerSchema, severityToImpact as severityToImpact$1, statisticsSchema, systemSchema, targetSchema } from "@mitre/hdf-schema";
|
|
5
5
|
import { DEFAULT_COMPONENT_MANAGEMENT_NIST_TAGS, DEFAULT_CONFIG_MANAGEMENT_NIST_TAGS, DEFAULT_REMEDIATION_NIST_TAGS, DEFAULT_STATIC_ANALYSIS_NIST_TAGS, DEFAULT_STATIC_ANALYSIS_NIST_TAGS as DEFAULT_STATIC_ANALYSIS_NIST_TAGS$1, awsConfigMappedRevisions, getAwsConfigNistControlByIdentifier, getAwsConfigNistControlByName, getAwsConfigNistControlsBySubstring, getCCINistMappings, getCurrentNistRevision, getCweNistControl, getHipcheckNistControls, getNessusNistControl, getNiktoNistControl, getOwaspNistControl, getScoutsuiteNistControl, isNistStrict, nistToCci } from "@mitre/hdf-mappings";
|
|
6
6
|
import Ajv from "ajv";
|
|
@@ -287,7 +287,7 @@ function mapCWEToNIST(cweIDs, fallback) {
|
|
|
287
287
|
}
|
|
288
288
|
return controls.size > 0 ? [...controls].sort() : fallback;
|
|
289
289
|
}
|
|
290
|
-
/** Matches CWE identifiers like "CWE-79", "CWE 89", "cwe22". */
|
|
290
|
+
/** Matches CWE identifiers like "CWE-79", "CWE 89", "cwe22"; group 1 is the number. */
|
|
291
291
|
const CWE_PATTERN$1 = /CWE[- ]?(\d+)/gi;
|
|
292
292
|
/**
|
|
293
293
|
* Extract all numeric CWE IDs from text.
|
|
@@ -317,23 +317,30 @@ function firstNonEmpty(...candidates) {
|
|
|
317
317
|
for (const c of candidates) if (c != null && c.trim() !== "") return c;
|
|
318
318
|
return "";
|
|
319
319
|
}
|
|
320
|
-
/** Default maximum input size for converters (50MB) */
|
|
321
|
-
const DEFAULT_MAX_INPUT_SIZE = 50 * 1024 * 1024;
|
|
322
320
|
/**
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
* counting would require TextEncoder.
|
|
328
|
-
*
|
|
329
|
-
* @param input - Raw input string to validate
|
|
330
|
-
* @param converterName - Name of the converter (used in error message)
|
|
331
|
-
* @param maxSize - Maximum allowed character count (defaults to DEFAULT_MAX_INPUT_SIZE)
|
|
332
|
-
* @throws Error if input exceeds maxSize
|
|
321
|
+
* The converter-facing face of the @mitre/hdf-utilities size guard: same
|
|
322
|
+
* limit, same UTF-8 byte-length measure as Go's ValidateJSONSize, with the
|
|
323
|
+
* converter name prefixed onto the error. A non-positive maxSize means "use
|
|
324
|
+
* the default" (an explicitly-passed 0 never rejects all non-empty input).
|
|
333
325
|
*/
|
|
334
|
-
function validateInputSize(input, converterName, maxSize = DEFAULT_MAX_INPUT_SIZE) {
|
|
335
|
-
|
|
336
|
-
|
|
326
|
+
function validateInputSize$1(input, converterName, maxSize = DEFAULT_MAX_INPUT_SIZE) {
|
|
327
|
+
const limit = maxSize > 0 ? maxSize : DEFAULT_MAX_INPUT_SIZE;
|
|
328
|
+
try {
|
|
329
|
+
validateInputSize(input, limit);
|
|
330
|
+
} catch (err) {
|
|
331
|
+
throw new Error(`${converterName}: ${err instanceof Error ? err.message : String(err)}`);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
/** The schema's Severity enum keyed by its lowercase token. */
|
|
335
|
+
const HDF_SEVERITIES = new Map(Object.values(Severity).map((s) => [s, s]));
|
|
336
|
+
/**
|
|
337
|
+
* Map a raw severity token onto the schema's Severity enum, case-insensitively.
|
|
338
|
+
* The one place the enum vocabulary is spelled out for converters that must not
|
|
339
|
+
* cast an off-vocabulary source value into the typed field. Whitespace is not
|
|
340
|
+
* trimmed; callers own that normalization. Go parity: shared.ParseSeverity.
|
|
341
|
+
*/
|
|
342
|
+
function parseSeverity(s) {
|
|
343
|
+
return HDF_SEVERITIES.get(s.toLowerCase());
|
|
337
344
|
}
|
|
338
345
|
/**
|
|
339
346
|
* Parse an HDF document. The single ingest point for every HDF-consuming
|
|
@@ -375,7 +382,7 @@ function requireHdfAmendments(input, converterName) {
|
|
|
375
382
|
*/
|
|
376
383
|
function requireHdfStructure(input, converterName, field) {
|
|
377
384
|
if (input.length === 0) throw new Error(`${converterName}: empty input`);
|
|
378
|
-
validateInputSize(input, converterName);
|
|
385
|
+
validateInputSize$1(input, converterName);
|
|
379
386
|
const parsed = parseHdf(input);
|
|
380
387
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error(`${converterName}: invalid HDF structure: missing ${field} field`);
|
|
381
388
|
const doc = parsed;
|
|
@@ -467,7 +474,7 @@ function ecosystemFromPurlType(type) {
|
|
|
467
474
|
* - purl alone
|
|
468
475
|
* - cpe alone
|
|
469
476
|
*/
|
|
470
|
-
function buildAffectedPackage$
|
|
477
|
+
function buildAffectedPackage$1(opts) {
|
|
471
478
|
const pkg = {};
|
|
472
479
|
if (opts.purl) pkg.purl = opts.purl;
|
|
473
480
|
if (opts.cpe) pkg.cpe = opts.cpe;
|
|
@@ -653,6 +660,36 @@ function deriveVerificationMethod(code) {
|
|
|
653
660
|
if (code === void 0 || code === null || code === "") return void 0;
|
|
654
661
|
return VerificationMethodEnum.Automated;
|
|
655
662
|
}
|
|
663
|
+
/**
|
|
664
|
+
* Renames the HDF severity bands into the OSCAL risk characterization facet
|
|
665
|
+
* vocabulary (medium is 'moderate' there, informational is 'info'). Returns ''
|
|
666
|
+
* for anything outside the HDF vocabulary so callers omit the facet rather than
|
|
667
|
+
* emit a value OSCAL does not define. Go peer: shared.OSCALSeverityFromHDF.
|
|
668
|
+
*/
|
|
669
|
+
const OSCAL_SEVERITY_BY_HDF_BAND = {
|
|
670
|
+
critical: "critical",
|
|
671
|
+
high: "high",
|
|
672
|
+
medium: "moderate",
|
|
673
|
+
low: "low",
|
|
674
|
+
informational: "info"
|
|
675
|
+
};
|
|
676
|
+
function oscalSeverityFromHdf(severity) {
|
|
677
|
+
const band = (severity ?? "").toLowerCase();
|
|
678
|
+
return Object.prototype.hasOwnProperty.call(OSCAL_SEVERITY_BY_HDF_BAND, band) ? OSCAL_SEVERITY_BY_HDF_BAND[band] : "";
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* The expiresAt an override takes when the source tool records no expiration:
|
|
682
|
+
* one calendar year after appliedAt, computed in UTC. A calendar year (not 365
|
|
683
|
+
* days) keeps the date on the same month/day across leap years, and doing the
|
|
684
|
+
* rollover in UTC keeps the result off the host timezone. Go peer:
|
|
685
|
+
* shared.DefaultOverrideExpiry.
|
|
686
|
+
*/
|
|
687
|
+
function defaultOverrideExpiry(appliedAt) {
|
|
688
|
+
const expiresAt = /* @__PURE__ */ new Date();
|
|
689
|
+
expiresAt.setTime(appliedAt.getTime());
|
|
690
|
+
expiresAt.setUTCFullYear(expiresAt.getUTCFullYear() + 1);
|
|
691
|
+
return expiresAt;
|
|
692
|
+
}
|
|
656
693
|
function buildNoFindingsRequirement(id, codeDesc, startTime) {
|
|
657
694
|
return {
|
|
658
695
|
id,
|
|
@@ -710,22 +747,13 @@ function typeViolations(result) {
|
|
|
710
747
|
* - Results: snake_case → camelCase for all fields
|
|
711
748
|
* - Overlay flattening: merge overlay/wrapper baselines so every requirement has results
|
|
712
749
|
*/
|
|
713
|
-
/** Valid severity values per HDF v2.0 schema (matches the Go converter). */
|
|
714
|
-
const VALID_SEVERITIES$1 = /* @__PURE__ */ new Set([
|
|
715
|
-
"critical",
|
|
716
|
-
"high",
|
|
717
|
-
"medium",
|
|
718
|
-
"low",
|
|
719
|
-
"informational"
|
|
720
|
-
]);
|
|
721
750
|
/**
|
|
722
751
|
* Convert tags.severity string to a valid severity value.
|
|
723
752
|
* Returns null if the value is not a recognized severity.
|
|
724
753
|
*/
|
|
725
754
|
function tagSeverityToSeverity(tagSeverity) {
|
|
726
755
|
if (typeof tagSeverity !== "string") return null;
|
|
727
|
-
|
|
728
|
-
return VALID_SEVERITIES$1.has(normalized) ? normalized : null;
|
|
756
|
+
return parseSeverity(tagSeverity.trim()) ?? null;
|
|
729
757
|
}
|
|
730
758
|
/**
|
|
731
759
|
* Normalize status values from v1.0 to v2.0 format.
|
|
@@ -1043,7 +1071,7 @@ function documentTimestamp(v1Data) {
|
|
|
1043
1071
|
return latest ? formatTimestamp(latest) : void 0;
|
|
1044
1072
|
}
|
|
1045
1073
|
function convertLegacyHdf(v1Data, converterVersion = "1.0.0") {
|
|
1046
|
-
validateInputSize(JSON.stringify(v1Data), "legacyhdf-to-hdf");
|
|
1074
|
+
validateInputSize$1(JSON.stringify(v1Data), "legacyhdf-to-hdf");
|
|
1047
1075
|
const v2 = {
|
|
1048
1076
|
baselines: (v1Data.profiles || []).map(convertProfile),
|
|
1049
1077
|
statistics: v1Data.statistics || {}
|
|
@@ -1514,7 +1542,7 @@ function buildBaseline$1(name, findings, resultsChecksum) {
|
|
|
1514
1542
|
/** Converts an ASFF document to HDF Results JSON. */
|
|
1515
1543
|
async function convertAsffToHdf(input, converterVersion = "1.0.0") {
|
|
1516
1544
|
if (!input || input.trim().length === 0) throw new Error("asff: empty input");
|
|
1517
|
-
validateInputSize(input, "asff");
|
|
1545
|
+
validateInputSize$1(input, "asff");
|
|
1518
1546
|
const findings = parseFindings$1(input);
|
|
1519
1547
|
const resultsChecksum = await inputChecksum(input);
|
|
1520
1548
|
const order = [];
|
|
@@ -1563,7 +1591,7 @@ const SARIF_ALIASES = {
|
|
|
1563
1591
|
note: .3
|
|
1564
1592
|
};
|
|
1565
1593
|
async function convertSarifToHdf(input, converterVersion = "1.0.0") {
|
|
1566
|
-
validateInputSize(input, "sarif");
|
|
1594
|
+
validateInputSize$1(input, "sarif");
|
|
1567
1595
|
const resultsChecksum = await inputChecksum(input);
|
|
1568
1596
|
const sarif = parseJSON(input);
|
|
1569
1597
|
if (!sarif || typeof sarif !== "object") throw new Error("Invalid SARIF structure: not a valid JSON object");
|
|
@@ -1701,7 +1729,7 @@ function packageFromSarifProperties(props) {
|
|
|
1701
1729
|
if (props.purl) ecosystem = ecosystemFromPurlType(parsePurl(props.purl)?.type);
|
|
1702
1730
|
else if (props.ecosystem) ecosystem = ecosystemFromPurlType(props.ecosystem);
|
|
1703
1731
|
else if (name && version) ecosystem = Ecosystem.Generic;
|
|
1704
|
-
return buildAffectedPackage$
|
|
1732
|
+
return buildAffectedPackage$1({
|
|
1705
1733
|
name,
|
|
1706
1734
|
version,
|
|
1707
1735
|
ecosystem,
|
|
@@ -1837,9 +1865,7 @@ function buildSuppressionOverride(result, timestamp) {
|
|
|
1837
1865
|
const isFalsePositive = accepted.some((s) => justificationIndicatesFalsePositive(s.justification));
|
|
1838
1866
|
const type = isFalsePositive ? OverrideType.FalsePositive : OverrideType.Waiver;
|
|
1839
1867
|
const effective = isFalsePositive ? ResultStatus.NotApplicable : ResultStatus.Passed;
|
|
1840
|
-
const expiresAt =
|
|
1841
|
-
expiresAt.setTime(timestamp.getTime());
|
|
1842
|
-
expiresAt.setUTCFullYear(expiresAt.getUTCFullYear() + 1);
|
|
1868
|
+
const expiresAt = defaultOverrideExpiry(timestamp);
|
|
1843
1869
|
return {
|
|
1844
1870
|
override: {
|
|
1845
1871
|
type,
|
|
@@ -1955,7 +1981,7 @@ const ARRAY_TAGS$2 = [
|
|
|
1955
1981
|
*/
|
|
1956
1982
|
async function convertJunitToHdf(input, converterVersion = "1.0.0") {
|
|
1957
1983
|
if (!input || !input.trim()) throw new Error("Empty input");
|
|
1958
|
-
validateInputSize(input, "junit");
|
|
1984
|
+
validateInputSize$1(input, "junit");
|
|
1959
1985
|
const { suites, name } = parseJUnitXML(input);
|
|
1960
1986
|
const scanTime = resolveScanTime(suites);
|
|
1961
1987
|
const requirements = buildRequirements(suites, scanTime);
|
|
@@ -2231,7 +2257,7 @@ function parseCpeVersion(testSystem) {
|
|
|
2231
2257
|
}
|
|
2232
2258
|
async function convertXccdfResultsToHdf(input, converterVersion = "1.0.0") {
|
|
2233
2259
|
if (!input || !input.trim()) throw new Error("Empty input");
|
|
2234
|
-
validateInputSize(input, "xccdf-results");
|
|
2260
|
+
validateInputSize$1(input, "xccdf-results");
|
|
2235
2261
|
const parsed = parseXmlWithArrays(input, ARRAY_TAGS$1, { trimValues: false });
|
|
2236
2262
|
const arfParsed = parsed;
|
|
2237
2263
|
if (arfParsed["asset-report-collection"]) return convertArfCollection(arfParsed["asset-report-collection"], input, converterVersion);
|
|
@@ -3155,13 +3181,6 @@ function cklbTitle(cl) {
|
|
|
3155
3181
|
//#endregion
|
|
3156
3182
|
//#region shared/typescript/checklist/to-hdf.ts
|
|
3157
3183
|
const CONVERTER_VERSION = "1.0.0";
|
|
3158
|
-
const VALID_SEVERITIES = /* @__PURE__ */ new Set([
|
|
3159
|
-
"critical",
|
|
3160
|
-
"high",
|
|
3161
|
-
"medium",
|
|
3162
|
-
"low",
|
|
3163
|
-
"informational"
|
|
3164
|
-
]);
|
|
3165
3184
|
/**
|
|
3166
3185
|
* Map the format-neutral Checklist model to an HDF Results object.
|
|
3167
3186
|
* controlType is derived per-Vuln from CCI->NIST; verificationMethod and
|
|
@@ -3233,7 +3252,8 @@ function vulnToRequirement(v, scanTime) {
|
|
|
3233
3252
|
if (v.legacyIDs && v.legacyIDs.length) tags["legacy_ids"] = v.legacyIDs;
|
|
3234
3253
|
if (v.extra && Object.keys(v.extra).length > 0) tags["cklMetadata"] = { ...v.extra };
|
|
3235
3254
|
const req = createRequirement(v.vulnNum, v.ruleTitle ?? v.vulnNum, descriptions, impact, [result], { tags });
|
|
3236
|
-
|
|
3255
|
+
const hdfSeverity = parseSeverity(severity);
|
|
3256
|
+
if (hdfSeverity !== void 0) req.severity = hdfSeverity;
|
|
3237
3257
|
const controlType = deriveControlTypeFromTags(nistTags);
|
|
3238
3258
|
if (controlType !== void 0) req.controlType = controlType;
|
|
3239
3259
|
return req;
|
|
@@ -3322,8 +3342,8 @@ function requirementEffectiveStatus(req) {
|
|
|
3322
3342
|
* fields are synthesized best-effort so any HDF yields a valid checklist.
|
|
3323
3343
|
*/
|
|
3324
3344
|
function hdfToChecklist(input) {
|
|
3325
|
-
const hdf =
|
|
3326
|
-
if (
|
|
3345
|
+
const hdf = requireHdfResults(input, "hdf to checklist").doc;
|
|
3346
|
+
if (hdf.baselines.length === 0) throw new Error("hdf to checklist: HDF has no baselines");
|
|
3327
3347
|
const ext = hdf.extensions ?? {};
|
|
3328
3348
|
const format = strVal(ext, "checklistFormat") || "ckl";
|
|
3329
3349
|
const cklbVersion = strVal(ext, "cklbVersion");
|
|
@@ -3450,7 +3470,7 @@ function formatOverride(o) {
|
|
|
3450
3470
|
}
|
|
3451
3471
|
function overrideSeverity(req) {
|
|
3452
3472
|
for (const o of req.statusOverrides ?? []) if (o.impact) return {
|
|
3453
|
-
severity:
|
|
3473
|
+
severity: cklSeverityFromImpact(o.impact.value) || "low",
|
|
3454
3474
|
justification: o.reason ?? ""
|
|
3455
3475
|
};
|
|
3456
3476
|
return {
|
|
@@ -3458,20 +3478,20 @@ function overrideSeverity(req) {
|
|
|
3458
3478
|
justification: ""
|
|
3459
3479
|
};
|
|
3460
3480
|
}
|
|
3461
|
-
function
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3481
|
+
function cklSeverityFromImpact(impact) {
|
|
3482
|
+
switch (impactToSeverity(impact)) {
|
|
3483
|
+
case "critical":
|
|
3484
|
+
case "high": return "high";
|
|
3485
|
+
case "medium": return "medium";
|
|
3486
|
+
case "low": return "low";
|
|
3487
|
+
default: return "";
|
|
3488
|
+
}
|
|
3465
3489
|
}
|
|
3466
3490
|
function resolveSeverity(req, tags) {
|
|
3467
3491
|
const tagSev = strVal(tags, "severity");
|
|
3468
3492
|
if (tagSev) return tagSev;
|
|
3469
3493
|
if (req.severity) return String(req.severity).toLowerCase();
|
|
3470
|
-
|
|
3471
|
-
if (i >= .7) return "high";
|
|
3472
|
-
if (i >= .4) return "medium";
|
|
3473
|
-
if (i > 0) return "low";
|
|
3474
|
-
return "";
|
|
3494
|
+
return cklSeverityFromImpact(req.impact ?? 0);
|
|
3475
3495
|
}
|
|
3476
3496
|
function resolveCcis(tags) {
|
|
3477
3497
|
const direct = strSlice(tags, "cci");
|
|
@@ -3521,7 +3541,7 @@ function strSlice(m, key) {
|
|
|
3521
3541
|
* skill Step 4d).
|
|
3522
3542
|
*/
|
|
3523
3543
|
async function convertCklToHdf(input) {
|
|
3524
|
-
validateInputSize(input, "ckl-to-hdf");
|
|
3544
|
+
validateInputSize$1(input, "ckl-to-hdf");
|
|
3525
3545
|
const resultsChecksum = await inputChecksum(input);
|
|
3526
3546
|
const checklist = parseCkl(input);
|
|
3527
3547
|
return JSON.stringify(checklistToHdf(checklist, resultsChecksum, "ckl-to-hdf"), null, 2);
|
|
@@ -3538,7 +3558,7 @@ async function convertCklToHdf(input) {
|
|
|
3538
3558
|
* skill Step 4d).
|
|
3539
3559
|
*/
|
|
3540
3560
|
async function convertCklbToHdf(input) {
|
|
3541
|
-
validateInputSize(input, "cklb-to-hdf");
|
|
3561
|
+
validateInputSize$1(input, "cklb-to-hdf");
|
|
3542
3562
|
const resultsChecksum = await inputChecksum(input);
|
|
3543
3563
|
const checklist = parseCklb(input);
|
|
3544
3564
|
return JSON.stringify(checklistToHdf(checklist, resultsChecksum, "cklb-to-hdf"), null, 2);
|
|
@@ -3767,7 +3787,7 @@ function buildRequirement$18(query, startTime) {
|
|
|
3767
3787
|
* @returns HDF JSON string
|
|
3768
3788
|
*/
|
|
3769
3789
|
async function convertKicsToHdf(input, converterVersion = "1.0.0") {
|
|
3770
|
-
validateInputSize(input, "kics");
|
|
3790
|
+
validateInputSize$1(input, "kics");
|
|
3771
3791
|
if (!input || input.trim().length === 0) throw new Error("kics: empty input");
|
|
3772
3792
|
const report = parseJSON(input);
|
|
3773
3793
|
if (!Array.isArray(report.queries) || typeof report.kics_version !== "string") throw new Error("kics: input does not look like a KICS report");
|
|
@@ -3830,10 +3850,11 @@ function lineOf(position) {
|
|
|
3830
3850
|
}
|
|
3831
3851
|
/**
|
|
3832
3852
|
* Semgrep emits CWEs in prose form -- 'CWE-89: Improper Neutralization of ...'
|
|
3833
|
-
* -- while the mapping keys on the bare number.
|
|
3853
|
+
* -- while the mapping keys on the bare number. Read entry by entry so source
|
|
3854
|
+
* order is kept, matching the Go twin.
|
|
3834
3855
|
*/
|
|
3835
3856
|
function extractCweIds(metadata) {
|
|
3836
|
-
return normalizeToArray(metadata.cwe).
|
|
3857
|
+
return normalizeToArray(metadata.cwe).flatMap((entry) => extractCWEIDs(entry)).map((id) => Number.parseInt(id, 10)).filter((id) => Number.isFinite(id));
|
|
3837
3858
|
}
|
|
3838
3859
|
/**
|
|
3839
3860
|
* The parsed CWE ids in the CWE-N catalog form the schema's cwe[] field asks
|
|
@@ -3853,6 +3874,15 @@ function impactFor(result) {
|
|
|
3853
3874
|
return severityToImpactWithAliases(severity, SEMGREP_SEVERITY_ALIASES, DEFAULT_IMPACT);
|
|
3854
3875
|
}
|
|
3855
3876
|
/**
|
|
3877
|
+
* Publishes the band the impact already implies, so the two fields cannot
|
|
3878
|
+
* disagree. An absent or redacted severity stays unset: the unrated tag is what
|
|
3879
|
+
* tells a consumer the 0.5 was a default, and a "medium" here would hide it.
|
|
3880
|
+
*/
|
|
3881
|
+
function severityFor(result) {
|
|
3882
|
+
if (!isPresent(result.extra?.severity)) return;
|
|
3883
|
+
return impactToSeverity(impactFor(result));
|
|
3884
|
+
}
|
|
3885
|
+
/**
|
|
3856
3886
|
* Semgrep rule ids are dotted paths whose final segment is the rule name. The
|
|
3857
3887
|
* JSON output carries no human-readable rule title anywhere -- unlike the SARIF
|
|
3858
3888
|
* output, whose rule objects have `name` and `shortDescription` -- so one is
|
|
@@ -3989,6 +4019,8 @@ function buildRequirement$17(checkId, results, startTime) {
|
|
|
3989
4019
|
...refs.length > 0 ? { refs } : {},
|
|
3990
4020
|
...sourceLocation ? { sourceLocation } : {}
|
|
3991
4021
|
});
|
|
4022
|
+
const severity = severityFor(representative);
|
|
4023
|
+
if (severity !== void 0) requirement.severity = severity;
|
|
3992
4024
|
requirement.verificationMethod = VerificationMethodEnum.Automated;
|
|
3993
4025
|
const controlType = deriveControlTypeFromTags(tags.nist);
|
|
3994
4026
|
if (controlType !== void 0) requirement.controlType = controlType;
|
|
@@ -4065,7 +4097,7 @@ function buildCoverageRequirement(report, ruleCount, startTime) {
|
|
|
4065
4097
|
* @returns HDF JSON string
|
|
4066
4098
|
*/
|
|
4067
4099
|
async function convertSemgrepToHdf(input, converterVersion = "1.0.0") {
|
|
4068
|
-
validateInputSize(input, "semgrep");
|
|
4100
|
+
validateInputSize$1(input, "semgrep");
|
|
4069
4101
|
if (!input || input.trim().length === 0) throw new Error("semgrep: empty input");
|
|
4070
4102
|
registerAllFingerprints();
|
|
4071
4103
|
const detected = detectConverter(input);
|
|
@@ -4301,7 +4333,7 @@ function buildRequirement$16(vulnID, vulns, scanTime, packageManager) {
|
|
|
4301
4333
|
const version = rep.version;
|
|
4302
4334
|
if (name && version) {
|
|
4303
4335
|
const ecosystem = ecosystemFromSnykPackageManager(packageManager);
|
|
4304
|
-
const pkg = buildAffectedPackage$
|
|
4336
|
+
const pkg = buildAffectedPackage$1({
|
|
4305
4337
|
name,
|
|
4306
4338
|
version,
|
|
4307
4339
|
ecosystem,
|
|
@@ -4348,7 +4380,7 @@ function convertSingleProject(report, resultsChecksum, scanTime) {
|
|
|
4348
4380
|
*/
|
|
4349
4381
|
async function convertSnykToHdf(input, converterVersion = "1.0.0") {
|
|
4350
4382
|
if (!input || input.trim().length === 0) throw new Error("snyk: empty input");
|
|
4351
|
-
validateInputSize(input, "snyk");
|
|
4383
|
+
validateInputSize$1(input, "snyk");
|
|
4352
4384
|
registerAllFingerprints();
|
|
4353
4385
|
const detected = detectConverter(input);
|
|
4354
4386
|
if (detected && detected.fingerprint.id === "sarif-to-hdf") return convertSarifToHdf(input, converterVersion);
|
|
@@ -4456,31 +4488,27 @@ function buildCvssEntries$7(vuln) {
|
|
|
4456
4488
|
}
|
|
4457
4489
|
function mapGrypeTypeToEcosystem(grypeType) {
|
|
4458
4490
|
switch ((grypeType ?? "").toLowerCase()) {
|
|
4459
|
-
case "rpm": return Ecosystem.RPM;
|
|
4460
|
-
case "deb": return Ecosystem.Deb;
|
|
4461
|
-
case "npm": return Ecosystem.Npm;
|
|
4462
4491
|
case "python": return Ecosystem.Pypi;
|
|
4463
|
-
case "gem": return Ecosystem.Gem;
|
|
4464
4492
|
case "go-module": return Ecosystem.Go;
|
|
4465
4493
|
case "java-archive":
|
|
4466
4494
|
case "jenkins-plugin": return Ecosystem.Maven;
|
|
4467
4495
|
case "dotnet": return Ecosystem.Nuget;
|
|
4468
4496
|
case "rust-crate": return Ecosystem.Cargo;
|
|
4469
|
-
default: return
|
|
4497
|
+
default: return ecosystemFromPurlType(grypeType);
|
|
4470
4498
|
}
|
|
4471
4499
|
}
|
|
4472
4500
|
function buildAffectedPackages(match) {
|
|
4473
4501
|
const artifact = match.artifact;
|
|
4474
|
-
const
|
|
4502
|
+
const fix = match.vulnerability.fix;
|
|
4503
|
+
const pkg = buildAffectedPackage$1({
|
|
4475
4504
|
name: artifact.name,
|
|
4476
4505
|
version: artifact.version,
|
|
4477
|
-
ecosystem: mapGrypeTypeToEcosystem(artifact.type)
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
return [pkg];
|
|
4506
|
+
ecosystem: mapGrypeTypeToEcosystem(artifact.type),
|
|
4507
|
+
cpe: artifact.cpes?.[0],
|
|
4508
|
+
purl: artifact.purl,
|
|
4509
|
+
fixedInVersion: fix?.state === "fixed" ? fix.versions?.[0] : void 0
|
|
4510
|
+
});
|
|
4511
|
+
return pkg ? [pkg] : [];
|
|
4484
4512
|
}
|
|
4485
4513
|
const CWE_ID_PATTERN$2 = /^CWE-[1-9]\d*$/;
|
|
4486
4514
|
function extractCwe(raw) {
|
|
@@ -4593,7 +4621,7 @@ function buildComponent$2(report, targetName) {
|
|
|
4593
4621
|
return component;
|
|
4594
4622
|
}
|
|
4595
4623
|
async function convertGrypeToHdf(input, converterVersion = "1.0.0") {
|
|
4596
|
-
validateInputSize(input, "grype");
|
|
4624
|
+
validateInputSize$1(input, "grype");
|
|
4597
4625
|
const resultsChecksum = await inputChecksum(input);
|
|
4598
4626
|
const grypeData = parseJSON(input);
|
|
4599
4627
|
const requirements = [];
|
|
@@ -4667,9 +4695,7 @@ function buildWaiverOverride(ar) {
|
|
|
4667
4695
|
let reason = ar.decision_details || ar.name || "";
|
|
4668
4696
|
if (!reason) reason = "Risk accepted in DefectDojo";
|
|
4669
4697
|
const appliedAt = (ar.created ? parseTimestamp(ar.created) : null) ?? /* @__PURE__ */ new Date();
|
|
4670
|
-
const oneYearOut =
|
|
4671
|
-
oneYearOut.setTime(appliedAt.getTime());
|
|
4672
|
-
oneYearOut.setFullYear(oneYearOut.getFullYear() + 1);
|
|
4698
|
+
const oneYearOut = defaultOverrideExpiry(appliedAt);
|
|
4673
4699
|
const expiresAt = (ar.expiration_date ? parseTimestamp(ar.expiration_date) : null) ?? oneYearOut;
|
|
4674
4700
|
return {
|
|
4675
4701
|
type: OverrideType.Waiver,
|
|
@@ -4701,9 +4727,7 @@ function falsePositiveReviewer(f) {
|
|
|
4701
4727
|
function buildFalsePositiveOverride(f) {
|
|
4702
4728
|
const reason = f.mitigation || "Marked as false positive in DefectDojo";
|
|
4703
4729
|
const appliedAt = (f.mitigated ? parseTimestamp(f.mitigated) : null) ?? parseFindingDate(f.date) ?? /* @__PURE__ */ new Date();
|
|
4704
|
-
const oneYearOut =
|
|
4705
|
-
oneYearOut.setTime(appliedAt.getTime());
|
|
4706
|
-
oneYearOut.setUTCFullYear(oneYearOut.getUTCFullYear() + 1);
|
|
4730
|
+
const oneYearOut = defaultOverrideExpiry(appliedAt);
|
|
4707
4731
|
return {
|
|
4708
4732
|
type: OverrideType.FalsePositive,
|
|
4709
4733
|
status: ResultStatus.NotApplicable,
|
|
@@ -4836,7 +4860,7 @@ function scannerName(f) {
|
|
|
4836
4860
|
return f.related_fields?.test?.test_type?.name || "DefectDojo";
|
|
4837
4861
|
}
|
|
4838
4862
|
async function convertDefectDojoToHdf(input, converterVersion = "0.1.0") {
|
|
4839
|
-
validateInputSize(input, "defectdojo");
|
|
4863
|
+
validateInputSize$1(input, "defectdojo");
|
|
4840
4864
|
const resultsChecksum = await inputChecksum(input);
|
|
4841
4865
|
const parsed = parseJSON(input);
|
|
4842
4866
|
const findings = Array.isArray(parsed) ? parsed : parsed.results ?? [];
|
|
@@ -4915,7 +4939,7 @@ function decodeEntitiesDeep(value) {
|
|
|
4915
4939
|
* Convert Nessus XML scan results to HDF format
|
|
4916
4940
|
*/
|
|
4917
4941
|
async function convertNessusToHdf(nessusXml, converterVersion = "1.0.0") {
|
|
4918
|
-
validateInputSize(nessusXml, "nessus");
|
|
4942
|
+
validateInputSize$1(nessusXml, "nessus");
|
|
4919
4943
|
const resultsChecksum = await inputChecksum(nessusXml);
|
|
4920
4944
|
const parsed = decodeEntitiesDeep(parseXmlWithArrays(nessusXml, [
|
|
4921
4945
|
"preference",
|
|
@@ -5376,7 +5400,7 @@ function foldNistControls(cweIds, owaspIds) {
|
|
|
5376
5400
|
* @returns HDF JSON string
|
|
5377
5401
|
*/
|
|
5378
5402
|
async function convertSonarqubeToHdf(input, converterVersion = "1.0.0") {
|
|
5379
|
-
validateInputSize(input, "sonarqube");
|
|
5403
|
+
validateInputSize$1(input, "sonarqube");
|
|
5380
5404
|
const resultsChecksum = await inputChecksum(input);
|
|
5381
5405
|
const sonarData = parseJSON(input);
|
|
5382
5406
|
if (!sonarData || typeof sonarData !== "object") throw new Error("Invalid SonarQube structure: not a valid JSON object");
|
|
@@ -5714,7 +5738,7 @@ function buildRequirement$15(rule) {
|
|
|
5714
5738
|
* @returns HDF JSON string
|
|
5715
5739
|
*/
|
|
5716
5740
|
async function convertAwsConfigToHdf(input, converterVersion = "1.0.0") {
|
|
5717
|
-
validateInputSize(input, "aws-config");
|
|
5741
|
+
validateInputSize$1(input, "aws-config");
|
|
5718
5742
|
const resultsChecksum = await inputChecksum(input);
|
|
5719
5743
|
const data = parseJSON(input);
|
|
5720
5744
|
if (!data || typeof data !== "object") throw new Error("Invalid AWS Config export: not a valid JSON object");
|
|
@@ -5852,7 +5876,7 @@ function parseInput(input) {
|
|
|
5852
5876
|
* @returns HDF JSON string
|
|
5853
5877
|
*/
|
|
5854
5878
|
async function convertCheckovToHdf(input, converterVersion = "1.0.0") {
|
|
5855
|
-
validateInputSize(input, "checkov");
|
|
5879
|
+
validateInputSize$1(input, "checkov");
|
|
5856
5880
|
registerAllFingerprints();
|
|
5857
5881
|
const detected = detectConverter(input);
|
|
5858
5882
|
if (detected && detected.fingerprint.id === "sarif-to-hdf") return convertSarifToHdf(input, converterVersion);
|
|
@@ -6037,7 +6061,7 @@ function buildGosecExtensions(report) {
|
|
|
6037
6061
|
* @returns HDF JSON string
|
|
6038
6062
|
*/
|
|
6039
6063
|
async function convertGosecToHdf(input, converterVersion = "1.0.0") {
|
|
6040
|
-
validateInputSize(input, "gosec");
|
|
6064
|
+
validateInputSize$1(input, "gosec");
|
|
6041
6065
|
registerAllFingerprints();
|
|
6042
6066
|
const detected = detectConverter(input);
|
|
6043
6067
|
if (detected && detected.fingerprint.id === "sarif-to-hdf") return convertSarifToHdf(input, converterVersion);
|
|
@@ -6111,7 +6135,7 @@ function convertVulnToRequirement(vuln) {
|
|
|
6111
6135
|
return req;
|
|
6112
6136
|
}
|
|
6113
6137
|
async function convertNiktoToHdf(input, converterVersion = "unknown") {
|
|
6114
|
-
validateInputSize(input, "nikto");
|
|
6138
|
+
validateInputSize$1(input, "nikto");
|
|
6115
6139
|
const resultsChecksum = await inputChecksum(input);
|
|
6116
6140
|
const niktoData = parseJSON(input);
|
|
6117
6141
|
const vulnGroups = /* @__PURE__ */ new Map();
|
|
@@ -6311,7 +6335,7 @@ function parseZapTimestamp(s) {
|
|
|
6311
6335
|
return parseTimestamp(s) ?? void 0;
|
|
6312
6336
|
}
|
|
6313
6337
|
async function convertZapToHdf(input, converterVersion = "1.0.0") {
|
|
6314
|
-
validateInputSize(input, "zap");
|
|
6338
|
+
validateInputSize$1(input, "zap");
|
|
6315
6339
|
registerAllFingerprints();
|
|
6316
6340
|
const detected = detectConverter(input);
|
|
6317
6341
|
if (detected && detected.fingerprint.id === "sarif-to-hdf") return convertSarifToHdf(input, converterVersion);
|
|
@@ -6850,7 +6874,7 @@ function buildBom(parts) {
|
|
|
6850
6874
|
* oversized or undetectable input.
|
|
6851
6875
|
*/
|
|
6852
6876
|
function parseBom(input) {
|
|
6853
|
-
validateInputSize(input, CONVERTER);
|
|
6877
|
+
validateInputSize$1(input, CONVERTER);
|
|
6854
6878
|
const obj = parseJSON(input);
|
|
6855
6879
|
const detected = detectFormat(obj);
|
|
6856
6880
|
if (!detected) throw new Error("bom-parser: could not detect a supported BOM format (expected CycloneDX or SPDX JSON)");
|
|
@@ -7468,9 +7492,7 @@ function analysisOverride(vuln, fallback) {
|
|
|
7468
7492
|
default: return;
|
|
7469
7493
|
}
|
|
7470
7494
|
const appliedAt = analysisAppliedAt(vuln, fallback);
|
|
7471
|
-
const expiresAt =
|
|
7472
|
-
expiresAt.setTime(appliedAt.getTime());
|
|
7473
|
-
expiresAt.setUTCFullYear(expiresAt.getUTCFullYear() + 1);
|
|
7495
|
+
const expiresAt = defaultOverrideExpiry(appliedAt);
|
|
7474
7496
|
const override = {
|
|
7475
7497
|
type: disposition,
|
|
7476
7498
|
status: effectiveStatus,
|
|
@@ -7498,7 +7520,7 @@ function analysisOverride(vuln, fallback) {
|
|
|
7498
7520
|
*/
|
|
7499
7521
|
async function convertCyclonedxToHdf(input, converterVersion = "1.0.0") {
|
|
7500
7522
|
if (!input || input.trim().length === 0) throw new Error("cyclonedx: empty input");
|
|
7501
|
-
validateInputSize(input, "cyclonedx");
|
|
7523
|
+
validateInputSize$1(input, "cyclonedx");
|
|
7502
7524
|
const bom = parseJSON(input);
|
|
7503
7525
|
if (!bom || typeof bom !== "object") throw new Error("cyclonedx: invalid JSON");
|
|
7504
7526
|
if (bom.bomFormat !== "CycloneDX") throw new Error(`cyclonedx: missing or invalid bomFormat (expected "CycloneDX", got "${bom.bomFormat ?? "undefined"}")`);
|
|
@@ -7760,10 +7782,7 @@ function getSeverity(requirement) {
|
|
|
7760
7782
|
if (Array.isArray(sev) && typeof sev[0] === "string") return sev[0];
|
|
7761
7783
|
}
|
|
7762
7784
|
}
|
|
7763
|
-
|
|
7764
|
-
if (impact >= .7) return "high";
|
|
7765
|
-
if (impact >= .4) return "medium";
|
|
7766
|
-
return "low";
|
|
7785
|
+
return impactToSeverity(requirement.impact);
|
|
7767
7786
|
}
|
|
7768
7787
|
/**
|
|
7769
7788
|
* Extract array values from tags object and join with semicolons
|
|
@@ -8462,7 +8481,7 @@ function buildEvidences(req) {
|
|
|
8462
8481
|
return out;
|
|
8463
8482
|
}
|
|
8464
8483
|
function floatMetric(f) {
|
|
8465
|
-
return
|
|
8484
|
+
return formatJsonNumber(f);
|
|
8466
8485
|
}
|
|
8467
8486
|
//#endregion
|
|
8468
8487
|
//#region converters/hdf-to-asff/typescript/converter.ts
|
|
@@ -8491,7 +8510,7 @@ const MAX_DESCRIPTION = 1024;
|
|
|
8491
8510
|
const EPOCH_SENTINEL = "1970-01-01T00:00:00Z";
|
|
8492
8511
|
function convertHdfToAsff(input, converterVersion = "0.1.0") {
|
|
8493
8512
|
const name = "hdf-to-asff";
|
|
8494
|
-
validateInputSize(input, name);
|
|
8513
|
+
validateInputSize$1(input, name);
|
|
8495
8514
|
const doc = parseHdf(input);
|
|
8496
8515
|
const baselines = asArr(doc.baselines);
|
|
8497
8516
|
if (!baselines) throw new Error(`${name}: invalid HDF structure: missing baselines field`);
|
|
@@ -8767,7 +8786,7 @@ function convertGroups(groups) {
|
|
|
8767
8786
|
* @returns HDF Results JSON string
|
|
8768
8787
|
*/
|
|
8769
8788
|
async function convertSplunkToHdf(input, converterVersion = "1.0.0") {
|
|
8770
|
-
validateInputSize(input, "splunk");
|
|
8789
|
+
validateInputSize$1(input, "splunk");
|
|
8771
8790
|
const resultsChecksum = await inputChecksum(input);
|
|
8772
8791
|
const events = parseJSON(input);
|
|
8773
8792
|
if (!Array.isArray(events) || events.length === 0) throw new Error("No Splunk events found in input");
|
|
@@ -8883,20 +8902,24 @@ function convertStatistics(stats) {
|
|
|
8883
8902
|
* The document is walked as a plain JSON tree and every key is emitted in
|
|
8884
8903
|
* source-JSON order, so the output can never silently lag a schema addition the
|
|
8885
8904
|
* way the previous hand-maintained struct mirror did (it dropped ~30 post-v3.2
|
|
8886
|
-
* fields). The Go converter walks the same normalized JSON in the same order
|
|
8887
|
-
*
|
|
8888
|
-
*
|
|
8905
|
+
* fields). The Go converter walks the same normalized JSON in the same order and
|
|
8906
|
+
* emits identical output after the shared XML golden normalization for every
|
|
8907
|
+
* shape this repo's fixtures and parity tests cover.
|
|
8908
|
+
*
|
|
8909
|
+
* Equality is NOT guaranteed in general. The largest seam is that JSON.parse
|
|
8910
|
+
* discards information before this builder ever runs, so anything it drops is
|
|
8911
|
+
* unreachable from the serializer; shared/xml-divergence-cases.json is the
|
|
8912
|
+
* census of THAT seam, read and pinned by both languages -- a duplicate key
|
|
8913
|
+
* keeps only the last value, an integer-like key is hoisted ahead of its
|
|
8914
|
+
* siblings, and a number too large for a double arrives as Infinity with its
|
|
8915
|
+
* token text gone. Closing any of them means parsing untrusted input with a
|
|
8916
|
+
* parser that preserves order, duplicates and the number token, a worse trade.
|
|
8889
8917
|
*
|
|
8890
|
-
*
|
|
8891
|
-
*
|
|
8892
|
-
*
|
|
8893
|
-
*
|
|
8894
|
-
*
|
|
8895
|
-
* XML-illegal rune to U+FFFD where this builder emits it verbatim. This builder
|
|
8896
|
-
* also caps nesting depth, which the Go peer does not. Anything landing in those
|
|
8897
|
-
* seams can differ; known instances are tracked as cards under the
|
|
8898
|
-
* exporter-conformance epic. Assume a shape outside the fixture corpus needs
|
|
8899
|
-
* checking against the peer rather than that it is covered.
|
|
8918
|
+
* That table is NOT the whole list, and at least one divergence has a different
|
|
8919
|
+
* cause: the underlying builder caps nesting depth where the Go peer does not,
|
|
8920
|
+
* so a deep enough document converts there and throws here (pinned by the
|
|
8921
|
+
* nesting-depth tests in both languages). A shape outside the fixture corpus
|
|
8922
|
+
* needs checking against the peer rather than assuming it is covered.
|
|
8900
8923
|
*/
|
|
8901
8924
|
/**
|
|
8902
8925
|
* Maps a container (plural) key to the element name emitted for each of its
|
|
@@ -8990,7 +9013,7 @@ function nodesFor(key, value) {
|
|
|
8990
9013
|
[name]: buildNodes(value),
|
|
8991
9014
|
...attrs
|
|
8992
9015
|
}];
|
|
8993
|
-
const text = typeof value === "string" ? xmlSafeText(value) : value;
|
|
9016
|
+
const text = typeof value === "string" ? xmlSafeText(value) : typeof value === "number" ? formatJsonNumber(value) : value;
|
|
8994
9017
|
return [{
|
|
8995
9018
|
[name]: [{ "#text": text }],
|
|
8996
9019
|
...attrs
|
|
@@ -9011,7 +9034,7 @@ function buildNodes(obj) {
|
|
|
9011
9034
|
* @returns XML string
|
|
9012
9035
|
*/
|
|
9013
9036
|
function convertHdfToXml(input) {
|
|
9014
|
-
validateInputSize(input, "hdf-to-xml");
|
|
9037
|
+
validateInputSize$1(input, "hdf-to-xml");
|
|
9015
9038
|
const hdf = parseHdf(input);
|
|
9016
9039
|
if (!hdf || typeof hdf !== "object" || Array.isArray(hdf) || !("baselines" in hdf)) throw new Error("Invalid HDF structure: missing baselines field");
|
|
9017
9040
|
if (!Array.isArray(hdf.baselines)) throw new Error("Invalid HDF structure: baselines must be an array");
|
|
@@ -9141,7 +9164,7 @@ function buildCodeDesc$5(scanType, location) {
|
|
|
9141
9164
|
}
|
|
9142
9165
|
}
|
|
9143
9166
|
async function convertGitlabToHdf(input, converterVersion = "1.0.0") {
|
|
9144
|
-
validateInputSize(input, "gitlab");
|
|
9167
|
+
validateInputSize$1(input, "gitlab");
|
|
9145
9168
|
const resultsChecksum = await inputChecksum(input);
|
|
9146
9169
|
const report = parseJSON(input);
|
|
9147
9170
|
const scanType = report.scan?.type ?? "sast";
|
|
@@ -9250,7 +9273,7 @@ const SEVERITY_ALIASES = { critical: .9 };
|
|
|
9250
9273
|
* converters. TypeScript peer of shared/go/../trivy-to-hdf converter.go.
|
|
9251
9274
|
*/
|
|
9252
9275
|
async function convertTrivyToHdf(input, converterVersion = "1.0.0") {
|
|
9253
|
-
validateInputSize(input, "trivy");
|
|
9276
|
+
validateInputSize$1(input, "trivy");
|
|
9254
9277
|
if (!input?.trim()) throw new Error("trivy: empty input");
|
|
9255
9278
|
const probe = parseJSON(input);
|
|
9256
9279
|
if (typeof probe !== "object" || probe === null || Array.isArray(probe)) throw new Error("trivy: input is not a JSON object");
|
|
@@ -9326,8 +9349,8 @@ function convertVuln(v, res, startTime) {
|
|
|
9326
9349
|
message: `Severity: ${firstNonEmpty(v.Severity ?? "", "UNKNOWN")}`
|
|
9327
9350
|
}]
|
|
9328
9351
|
};
|
|
9329
|
-
const ap =
|
|
9330
|
-
if (ap
|
|
9352
|
+
const ap = buildTrivyAffectedPackage(v);
|
|
9353
|
+
if (ap) req.affectedPackages = [ap];
|
|
9331
9354
|
if (v.PkgPath) req.sourceLocation = { ref: v.PkgPath };
|
|
9332
9355
|
return req;
|
|
9333
9356
|
}
|
|
@@ -9494,18 +9517,15 @@ function buildCvssEntries$4(m) {
|
|
|
9494
9517
|
}
|
|
9495
9518
|
return entries.length > 0 ? entries : void 0;
|
|
9496
9519
|
}
|
|
9497
|
-
function
|
|
9498
|
-
const ap = {};
|
|
9499
|
-
if (v.PkgName) ap.name = v.PkgName;
|
|
9500
|
-
if (v.InstalledVersion) ap.version = v.InstalledVersion;
|
|
9501
|
-
if (v.FixedVersion) ap.fixedInVersion = v.FixedVersion;
|
|
9520
|
+
function buildTrivyAffectedPackage(v) {
|
|
9502
9521
|
const purl = v.PkgIdentifier?.PURL;
|
|
9503
|
-
|
|
9504
|
-
|
|
9505
|
-
|
|
9506
|
-
|
|
9507
|
-
|
|
9508
|
-
|
|
9522
|
+
return buildAffectedPackage$1({
|
|
9523
|
+
name: v.PkgName,
|
|
9524
|
+
version: v.InstalledVersion,
|
|
9525
|
+
fixedInVersion: v.FixedVersion,
|
|
9526
|
+
purl,
|
|
9527
|
+
ecosystem: purl ? ecosystemFromPurl(purl) : void 0
|
|
9528
|
+
});
|
|
9509
9529
|
}
|
|
9510
9530
|
function ecosystemFromPurl(purl) {
|
|
9511
9531
|
const eco = ecosystemFromPurlType(purl.replace(/^pkg:/, "").split(/[/@?]/)[0] ?? "");
|
|
@@ -9695,7 +9715,7 @@ function buildRequirement$12(reqID, findings) {
|
|
|
9695
9715
|
* @returns HDF JSON string
|
|
9696
9716
|
*/
|
|
9697
9717
|
async function convertTrufflehogToHdf(input, converterVersion = "1.0.0") {
|
|
9698
|
-
validateInputSize(input, "trufflehog");
|
|
9718
|
+
validateInputSize$1(input, "trufflehog");
|
|
9699
9719
|
const findings = !input || input.trim().length === 0 ? [] : parseFindings(input);
|
|
9700
9720
|
const resultsChecksum = await inputChecksum(input);
|
|
9701
9721
|
const limitedFindings = limitArrayWithWarning(findings, "finding");
|
|
@@ -9828,7 +9848,7 @@ function investigateReason(reason) {
|
|
|
9828
9848
|
* @returns HDF JSON string
|
|
9829
9849
|
*/
|
|
9830
9850
|
async function convertHipcheckToHdf(input, converterVersion = "1.0.0") {
|
|
9831
|
-
validateInputSize(input, "hipcheck");
|
|
9851
|
+
validateInputSize$1(input, "hipcheck");
|
|
9832
9852
|
if (!input || input.trim().length === 0) throw new Error("hipcheck: empty input");
|
|
9833
9853
|
const report = parseJSON(input);
|
|
9834
9854
|
if (!report.hipcheck_version && !report.repo_name) throw new Error("hipcheck: input does not look like a Hipcheck report");
|
|
@@ -9951,7 +9971,7 @@ function buildIssueCode(issue) {
|
|
|
9951
9971
|
*/
|
|
9952
9972
|
async function convertBurpsuiteToHdf(input, converterVersion = "1.0.0") {
|
|
9953
9973
|
if (!input || input.trim().length === 0) throw new Error("burpsuite: empty input");
|
|
9954
|
-
validateInputSize(input, "burpsuite");
|
|
9974
|
+
validateInputSize$1(input, "burpsuite");
|
|
9955
9975
|
const resultsChecksum = await inputChecksum(input);
|
|
9956
9976
|
const parsed = parseXmlWithArrays(input, ["issue"]);
|
|
9957
9977
|
if (!parsed.issues) throw new Error("burpsuite: invalid XML — missing <issues> root element");
|
|
@@ -10257,7 +10277,7 @@ function buildRequirement$10(checkID, findings, hasStatus) {
|
|
|
10257
10277
|
*/
|
|
10258
10278
|
async function convertDbprotectToHdf(input, converterVersion = "1.0.0") {
|
|
10259
10279
|
if (!input || input.trim().length === 0) throw new Error("dbprotect: empty input");
|
|
10260
|
-
validateInputSize(input, "dbprotect");
|
|
10280
|
+
validateInputSize$1(input, "dbprotect");
|
|
10261
10281
|
const resultsChecksum = await inputChecksum(input);
|
|
10262
10282
|
const parsed = parseXmlWithArrays(input, [
|
|
10263
10283
|
"item",
|
|
@@ -10340,15 +10360,15 @@ function buildCvss$1(vuln) {
|
|
|
10340
10360
|
source: vuln.cve ?? vuln.id
|
|
10341
10361
|
});
|
|
10342
10362
|
}
|
|
10343
|
-
const CWE_REGEX = /cwe[-_]?(\d+)/gi;
|
|
10344
10363
|
/**
|
|
10345
|
-
* Extracts canonical CWE-N identifiers from a free-form string
|
|
10364
|
+
* Extracts canonical CWE-N identifiers from a free-form string, deduplicated
|
|
10365
|
+
* in source order.
|
|
10346
10366
|
*/
|
|
10347
10367
|
function parseCwes(raw) {
|
|
10348
10368
|
if (!raw) return [];
|
|
10349
10369
|
const out = [];
|
|
10350
10370
|
const seen = /* @__PURE__ */ new Set();
|
|
10351
|
-
for (const m of raw.matchAll(
|
|
10371
|
+
for (const m of raw.matchAll(CWE_PATTERN$1)) {
|
|
10352
10372
|
const id = `CWE-${m[1]}`;
|
|
10353
10373
|
if (seen.has(id)) continue;
|
|
10354
10374
|
seen.add(id);
|
|
@@ -10375,7 +10395,9 @@ function debDistro(distro) {
|
|
|
10375
10395
|
}
|
|
10376
10396
|
/**
|
|
10377
10397
|
* Maps a Twistlock package type plus the result's distro string to a schema
|
|
10378
|
-
* Ecosystem value.
|
|
10398
|
+
* Ecosystem value. Only the Twistlock spellings that differ from the PURL type
|
|
10399
|
+
* vocabulary are listed; the rest defer to the shared resolver, which falls
|
|
10400
|
+
* back to 'generic' for unknown types.
|
|
10379
10401
|
*/
|
|
10380
10402
|
function resolveEcosystem(packageType, distro) {
|
|
10381
10403
|
const t = (packageType ?? "").toLowerCase();
|
|
@@ -10385,19 +10407,10 @@ function resolveEcosystem(packageType, distro) {
|
|
|
10385
10407
|
if (rhelDistro(d)) return Ecosystem.RPM;
|
|
10386
10408
|
if (debDistro(d)) return Ecosystem.Deb;
|
|
10387
10409
|
return Ecosystem.Generic;
|
|
10388
|
-
case "
|
|
10389
|
-
case "
|
|
10390
|
-
case "
|
|
10391
|
-
|
|
10392
|
-
case "python":
|
|
10393
|
-
case "pypi": return Ecosystem.Pypi;
|
|
10394
|
-
case "nodejs":
|
|
10395
|
-
case "npm": return Ecosystem.Npm;
|
|
10396
|
-
case "gem": return Ecosystem.Gem;
|
|
10397
|
-
case "nuget": return Ecosystem.Nuget;
|
|
10398
|
-
case "go": return Ecosystem.Go;
|
|
10399
|
-
case "cargo": return Ecosystem.Cargo;
|
|
10400
|
-
default: return Ecosystem.Generic;
|
|
10410
|
+
case "jar": return Ecosystem.Maven;
|
|
10411
|
+
case "python": return Ecosystem.Pypi;
|
|
10412
|
+
case "nodejs": return Ecosystem.Npm;
|
|
10413
|
+
default: return ecosystemFromPurlType(t);
|
|
10401
10414
|
}
|
|
10402
10415
|
}
|
|
10403
10416
|
const FIX_VERSION_REGEX = /\d+(?:\.\d+)+[A-Za-z0-9._+\-]*/;
|
|
@@ -10412,20 +10425,18 @@ function extractFixedInVersion(vuln) {
|
|
|
10412
10425
|
return m ? m[0] : "";
|
|
10413
10426
|
}
|
|
10414
10427
|
/**
|
|
10415
|
-
* Builds an AffectedPackage entry from per-vulnerability fields.
|
|
10416
|
-
*
|
|
10428
|
+
* Builds an AffectedPackage entry from per-vulnerability fields. Twistlock
|
|
10429
|
+
* carries no purl or cpe, so the shared builder returns undefined unless the
|
|
10430
|
+
* name + version + ecosystem triple is complete.
|
|
10417
10431
|
*/
|
|
10418
10432
|
function buildAffectedPackage(vuln, packageTypes, distro) {
|
|
10419
|
-
|
|
10420
|
-
|
|
10421
|
-
const pkg = {
|
|
10433
|
+
const pkgType = vuln.packageType ?? packageTypes.get(vuln.packageName ?? "");
|
|
10434
|
+
return buildAffectedPackage$1({
|
|
10422
10435
|
name: vuln.packageName,
|
|
10423
10436
|
version: vuln.packageVersion,
|
|
10424
|
-
ecosystem: resolveEcosystem(pkgType, distro)
|
|
10425
|
-
|
|
10426
|
-
|
|
10427
|
-
if (fixed) pkg.fixedInVersion = fixed;
|
|
10428
|
-
return pkg;
|
|
10437
|
+
ecosystem: resolveEcosystem(pkgType, distro),
|
|
10438
|
+
fixedInVersion: extractFixedInVersion(vuln)
|
|
10439
|
+
});
|
|
10429
10440
|
}
|
|
10430
10441
|
/**
|
|
10431
10442
|
* Indexes packageName → packageType from the result-level packages array.
|
|
@@ -10555,7 +10566,7 @@ function convertSingleResult(result, resultsChecksum) {
|
|
|
10555
10566
|
*/
|
|
10556
10567
|
async function convertTwistlockToHdf(input, converterVersion = "1.0.0") {
|
|
10557
10568
|
if (!input || input.trim().length === 0) throw new Error("twistlock: empty input");
|
|
10558
|
-
validateInputSize(input, "twistlock");
|
|
10569
|
+
validateInputSize$1(input, "twistlock");
|
|
10559
10570
|
const resultsChecksum = await inputChecksum(input);
|
|
10560
10571
|
const parsed = parseJSON(input);
|
|
10561
10572
|
if (!parsed || typeof parsed !== "object") throw new Error("twistlock: invalid JSON");
|
|
@@ -10762,7 +10773,7 @@ function buildAffectedPackageFromComponent(c) {
|
|
|
10762
10773
|
let ecosystem;
|
|
10763
10774
|
if (c.purl) ecosystem = ecosystemFromPurlType(parsePurl(c.purl)?.type);
|
|
10764
10775
|
else if (c.name && c.version) ecosystem = ecosystemFromPurlType(void 0);
|
|
10765
|
-
return buildAffectedPackage$
|
|
10776
|
+
return buildAffectedPackage$1({
|
|
10766
10777
|
name: c.name,
|
|
10767
10778
|
version: c.version,
|
|
10768
10779
|
ecosystem,
|
|
@@ -10779,7 +10790,7 @@ function buildAffectedPackageFromComponent(c) {
|
|
|
10779
10790
|
*/
|
|
10780
10791
|
async function convertDeptrackToHdf(input, converterVersion = "1.0.0") {
|
|
10781
10792
|
if (!input || input.trim().length === 0) throw new Error("deptrack: empty input");
|
|
10782
|
-
validateInputSize(input, "deptrack");
|
|
10793
|
+
validateInputSize$1(input, "deptrack");
|
|
10783
10794
|
const resultsChecksum = await inputChecksum(input);
|
|
10784
10795
|
const parsed = parseJSON(input);
|
|
10785
10796
|
if (!parsed || typeof parsed !== "object") throw new Error("deptrack: invalid JSON");
|
|
@@ -11034,7 +11045,7 @@ function buildAffectedPackageFromEntry(entry) {
|
|
|
11034
11045
|
ecosystem = ecosystemFromXraySource(parsed.scheme);
|
|
11035
11046
|
}
|
|
11036
11047
|
const fixed = entry.component_versions?.fixed_versions?.[0];
|
|
11037
|
-
return buildAffectedPackage$
|
|
11048
|
+
return buildAffectedPackage$1({
|
|
11038
11049
|
name,
|
|
11039
11050
|
version,
|
|
11040
11051
|
ecosystem: ecosystem ?? (name ? Ecosystem.Generic : void 0),
|
|
@@ -11049,7 +11060,7 @@ function buildAffectedPackageFromEntry(entry) {
|
|
|
11049
11060
|
*/
|
|
11050
11061
|
async function convertJfrogXrayToHdf(input, converterVersion = "1.0.0") {
|
|
11051
11062
|
if (!input || input.trim().length === 0) throw new Error("jfrog-xray: empty input");
|
|
11052
|
-
validateInputSize(input, "jfrog-xray");
|
|
11063
|
+
validateInputSize$1(input, "jfrog-xray");
|
|
11053
11064
|
const resultsChecksum = await inputChecksum(input);
|
|
11054
11065
|
const parsed = parseJSON(input);
|
|
11055
11066
|
if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.data)) throw new Error("jfrog-xray: invalid JSON structure");
|
|
@@ -11266,7 +11277,7 @@ function buildRequirement$6(vuln, scanTime, ml) {
|
|
|
11266
11277
|
const refs = buildRefs$3(vuln);
|
|
11267
11278
|
if (refs) req.refs = refs;
|
|
11268
11279
|
const cpe23 = (vuln.cpes ?? []).find((c) => /^cpe:2\.3:[aho]:/.test(c));
|
|
11269
|
-
const pkg = buildAffectedPackage$
|
|
11280
|
+
const pkg = buildAffectedPackage$1({
|
|
11270
11281
|
name: vuln.package_name,
|
|
11271
11282
|
version: vuln.package_version,
|
|
11272
11283
|
ecosystem: vuln.package_name && vuln.package_version ? Ecosystem.Generic : void 0,
|
|
@@ -11351,7 +11362,7 @@ function buildComponent(report) {
|
|
|
11351
11362
|
*/
|
|
11352
11363
|
async function convertNeuvectorToHdf(input, converterVersion = "1.0.0") {
|
|
11353
11364
|
if (!input || input.trim().length === 0) throw new Error("neuvector: empty input");
|
|
11354
|
-
validateInputSize(input, "neuvector");
|
|
11365
|
+
validateInputSize$1(input, "neuvector");
|
|
11355
11366
|
const scan = parseJSON(input);
|
|
11356
11367
|
if (!scan || typeof scan !== "object" || !("report" in scan)) throw new Error("neuvector: invalid JSON structure");
|
|
11357
11368
|
const resultsChecksum = await inputChecksum(input);
|
|
@@ -11593,7 +11604,7 @@ function buildRequirement$5(desc, vulns, snippetMap, startTimeStr) {
|
|
|
11593
11604
|
*/
|
|
11594
11605
|
async function convertFortifyToHdf(input, converterVersion = "1.0.0") {
|
|
11595
11606
|
if (!input || input.trim().length === 0) throw new Error("fortify: empty input");
|
|
11596
|
-
validateInputSize(input, "fortify");
|
|
11607
|
+
validateInputSize$1(input, "fortify");
|
|
11597
11608
|
const resultsChecksum = await inputChecksum(input);
|
|
11598
11609
|
const parsed = parseXml(input, { stopNodes: ["FVDL.Description.Abstract", "FVDL.Description.Explanation"] });
|
|
11599
11610
|
if (!parsed.FVDL) throw new Error("fortify: invalid FVDL — missing <FVDL> root element");
|
|
@@ -11839,7 +11850,7 @@ function buildAffectedPackageFromRecord(rec) {
|
|
|
11839
11850
|
const version = rec["Package Version"];
|
|
11840
11851
|
if (!name || !version) return void 0;
|
|
11841
11852
|
const fixMatch = rec["Fix Status"] ? FIX_VERSION_PATTERN.exec(rec["Fix Status"]) : null;
|
|
11842
|
-
return buildAffectedPackage$
|
|
11853
|
+
return buildAffectedPackage$1({
|
|
11843
11854
|
name,
|
|
11844
11855
|
version,
|
|
11845
11856
|
ecosystem: ecosystemFromDistro(rec.Distro),
|
|
@@ -11876,7 +11887,7 @@ function buildBaseline(hostname, records, resultsChecksum, scanTime) {
|
|
|
11876
11887
|
*/
|
|
11877
11888
|
async function convertPrismaToHdf(input, converterVersion = "1.0.0") {
|
|
11878
11889
|
if (!input || input.trim().length === 0) throw new Error("prisma: empty input");
|
|
11879
|
-
validateInputSize(input, "prisma");
|
|
11890
|
+
validateInputSize$1(input, "prisma");
|
|
11880
11891
|
const headers = (input.split(/\r?\n/, 1)[0] ?? "").split(",").map((h) => h.trim());
|
|
11881
11892
|
for (const col of REQUIRED_COLUMNS) if (!headers.includes(col)) throw new Error(`prisma: missing required CSV column "${col}"`);
|
|
11882
11893
|
const records = parseCsv(input);
|
|
@@ -11978,12 +11989,13 @@ function baseScoreFromBlock(block) {
|
|
|
11978
11989
|
*/
|
|
11979
11990
|
function buildNetsparkerCvss(classification) {
|
|
11980
11991
|
const out = [];
|
|
11981
|
-
|
|
11992
|
+
const blocks = [[classification?.cvss, Version.The30], [classification?.cvss31, Version.The31]];
|
|
11993
|
+
for (const [block, elementVersion] of blocks) {
|
|
11982
11994
|
const baseScore = baseScoreFromBlock(block);
|
|
11983
11995
|
const vector = block?.vector ?? "";
|
|
11984
11996
|
if (!vector && baseScore === void 0) continue;
|
|
11985
11997
|
out.push(buildCvss$3({
|
|
11986
|
-
version: cvssVersionFromVector(vector),
|
|
11998
|
+
version: cvssVersionFromVector(vector, elementVersion),
|
|
11987
11999
|
baseScore,
|
|
11988
12000
|
baseVector: vector
|
|
11989
12001
|
}));
|
|
@@ -12104,7 +12116,7 @@ function buildRequirement$3(vuln, initiated) {
|
|
|
12104
12116
|
*/
|
|
12105
12117
|
async function convertNetsparkerToHdf(input, converterVersion = "1.0.0") {
|
|
12106
12118
|
if (!input || input.trim().length === 0) throw new Error("netsparker: empty input");
|
|
12107
|
-
validateInputSize(input, "netsparker");
|
|
12119
|
+
validateInputSize$1(input, "netsparker");
|
|
12108
12120
|
const resultsChecksum = await inputChecksum(input);
|
|
12109
12121
|
const parsed = parseXmlWithArrays(input, [
|
|
12110
12122
|
"vulnerability",
|
|
@@ -12265,7 +12277,7 @@ function buildRequirement$2(ruleID, finding, startTime) {
|
|
|
12265
12277
|
*/
|
|
12266
12278
|
async function convertScoutsuiteToHdf(input, converterVersion = "1.0.0") {
|
|
12267
12279
|
if (!input || input.trim().length === 0) throw new Error("scoutsuite: empty input");
|
|
12268
|
-
validateInputSize(input, "scoutsuite");
|
|
12280
|
+
validateInputSize$1(input, "scoutsuite");
|
|
12269
12281
|
const jsonStr = stripJSPrefix(input);
|
|
12270
12282
|
const resultsChecksum = await inputChecksum(jsonStr);
|
|
12271
12283
|
const report = parseJSON(jsonStr);
|
|
@@ -12477,7 +12489,7 @@ function buildScannerBaseline(scannerName, results, shaMap, resultsChecksum) {
|
|
|
12477
12489
|
*/
|
|
12478
12490
|
async function convertConveyorToHdf(input, converterVersion = "1.0.0") {
|
|
12479
12491
|
if (!input || input.trim().length === 0) throw new Error("conveyor: empty input");
|
|
12480
|
-
validateInputSize(input, "conveyor");
|
|
12492
|
+
validateInputSize$1(input, "conveyor");
|
|
12481
12493
|
const data = parseJSON(input);
|
|
12482
12494
|
if (!data || typeof data !== "object") throw new Error("conveyor: invalid JSON");
|
|
12483
12495
|
if (!data.api_response) throw new Error("conveyor: missing api_response field");
|
|
@@ -12949,7 +12961,7 @@ function buildCVERequirement(vuln, components, firstBuildDate) {
|
|
|
12949
12961
|
*/
|
|
12950
12962
|
async function convertVeracodeToHdf(input, converterVersion = "1.0.0") {
|
|
12951
12963
|
if (!input || input.trim().length === 0) throw new Error("veracode: empty input");
|
|
12952
|
-
validateInputSize(input, "veracode");
|
|
12964
|
+
validateInputSize$1(input, "veracode");
|
|
12953
12965
|
const parsed = parseXml(input, {
|
|
12954
12966
|
attributeNamePrefix: "@_",
|
|
12955
12967
|
trimValues: false
|
|
@@ -13105,7 +13117,7 @@ function buildRequirement$1(cs, profiles, createdDateTime) {
|
|
|
13105
13117
|
*/
|
|
13106
13118
|
async function convertMsftSecureScoreToHdf(input, converterVersion = "1.0.0") {
|
|
13107
13119
|
if (!input || input.trim().length === 0) throw new Error("msft-secure-score: empty input");
|
|
13108
|
-
validateInputSize(input, "msft-secure-score");
|
|
13120
|
+
validateInputSize$1(input, "msft-secure-score");
|
|
13109
13121
|
const combined = parseJSON(input);
|
|
13110
13122
|
if (!combined || typeof combined !== "object") throw new Error("msft-secure-score: invalid JSON");
|
|
13111
13123
|
if (!combined.secureScore?.value) throw new Error("msft-secure-score: missing secureScore.value");
|
|
@@ -13152,7 +13164,7 @@ async function convertMsftSecureScoreToHdf(input, converterVersion = "1.0.0") {
|
|
|
13152
13164
|
* the output with MSDO-specific metadata.
|
|
13153
13165
|
*/
|
|
13154
13166
|
async function convertMsftDefenderDevopsToHdf(input, converterVersion = "1.0.0") {
|
|
13155
|
-
validateInputSize(input, "msft-defender-devops");
|
|
13167
|
+
validateInputSize$1(input, "msft-defender-devops");
|
|
13156
13168
|
const raw = parseJSON(input);
|
|
13157
13169
|
if (!raw || !Array.isArray(raw.runs)) throw new Error("Invalid MSDO SARIF structure: missing or invalid runs field");
|
|
13158
13170
|
const { components, runEnrichments } = extractEnrichments(raw);
|
|
@@ -13317,7 +13329,7 @@ function buildResultFromAssessment(a, scanTime) {
|
|
|
13317
13329
|
* @returns HDF JSON string
|
|
13318
13330
|
*/
|
|
13319
13331
|
async function convertMsftDefenderCloudToHdf(input, converterVersion = "1.0.0") {
|
|
13320
|
-
validateInputSize(input, "msft-defender-cloud");
|
|
13332
|
+
validateInputSize$1(input, "msft-defender-cloud");
|
|
13321
13333
|
const scanTime = /* @__PURE__ */ new Date();
|
|
13322
13334
|
const resultsChecksum = await inputChecksum(input);
|
|
13323
13335
|
const raw = parseJSON(input);
|
|
@@ -13427,9 +13439,7 @@ function buildTriageOverride(alert, startTime) {
|
|
|
13427
13439
|
default: return null;
|
|
13428
13440
|
}
|
|
13429
13441
|
const appliedAt = (alert.resolvedDateTime ? parseTimestamp(alert.resolvedDateTime) : null) ?? (alert.lastUpdateDateTime ? parseTimestamp(alert.lastUpdateDateTime) : null) ?? startTime;
|
|
13430
|
-
const expiresAt =
|
|
13431
|
-
expiresAt.setTime(appliedAt.getTime());
|
|
13432
|
-
expiresAt.setUTCFullYear(expiresAt.getUTCFullYear() + 1);
|
|
13442
|
+
const expiresAt = defaultOverrideExpiry(appliedAt);
|
|
13433
13443
|
return {
|
|
13434
13444
|
override: {
|
|
13435
13445
|
type: disposition,
|
|
@@ -13603,7 +13613,7 @@ function alertToRequirement(alert, scanTime) {
|
|
|
13603
13613
|
* @returns HDF JSON string
|
|
13604
13614
|
*/
|
|
13605
13615
|
async function convertMsftDefenderEndpointToHdf(input, converterVersion = "1.0.0") {
|
|
13606
|
-
validateInputSize(input, "msft-defender-endpoint");
|
|
13616
|
+
validateInputSize$1(input, "msft-defender-endpoint");
|
|
13607
13617
|
const resultsChecksum = await inputChecksum(input);
|
|
13608
13618
|
const response = parseJSON(input);
|
|
13609
13619
|
if (!response || typeof response !== "object") throw new Error("Invalid Microsoft Defender for Endpoint structure: not a valid JSON object");
|
|
@@ -13655,7 +13665,7 @@ const BUILD_OPTIONS = {
|
|
|
13655
13665
|
* @returns XCCDF 1.2 XML string
|
|
13656
13666
|
*/
|
|
13657
13667
|
function convertHdfToXccdf(input) {
|
|
13658
|
-
validateInputSize(input, "hdf-to-xccdf");
|
|
13668
|
+
validateInputSize$1(input, "hdf-to-xccdf");
|
|
13659
13669
|
const hdfData = parseHdf(input);
|
|
13660
13670
|
if (!hdfData || typeof hdfData !== "object" || !("baselines" in hdfData)) throw new Error("Invalid HDF structure: missing baselines field");
|
|
13661
13671
|
if (!Array.isArray(hdfData.baselines)) throw new Error("Invalid HDF structure: baselines must be an array");
|
|
@@ -13665,12 +13675,14 @@ function convertHdfToXccdf(input) {
|
|
|
13665
13675
|
function wrap(value) {
|
|
13666
13676
|
return { "#text": value };
|
|
13667
13677
|
}
|
|
13668
|
-
/** Map HDF impact (0.0-1.0) to XCCDF severity
|
|
13678
|
+
/** Map HDF impact (0.0-1.0) to XCCDF severity via the shared band mapper. The
|
|
13679
|
+
* XCCDF vocabulary has no critical band, so critical folds into high, and its
|
|
13680
|
+
* zero band is spelled 'info'. */
|
|
13669
13681
|
function impactToSeverity$2(impact) {
|
|
13670
|
-
|
|
13671
|
-
if (
|
|
13672
|
-
if (
|
|
13673
|
-
return
|
|
13682
|
+
const sev = impactToSeverity(impact);
|
|
13683
|
+
if (sev === "critical") return "high";
|
|
13684
|
+
if (sev === "informational") return "info";
|
|
13685
|
+
return sev;
|
|
13674
13686
|
}
|
|
13675
13687
|
/** Map HDF result status to XCCDF result value. */
|
|
13676
13688
|
function hdfStatusToXccdf(status) {
|
|
@@ -13977,6 +13989,11 @@ function buildTestResultObj(hdfData, baseline) {
|
|
|
13977
13989
|
}
|
|
13978
13990
|
//#endregion
|
|
13979
13991
|
//#region converters/oscal-to-hdf/typescript/shared.ts
|
|
13992
|
+
/**
|
|
13993
|
+
* Shared helper functions for OSCAL-to-HDF converters.
|
|
13994
|
+
*
|
|
13995
|
+
* Mirrors the Go helpers in converters/oscal-to-hdf/go/shared.go.
|
|
13996
|
+
*/
|
|
13980
13997
|
const controlEnhancementRe = /^([a-z]{2}-\d+)\.(\d+)$/;
|
|
13981
13998
|
const objectiveIDRe = /^([a-z]{2}-\d+(?:\.\d+)?)/;
|
|
13982
13999
|
/**
|
|
@@ -14061,6 +14078,12 @@ function flattenPartsByName(parts, name) {
|
|
|
14061
14078
|
}
|
|
14062
14079
|
return pieces.join("\n").trim();
|
|
14063
14080
|
}
|
|
14081
|
+
/** The one OSCAL spelling the standard severity map does not know; every other
|
|
14082
|
+
* facet value is standard vocabulary. */
|
|
14083
|
+
const RISK_FACET_SEVERITY_ALIASES = { moderate: .5 };
|
|
14084
|
+
/** Sentinel for "this facet's value is not a severity" — impact is 0.0-1.0, so
|
|
14085
|
+
* a negative can never be a real reading. */
|
|
14086
|
+
const UNRECOGNIZED_FACET_IMPACT = -1;
|
|
14064
14087
|
/**
|
|
14065
14088
|
* Extracts impact/severity from risk characterization facets.
|
|
14066
14089
|
* Returns a normalized 0.0-1.0 impact value. Falls back to defaultImpact.
|
|
@@ -14069,15 +14092,10 @@ function extractRiskSeverity(characterizations, defaultImpact) {
|
|
|
14069
14092
|
if (!characterizations) return defaultImpact;
|
|
14070
14093
|
for (const c of characterizations) {
|
|
14071
14094
|
if (!c.facets) continue;
|
|
14072
|
-
for (const f of c.facets)
|
|
14073
|
-
|
|
14074
|
-
|
|
14075
|
-
|
|
14076
|
-
case "medium": return .5;
|
|
14077
|
-
case "low": return .3;
|
|
14078
|
-
case "info":
|
|
14079
|
-
case "informational":
|
|
14080
|
-
case "none": return 0;
|
|
14095
|
+
for (const f of c.facets) {
|
|
14096
|
+
if (f.name !== "impact" && f.name !== "risk" && f.name !== "likelihood") continue;
|
|
14097
|
+
const impact = severityToImpactWithAliases(f.value, RISK_FACET_SEVERITY_ALIASES, UNRECOGNIZED_FACET_IMPACT);
|
|
14098
|
+
if (impact >= 0) return impact;
|
|
14081
14099
|
}
|
|
14082
14100
|
}
|
|
14083
14101
|
return defaultImpact;
|
|
@@ -14108,11 +14126,7 @@ function nistTagToControlId(tag) {
|
|
|
14108
14126
|
* This is the reverse of extractRiskSeverity.
|
|
14109
14127
|
*/
|
|
14110
14128
|
function impactToSeverity$1(impact) {
|
|
14111
|
-
|
|
14112
|
-
if (impact >= .7) return "high";
|
|
14113
|
-
if (impact >= .4) return "moderate";
|
|
14114
|
-
if (impact >= .1) return "low";
|
|
14115
|
-
return "info";
|
|
14129
|
+
return oscalSeverityFromHdf(impactToSeverity(impact));
|
|
14116
14130
|
}
|
|
14117
14131
|
/**
|
|
14118
14132
|
* Maps an HDF status string to an OSCAL risk status string.
|
|
@@ -14450,7 +14464,7 @@ function requirementToFindingSet(req, timestamp, toolActorUuid, subjects) {
|
|
|
14450
14464
|
uuid: resourceUuid,
|
|
14451
14465
|
title: `Check source code for ${req.id}`,
|
|
14452
14466
|
base64: {
|
|
14453
|
-
value:
|
|
14467
|
+
value: encodeBase64Utf8(req.code),
|
|
14454
14468
|
"media-type": "text/plain"
|
|
14455
14469
|
}
|
|
14456
14470
|
};
|
|
@@ -14632,14 +14646,7 @@ function sourceLocationText(loc) {
|
|
|
14632
14646
|
}
|
|
14633
14647
|
/** Maps an explicit HDF severity to the OSCAL risk facet value vocabulary. */
|
|
14634
14648
|
function severityToFacetValue(s) {
|
|
14635
|
-
|
|
14636
|
-
case "critical": return "critical";
|
|
14637
|
-
case "high": return "high";
|
|
14638
|
-
case "medium": return "moderate";
|
|
14639
|
-
case "low": return "low";
|
|
14640
|
-
case "informational": return "info";
|
|
14641
|
-
default: return "";
|
|
14642
|
-
}
|
|
14649
|
+
return oscalSeverityFromHdf(s);
|
|
14643
14650
|
}
|
|
14644
14651
|
/**
|
|
14645
14652
|
* Turns the requirement's fix description and any governing risk-acceptance
|
|
@@ -15256,7 +15263,7 @@ function verdictLabels(a) {
|
|
|
15256
15263
|
}
|
|
15257
15264
|
async function convertIonchannelToHdf(input, converterVersion = "1.0.0") {
|
|
15258
15265
|
if (!input?.trim()) throw new Error("Empty input");
|
|
15259
|
-
validateInputSize(input, "ionchannel");
|
|
15266
|
+
validateInputSize$1(input, "ionchannel");
|
|
15260
15267
|
const analysis = parseJSON(input);
|
|
15261
15268
|
if (!Array.isArray(analysis.scan_summaries)) throw new Error(`Ion Channel scan_summaries invalid summary data (expecting array, got ${typeof analysis.scan_summaries})`);
|
|
15262
15269
|
let allDeps = [];
|
|
@@ -15618,12 +15625,8 @@ function supplierEvidence(sourceURI, description) {
|
|
|
15618
15625
|
*
|
|
15619
15626
|
* Spec: https://github.com/openvex/spec
|
|
15620
15627
|
*/
|
|
15621
|
-
/** One year in milliseconds. VEX statements are re-evaluated as new info
|
|
15622
|
-
* arrives; one year is a defensive default consistent with the
|
|
15623
|
-
* no-permanent-amendment rule on Standalone_Override. */
|
|
15624
|
-
const DEFAULT_EXPIRY_HORIZON_MS$3 = 365 * 24 * 60 * 60 * 1e3;
|
|
15625
15628
|
async function convertOpenVexToHdf(input, converterVersion = "1.0.0") {
|
|
15626
|
-
validateInputSize(input, "openvex-to-hdf");
|
|
15629
|
+
validateInputSize$1(input, "openvex-to-hdf");
|
|
15627
15630
|
const doc = parseJSON(input);
|
|
15628
15631
|
const docTime = (doc.timestamp ? parseTimestamp(doc.timestamp) : null) ?? /* @__PURE__ */ new Date();
|
|
15629
15632
|
const overrides = [];
|
|
@@ -15655,7 +15658,7 @@ function statementToOverride(stmt, doc, docTime) {
|
|
|
15655
15658
|
if (!requirementId) return void 0;
|
|
15656
15659
|
const stmtTime = (stmt.timestamp ? parseTimestamp(stmt.timestamp) : null) ?? docTime;
|
|
15657
15660
|
const author = stmt.author ?? doc.author ?? "";
|
|
15658
|
-
const expiresAt =
|
|
15661
|
+
const expiresAt = defaultOverrideExpiry(stmtTime);
|
|
15659
15662
|
const override = {
|
|
15660
15663
|
type: target.overrideType,
|
|
15661
15664
|
requirementId,
|
|
@@ -15715,9 +15718,8 @@ function truncateId(id) {
|
|
|
15715
15718
|
*
|
|
15716
15719
|
* Spec: https://docs.oasis-open.org/csaf/csaf/v2.0/csaf-v2.0.html
|
|
15717
15720
|
*/
|
|
15718
|
-
const DEFAULT_EXPIRY_HORIZON_MS$2 = 365 * 24 * 60 * 60 * 1e3;
|
|
15719
15721
|
async function convertCsafVexToHdf(input, converterVersion = "1.0.0") {
|
|
15720
|
-
validateInputSize(input, "csaf-vex-to-hdf");
|
|
15722
|
+
validateInputSize$1(input, "csaf-vex-to-hdf");
|
|
15721
15723
|
const doc = parseJSON(input);
|
|
15722
15724
|
if (doc.document?.category !== "csaf_vex") throw new Error(`csaf-vex-to-hdf: document.category is ${JSON.stringify(doc.document?.category)}; only 'csaf_vex' is supported`);
|
|
15723
15725
|
const dm = doc.document;
|
|
@@ -15762,7 +15764,7 @@ function vulnerabilityToOverrides(vuln, publisher, tracking, docTime, productLoo
|
|
|
15762
15764
|
function buildOverride(vuln, publisher, tracking, docTime, canonical, products, productLookup) {
|
|
15763
15765
|
const target = importTargetFor(canonical);
|
|
15764
15766
|
if (!target) return void 0;
|
|
15765
|
-
const expiresAt =
|
|
15767
|
+
const expiresAt = defaultOverrideExpiry(docTime);
|
|
15766
15768
|
const override = {
|
|
15767
15769
|
type: target.overrideType,
|
|
15768
15770
|
requirementId: vuln.cve,
|
|
@@ -15933,9 +15935,8 @@ function overlap(ids, scope) {
|
|
|
15933
15935
|
*
|
|
15934
15936
|
* Spec: https://cyclonedx.org/use-cases/#vulnerability-exploitability
|
|
15935
15937
|
*/
|
|
15936
|
-
const DEFAULT_EXPIRY_HORIZON_MS$1 = 365 * 24 * 60 * 60 * 1e3;
|
|
15937
15938
|
async function convertCyclonedxVexToHdf(input, converterVersion = "1.0.0") {
|
|
15938
|
-
validateInputSize(input, "cyclonedx-vex-to-hdf");
|
|
15939
|
+
validateInputSize$1(input, "cyclonedx-vex-to-hdf");
|
|
15939
15940
|
const bom = parseJSON(input);
|
|
15940
15941
|
if (bom.bomFormat !== "CycloneDX") throw new Error(`cyclonedx-vex-to-hdf: bomFormat is ${JSON.stringify(bom.bomFormat)}; only 'CycloneDX' is supported`);
|
|
15941
15942
|
const docTime = (bom.metadata?.timestamp ? parseTimestamp(bom.metadata.timestamp) : null) ?? /* @__PURE__ */ new Date();
|
|
@@ -15970,7 +15971,7 @@ function vulnerabilityToOverride(v, productLookup, docTime, publisher) {
|
|
|
15970
15971
|
const target = importTargetFor(canonical);
|
|
15971
15972
|
if (!target) return void 0;
|
|
15972
15973
|
const affectedPackages = affectedPackagesForVuln(v, productLookup);
|
|
15973
|
-
const expiresAt =
|
|
15974
|
+
const expiresAt = defaultOverrideExpiry(docTime);
|
|
15974
15975
|
const override = {
|
|
15975
15976
|
type: target.overrideType,
|
|
15976
15977
|
requirementId: v.id,
|
|
@@ -16104,8 +16105,6 @@ function publisherIdentityOrDefault(bom) {
|
|
|
16104
16105
|
*
|
|
16105
16106
|
* Spec: https://spdx.github.io/spdx-spec/v3.0.1/ (security profile)
|
|
16106
16107
|
*/
|
|
16107
|
-
/** One year in milliseconds — the override expiresAt horizon. */
|
|
16108
|
-
const DEFAULT_EXPIRY_HORIZON_MS = 365 * 24 * 60 * 60 * 1e3;
|
|
16109
16108
|
/** Fallback system identity when no supplier agent resolves. */
|
|
16110
16109
|
const DEFAULT_APPLIED_BY = "spdx-vex-import";
|
|
16111
16110
|
/** The four SPDX-3 VEX assessment relationship subtypes -> canonical status. */
|
|
@@ -16116,7 +16115,7 @@ const VEX_STATUS_BY_TYPE = {
|
|
|
16116
16115
|
security_VexUnderInvestigationVulnAssessmentRelationship: VexStatus.UnderInvestigation
|
|
16117
16116
|
};
|
|
16118
16117
|
async function convertSpdxVexToHdf(input, converterVersion = "1.0.0") {
|
|
16119
|
-
validateInputSize(input, "spdx-vex-to-hdf");
|
|
16118
|
+
validateInputSize$1(input, "spdx-vex-to-hdf");
|
|
16120
16119
|
const graph = parseJSON(input)["@graph"] ?? [];
|
|
16121
16120
|
if (graph.length === 0) throw new Error("spdx-vex-to-hdf: document has no @graph elements");
|
|
16122
16121
|
const idx = buildIndex(graph);
|
|
@@ -16178,7 +16177,7 @@ function relationshipToOverride(rel, idx) {
|
|
|
16178
16177
|
const requirementId = cveIdentifier(vuln);
|
|
16179
16178
|
if (!requirementId) return void 0;
|
|
16180
16179
|
const appliedAt = createdAt(rel.creationInfo, idx) ?? createdAt(vuln?.creationInfo, idx) ?? /* @__PURE__ */ new Date();
|
|
16181
|
-
const expiresAt =
|
|
16180
|
+
const expiresAt = defaultOverrideExpiry(appliedAt);
|
|
16182
16181
|
const override = {
|
|
16183
16182
|
type: target.overrideType,
|
|
16184
16183
|
requirementId,
|
|
@@ -16275,16 +16274,11 @@ function buildCvss(rel, cve) {
|
|
|
16275
16274
|
return cvss;
|
|
16276
16275
|
}
|
|
16277
16276
|
function cvssVersion(relType, vector) {
|
|
16278
|
-
|
|
16279
|
-
|
|
16280
|
-
|
|
16281
|
-
|
|
16282
|
-
|
|
16283
|
-
case "3.0": return Version.The30;
|
|
16284
|
-
case "3.1": return Version.The31;
|
|
16285
|
-
case "4.0": return Version.The40;
|
|
16286
|
-
}
|
|
16287
|
-
}
|
|
16277
|
+
return cvssVersionFromVector(vector, cvssVersionFromRelType(relType));
|
|
16278
|
+
}
|
|
16279
|
+
/** Fallback when the vector carries no recognized prefix: the relationship
|
|
16280
|
+
* subtype names the CVSS generation. */
|
|
16281
|
+
function cvssVersionFromRelType(relType) {
|
|
16288
16282
|
if ((relType ?? "").includes("CvssV2")) return Version.The20;
|
|
16289
16283
|
if ((relType ?? "").includes("CvssV4")) return Version.The40;
|
|
16290
16284
|
return Version.The31;
|
|
@@ -16359,7 +16353,7 @@ function buildCsafScore(cvss, products) {
|
|
|
16359
16353
|
};
|
|
16360
16354
|
}
|
|
16361
16355
|
function convertHdfToCsafVex(input, converterVersion) {
|
|
16362
|
-
validateInputSize(input, "hdf-to-csaf-vex");
|
|
16356
|
+
validateInputSize$1(input, "hdf-to-csaf-vex");
|
|
16363
16357
|
const amendments = parseHdf(input);
|
|
16364
16358
|
const groups = groupByCVE(amendments.overrides ?? []);
|
|
16365
16359
|
const registry = /* @__PURE__ */ new Map();
|
|
@@ -16717,7 +16711,7 @@ const PRODUCTS_LINE$1 = /^Products:\s*(.+)$/m;
|
|
|
16717
16711
|
const OPENVEX_CONTEXT = "https://openvex.dev/ns/v0.2.0";
|
|
16718
16712
|
const OPENVEX_NAMESPACE = "https://openvex.dev/docs/public/";
|
|
16719
16713
|
async function convertHdfToOpenVex(input, converterVersion) {
|
|
16720
|
-
validateInputSize(input, "hdf-to-openvex");
|
|
16714
|
+
validateInputSize$1(input, "hdf-to-openvex");
|
|
16721
16715
|
const amendments = parseHdf(input);
|
|
16722
16716
|
const author = amendments.appliedBy?.identifier || "HDF Amendments Export";
|
|
16723
16717
|
const role = amendments.appliedBy?.description;
|
|
@@ -16915,7 +16909,7 @@ function buildCdxRating(cvss) {
|
|
|
16915
16909
|
return rating;
|
|
16916
16910
|
}
|
|
16917
16911
|
async function convertHdfToCyclonedxVex(input, converterVersion) {
|
|
16918
|
-
validateInputSize(input, "hdf-to-cyclonedx-vex");
|
|
16912
|
+
validateInputSize$1(input, "hdf-to-cyclonedx-vex");
|
|
16919
16913
|
const amendments = parseHdf(input);
|
|
16920
16914
|
const componentRegistry = /* @__PURE__ */ new Map();
|
|
16921
16915
|
const vulnerabilities = [];
|
|
@@ -17115,7 +17109,7 @@ function detectOscalDocumentType(input) {
|
|
|
17115
17109
|
* @returns HDF Baseline JSON string
|
|
17116
17110
|
*/
|
|
17117
17111
|
async function convertOscalCatalogToHdf(input) {
|
|
17118
|
-
validateInputSize(input, "oscal-catalog");
|
|
17112
|
+
validateInputSize$1(input, "oscal-catalog");
|
|
17119
17113
|
if (!input || input.trim().length === 0) throw new Error("empty input");
|
|
17120
17114
|
const doc = parseJSON(input);
|
|
17121
17115
|
if (!doc.catalog) throw new Error("oscal-catalog: input is not a catalog document (root key is not 'catalog')");
|
|
@@ -17236,7 +17230,7 @@ function catalogBaselineName(catalog) {
|
|
|
17236
17230
|
* @returns HDF Baseline JSON string
|
|
17237
17231
|
*/
|
|
17238
17232
|
async function convertOscalComponentToHdf(input) {
|
|
17239
|
-
validateInputSize(input, "oscal-component-definition");
|
|
17233
|
+
validateInputSize$1(input, "oscal-component-definition");
|
|
17240
17234
|
if (!input || input.trim().length === 0) throw new Error("empty input");
|
|
17241
17235
|
const doc = parseJSON(input);
|
|
17242
17236
|
if (!doc["component-definition"]) throw new Error("oscal-component-definition: input is not a component-definition document (root key is not 'component-definition')");
|
|
@@ -17305,7 +17299,7 @@ function componentBaselineName(comp, compDef) {
|
|
|
17305
17299
|
* @returns HDF Amendments JSON string
|
|
17306
17300
|
*/
|
|
17307
17301
|
async function convertOscalPoamToHdf(input) {
|
|
17308
|
-
validateInputSize(input, "oscal-poam");
|
|
17302
|
+
validateInputSize$1(input, "oscal-poam");
|
|
17309
17303
|
if (!input || input.trim().length === 0) throw new Error("empty input");
|
|
17310
17304
|
const doc = parseJSON(input);
|
|
17311
17305
|
if (!doc["plan-of-action-and-milestones"]) throw new Error("oscal-poam: input is not a plan-of-action-and-milestones document (root key is not 'plan-of-action-and-milestones')");
|
|
@@ -17377,27 +17371,27 @@ function poamItemStatus(item, riskMap) {
|
|
|
17377
17371
|
const risk = riskMap.get(riskUuid);
|
|
17378
17372
|
if (risk) {
|
|
17379
17373
|
const status = oscalStatusToHdf(risk.status);
|
|
17380
|
-
if (status === "passed") return
|
|
17381
|
-
if (status === "failed") return
|
|
17374
|
+
if (status === "passed") return ResultStatus.Passed;
|
|
17375
|
+
if (status === "failed") return ResultStatus.Failed;
|
|
17382
17376
|
}
|
|
17383
17377
|
}
|
|
17384
17378
|
}
|
|
17385
|
-
return
|
|
17379
|
+
return ResultStatus.Failed;
|
|
17386
17380
|
}
|
|
17387
17381
|
function poamItemAppliedBy(poam) {
|
|
17388
17382
|
const rps = poam.metadata["responsible-parties"];
|
|
17389
17383
|
if (rps) {
|
|
17390
17384
|
for (const rp of rps) if (rp["role-id"] === "prepared-by" && rp["party-uuids"].length > 0) return {
|
|
17391
|
-
type:
|
|
17385
|
+
type: IdentityType.Simple,
|
|
17392
17386
|
identifier: rp["party-uuids"][0]
|
|
17393
17387
|
};
|
|
17394
17388
|
if (rps.length > 0 && rps[0]["party-uuids"].length > 0) return {
|
|
17395
|
-
type:
|
|
17389
|
+
type: IdentityType.Simple,
|
|
17396
17390
|
identifier: rps[0]["party-uuids"][0]
|
|
17397
17391
|
};
|
|
17398
17392
|
}
|
|
17399
17393
|
return {
|
|
17400
|
-
type:
|
|
17394
|
+
type: IdentityType.System,
|
|
17401
17395
|
identifier: "oscal-poam-converter"
|
|
17402
17396
|
};
|
|
17403
17397
|
}
|
|
@@ -17433,7 +17427,7 @@ function extractMilestones(item, riskMap) {
|
|
|
17433
17427
|
milestones.push({
|
|
17434
17428
|
description: task.description ? `${task.title}: ${task.description}` : task.title,
|
|
17435
17429
|
estimatedCompletion,
|
|
17436
|
-
status:
|
|
17430
|
+
status: MilestoneStatus.Pending
|
|
17437
17431
|
});
|
|
17438
17432
|
}
|
|
17439
17433
|
}
|
|
@@ -17444,7 +17438,7 @@ function extractAppliedBy(meta) {
|
|
|
17444
17438
|
const rps = meta["responsible-parties"];
|
|
17445
17439
|
if (rps) {
|
|
17446
17440
|
for (const rp of rps) if (rp["role-id"] === "prepared-by" && rp["party-uuids"].length > 0) return {
|
|
17447
|
-
type:
|
|
17441
|
+
type: IdentityType.Simple,
|
|
17448
17442
|
identifier: rp["party-uuids"][0]
|
|
17449
17443
|
};
|
|
17450
17444
|
}
|
|
@@ -17463,7 +17457,7 @@ function extractAppliedBy(meta) {
|
|
|
17463
17457
|
* @returns HDF Plan JSON string
|
|
17464
17458
|
*/
|
|
17465
17459
|
async function convertOscalSapToHdf(input) {
|
|
17466
|
-
validateInputSize(input, "oscal-assessment-plan");
|
|
17460
|
+
validateInputSize$1(input, "oscal-assessment-plan");
|
|
17467
17461
|
if (!input || input.trim().length === 0) throw new Error("empty input");
|
|
17468
17462
|
const doc = parseJSON(input);
|
|
17469
17463
|
if (!doc["assessment-plan"]) throw new Error("oscal-assessment-plan: input is not an assessment-plan document (root key is not 'assessment-plan')");
|
|
@@ -17593,7 +17587,7 @@ function buildPlanDescription(ap) {
|
|
|
17593
17587
|
* @returns HDF Results JSON string
|
|
17594
17588
|
*/
|
|
17595
17589
|
async function convertOscalSarToHdf(input) {
|
|
17596
|
-
validateInputSize(input, "oscal-assessment-results");
|
|
17590
|
+
validateInputSize$1(input, "oscal-assessment-results");
|
|
17597
17591
|
if (!input || input.trim().length === 0) throw new Error("empty input");
|
|
17598
17592
|
const doc = parseJSON(input);
|
|
17599
17593
|
if (!doc["assessment-results"]) throw new Error("oscal-assessment-results: input is not an assessment-results document (root key is not 'assessment-results')");
|
|
@@ -17902,7 +17896,7 @@ function sarBaselineName(result, sar) {
|
|
|
17902
17896
|
* @returns HDF System JSON string
|
|
17903
17897
|
*/
|
|
17904
17898
|
async function convertOscalSspToHdf(input) {
|
|
17905
|
-
validateInputSize(input, "oscal-ssp");
|
|
17899
|
+
validateInputSize$1(input, "oscal-ssp");
|
|
17906
17900
|
if (!input || input.trim().length === 0) throw new Error("empty input");
|
|
17907
17901
|
const doc = parseJSON(input);
|
|
17908
17902
|
if (!doc["system-security-plan"]) throw new Error("oscal-ssp: input is not a system-security-plan document (root key is not 'system-security-plan')");
|
|
@@ -18079,7 +18073,7 @@ function mapOSCALComponentType(oscalType) {
|
|
|
18079
18073
|
* @returns HDF Baseline JSON string
|
|
18080
18074
|
*/
|
|
18081
18075
|
async function convertOscalProfileToHdf(profileInput, catalogInput) {
|
|
18082
|
-
validateInputSize(profileInput, "oscal-profile");
|
|
18076
|
+
validateInputSize$1(profileInput, "oscal-profile");
|
|
18083
18077
|
if (!profileInput || profileInput.trim().length === 0) throw new Error("empty profile input");
|
|
18084
18078
|
if (!catalogInput || catalogInput.trim().length === 0) throw new Error("empty catalog input");
|
|
18085
18079
|
const profileDoc = parseJSON(profileInput);
|
|
@@ -18276,8 +18270,8 @@ function toRfc3339(d) {
|
|
|
18276
18270
|
* TypeScript peer of shared/go/enrich_stix.go (kept at parity).
|
|
18277
18271
|
*/
|
|
18278
18272
|
function enrichStix(resultsInput, bundleInput, opts) {
|
|
18279
|
-
validateInputSize(resultsInput, "enrich-stix", opts?.maxSize);
|
|
18280
|
-
validateInputSize(bundleInput, "enrich-stix", opts?.maxSize);
|
|
18273
|
+
validateInputSize$1(resultsInput, "enrich-stix", opts?.maxSize);
|
|
18274
|
+
validateInputSize$1(bundleInput, "enrich-stix", opts?.maxSize);
|
|
18281
18275
|
if (!resultsInput) throw new Error("enrich-stix: empty results input");
|
|
18282
18276
|
const bundle = parseStixBundle(bundleInput);
|
|
18283
18277
|
let parsed;
|