@cclabsnz/sf-audit 1.0.1 → 1.2.0
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 +228 -31
- package/lib/api/ToolingClientImpl.js +5 -2
- package/lib/chains/AttackChain.d.ts +20 -0
- package/lib/chains/AttackChain.js +2 -0
- package/lib/chains/Capability.d.ts +7 -0
- package/lib/chains/Capability.js +11 -0
- package/lib/chains/CapabilityRegistry.d.ts +18 -0
- package/lib/chains/CapabilityRegistry.js +53 -0
- package/lib/chains/ChainEngine.d.ts +13 -0
- package/lib/chains/ChainEngine.js +137 -0
- package/lib/chains/namedChains.d.ts +14 -0
- package/lib/chains/namedChains.js +99 -0
- package/lib/checks/CheckEngine.js +33 -5
- package/lib/checks/impl/AnonymousApexAuditCheck.d.ts +10 -0
- package/lib/checks/impl/AnonymousApexAuditCheck.js +106 -0
- package/lib/checks/impl/ApexCrudFLSCheck.d.ts +11 -0
- package/lib/checks/impl/ApexCrudFLSCheck.js +98 -0
- package/lib/checks/impl/ApexLoggingCheck.d.ts +11 -0
- package/lib/checks/impl/ApexLoggingCheck.js +124 -0
- package/lib/checks/impl/ApexRestEndpointCheck.d.ts +11 -0
- package/lib/checks/impl/ApexRestEndpointCheck.js +94 -0
- package/lib/checks/impl/ApexSharingCheck.js +29 -0
- package/lib/checks/impl/ApiClientPermissionCheck.d.ts +10 -0
- package/lib/checks/impl/ApiClientPermissionCheck.js +59 -0
- package/lib/checks/impl/AuditTrailCheck.js +29 -0
- package/lib/checks/impl/CertificateExpiryCheck.d.ts +10 -0
- package/lib/checks/impl/CertificateExpiryCheck.js +123 -0
- package/lib/checks/impl/CodeSecurityCheck.d.ts +2 -1
- package/lib/checks/impl/CodeSecurityCheck.js +46 -6
- package/lib/checks/impl/ConnectedAppInactivityCheck.d.ts +11 -0
- package/lib/checks/impl/ConnectedAppInactivityCheck.js +86 -0
- package/lib/checks/impl/ConnectedAppScopeCheck.d.ts +10 -0
- package/lib/checks/impl/ConnectedAppScopeCheck.js +125 -0
- package/lib/checks/impl/ConnectedAppsCheck.d.ts +1 -0
- package/lib/checks/impl/ConnectedAppsCheck.js +37 -2
- package/lib/checks/impl/ContentLinksCheck.d.ts +10 -0
- package/lib/checks/impl/ContentLinksCheck.js +115 -0
- package/lib/checks/impl/CorsAllowlistCheck.d.ts +10 -0
- package/lib/checks/impl/CorsAllowlistCheck.js +80 -0
- package/lib/checks/impl/CspTrustedSitesCheck.d.ts +10 -0
- package/lib/checks/impl/CspTrustedSitesCheck.js +55 -0
- package/lib/checks/impl/CustomLabelsCredentialCheck.d.ts +10 -0
- package/lib/checks/impl/CustomLabelsCredentialCheck.js +97 -0
- package/lib/checks/impl/DataClassificationCheck.d.ts +10 -0
- package/lib/checks/impl/DataClassificationCheck.js +112 -0
- package/lib/checks/impl/DebugLogAccessCheck.d.ts +10 -0
- package/lib/checks/impl/DebugLogAccessCheck.js +81 -0
- package/lib/checks/impl/DeploymentIdentityCheck.d.ts +11 -0
- package/lib/checks/impl/DeploymentIdentityCheck.js +144 -0
- package/lib/checks/impl/EnhancedDomainsCheck.d.ts +10 -0
- package/lib/checks/impl/EnhancedDomainsCheck.js +84 -0
- package/lib/checks/impl/EscalationPermsCheck.d.ts +10 -0
- package/lib/checks/impl/EscalationPermsCheck.js +77 -0
- package/lib/checks/impl/EventMonitoringCheck.d.ts +11 -0
- package/lib/checks/impl/EventMonitoringCheck.js +84 -0
- package/lib/checks/impl/ExperienceCloudSiteCheck.d.ts +10 -0
- package/lib/checks/impl/ExperienceCloudSiteCheck.js +91 -0
- package/lib/checks/impl/FailedLoginCheck.d.ts +10 -0
- package/lib/checks/impl/FailedLoginCheck.js +122 -0
- package/lib/checks/impl/FieldHistoryTrackingCheck.d.ts +10 -0
- package/lib/checks/impl/FieldHistoryTrackingCheck.js +70 -0
- package/lib/checks/impl/FieldLevelSecurityCheck.js +28 -18
- package/lib/checks/impl/GuestExecutableApexCheck.d.ts +11 -0
- package/lib/checks/impl/GuestExecutableApexCheck.js +93 -0
- package/lib/checks/impl/GuestUserAccessCheck.js +74 -66
- package/lib/checks/impl/HardcodedCredentialsCheck.js +2 -2
- package/lib/checks/impl/HighAssuranceSessionCheck.d.ts +10 -0
- package/lib/checks/impl/HighAssuranceSessionCheck.js +103 -0
- package/lib/checks/impl/InactiveUsersCheck.js +38 -19
- package/lib/checks/impl/InstalledPackagesCheck.d.ts +10 -0
- package/lib/checks/impl/InstalledPackagesCheck.js +94 -0
- package/lib/checks/impl/IntegrationUsersCheck.d.ts +10 -0
- package/lib/checks/impl/IntegrationUsersCheck.js +108 -0
- package/lib/checks/impl/InternalUserMfaCheck.d.ts +10 -0
- package/lib/checks/impl/InternalUserMfaCheck.js +81 -0
- package/lib/checks/impl/IpRestrictionsCheck.js +86 -23
- package/lib/checks/impl/LegacyApiVersionCheck.d.ts +10 -0
- package/lib/checks/impl/LegacyApiVersionCheck.js +91 -0
- package/lib/checks/impl/MfaEnforcementCheck.d.ts +10 -0
- package/lib/checks/impl/MfaEnforcementCheck.js +76 -0
- package/lib/checks/impl/MfaMethodStrengthCheck.d.ts +11 -0
- package/lib/checks/impl/MfaMethodStrengthCheck.js +116 -0
- package/lib/checks/impl/MfaRegistrationCheck.d.ts +11 -0
- package/lib/checks/impl/MfaRegistrationCheck.js +95 -0
- package/lib/checks/impl/MyDomainLoginPolicyCheck.d.ts +10 -0
- package/lib/checks/impl/MyDomainLoginPolicyCheck.js +105 -0
- package/lib/checks/impl/NamedCredentialsCheck.js +37 -2
- package/lib/checks/impl/PermissionsCheck.js +67 -14
- package/lib/checks/impl/PublicGroupSharingCheck.js +20 -9
- package/lib/checks/impl/ReleaseUpdatesCheck.d.ts +10 -0
- package/lib/checks/impl/ReleaseUpdatesCheck.js +106 -0
- package/lib/checks/impl/ReportFolderAccessCheck.d.ts +10 -0
- package/lib/checks/impl/ReportFolderAccessCheck.js +54 -0
- package/lib/checks/impl/ScheduledApexCheck.d.ts +1 -0
- package/lib/checks/impl/ScheduledApexCheck.js +3 -0
- package/lib/checks/impl/SharingModelCheck.d.ts +1 -1
- package/lib/checks/impl/SharingModelCheck.js +103 -32
- package/lib/checks/impl/SiemIntegrationCheck.d.ts +11 -0
- package/lib/checks/impl/SiemIntegrationCheck.js +102 -0
- package/lib/checks/impl/SsoEnforcementCheck.d.ts +10 -0
- package/lib/checks/impl/SsoEnforcementCheck.js +90 -0
- package/lib/checks/impl/StandardProfilesCheck.d.ts +10 -0
- package/lib/checks/impl/StandardProfilesCheck.js +68 -0
- package/lib/checks/impl/TransactionSecurityPolicyCheck.d.ts +10 -0
- package/lib/checks/impl/TransactionSecurityPolicyCheck.js +62 -0
- package/lib/checks/impl/TrustedIPRangesCheck.d.ts +10 -0
- package/lib/checks/impl/TrustedIPRangesCheck.js +106 -0
- package/lib/checks/impl/UsersAndAdminsCheck.js +50 -20
- package/lib/checks/impl/VisualforceXssCheck.d.ts +11 -0
- package/lib/checks/impl/VisualforceXssCheck.js +150 -0
- package/lib/checks/registry.js +97 -12
- package/lib/commands/audit/diff.d.ts +17 -0
- package/lib/commands/audit/diff.js +76 -0
- package/lib/commands/audit/history.d.ts +15 -0
- package/lib/commands/audit/history.js +59 -0
- package/lib/commands/audit/security.d.ts +5 -0
- package/lib/commands/audit/security.js +38 -9
- package/lib/compliance/catalogs/hiso10029.d.ts +3 -0
- package/lib/compliance/catalogs/hiso10029.js +35 -0
- package/lib/compliance/catalogs/index.d.ts +4 -0
- package/lib/compliance/catalogs/index.js +21 -0
- package/lib/compliance/catalogs/iso27001.d.ts +3 -0
- package/lib/compliance/catalogs/iso27001.js +39 -0
- package/lib/compliance/catalogs/nzism.d.ts +3 -0
- package/lib/compliance/catalogs/nzism.js +31 -0
- package/lib/compliance/catalogs/owasp.d.ts +3 -0
- package/lib/compliance/catalogs/owasp.js +37 -0
- package/lib/compliance/catalogs/privacyAct.d.ts +3 -0
- package/lib/compliance/catalogs/privacyAct.js +17 -0
- package/lib/compliance/catalogs/sbs.d.ts +3 -0
- package/lib/compliance/catalogs/sbs.js +61 -0
- package/lib/compliance/catalogs/soc2.d.ts +3 -0
- package/lib/compliance/catalogs/soc2.js +42 -0
- package/lib/compliance/mapping.d.ts +2 -0
- package/lib/compliance/mapping.js +111 -0
- package/lib/compliance/resolve.d.ts +12 -0
- package/lib/compliance/resolve.js +49 -0
- package/lib/compliance/types.d.ts +13 -0
- package/lib/compliance/types.js +2 -0
- package/lib/context/AuditCache.d.ts +20 -0
- package/lib/context/AuditContext.d.ts +0 -2
- package/lib/findings/AuditResult.d.ts +3 -0
- package/lib/findings/CheckMeta.d.ts +9 -0
- package/lib/findings/CheckMeta.js +67 -0
- package/lib/findings/ComplianceMapping.d.ts +3 -0
- package/lib/findings/ComplianceMapping.js +75 -0
- package/lib/findings/Finding.d.ts +20 -0
- package/lib/findings/loadScoringConfig.js +9 -2
- package/lib/findings/scoring.d.ts +2 -1
- package/lib/findings/scoring.js +20 -7
- package/lib/history/AuditDiff.d.ts +26 -0
- package/lib/history/AuditDiff.js +2 -0
- package/lib/history/DiffEngine.d.ts +4 -0
- package/lib/history/DiffEngine.js +61 -0
- package/lib/history/HistoryStore.d.ts +11 -0
- package/lib/history/HistoryStore.js +56 -0
- package/lib/history/metricMeta.d.ts +9 -0
- package/lib/history/metricMeta.js +28 -0
- package/lib/index.d.ts +7 -1
- package/lib/index.js +2 -1
- package/lib/lib/wire.d.ts +1 -2
- package/lib/lib/wire.js +1 -2
- package/lib/renderers/AuditRenderer.d.ts +2 -0
- package/lib/renderers/ClientReportRenderer.d.ts +29 -0
- package/lib/renderers/ClientReportRenderer.js +205 -0
- package/lib/renderers/DiffHtmlRenderer.d.ts +8 -0
- package/lib/renderers/DiffHtmlRenderer.js +164 -0
- package/lib/renderers/DiffJsonRenderer.d.ts +8 -0
- package/lib/renderers/DiffJsonRenderer.js +8 -0
- package/lib/renderers/DiffRenderer.d.ts +7 -0
- package/lib/renderers/DiffRenderer.js +2 -0
- package/lib/renderers/HistoryRenderer.d.ts +6 -0
- package/lib/renderers/HistoryRenderer.js +140 -0
- package/lib/renderers/HtmlRenderer.d.ts +1 -0
- package/lib/renderers/HtmlRenderer.js +354 -60
- package/lib/renderers/MarkdownRenderer.js +34 -1
- package/lib/renderers/html-utils.d.ts +2 -0
- package/lib/renderers/html-utils.js +8 -0
- package/lib/report/ComplianceMatrix.d.ts +19 -0
- package/lib/report/ComplianceMatrix.js +47 -0
- package/lib/report/ExecutivePriorities.d.ts +8 -0
- package/lib/report/ExecutivePriorities.js +22 -0
- package/lib/report/RemediationRoadmap.d.ts +9 -0
- package/lib/report/RemediationRoadmap.js +18 -0
- package/lib/report/branding.d.ts +18 -0
- package/lib/report/branding.js +19 -0
- package/lib/report/fonts.d.ts +2 -0
- package/lib/report/fonts.js +22 -0
- package/package.json +4 -3
- package/src/assets/fonts/dm-sans-italic-latin.woff2 +0 -0
- package/src/assets/fonts/dm-sans-normal-latin.woff2 +0 -0
- package/src/assets/fonts/dm-serif-display-italic-latin.woff2 +0 -0
- package/src/assets/fonts/dm-serif-display-normal-latin.woff2 +0 -0
- package/config/queries/soql.json +0 -24
- package/config/queries/tooling.json +0 -28
- package/config/scoring.json +0 -17
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { esc } from './html-utils.js';
|
|
1
2
|
const RISK_COLORS = {
|
|
2
3
|
CRITICAL: '#dc2626',
|
|
3
4
|
HIGH: '#ea580c',
|
|
@@ -14,40 +15,198 @@ const RISK_BG = {
|
|
|
14
15
|
};
|
|
15
16
|
const PASS_COLOR = '#22c55e';
|
|
16
17
|
const PASS_BG = 'rgba(34,197,94,0.10)';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
const GRADE_COLOR = {
|
|
19
|
+
A: '#22c55e', B: '#84cc16', C: '#eab308', D: '#f97316', F: '#ef4444',
|
|
20
|
+
};
|
|
21
|
+
// ── Dashboard helpers ────────────────────────────────────────────────────────
|
|
22
|
+
function statusColor(value, warnThreshold, dangerThreshold) {
|
|
23
|
+
if (value <= warnThreshold)
|
|
24
|
+
return '#22c55e';
|
|
25
|
+
if (value <= dangerThreshold)
|
|
26
|
+
return '#d97706';
|
|
27
|
+
return '#dc2626';
|
|
28
|
+
}
|
|
29
|
+
function progressBar(value, max, color) {
|
|
30
|
+
if (max === 0)
|
|
31
|
+
return '';
|
|
32
|
+
const pct = Math.min(100, Math.round((value / max) * 100));
|
|
33
|
+
return `<div class="prog-bar"><div class="prog-fill" style="width:${pct}%;background:${color}"></div></div>`;
|
|
34
|
+
}
|
|
35
|
+
function metricRow(label, value, color, bar) {
|
|
36
|
+
const val = color
|
|
37
|
+
? `<span style="color:${color};font-weight:700">${esc(String(value))}</span>`
|
|
38
|
+
: `<span class="metric-value">${esc(String(value))}</span>`;
|
|
39
|
+
return `<div class="metric-row"><span class="metric-label">${esc(label)}</span><div class="metric-right">${val}${bar ?? ''}</div></div>`;
|
|
23
40
|
}
|
|
41
|
+
function inventoryCard(title, rows) {
|
|
42
|
+
return `<div class="inv-card"><div class="inv-card-title">${esc(title)}</div>${rows.join('')}</div>`;
|
|
43
|
+
}
|
|
44
|
+
function buildScoreRing(score, grade, color) {
|
|
45
|
+
return `
|
|
46
|
+
<div class="score-ring" style="background:conic-gradient(from -90deg, ${color} ${score}%, #2d3748 ${score}%)" aria-label="Health score ${score} out of 100, grade ${grade}">
|
|
47
|
+
<div class="score-inner">
|
|
48
|
+
<div class="score-num" style="color:${color}">${score}<span>/100</span></div>
|
|
49
|
+
<div class="score-grade" style="background:${color}">${esc(grade)}</div>
|
|
50
|
+
</div>
|
|
51
|
+
</div>`;
|
|
52
|
+
}
|
|
53
|
+
function buildDonutSvg(counts) {
|
|
54
|
+
const levels = ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'];
|
|
55
|
+
const total = levels.reduce((s, l) => s + (counts[l] ?? 0), 0);
|
|
56
|
+
const cx = 60, cy = 60, R = 44;
|
|
57
|
+
const CIRC = 2 * Math.PI * R;
|
|
58
|
+
if (total === 0) {
|
|
59
|
+
return `<svg width="120" height="120" viewBox="0 0 120 120" aria-hidden="true">
|
|
60
|
+
<circle cx="${cx}" cy="${cy}" r="${R}" fill="none" stroke="#21262d" stroke-width="14" />
|
|
61
|
+
<text x="${cx}" y="${cy + 5}" text-anchor="middle" fill="#22c55e" font-size="12" font-family="system-ui,sans-serif">Clean</text>
|
|
62
|
+
</svg>`;
|
|
63
|
+
}
|
|
64
|
+
let offset = CIRC / 4; // Start from 12 o'clock
|
|
65
|
+
const arcs = levels.map(l => {
|
|
66
|
+
const count = counts[l] ?? 0;
|
|
67
|
+
if (count === 0)
|
|
68
|
+
return '';
|
|
69
|
+
const dash = (count / total) * CIRC;
|
|
70
|
+
const arc = `<circle cx="${cx}" cy="${cy}" r="${R}" fill="none" stroke="${RISK_COLORS[l]}" stroke-width="14" stroke-dasharray="${dash.toFixed(2)} ${CIRC.toFixed(2)}" stroke-dashoffset="${offset.toFixed(2)}" />`;
|
|
71
|
+
offset -= dash;
|
|
72
|
+
return arc;
|
|
73
|
+
});
|
|
74
|
+
return `<svg width="120" height="120" viewBox="0 0 120 120" aria-hidden="true">
|
|
75
|
+
<circle cx="${cx}" cy="${cy}" r="${R}" fill="none" stroke="#21262d" stroke-width="14" />
|
|
76
|
+
${arcs.join('')}
|
|
77
|
+
<text x="${cx}" y="${cy - 5}" text-anchor="middle" fill="#f0f6fc" font-size="20" font-weight="700" font-family="system-ui,sans-serif">${total}</text>
|
|
78
|
+
<text x="${cx}" y="${cy + 14}" text-anchor="middle" fill="#8b949e" font-size="10" font-family="system-ui,sans-serif">findings</text>
|
|
79
|
+
</svg>`;
|
|
80
|
+
}
|
|
81
|
+
function buildDashboard(result, counts) {
|
|
82
|
+
const m = result.metrics;
|
|
83
|
+
const gradeColor = GRADE_COLOR[result.grade] ?? '#64748b';
|
|
84
|
+
const gauge = buildScoreRing(result.healthScore, result.grade, gradeColor);
|
|
85
|
+
const donut = buildDonutSvg(counts);
|
|
86
|
+
const kpiCards = ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'].map(l => `<div class="kpi-card" style="border-top:3px solid ${RISK_COLORS[l]}">
|
|
87
|
+
<div class="kpi-value" style="color:${RISK_COLORS[l]}">${counts[l] ?? 0}</div>
|
|
88
|
+
<div class="kpi-label">${l}</div>
|
|
89
|
+
</div>`).join('');
|
|
90
|
+
// Users & Access
|
|
91
|
+
const modifyColor = statusColor(m.modifyAllDataUsersCount, 2, 5);
|
|
92
|
+
const viewColor = statusColor(m.viewAllDataUsersCount, 5, 15);
|
|
93
|
+
const inactiveColor = statusColor(m.inactiveUsers90d, 0, 5);
|
|
94
|
+
const usersCard = inventoryCard('Users & Access', [
|
|
95
|
+
metricRow('Active Users', m.totalActiveUsers),
|
|
96
|
+
metricRow('Modify All Data', m.modifyAllDataUsersCount, modifyColor, m.totalActiveUsers > 0 ? progressBar(m.modifyAllDataUsersCount, m.totalActiveUsers, modifyColor) : ''),
|
|
97
|
+
metricRow('View All Data', m.viewAllDataUsersCount, viewColor, m.totalActiveUsers > 0 ? progressBar(m.viewAllDataUsersCount, m.totalActiveUsers, viewColor) : ''),
|
|
98
|
+
metricRow('Inactive 90d', m.inactiveUsers90d, inactiveColor),
|
|
99
|
+
metricRow('Profiles', m.profileCount),
|
|
100
|
+
metricRow('Permission Sets', m.permissionSetCount),
|
|
101
|
+
]);
|
|
102
|
+
// Code Quality
|
|
103
|
+
const covColor = m.codeCoveragePercent >= 75 ? '#22c55e' : m.codeCoveragePercent >= 50 ? '#d97706' : '#dc2626';
|
|
104
|
+
const codeCard = inventoryCard('Code Quality', [
|
|
105
|
+
metricRow('Apex Classes', m.apexClassCount),
|
|
106
|
+
metricRow('Apex Triggers', m.apexTriggerCount),
|
|
107
|
+
metricRow('Code Coverage', `${m.codeCoveragePercent}%`, covColor, progressBar(m.codeCoveragePercent, 100, covColor)),
|
|
108
|
+
]);
|
|
109
|
+
// Integrations
|
|
110
|
+
const insecureColor = m.insecureRemoteSitesCount > 0 ? '#dc2626' : '#22c55e';
|
|
111
|
+
const unusedCredColor = statusColor(m.unusedNamedCredentialsCount, 0, 2);
|
|
112
|
+
const integrationsCard = inventoryCard('Integrations', [
|
|
113
|
+
metricRow('Connected Apps', m.connectedAppsCount),
|
|
114
|
+
metricRow('Remote Sites', m.remoteSitesCount),
|
|
115
|
+
metricRow('↳ Insecure', m.insecureRemoteSitesCount, insecureColor, m.remoteSitesCount > 0 ? progressBar(m.insecureRemoteSitesCount, m.remoteSitesCount, insecureColor) : ''),
|
|
116
|
+
metricRow('Named Credentials', m.namedCredentialsCount),
|
|
117
|
+
metricRow('↳ Unused', m.unusedNamedCredentialsCount, m.unusedNamedCredentialsCount > 0 ? '#d97706' : '#22c55e', m.namedCredentialsCount > 0 ? progressBar(m.unusedNamedCredentialsCount, m.namedCredentialsCount, unusedCredColor) : ''),
|
|
118
|
+
]);
|
|
119
|
+
// Governance & Events
|
|
120
|
+
const failedColor = statusColor(m.failedLogins30d, 10, 100);
|
|
121
|
+
const healthChkColor = m.healthCheckScore >= 75 ? '#22c55e' : m.healthCheckScore >= 50 ? '#d97706' : '#dc2626';
|
|
122
|
+
const governanceCard = inventoryCard('Governance & Events', [
|
|
123
|
+
metricRow('Failed Logins (30d)', m.failedLogins30d, failedColor),
|
|
124
|
+
metricRow('SF Health Check', `${m.healthCheckScore}%`, healthChkColor, progressBar(m.healthCheckScore, 100, healthChkColor)),
|
|
125
|
+
]);
|
|
126
|
+
return `
|
|
127
|
+
<div class="dashboard">
|
|
128
|
+
<div class="dash-top">
|
|
129
|
+
<div class="dash-score-panel">
|
|
130
|
+
<div class="gauge-wrap">
|
|
131
|
+
${gauge}
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
<div class="dash-risk-panel">
|
|
135
|
+
<div class="donut-wrap">
|
|
136
|
+
${donut}
|
|
137
|
+
<div class="donut-legend">
|
|
138
|
+
${['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'].map(l => `<div class="legend-row">
|
|
139
|
+
<span class="legend-dot" style="background:${RISK_COLORS[l]}"></span>
|
|
140
|
+
<span>${l}</span>
|
|
141
|
+
<span class="legend-count">${counts[l] ?? 0}</span>
|
|
142
|
+
</div>`).join('')}
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
<div class="kpi-strip">${kpiCards}</div>
|
|
148
|
+
<div class="inv-grid">
|
|
149
|
+
${usersCard}
|
|
150
|
+
${codeCard}
|
|
151
|
+
${integrationsCard}
|
|
152
|
+
${governanceCard}
|
|
153
|
+
</div>
|
|
154
|
+
</div>`;
|
|
155
|
+
}
|
|
156
|
+
// ── Main renderer ────────────────────────────────────────────────────────────
|
|
24
157
|
export class HtmlRenderer {
|
|
25
158
|
format = 'html';
|
|
26
159
|
fileExtension = '.html';
|
|
160
|
+
renderAttackPaths(result) {
|
|
161
|
+
if (!result.attackChains || result.attackChains.length === 0)
|
|
162
|
+
return '';
|
|
163
|
+
const escStr = (s) => s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
164
|
+
const cards = result.attackChains
|
|
165
|
+
.map((c) => {
|
|
166
|
+
const conf = c.confidence === 'named' ? '' : ' (potential)';
|
|
167
|
+
const steps = c.steps
|
|
168
|
+
.map((s, i) => `<li><strong>${escStr(s.title ?? s.findingId)}</strong> (${escStr(s.severity ?? '—')}) — grants <code>${escStr(s.capability)}</code></li>`)
|
|
169
|
+
.join('');
|
|
170
|
+
return `<div class="attack-chain severity-${c.severity.toLowerCase()}">
|
|
171
|
+
<h3>[${escStr(c.severity)}] ${escStr(c.title)}${conf}</h3>
|
|
172
|
+
<p>${escStr(c.narrative)}</p>
|
|
173
|
+
<ol>${steps}</ol>
|
|
174
|
+
<p class="remediation"><strong>Remediation:</strong> ${escStr(c.remediation)}</p>
|
|
175
|
+
</div>`;
|
|
176
|
+
})
|
|
177
|
+
.join('\n');
|
|
178
|
+
return `<section class="attack-paths">
|
|
179
|
+
<h2>Attack Paths (${result.attackChains.length})</h2>
|
|
180
|
+
<p class="subtitle">Combinations of findings that together enable an exploit more severe than any single finding.</p>
|
|
181
|
+
${cards}
|
|
182
|
+
</section>`;
|
|
183
|
+
}
|
|
27
184
|
render(result) {
|
|
28
185
|
const levels = ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'];
|
|
29
186
|
const counts = Object.fromEntries(levels.map((l) => [l, result.findings.filter((f) => f.riskLevel === l).length]));
|
|
30
|
-
const gradeColor = {
|
|
31
|
-
A: '#22c55e', B: '#84cc16', C: '#eab308', D: '#f97316', F: '#ef4444',
|
|
32
|
-
};
|
|
33
|
-
const summaryBadges = levels
|
|
34
|
-
.map((l) => `<span class="badge" style="background:${RISK_COLORS[l]}">${counts[l]} ${l}</span>`)
|
|
35
|
-
.join('');
|
|
36
187
|
const filterButtons = [
|
|
37
188
|
`<button class="filter-btn active" data-filter="all">All (${result.findings.length})</button>`,
|
|
38
189
|
...levels.map((l) => `<button class="filter-btn" data-filter="${l}" style="--accent:${RISK_COLORS[l]}">${l} (${counts[l]})</button>`),
|
|
39
190
|
].join('\n ');
|
|
191
|
+
const attackPathsHtml = this.renderAttackPaths(result);
|
|
40
192
|
const findingsHtml = result.findings.length === 0
|
|
41
|
-
? '<p
|
|
193
|
+
? '<p class="no-findings">No findings.</p>'
|
|
42
194
|
: result.findings.map((f) => {
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
195
|
+
const isInconclusive = !!f.inconclusive;
|
|
196
|
+
const cardAccent = isInconclusive ? '#8b949e' : (f.passed ? PASS_COLOR : (RISK_COLORS[f.riskLevel] ?? '#64748b'));
|
|
197
|
+
const cardBg = isInconclusive ? 'rgba(139,148,158,0.06)' : (f.passed ? PASS_BG : (RISK_BG[f.riskLevel] ?? 'rgba(100,116,139,0.12)'));
|
|
198
|
+
const badgeHtml = isInconclusive
|
|
199
|
+
? `<span class="inconclusive-badge">? INCONCLUSIVE</span>`
|
|
200
|
+
: f.passed
|
|
201
|
+
? `<span class="risk-badge" style="background:${PASS_COLOR}">✓ PASS</span>`
|
|
202
|
+
: `<span class="risk-badge" style="background:${RISK_COLORS[f.riskLevel] ?? '#64748b'}">${esc(f.riskLevel)}</span>`;
|
|
203
|
+
const tagsHtml = f.complianceTags?.length
|
|
204
|
+
? `<div class="compliance-tags">${f.complianceTags.map((t) => `<span class="compliance-tag">${esc(t)}</span>`).join('')}</div>`
|
|
205
|
+
: '';
|
|
47
206
|
return `
|
|
48
|
-
<details class="finding-card" data-risk="${esc(f.riskLevel)}" style="--card-accent:${cardAccent};--card-bg:${cardBg}">
|
|
207
|
+
<details class="finding-card${isInconclusive ? ' is-inconclusive' : ''}" data-risk="${esc(f.riskLevel)}" style="--card-accent:${cardAccent};--card-bg:${cardBg}">
|
|
49
208
|
<summary class="finding-summary">
|
|
50
|
-
|
|
209
|
+
${badgeHtml}
|
|
51
210
|
<span class="finding-title">${esc(f.title)}</span>
|
|
52
211
|
<span class="finding-category">${esc(f.category)}</span>
|
|
53
212
|
<span class="chevron">›</span>
|
|
@@ -73,6 +232,7 @@ export class HtmlRenderer {
|
|
|
73
232
|
}).join('');
|
|
74
233
|
return `<div class="affected-items"><strong>Affected items (${f.affectedItems.length})</strong><table class="affected-table"><thead>${thead}</thead><tbody>${tbody}</tbody></table></div>`;
|
|
75
234
|
})() : ''}
|
|
235
|
+
${tagsHtml}
|
|
76
236
|
</div>
|
|
77
237
|
</details>`;
|
|
78
238
|
}).join('\n');
|
|
@@ -82,57 +242,143 @@ export class HtmlRenderer {
|
|
|
82
242
|
<meta charset="UTF-8">
|
|
83
243
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
84
244
|
<title>SF Security Audit — ${esc(result.orgName)}</title>
|
|
245
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
246
|
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;700&family=Fira+Sans:wght@300;400;500;600;700&display=swap">
|
|
85
247
|
<style>
|
|
86
248
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
87
249
|
body {
|
|
88
|
-
font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
|
|
250
|
+
font-family: 'Fira Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
|
|
89
251
|
background: #0d1117;
|
|
90
252
|
color: #c9d1d9;
|
|
91
|
-
max-width:
|
|
253
|
+
max-width: 1100px;
|
|
92
254
|
margin: 2rem auto;
|
|
93
255
|
padding: 0 1.25rem 4rem;
|
|
94
256
|
line-height: 1.6;
|
|
95
257
|
}
|
|
96
|
-
|
|
97
|
-
|
|
258
|
+
|
|
259
|
+
/* ── Header ── */
|
|
260
|
+
.header { margin-bottom: 1.5rem; }
|
|
98
261
|
.header h1 { color: #f0f6fc; font-size: 1.5rem; font-weight: 700; margin-bottom: 0.4rem; }
|
|
99
|
-
.meta { font-size: 0.8rem; color: #8b949e; display: flex; flex-wrap: wrap; gap: 0.
|
|
100
|
-
|
|
101
|
-
|
|
262
|
+
.meta { font-size: 0.8rem; color: #8b949e; display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; }
|
|
263
|
+
|
|
264
|
+
/* ── Dashboard ── */
|
|
265
|
+
.dashboard { margin-bottom: 2rem; }
|
|
266
|
+
|
|
267
|
+
.dash-top {
|
|
268
|
+
display: grid;
|
|
269
|
+
grid-template-columns: 1fr 1fr;
|
|
270
|
+
gap: 0.75rem;
|
|
271
|
+
margin-bottom: 0.75rem;
|
|
272
|
+
}
|
|
273
|
+
.dash-score-panel, .dash-risk-panel {
|
|
102
274
|
background: #161b22;
|
|
103
275
|
border: 1px solid #30363d;
|
|
104
276
|
border-radius: 12px;
|
|
105
|
-
padding: 1.5rem
|
|
277
|
+
padding: 1.5rem;
|
|
106
278
|
display: flex;
|
|
107
279
|
align-items: center;
|
|
108
|
-
|
|
109
|
-
margin-bottom: 1.5rem;
|
|
110
|
-
flex-wrap: wrap;
|
|
280
|
+
justify-content: center;
|
|
111
281
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
282
|
+
|
|
283
|
+
/* Score ring */
|
|
284
|
+
.gauge-wrap { display: flex; align-items: center; justify-content: center; }
|
|
285
|
+
.score-ring {
|
|
286
|
+
width: 152px;
|
|
287
|
+
height: 152px;
|
|
288
|
+
border-radius: 50%;
|
|
289
|
+
padding: 11px;
|
|
290
|
+
display: flex;
|
|
291
|
+
align-items: center;
|
|
292
|
+
justify-content: center;
|
|
293
|
+
}
|
|
294
|
+
.score-inner {
|
|
295
|
+
width: 100%;
|
|
296
|
+
height: 100%;
|
|
297
|
+
border-radius: 50%;
|
|
298
|
+
background: #161b22;
|
|
299
|
+
display: flex;
|
|
300
|
+
flex-direction: column;
|
|
301
|
+
align-items: center;
|
|
302
|
+
justify-content: center;
|
|
303
|
+
gap: 0.4rem;
|
|
304
|
+
}
|
|
305
|
+
.score-num {
|
|
306
|
+
font-size: 2rem;
|
|
307
|
+
font-weight: 700;
|
|
116
308
|
line-height: 1;
|
|
309
|
+
font-family: 'Fira Code', monospace;
|
|
117
310
|
}
|
|
118
|
-
.score-
|
|
119
|
-
.grade
|
|
120
|
-
|
|
311
|
+
.score-num span { font-size: 0.75rem; color: #8b949e; font-weight: 400; }
|
|
312
|
+
.score-grade {
|
|
313
|
+
display: inline-flex;
|
|
314
|
+
align-items: center;
|
|
315
|
+
justify-content: center;
|
|
316
|
+
width: 1.75rem;
|
|
317
|
+
height: 1.75rem;
|
|
121
318
|
border-radius: 50%;
|
|
122
|
-
|
|
123
|
-
font-
|
|
319
|
+
font-size: 0.9rem;
|
|
320
|
+
font-weight: 800;
|
|
124
321
|
color: #fff;
|
|
125
|
-
background: ${gradeColor[result.grade] ?? '#64748b'};
|
|
126
322
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
323
|
+
|
|
324
|
+
/* Donut */
|
|
325
|
+
.donut-wrap { display: flex; align-items: center; gap: 1.5rem; }
|
|
326
|
+
.donut-legend { display: flex; flex-direction: column; gap: 0.45rem; }
|
|
327
|
+
.legend-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; color: #c9d1d9; }
|
|
328
|
+
.legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
|
|
329
|
+
.legend-count { margin-left: auto; font-weight: 700; color: #f0f6fc; padding-left: 1rem; }
|
|
330
|
+
|
|
331
|
+
/* KPI strip */
|
|
332
|
+
.kpi-strip {
|
|
333
|
+
display: grid;
|
|
334
|
+
grid-template-columns: repeat(4, 1fr);
|
|
335
|
+
gap: 0.75rem;
|
|
336
|
+
margin-bottom: 0.75rem;
|
|
337
|
+
}
|
|
338
|
+
.kpi-card {
|
|
339
|
+
background: #161b22;
|
|
340
|
+
border: 1px solid #30363d;
|
|
341
|
+
border-radius: 10px;
|
|
342
|
+
padding: 1rem 1.25rem;
|
|
343
|
+
}
|
|
344
|
+
.kpi-value { font-size: 2rem; font-weight: 800; line-height: 1; margin-bottom: 0.25rem; }
|
|
345
|
+
.kpi-label { font-size: 0.7rem; font-weight: 700; color: #8b949e; letter-spacing: 0.06em; }
|
|
346
|
+
|
|
347
|
+
/* Inventory grid */
|
|
348
|
+
.inv-grid {
|
|
349
|
+
display: grid;
|
|
350
|
+
grid-template-columns: repeat(2, 1fr);
|
|
351
|
+
gap: 0.75rem;
|
|
352
|
+
}
|
|
353
|
+
.inv-card {
|
|
354
|
+
background: #161b22;
|
|
355
|
+
border: 1px solid #30363d;
|
|
356
|
+
border-radius: 10px;
|
|
357
|
+
padding: 1rem 1.25rem;
|
|
358
|
+
}
|
|
359
|
+
.inv-card-title {
|
|
360
|
+
font-size: 0.7rem;
|
|
132
361
|
font-weight: 700;
|
|
133
|
-
color: #
|
|
362
|
+
color: #8b949e;
|
|
363
|
+
letter-spacing: 0.06em;
|
|
364
|
+
text-transform: uppercase;
|
|
365
|
+
margin-bottom: 0.6rem;
|
|
366
|
+
padding-bottom: 0.5rem;
|
|
367
|
+
border-bottom: 1px solid #21262d;
|
|
134
368
|
}
|
|
135
|
-
|
|
369
|
+
.metric-row {
|
|
370
|
+
display: flex;
|
|
371
|
+
align-items: center;
|
|
372
|
+
gap: 0.5rem;
|
|
373
|
+
padding: 0.28rem 0;
|
|
374
|
+
}
|
|
375
|
+
.metric-label { flex: 1; font-size: 0.82rem; color: #c9d1d9; }
|
|
376
|
+
.metric-right { display: flex; flex-direction: column; align-items: flex-end; gap: 0.2rem; min-width: 72px; }
|
|
377
|
+
.metric-value { font-size: 0.9rem; font-weight: 700; color: #f0f6fc; }
|
|
378
|
+
.prog-bar { width: 72px; height: 4px; background: #21262d; border-radius: 2px; overflow: hidden; }
|
|
379
|
+
.prog-fill { height: 100%; border-radius: 2px; }
|
|
380
|
+
|
|
381
|
+
/* ── Filters ── */
|
|
136
382
|
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; }
|
|
137
383
|
.filter-btn {
|
|
138
384
|
padding: 0.35rem 0.9rem;
|
|
@@ -151,7 +397,8 @@ export class HtmlRenderer {
|
|
|
151
397
|
border-color: var(--accent, #238636);
|
|
152
398
|
color: #fff;
|
|
153
399
|
}
|
|
154
|
-
|
|
400
|
+
|
|
401
|
+
/* ── Finding cards ── */
|
|
155
402
|
.finding-card {
|
|
156
403
|
background: var(--card-bg);
|
|
157
404
|
border: 1px solid #30363d;
|
|
@@ -185,7 +432,7 @@ export class HtmlRenderer {
|
|
|
185
432
|
.finding-category { font-size: 0.75rem; color: #8b949e; white-space: nowrap; }
|
|
186
433
|
.chevron { color: #8b949e; font-size: 1.2rem; transition: transform 0.2s; }
|
|
187
434
|
.finding-card[open] .chevron { transform: rotate(90deg); }
|
|
188
|
-
.finding-body { padding: 0 1rem 1rem
|
|
435
|
+
.finding-body { padding: 0 1rem 1rem; border-top: 1px solid #30363d; }
|
|
189
436
|
.finding-detail { color: #c9d1d9; font-size: 0.875rem; padding: 0.75rem 0 0.5rem; }
|
|
190
437
|
.remediation-box {
|
|
191
438
|
background: rgba(35,134,54,0.1);
|
|
@@ -196,10 +443,7 @@ export class HtmlRenderer {
|
|
|
196
443
|
font-size: 0.85rem;
|
|
197
444
|
}
|
|
198
445
|
.remediation-box strong { color: #3fb950; display: block; margin-bottom: 0.25rem; }
|
|
199
|
-
.affected-items {
|
|
200
|
-
margin-top: 0.75rem;
|
|
201
|
-
font-size: 0.82rem;
|
|
202
|
-
}
|
|
446
|
+
.affected-items { margin-top: 0.75rem; font-size: 0.82rem; }
|
|
203
447
|
.affected-items strong { color: #c9d1d9; display: block; margin-bottom: 0.5rem; }
|
|
204
448
|
.affected-table {
|
|
205
449
|
width: 100%;
|
|
@@ -226,8 +470,57 @@ export class HtmlRenderer {
|
|
|
226
470
|
.affected-table tr:last-child td { border-bottom: none; }
|
|
227
471
|
.affected-table a { color: #58a6ff; text-decoration: none; white-space: nowrap; }
|
|
228
472
|
.affected-table a:hover { text-decoration: underline; }
|
|
229
|
-
|
|
473
|
+
|
|
230
474
|
.no-findings { color: #8b949e; text-align: center; padding: 3rem 0; }
|
|
475
|
+
|
|
476
|
+
/* ── Compliance tags ── */
|
|
477
|
+
.compliance-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.5rem; }
|
|
478
|
+
.compliance-tag {
|
|
479
|
+
font-size: 0.65rem;
|
|
480
|
+
font-weight: 700;
|
|
481
|
+
padding: 0.1rem 0.45rem;
|
|
482
|
+
border-radius: 3px;
|
|
483
|
+
background: rgba(88,166,255,0.12);
|
|
484
|
+
border: 1px solid rgba(88,166,255,0.25);
|
|
485
|
+
color: #58a6ff;
|
|
486
|
+
letter-spacing: 0.03em;
|
|
487
|
+
white-space: nowrap;
|
|
488
|
+
}
|
|
489
|
+
/* ── Inconclusive findings ── */
|
|
490
|
+
.finding-card.is-inconclusive {
|
|
491
|
+
border-left-color: #8b949e !important;
|
|
492
|
+
opacity: 0.8;
|
|
493
|
+
}
|
|
494
|
+
.finding-card.is-inconclusive .finding-summary { background: rgba(139,148,158,0.05); }
|
|
495
|
+
.inconclusive-badge {
|
|
496
|
+
flex-shrink: 0;
|
|
497
|
+
padding: 0.15rem 0.6rem;
|
|
498
|
+
border-radius: 4px;
|
|
499
|
+
font-size: 0.7rem;
|
|
500
|
+
font-weight: 800;
|
|
501
|
+
color: #8b949e;
|
|
502
|
+
border: 1px dashed #8b949e;
|
|
503
|
+
letter-spacing: 0.04em;
|
|
504
|
+
}
|
|
505
|
+
/* ── Offline footer ── */
|
|
506
|
+
.offline-footer {
|
|
507
|
+
margin-top: 3rem;
|
|
508
|
+
padding: 0.75rem 1rem;
|
|
509
|
+
border-radius: 8px;
|
|
510
|
+
background: rgba(34,197,94,0.05);
|
|
511
|
+
border: 1px solid rgba(34,197,94,0.15);
|
|
512
|
+
font-size: 0.78rem;
|
|
513
|
+
color: #8b949e;
|
|
514
|
+
text-align: center;
|
|
515
|
+
}
|
|
516
|
+
.offline-footer strong { color: #3fb950; }
|
|
517
|
+
|
|
518
|
+
/* ── Responsive ── */
|
|
519
|
+
@media (max-width: 680px) {
|
|
520
|
+
.dash-top { grid-template-columns: 1fr; }
|
|
521
|
+
.kpi-strip { grid-template-columns: repeat(2, 1fr); }
|
|
522
|
+
.inv-grid { grid-template-columns: 1fr; }
|
|
523
|
+
}
|
|
231
524
|
</style>
|
|
232
525
|
</head>
|
|
233
526
|
<body>
|
|
@@ -242,11 +535,9 @@ export class HtmlRenderer {
|
|
|
242
535
|
</div>
|
|
243
536
|
</div>
|
|
244
537
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
<div class="summary-badges">${summaryBadges}</div>
|
|
249
|
-
</div>
|
|
538
|
+
${buildDashboard(result, counts)}
|
|
539
|
+
|
|
540
|
+
${attackPathsHtml}
|
|
250
541
|
|
|
251
542
|
<div class="filters">
|
|
252
543
|
${filterButtons}
|
|
@@ -258,7 +549,7 @@ export class HtmlRenderer {
|
|
|
258
549
|
|
|
259
550
|
<script>
|
|
260
551
|
const buttons = document.querySelectorAll('.filter-btn');
|
|
261
|
-
const cards
|
|
552
|
+
const cards = document.querySelectorAll('.finding-card');
|
|
262
553
|
|
|
263
554
|
buttons.forEach(btn => {
|
|
264
555
|
btn.addEventListener('click', () => {
|
|
@@ -271,6 +562,9 @@ export class HtmlRenderer {
|
|
|
271
562
|
});
|
|
272
563
|
});
|
|
273
564
|
</script>
|
|
565
|
+
<div class="offline-footer">
|
|
566
|
+
<strong>Offline-first audit</strong> — all analysis performed locally; no data is transmitted outside your Salesforce org. Generated by CloudCounsel SF Audit.
|
|
567
|
+
</div>
|
|
274
568
|
</body>
|
|
275
569
|
</html>`;
|
|
276
570
|
}
|
|
@@ -12,6 +12,29 @@ export class MarkdownRenderer {
|
|
|
12
12
|
lines.push(`**Instance:** ${result.instance} | **Type:** ${result.orgType}${result.isSandbox ? ' (Sandbox)' : ''}`);
|
|
13
13
|
lines.push(`**Health Score:** ${result.healthScore}/100 | **Grade:** ${result.grade}`);
|
|
14
14
|
lines.push('');
|
|
15
|
+
if (result.attackChains && result.attackChains.length > 0) {
|
|
16
|
+
lines.push(`## Attack Paths (${result.attackChains.length})`);
|
|
17
|
+
lines.push('');
|
|
18
|
+
lines.push('_Combinations of findings that together enable an exploit more severe than any single finding._');
|
|
19
|
+
lines.push('');
|
|
20
|
+
for (const c of result.attackChains) {
|
|
21
|
+
const conf = c.confidence === 'named' ? '' : ' _(potential)_';
|
|
22
|
+
lines.push(`### [${c.severity}] ${c.title}${conf}`);
|
|
23
|
+
lines.push('');
|
|
24
|
+
lines.push(c.narrative);
|
|
25
|
+
lines.push('');
|
|
26
|
+
lines.push('**Steps:**');
|
|
27
|
+
lines.push('');
|
|
28
|
+
c.steps.forEach((s, i) => {
|
|
29
|
+
lines.push(`${i + 1}. **${s.title ?? s.findingId}** (${s.severity ?? '—'}) — grants \`${s.capability}\``);
|
|
30
|
+
});
|
|
31
|
+
lines.push('');
|
|
32
|
+
lines.push(`**Remediation:** ${c.remediation}`);
|
|
33
|
+
lines.push('');
|
|
34
|
+
lines.push('---');
|
|
35
|
+
lines.push('');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
15
38
|
lines.push(`## Findings (${result.findings.length})`);
|
|
16
39
|
lines.push('');
|
|
17
40
|
if (result.findings.length === 0) {
|
|
@@ -19,12 +42,17 @@ export class MarkdownRenderer {
|
|
|
19
42
|
}
|
|
20
43
|
else {
|
|
21
44
|
for (const f of result.findings) {
|
|
22
|
-
|
|
45
|
+
const levelLabel = f.inconclusive ? 'INCONCLUSIVE' : f.riskLevel;
|
|
46
|
+
lines.push(`### [${levelLabel}] ${f.title}`);
|
|
23
47
|
lines.push(`**Category:** ${f.category}`);
|
|
24
48
|
lines.push('');
|
|
25
49
|
lines.push(f.detail);
|
|
26
50
|
lines.push('');
|
|
27
51
|
lines.push(`**Remediation:** ${f.remediation}`);
|
|
52
|
+
if (f.complianceTags?.length) {
|
|
53
|
+
lines.push('');
|
|
54
|
+
lines.push(`**Compliance:** ${f.complianceTags.join(' · ')}`);
|
|
55
|
+
}
|
|
28
56
|
if (f.affectedItems?.length) {
|
|
29
57
|
const hasUrls = f.affectedItems.some((i) => i.url);
|
|
30
58
|
const hasNotes = f.affectedItems.some((i) => i.note);
|
|
@@ -48,6 +76,11 @@ export class MarkdownRenderer {
|
|
|
48
76
|
lines.push('');
|
|
49
77
|
}
|
|
50
78
|
}
|
|
79
|
+
lines.push('');
|
|
80
|
+
lines.push('---');
|
|
81
|
+
lines.push('');
|
|
82
|
+
lines.push('> **Offline-first audit** — all analysis is performed locally; no data is transmitted outside your Salesforce org. Generated by CloudCounsel SF Audit.');
|
|
83
|
+
lines.push('');
|
|
51
84
|
return lines.join('\n');
|
|
52
85
|
}
|
|
53
86
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AuditResult } from '../findings/AuditResult.js';
|
|
2
|
+
import type { Finding } from '../findings/Finding.js';
|
|
3
|
+
import type { ControlDef, Framework } from '../compliance/types.js';
|
|
4
|
+
export interface MatrixRow {
|
|
5
|
+
control: ControlDef;
|
|
6
|
+
findings: Finding[];
|
|
7
|
+
}
|
|
8
|
+
export interface FrameworkMatrix {
|
|
9
|
+
framework: Framework;
|
|
10
|
+
version: string;
|
|
11
|
+
rows: MatrixRow[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Invert the check→control mapping into framework→control→findings, for verified controls
|
|
15
|
+
* in the selected frameworks only. A control is "in scope" if any check maps to it; its row
|
|
16
|
+
* carries the active (non-passed, non-inconclusive) findings whose check maps to that control.
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildComplianceMatrix(result: AuditResult, frameworks: Framework[]): FrameworkMatrix[];
|
|
19
|
+
//# sourceMappingURL=ComplianceMatrix.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { CHECK_CONTROL_MAP } from '../compliance/mapping.js';
|
|
2
|
+
import { getControl } from '../compliance/catalogs/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Invert the check→control mapping into framework→control→findings, for verified controls
|
|
5
|
+
* in the selected frameworks only. A control is "in scope" if any check maps to it; its row
|
|
6
|
+
* carries the active (non-passed, non-inconclusive) findings whose check maps to that control.
|
|
7
|
+
*/
|
|
8
|
+
export function buildComplianceMatrix(result, frameworks) {
|
|
9
|
+
const fwSet = new Set(frameworks);
|
|
10
|
+
const active = result.findings.filter((f) => !f.passed && !f.inconclusive);
|
|
11
|
+
const inScope = new Map();
|
|
12
|
+
const hits = new Map();
|
|
13
|
+
for (const controlIds of Object.values(CHECK_CONTROL_MAP)) {
|
|
14
|
+
for (const id of controlIds) {
|
|
15
|
+
const c = getControl(id);
|
|
16
|
+
if (!c || !c.verified || !fwSet.has(c.framework))
|
|
17
|
+
continue;
|
|
18
|
+
inScope.set(id, c);
|
|
19
|
+
if (!hits.has(id))
|
|
20
|
+
hits.set(id, []);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
for (const f of active) {
|
|
24
|
+
if (!f.checkId)
|
|
25
|
+
continue;
|
|
26
|
+
for (const id of CHECK_CONTROL_MAP[f.checkId] ?? []) {
|
|
27
|
+
if (hits.has(id))
|
|
28
|
+
hits.get(id).push(f);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const byFw = new Map();
|
|
32
|
+
for (const [id, control] of inScope) {
|
|
33
|
+
const rows = byFw.get(control.framework) ?? [];
|
|
34
|
+
rows.push({ control, findings: hits.get(id) ?? [] });
|
|
35
|
+
byFw.set(control.framework, rows);
|
|
36
|
+
}
|
|
37
|
+
const out = [];
|
|
38
|
+
for (const fw of frameworks) {
|
|
39
|
+
const rows = byFw.get(fw);
|
|
40
|
+
if (!rows || rows.length === 0)
|
|
41
|
+
continue;
|
|
42
|
+
rows.sort((a, b) => a.control.id.localeCompare(b.control.id, undefined, { numeric: true }));
|
|
43
|
+
out.push({ framework: fw, version: rows[0].control.version, rows });
|
|
44
|
+
}
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=ComplianceMatrix.js.map
|