Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion server/lib/secscore-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
import type { CvssTemporalMultipliers, EpssSignal } from '~/types/secscore.types';
import type { ExplanationParams } from '~/types/secscore-engine.types';

// Parses a normalized CPE string. Returns the product field lowercased, or null if parse fails.
function parseCpeProduct(entry: string): string | null {
// Typical CPE: cpe:2.3:a:microsoft:asp.net:*
const parts = entry.split(':');
// CPE formatted strings have 'cpe' or 'cpe23', then possibly version, then part ('a', 'o', 'h'), then vendor, product, version, update ...
// Product is typically the 4th or 5th field, depending on normalization, e.g. cpe:2.3:a:vendor:product:...
// Find 'a','o','h' and get product field after vendor
const idx = parts.findIndex(p => p === 'a' || p === 'o' || p === 'h');
if (idx >= 0 && parts.length > idx + 2) {
// vendor: parts[idx+1], product: parts[idx+2]
return parts[idx+2]?.toLowerCase() || null;

Check failure on line 15 in server/lib/secscore-engine.ts

View workflow job for this annotation

GitHub Actions / ci (22)

Operator '+' must be spaced
}
return null;
}

const BASE_DEFAULT: number = 0;
const EXPONENT_BOUND: number = 50;
const CVSS_V4_EXPLOIT_MATURITY: Record<string, number> = {
Expand Down Expand Up @@ -138,7 +153,10 @@
}

// 7. ASP.NET applications.
if (normalizedCpeEntries.some(entry => entry.includes('asp.net') || entry.includes('aspnet'))) {
if (normalizedCpeEntries.some(entry => {

Check failure on line 156 in server/lib/secscore-engine.ts

View workflow job for this annotation

GitHub Actions / ci (22)

Expected parentheses around arrow function argument having a body with curly braces
const product = parseCpeProduct(entry);
return product === 'asp.net' || product === 'aspnet';
})) {
return 'asp';
}

Expand Down
Loading