@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.
Files changed (196) hide show
  1. package/README.md +228 -31
  2. package/lib/api/ToolingClientImpl.js +5 -2
  3. package/lib/chains/AttackChain.d.ts +20 -0
  4. package/lib/chains/AttackChain.js +2 -0
  5. package/lib/chains/Capability.d.ts +7 -0
  6. package/lib/chains/Capability.js +11 -0
  7. package/lib/chains/CapabilityRegistry.d.ts +18 -0
  8. package/lib/chains/CapabilityRegistry.js +53 -0
  9. package/lib/chains/ChainEngine.d.ts +13 -0
  10. package/lib/chains/ChainEngine.js +137 -0
  11. package/lib/chains/namedChains.d.ts +14 -0
  12. package/lib/chains/namedChains.js +99 -0
  13. package/lib/checks/CheckEngine.js +33 -5
  14. package/lib/checks/impl/AnonymousApexAuditCheck.d.ts +10 -0
  15. package/lib/checks/impl/AnonymousApexAuditCheck.js +106 -0
  16. package/lib/checks/impl/ApexCrudFLSCheck.d.ts +11 -0
  17. package/lib/checks/impl/ApexCrudFLSCheck.js +98 -0
  18. package/lib/checks/impl/ApexLoggingCheck.d.ts +11 -0
  19. package/lib/checks/impl/ApexLoggingCheck.js +124 -0
  20. package/lib/checks/impl/ApexRestEndpointCheck.d.ts +11 -0
  21. package/lib/checks/impl/ApexRestEndpointCheck.js +94 -0
  22. package/lib/checks/impl/ApexSharingCheck.js +29 -0
  23. package/lib/checks/impl/ApiClientPermissionCheck.d.ts +10 -0
  24. package/lib/checks/impl/ApiClientPermissionCheck.js +59 -0
  25. package/lib/checks/impl/AuditTrailCheck.js +29 -0
  26. package/lib/checks/impl/CertificateExpiryCheck.d.ts +10 -0
  27. package/lib/checks/impl/CertificateExpiryCheck.js +123 -0
  28. package/lib/checks/impl/CodeSecurityCheck.d.ts +2 -1
  29. package/lib/checks/impl/CodeSecurityCheck.js +46 -6
  30. package/lib/checks/impl/ConnectedAppInactivityCheck.d.ts +11 -0
  31. package/lib/checks/impl/ConnectedAppInactivityCheck.js +86 -0
  32. package/lib/checks/impl/ConnectedAppScopeCheck.d.ts +10 -0
  33. package/lib/checks/impl/ConnectedAppScopeCheck.js +125 -0
  34. package/lib/checks/impl/ConnectedAppsCheck.d.ts +1 -0
  35. package/lib/checks/impl/ConnectedAppsCheck.js +37 -2
  36. package/lib/checks/impl/ContentLinksCheck.d.ts +10 -0
  37. package/lib/checks/impl/ContentLinksCheck.js +115 -0
  38. package/lib/checks/impl/CorsAllowlistCheck.d.ts +10 -0
  39. package/lib/checks/impl/CorsAllowlistCheck.js +80 -0
  40. package/lib/checks/impl/CspTrustedSitesCheck.d.ts +10 -0
  41. package/lib/checks/impl/CspTrustedSitesCheck.js +55 -0
  42. package/lib/checks/impl/CustomLabelsCredentialCheck.d.ts +10 -0
  43. package/lib/checks/impl/CustomLabelsCredentialCheck.js +97 -0
  44. package/lib/checks/impl/DataClassificationCheck.d.ts +10 -0
  45. package/lib/checks/impl/DataClassificationCheck.js +112 -0
  46. package/lib/checks/impl/DebugLogAccessCheck.d.ts +10 -0
  47. package/lib/checks/impl/DebugLogAccessCheck.js +81 -0
  48. package/lib/checks/impl/DeploymentIdentityCheck.d.ts +11 -0
  49. package/lib/checks/impl/DeploymentIdentityCheck.js +144 -0
  50. package/lib/checks/impl/EnhancedDomainsCheck.d.ts +10 -0
  51. package/lib/checks/impl/EnhancedDomainsCheck.js +84 -0
  52. package/lib/checks/impl/EscalationPermsCheck.d.ts +10 -0
  53. package/lib/checks/impl/EscalationPermsCheck.js +77 -0
  54. package/lib/checks/impl/EventMonitoringCheck.d.ts +11 -0
  55. package/lib/checks/impl/EventMonitoringCheck.js +84 -0
  56. package/lib/checks/impl/ExperienceCloudSiteCheck.d.ts +10 -0
  57. package/lib/checks/impl/ExperienceCloudSiteCheck.js +91 -0
  58. package/lib/checks/impl/FailedLoginCheck.d.ts +10 -0
  59. package/lib/checks/impl/FailedLoginCheck.js +122 -0
  60. package/lib/checks/impl/FieldHistoryTrackingCheck.d.ts +10 -0
  61. package/lib/checks/impl/FieldHistoryTrackingCheck.js +70 -0
  62. package/lib/checks/impl/FieldLevelSecurityCheck.js +28 -18
  63. package/lib/checks/impl/GuestExecutableApexCheck.d.ts +11 -0
  64. package/lib/checks/impl/GuestExecutableApexCheck.js +93 -0
  65. package/lib/checks/impl/GuestUserAccessCheck.js +74 -66
  66. package/lib/checks/impl/HardcodedCredentialsCheck.js +2 -2
  67. package/lib/checks/impl/HighAssuranceSessionCheck.d.ts +10 -0
  68. package/lib/checks/impl/HighAssuranceSessionCheck.js +103 -0
  69. package/lib/checks/impl/InactiveUsersCheck.js +38 -19
  70. package/lib/checks/impl/InstalledPackagesCheck.d.ts +10 -0
  71. package/lib/checks/impl/InstalledPackagesCheck.js +94 -0
  72. package/lib/checks/impl/IntegrationUsersCheck.d.ts +10 -0
  73. package/lib/checks/impl/IntegrationUsersCheck.js +108 -0
  74. package/lib/checks/impl/InternalUserMfaCheck.d.ts +10 -0
  75. package/lib/checks/impl/InternalUserMfaCheck.js +81 -0
  76. package/lib/checks/impl/IpRestrictionsCheck.js +86 -23
  77. package/lib/checks/impl/LegacyApiVersionCheck.d.ts +10 -0
  78. package/lib/checks/impl/LegacyApiVersionCheck.js +91 -0
  79. package/lib/checks/impl/MfaEnforcementCheck.d.ts +10 -0
  80. package/lib/checks/impl/MfaEnforcementCheck.js +76 -0
  81. package/lib/checks/impl/MfaMethodStrengthCheck.d.ts +11 -0
  82. package/lib/checks/impl/MfaMethodStrengthCheck.js +116 -0
  83. package/lib/checks/impl/MfaRegistrationCheck.d.ts +11 -0
  84. package/lib/checks/impl/MfaRegistrationCheck.js +95 -0
  85. package/lib/checks/impl/MyDomainLoginPolicyCheck.d.ts +10 -0
  86. package/lib/checks/impl/MyDomainLoginPolicyCheck.js +105 -0
  87. package/lib/checks/impl/NamedCredentialsCheck.js +37 -2
  88. package/lib/checks/impl/PermissionsCheck.js +67 -14
  89. package/lib/checks/impl/PublicGroupSharingCheck.js +20 -9
  90. package/lib/checks/impl/ReleaseUpdatesCheck.d.ts +10 -0
  91. package/lib/checks/impl/ReleaseUpdatesCheck.js +106 -0
  92. package/lib/checks/impl/ReportFolderAccessCheck.d.ts +10 -0
  93. package/lib/checks/impl/ReportFolderAccessCheck.js +54 -0
  94. package/lib/checks/impl/ScheduledApexCheck.d.ts +1 -0
  95. package/lib/checks/impl/ScheduledApexCheck.js +3 -0
  96. package/lib/checks/impl/SharingModelCheck.d.ts +1 -1
  97. package/lib/checks/impl/SharingModelCheck.js +103 -32
  98. package/lib/checks/impl/SiemIntegrationCheck.d.ts +11 -0
  99. package/lib/checks/impl/SiemIntegrationCheck.js +102 -0
  100. package/lib/checks/impl/SsoEnforcementCheck.d.ts +10 -0
  101. package/lib/checks/impl/SsoEnforcementCheck.js +90 -0
  102. package/lib/checks/impl/StandardProfilesCheck.d.ts +10 -0
  103. package/lib/checks/impl/StandardProfilesCheck.js +68 -0
  104. package/lib/checks/impl/TransactionSecurityPolicyCheck.d.ts +10 -0
  105. package/lib/checks/impl/TransactionSecurityPolicyCheck.js +62 -0
  106. package/lib/checks/impl/TrustedIPRangesCheck.d.ts +10 -0
  107. package/lib/checks/impl/TrustedIPRangesCheck.js +106 -0
  108. package/lib/checks/impl/UsersAndAdminsCheck.js +50 -20
  109. package/lib/checks/impl/VisualforceXssCheck.d.ts +11 -0
  110. package/lib/checks/impl/VisualforceXssCheck.js +150 -0
  111. package/lib/checks/registry.js +97 -12
  112. package/lib/commands/audit/diff.d.ts +17 -0
  113. package/lib/commands/audit/diff.js +76 -0
  114. package/lib/commands/audit/history.d.ts +15 -0
  115. package/lib/commands/audit/history.js +59 -0
  116. package/lib/commands/audit/security.d.ts +5 -0
  117. package/lib/commands/audit/security.js +38 -9
  118. package/lib/compliance/catalogs/hiso10029.d.ts +3 -0
  119. package/lib/compliance/catalogs/hiso10029.js +35 -0
  120. package/lib/compliance/catalogs/index.d.ts +4 -0
  121. package/lib/compliance/catalogs/index.js +21 -0
  122. package/lib/compliance/catalogs/iso27001.d.ts +3 -0
  123. package/lib/compliance/catalogs/iso27001.js +39 -0
  124. package/lib/compliance/catalogs/nzism.d.ts +3 -0
  125. package/lib/compliance/catalogs/nzism.js +31 -0
  126. package/lib/compliance/catalogs/owasp.d.ts +3 -0
  127. package/lib/compliance/catalogs/owasp.js +37 -0
  128. package/lib/compliance/catalogs/privacyAct.d.ts +3 -0
  129. package/lib/compliance/catalogs/privacyAct.js +17 -0
  130. package/lib/compliance/catalogs/sbs.d.ts +3 -0
  131. package/lib/compliance/catalogs/sbs.js +61 -0
  132. package/lib/compliance/catalogs/soc2.d.ts +3 -0
  133. package/lib/compliance/catalogs/soc2.js +42 -0
  134. package/lib/compliance/mapping.d.ts +2 -0
  135. package/lib/compliance/mapping.js +111 -0
  136. package/lib/compliance/resolve.d.ts +12 -0
  137. package/lib/compliance/resolve.js +49 -0
  138. package/lib/compliance/types.d.ts +13 -0
  139. package/lib/compliance/types.js +2 -0
  140. package/lib/context/AuditCache.d.ts +20 -0
  141. package/lib/context/AuditContext.d.ts +0 -2
  142. package/lib/findings/AuditResult.d.ts +3 -0
  143. package/lib/findings/CheckMeta.d.ts +9 -0
  144. package/lib/findings/CheckMeta.js +67 -0
  145. package/lib/findings/ComplianceMapping.d.ts +3 -0
  146. package/lib/findings/ComplianceMapping.js +75 -0
  147. package/lib/findings/Finding.d.ts +20 -0
  148. package/lib/findings/loadScoringConfig.js +9 -2
  149. package/lib/findings/scoring.d.ts +2 -1
  150. package/lib/findings/scoring.js +20 -7
  151. package/lib/history/AuditDiff.d.ts +26 -0
  152. package/lib/history/AuditDiff.js +2 -0
  153. package/lib/history/DiffEngine.d.ts +4 -0
  154. package/lib/history/DiffEngine.js +61 -0
  155. package/lib/history/HistoryStore.d.ts +11 -0
  156. package/lib/history/HistoryStore.js +56 -0
  157. package/lib/history/metricMeta.d.ts +9 -0
  158. package/lib/history/metricMeta.js +28 -0
  159. package/lib/index.d.ts +7 -1
  160. package/lib/index.js +2 -1
  161. package/lib/lib/wire.d.ts +1 -2
  162. package/lib/lib/wire.js +1 -2
  163. package/lib/renderers/AuditRenderer.d.ts +2 -0
  164. package/lib/renderers/ClientReportRenderer.d.ts +29 -0
  165. package/lib/renderers/ClientReportRenderer.js +205 -0
  166. package/lib/renderers/DiffHtmlRenderer.d.ts +8 -0
  167. package/lib/renderers/DiffHtmlRenderer.js +164 -0
  168. package/lib/renderers/DiffJsonRenderer.d.ts +8 -0
  169. package/lib/renderers/DiffJsonRenderer.js +8 -0
  170. package/lib/renderers/DiffRenderer.d.ts +7 -0
  171. package/lib/renderers/DiffRenderer.js +2 -0
  172. package/lib/renderers/HistoryRenderer.d.ts +6 -0
  173. package/lib/renderers/HistoryRenderer.js +140 -0
  174. package/lib/renderers/HtmlRenderer.d.ts +1 -0
  175. package/lib/renderers/HtmlRenderer.js +354 -60
  176. package/lib/renderers/MarkdownRenderer.js +34 -1
  177. package/lib/renderers/html-utils.d.ts +2 -0
  178. package/lib/renderers/html-utils.js +8 -0
  179. package/lib/report/ComplianceMatrix.d.ts +19 -0
  180. package/lib/report/ComplianceMatrix.js +47 -0
  181. package/lib/report/ExecutivePriorities.d.ts +8 -0
  182. package/lib/report/ExecutivePriorities.js +22 -0
  183. package/lib/report/RemediationRoadmap.d.ts +9 -0
  184. package/lib/report/RemediationRoadmap.js +18 -0
  185. package/lib/report/branding.d.ts +18 -0
  186. package/lib/report/branding.js +19 -0
  187. package/lib/report/fonts.d.ts +2 -0
  188. package/lib/report/fonts.js +22 -0
  189. package/package.json +4 -3
  190. package/src/assets/fonts/dm-sans-italic-latin.woff2 +0 -0
  191. package/src/assets/fonts/dm-sans-normal-latin.woff2 +0 -0
  192. package/src/assets/fonts/dm-serif-display-italic-latin.woff2 +0 -0
  193. package/src/assets/fonts/dm-serif-display-normal-latin.woff2 +0 -0
  194. package/config/queries/soql.json +0 -24
  195. package/config/queries/tooling.json +0 -28
  196. package/config/scoring.json +0 -17
@@ -0,0 +1,61 @@
1
+ import { METRIC_META, metricDirection } from './metricMeta.js';
2
+ function detailChanged(a, b) {
3
+ return (a.detail !== b.detail ||
4
+ a.remediation !== b.remediation ||
5
+ JSON.stringify(a.affectedItems) !== JSON.stringify(b.affectedItems));
6
+ }
7
+ export function computeDiff(baseline, current) {
8
+ const baselineMap = new Map(baseline.findings.map((f) => [f.id, f]));
9
+ const currentMap = new Map(current.findings.map((f) => [f.id, f]));
10
+ const findingChanges = [];
11
+ // Walk current findings
12
+ for (const [id, cur] of currentMap) {
13
+ const prev = baselineMap.get(id);
14
+ if (!prev) {
15
+ findingChanges.push({ type: 'new', finding: cur });
16
+ }
17
+ else if (cur.riskLevel !== prev.riskLevel) {
18
+ findingChanges.push({ type: 'severity-changed', finding: cur, previous: prev });
19
+ }
20
+ else if (detailChanged(prev, cur)) {
21
+ findingChanges.push({ type: 'detail-changed', finding: cur, previous: prev });
22
+ }
23
+ else {
24
+ findingChanges.push({ type: 'unchanged', finding: cur });
25
+ }
26
+ }
27
+ // Resolved: in baseline but not in current
28
+ for (const [id, prev] of baselineMap) {
29
+ if (!currentMap.has(id)) {
30
+ findingChanges.push({ type: 'resolved', finding: prev });
31
+ }
32
+ }
33
+ // Metric deltas — only emit when before !== after
34
+ const metricDeltas = [];
35
+ for (const key of Object.keys(METRIC_META)) {
36
+ const before = baseline.metrics[key];
37
+ const after = current.metrics[key];
38
+ if (before === after)
39
+ continue;
40
+ metricDeltas.push({
41
+ key,
42
+ label: METRIC_META[key].label,
43
+ before,
44
+ after,
45
+ delta: after - before,
46
+ direction: metricDirection(key, before, after),
47
+ });
48
+ }
49
+ const gradeDelta = baseline.grade === current.grade
50
+ ? 'unchanged'
51
+ : `${baseline.grade} → ${current.grade}`;
52
+ return {
53
+ baseline,
54
+ current,
55
+ findingChanges,
56
+ metricDeltas,
57
+ scoreDelta: current.healthScore - baseline.healthScore,
58
+ gradeDelta,
59
+ };
60
+ }
61
+ //# sourceMappingURL=DiffEngine.js.map
@@ -0,0 +1,11 @@
1
+ import type { AuditResult } from '../findings/AuditResult.js';
2
+ export declare class HistoryStore {
3
+ private readonly root;
4
+ constructor(root?: string);
5
+ static defaultRoot(): string;
6
+ archive(result: AuditResult): void;
7
+ list(orgId: string, dir?: string): AuditResult[];
8
+ latest(orgId: string, dir?: string): AuditResult | null;
9
+ load(filePath: string): AuditResult;
10
+ }
11
+ //# sourceMappingURL=HistoryStore.d.ts.map
@@ -0,0 +1,56 @@
1
+ // src/history/HistoryStore.ts
2
+ import * as fs from 'node:fs';
3
+ import * as os from 'node:os';
4
+ import * as path from 'node:path';
5
+ function parseResult(raw) {
6
+ const obj = JSON.parse(raw);
7
+ obj.generatedAt = new Date(obj.generatedAt);
8
+ return obj;
9
+ }
10
+ export class HistoryStore {
11
+ root;
12
+ constructor(root) {
13
+ this.root = root ?? HistoryStore.defaultRoot();
14
+ }
15
+ static defaultRoot() {
16
+ return path.join(os.homedir(), '.sf', 'audit-history');
17
+ }
18
+ archive(result) {
19
+ try {
20
+ const dir = path.join(this.root, result.orgId);
21
+ fs.mkdirSync(dir, { recursive: true });
22
+ const suffix = Math.random().toString(36).slice(2, 8);
23
+ const filename = `sf-audit-${result.orgId}-${Date.now()}-${suffix}.json`;
24
+ fs.writeFileSync(path.join(dir, filename), JSON.stringify(result, null, 2), 'utf-8');
25
+ }
26
+ catch (err) {
27
+ process.stderr.write(`[sf-audit] Warning: could not archive audit result: ${String(err)}\n`);
28
+ }
29
+ }
30
+ list(orgId, dir) {
31
+ const searchDir = dir ? path.join(dir, orgId) : path.join(this.root, orgId);
32
+ if (!fs.existsSync(searchDir))
33
+ return [];
34
+ const files = fs.readdirSync(searchDir)
35
+ .filter((f) => f.startsWith('sf-audit-') && f.endsWith('.json'))
36
+ .map((f) => path.join(searchDir, f));
37
+ const results = [];
38
+ for (const file of files) {
39
+ try {
40
+ results.push(parseResult(fs.readFileSync(file, 'utf-8')));
41
+ }
42
+ catch {
43
+ // skip unparseable files silently
44
+ }
45
+ }
46
+ return results.sort((a, b) => a.generatedAt.getTime() - b.generatedAt.getTime());
47
+ }
48
+ latest(orgId, dir) {
49
+ const all = this.list(orgId, dir);
50
+ return all.length > 0 ? all[all.length - 1] : null;
51
+ }
52
+ load(filePath) {
53
+ return parseResult(fs.readFileSync(filePath, 'utf-8'));
54
+ }
55
+ }
56
+ //# sourceMappingURL=HistoryStore.js.map
@@ -0,0 +1,9 @@
1
+ import type { OrgMetrics } from '../context/OrgMetrics.js';
2
+ export interface MetricMeta {
3
+ label: string;
4
+ /** Which direction means "getting better"? */
5
+ improvedWhen: 'higher' | 'lower' | 'neutral';
6
+ }
7
+ export declare const METRIC_META: Record<keyof OrgMetrics, MetricMeta>;
8
+ export declare function metricDirection(key: keyof OrgMetrics, before: number, after: number): 'improved' | 'degraded' | 'neutral';
9
+ //# sourceMappingURL=metricMeta.d.ts.map
@@ -0,0 +1,28 @@
1
+ // Every key of OrgMetrics must have an entry here.
2
+ export const METRIC_META = {
3
+ totalActiveUsers: { label: 'Total Active Users', improvedWhen: 'neutral' },
4
+ modifyAllDataUsersCount: { label: 'Modify All Data Users', improvedWhen: 'lower' },
5
+ viewAllDataUsersCount: { label: 'View All Data Users', improvedWhen: 'lower' },
6
+ permissionSetCount: { label: 'Permission Sets', improvedWhen: 'neutral' },
7
+ profileCount: { label: 'Profiles', improvedWhen: 'neutral' },
8
+ apexClassCount: { label: 'Apex Classes', improvedWhen: 'neutral' },
9
+ apexTriggerCount: { label: 'Apex Triggers', improvedWhen: 'neutral' },
10
+ codeCoveragePercent: { label: 'Code Coverage %', improvedWhen: 'higher' },
11
+ failedLogins30d: { label: 'Failed Logins (30d)', improvedWhen: 'lower' },
12
+ inactiveUsers90d: { label: 'Inactive Users (90d)', improvedWhen: 'lower' },
13
+ connectedAppsCount: { label: 'Connected Apps', improvedWhen: 'neutral' },
14
+ remoteSitesCount: { label: 'Remote Site Settings', improvedWhen: 'neutral' },
15
+ insecureRemoteSitesCount: { label: 'Insecure Remote Sites', improvedWhen: 'lower' },
16
+ namedCredentialsCount: { label: 'Named Credentials', improvedWhen: 'neutral' },
17
+ unusedNamedCredentialsCount: { label: 'Unused Named Credentials', improvedWhen: 'lower' },
18
+ healthCheckScore: { label: 'Health Check Score', improvedWhen: 'higher' },
19
+ };
20
+ export function metricDirection(key, before, after) {
21
+ const meta = METRIC_META[key];
22
+ if (meta.improvedWhen === 'neutral' || before === after)
23
+ return 'neutral';
24
+ if (meta.improvedWhen === 'higher')
25
+ return after > before ? 'improved' : 'degraded';
26
+ return after < before ? 'improved' : 'degraded';
27
+ }
28
+ //# sourceMappingURL=metricMeta.js.map
package/lib/index.d.ts CHANGED
@@ -1,2 +1,8 @@
1
- export {};
1
+ export type { AuditResult } from './findings/AuditResult.js';
2
+ export type { Finding } from './findings/Finding.js';
3
+ export type { RiskLevel } from './findings/RiskLevel.js';
4
+ export type { OrgMetrics } from './context/OrgMetrics.js';
5
+ export type { AuditDiff, FindingChange, FindingChangeType, MetricDelta } from './history/AuditDiff.js';
6
+ export { HistoryStore } from './history/HistoryStore.js';
7
+ export { computeDiff } from './history/DiffEngine.js';
2
8
  //# sourceMappingURL=index.d.ts.map
package/lib/index.js CHANGED
@@ -1,2 +1,3 @@
1
- export {};
1
+ export { HistoryStore } from './history/HistoryStore.js';
2
+ export { computeDiff } from './history/DiffEngine.js';
2
3
  //# sourceMappingURL=index.js.map
package/lib/lib/wire.d.ts CHANGED
@@ -4,12 +4,11 @@ import { ToolingClientImpl } from '../api/ToolingClientImpl.js';
4
4
  import { RestClientImpl } from '../api/RestClientImpl.js';
5
5
  import type { AuditContext } from '../context/AuditContext.js';
6
6
  import type { OrgInfo } from '../context/OrgInfo.js';
7
- import type { QueryRegistry } from '../queries/QueryRegistry.js';
8
7
  export declare function buildApiClients(conn: Connection): {
9
8
  soql: SoqlClientImpl;
10
9
  tooling: ToolingClientImpl;
11
10
  rest: RestClientImpl;
12
11
  };
13
12
  export declare function resolveOrgInfo(conn: Connection): Promise<OrgInfo>;
14
- export declare function buildAuditContext(conn: Connection, queries: QueryRegistry, orgInfo: OrgInfo): AuditContext;
13
+ export declare function buildAuditContext(conn: Connection, orgInfo: OrgInfo): AuditContext;
15
14
  //# sourceMappingURL=wire.d.ts.map
package/lib/lib/wire.js CHANGED
@@ -22,13 +22,12 @@ export async function resolveOrgInfo(conn) {
22
22
  instanceUrl: conn.instanceUrl,
23
23
  };
24
24
  }
25
- export function buildAuditContext(conn, queries, orgInfo) {
25
+ export function buildAuditContext(conn, orgInfo) {
26
26
  const clients = buildApiClients(conn);
27
27
  return {
28
28
  soql: clients.soql,
29
29
  tooling: clients.tooling,
30
30
  rest: clients.rest,
31
- queries,
32
31
  orgInfo,
33
32
  cache: {},
34
33
  };
@@ -2,6 +2,8 @@ import type { AuditResult } from '../findings/AuditResult.js';
2
2
  export interface AuditRenderer {
3
3
  readonly format: string;
4
4
  readonly fileExtension: string;
5
+ /** When set, used instead of 'sf-audit' for the output filename (avoids collisions between renderers sharing an extension). */
6
+ readonly filenamePrefix?: string;
5
7
  render(result: AuditResult): string;
6
8
  }
7
9
  //# sourceMappingURL=AuditRenderer.d.ts.map
@@ -0,0 +1,29 @@
1
+ import type { AuditResult } from '../findings/AuditResult.js';
2
+ import type { AuditRenderer } from './AuditRenderer.js';
3
+ import type { Branding } from '../report/branding.js';
4
+ import type { Framework } from '../compliance/types.js';
5
+ export interface ClientReportOptions {
6
+ branding: Branding;
7
+ topN: number;
8
+ frameworks: Framework[];
9
+ }
10
+ export declare class ClientReportRenderer implements AuditRenderer {
11
+ private readonly opts;
12
+ readonly format = "executive";
13
+ readonly fileExtension = ".html";
14
+ readonly filenamePrefix = "SF_Audit_Executive";
15
+ constructor(opts: ClientReportOptions);
16
+ render(result: AuditResult): string;
17
+ private chip;
18
+ private sectionHead;
19
+ private cover;
20
+ private summary;
21
+ private prioritiesSection;
22
+ private scenarios;
23
+ private roadmapSection;
24
+ private worst;
25
+ private matrixSection;
26
+ private findingsAppendix;
27
+ private footer;
28
+ }
29
+ //# sourceMappingURL=ClientReportRenderer.d.ts.map
@@ -0,0 +1,205 @@
1
+ import { esc } from './html-utils.js';
2
+ import { fontFaceCss } from '../report/fonts.js';
3
+ import { getCheckMeta } from '../findings/CheckMeta.js';
4
+ import { selectPriorities } from '../report/ExecutivePriorities.js';
5
+ import { buildRoadmap } from '../report/RemediationRoadmap.js';
6
+ import { buildComplianceMatrix } from '../report/ComplianceMatrix.js';
7
+ const SEV_COLOR = {
8
+ CRITICAL: '#7d3a3a', HIGH: '#a35a2a', MEDIUM: '#8a6d1f', LOW: '#3a5a82', INFO: '#636770',
9
+ };
10
+ const SEV_RANK = { CRITICAL: 0, HIGH: 1, MEDIUM: 2, LOW: 3, INFO: 4 };
11
+ const GRADE_COLOR = {
12
+ A: '#4a7d5e', B: '#4a7d5e', C: '#8a6d1f', D: '#a35a2a', F: '#7d3a3a',
13
+ };
14
+ const SEV_ORDER = ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'];
15
+ const FRAMEWORK_LABEL = {
16
+ OWASP: 'OWASP Top 10', SOC2: 'SOC 2', ISO27001: 'ISO/IEC 27001',
17
+ SBS: 'Security Benchmark for Salesforce', PRIVACY_ACT: 'NZ Privacy Act',
18
+ HISO10029: 'HISO 10029', NZISM: 'NZISM', HIPAA: 'HIPAA', GDPR: 'GDPR',
19
+ };
20
+ export class ClientReportRenderer {
21
+ opts;
22
+ format = 'executive';
23
+ fileExtension = '.html';
24
+ filenamePrefix = 'SF_Audit_Executive';
25
+ constructor(opts) {
26
+ this.opts = opts;
27
+ }
28
+ render(result) {
29
+ const b = this.opts.branding;
30
+ const chains = result.attackChains ?? [];
31
+ const chainIds = new Set();
32
+ for (const c of chains)
33
+ for (const s of c.steps)
34
+ chainIds.add(s.findingId);
35
+ const priorities = selectPriorities(result.findings, chainIds, this.opts.topN);
36
+ const roadmap = buildRoadmap(result.findings);
37
+ const matrix = buildComplianceMatrix(result, this.opts.frameworks);
38
+ let n = 0;
39
+ const num = () => String(++n).padStart(2, '0');
40
+ const sections = [
41
+ this.summary(result, num()),
42
+ this.prioritiesSection(priorities, chainIds, num()),
43
+ chains.length ? this.scenarios(chains, num()) : '',
44
+ this.roadmapSection(roadmap, num()),
45
+ matrix.length ? this.matrixSection(matrix, num()) : '',
46
+ this.findingsAppendix(result, num()),
47
+ ].join('\n');
48
+ return `<!DOCTYPE html>
49
+ <html lang="en"><head><meta charset="utf-8"><title>Security Audit — ${esc(result.orgName)}</title>
50
+ <style>${fontFaceCss()}
51
+ :root{--ink:${b.ink};--bg:${b.bg};--bgalt:${b.bgAlt};--muted:${b.muted};--border:${b.border};--primary:${b.primary};
52
+ --display:'${b.fontDisplay}',Georgia,serif;--body:'${b.fontBody}',system-ui,sans-serif;--mono:ui-monospace,'SF Mono',Menlo,monospace;}
53
+ *{box-sizing:border-box}
54
+ html{-webkit-print-color-adjust:exact;print-color-adjust:exact}
55
+ body{font-family:var(--body);color:var(--ink);background:var(--bg);margin:0;line-height:1.6;font-variant-numeric:tabular-nums}
56
+ .wrap{max-width:780px;margin:0 auto;padding:64px 44px}
57
+ h1{font-family:var(--display);font-size:clamp(38px,6vw,52px);line-height:1.02;letter-spacing:-0.02em;margin:6px 0 0}
58
+ h2{font-family:var(--display);font-size:25px;letter-spacing:-0.01em;line-height:1.1;margin:0}
59
+ h3{font-family:var(--display);font-size:18px;letter-spacing:-0.01em;margin:0 0 6px}
60
+ p{margin:0 0 10px;max-width:68ch}
61
+ .label{font-family:var(--mono);text-transform:uppercase;letter-spacing:0.16em;font-size:11px;color:var(--muted)}
62
+ .muted{color:var(--muted)}
63
+ /* cover */
64
+ .cover{padding-bottom:8px}
65
+ .meta{font-family:var(--mono);font-size:11px;letter-spacing:0.12em;color:var(--muted);text-transform:uppercase;margin-top:6px}
66
+ .prepared{font-family:var(--mono);font-size:11px;letter-spacing:0.08em;color:var(--muted);text-transform:uppercase;margin-top:14px}
67
+ /* scorecard */
68
+ .scorecard{display:flex;align-items:center;gap:28px;margin:30px 0 8px;padding:24px 28px;background:var(--bgalt);border:1px solid var(--border);border-radius:12px;break-inside:avoid}
69
+ .grade{font-family:var(--display);font-size:104px;line-height:0.86;font-weight:400}
70
+ .score-num{font-family:var(--display);font-size:34px;line-height:1}
71
+ .score-num span{font-size:18px;color:var(--muted)}
72
+ .chips{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}
73
+ .chip{font-family:var(--mono);font-size:11px;letter-spacing:0.04em;font-weight:600;color:var(--c);border:1px solid var(--c);border-radius:999px;padding:2px 9px;white-space:nowrap}
74
+ .chip.solid{background:var(--c);color:#fff;border-color:var(--c)}
75
+ .pnum{font-family:var(--mono);color:var(--primary);font-size:13px;letter-spacing:0.05em;margin-right:10px}
76
+ /* section markers */
77
+ .sec{display:flex;align-items:baseline;gap:14px;margin:56px 0 18px;border-bottom:1px solid var(--border);padding-bottom:10px}
78
+ .sec-num{font-family:var(--mono);font-size:13px;letter-spacing:0.1em;color:var(--primary)}
79
+ /* cards */
80
+ .card{background:var(--bgalt);border:1px solid var(--border);border-left:3px solid var(--c,var(--border));border-radius:8px;padding:16px 18px;margin:12px 0;break-inside:avoid}
81
+ .card .row{display:flex;align-items:baseline;justify-content:space-between;gap:12px}
82
+ .scenario{border-left-width:3px}
83
+ /* roadmap */
84
+ .tier{display:flex;align-items:baseline;gap:10px;margin:22px 0 6px}
85
+ .tier h3{margin:0}
86
+ .count{font-family:var(--mono);font-size:11px;color:var(--muted);border:1px solid var(--border);border-radius:999px;padding:1px 8px}
87
+ .tier-list{list-style:none;margin:0;padding:0}
88
+ .tier-list li{display:flex;align-items:baseline;justify-content:space-between;gap:12px;padding:6px 0;border-bottom:1px solid var(--border)}
89
+ /* findings appendix — denser, quieter */
90
+ .find{padding:12px 0;border-bottom:1px solid var(--border)}
91
+ .find h3{font-family:var(--body);font-size:15px;font-weight:600;margin:0 0 3px}
92
+ .find p{font-size:13px;color:var(--muted);margin:0}
93
+ .matrix{width:100%;border-collapse:collapse;margin:8px 0 22px;font-size:13px}
94
+ .matrix th{text-align:left;font-family:var(--mono);text-transform:uppercase;letter-spacing:0.08em;font-size:10px;color:var(--muted);border-bottom:1px solid var(--border);padding:6px 8px}
95
+ .matrix td{border-bottom:1px solid var(--border);padding:7px 8px;vertical-align:top}
96
+ .matrix .cid{font-family:var(--mono);font-size:12px;color:var(--primary);white-space:nowrap}
97
+ .matrix .st{text-align:right;white-space:nowrap}
98
+ footer{margin-top:56px;border-top:1px solid var(--border);padding-top:18px;color:var(--muted);font-size:12px;line-height:1.55}
99
+ footer .label{display:block;margin-bottom:6px;color:var(--ink)}
100
+ @page{margin:18mm}
101
+ @media print{.wrap{padding:0 0 24px}.sec{break-after:avoid}.card,.scorecard{break-inside:avoid}}
102
+ </style></head><body><div class="wrap">
103
+ ${this.cover(result, b)}
104
+ ${sections}
105
+ ${this.footer(b)}
106
+ </div></body></html>`;
107
+ }
108
+ chip(sev, text) {
109
+ const solid = sev === 'CRITICAL' ? ' solid' : '';
110
+ return `<span class="chip${solid}" style="--c:${SEV_COLOR[sev]}">${esc(text)}</span>`;
111
+ }
112
+ sectionHead(numStr, title) {
113
+ return `<div class="sec"><span class="sec-num">${numStr} /</span><h2>${esc(title)}</h2></div>`;
114
+ }
115
+ cover(r, b) {
116
+ const meta = [r.orgName, r.orgType, r.orgId, r.generatedAt.toISOString().slice(0, 10)]
117
+ .map((s) => esc(String(s))).join(' · ');
118
+ const counts = SEV_ORDER
119
+ .map((l) => ({ l, n: r.findings.filter((f) => f.riskLevel === l && !f.passed && !f.inconclusive).length }))
120
+ .filter((c) => c.n > 0)
121
+ .map((c) => this.chip(c.l, `${c.n} ${c.l}`)).join('');
122
+ const prepared = b.preparedFor ? ` for ${esc(b.preparedFor)}` : '';
123
+ return `<header class="cover">
124
+ <div class="label">${esc(b.firmName)}</div>
125
+ <h1>Salesforce Security Audit</h1>
126
+ <div class="meta">${meta}</div>
127
+ <div class="scorecard" style="border-left:4px solid ${GRADE_COLOR[r.grade] ?? b.primary}">
128
+ <div class="grade" style="color:${GRADE_COLOR[r.grade] ?? b.primary}">${esc(r.grade)}</div>
129
+ <div>
130
+ <div class="label">Security grade · health score</div>
131
+ <div class="score-num">${r.healthScore}<span>/100</span></div>
132
+ <div class="chips">${counts || this.chip('LOW', 'No active findings')}</div>
133
+ </div>
134
+ </div>
135
+ <div class="prepared">Prepared by ${esc(b.firmName)}${prepared}</div></header>`;
136
+ }
137
+ summary(r, numStr) {
138
+ const incon = r.findings.filter((f) => f.inconclusive).length;
139
+ const active = r.findings.filter((f) => !f.passed && !f.inconclusive).length;
140
+ return `${this.sectionHead(numStr, 'Executive Summary')}
141
+ <p>This audit assessed the org’s security configuration and scored it <strong>${r.healthScore}/100 (Grade ${esc(r.grade)})</strong> across ${active} active finding${active === 1 ? '' : 's'}${incon ? `, with ${incon} inconclusive (insufficient access)` : ''}. The priorities below are the highest-impact items to address first; the remediation roadmap groups every fix by effort. See Scope &amp; Liability for the basis and limits of this assessment.</p>`;
142
+ }
143
+ prioritiesSection(priorities, chainIds, numStr) {
144
+ const head = this.sectionHead(numStr, 'Executive Priorities');
145
+ if (priorities.length === 0)
146
+ return `${head}<p class="muted">No active findings to prioritise.</p>`;
147
+ const items = priorities.map((f, i) => {
148
+ const meta = f.checkId ? getCheckMeta(f.checkId) : undefined;
149
+ const chained = chainIds.has(f.id) ? '<p class="muted">Part of an attack chain — see Attack Scenarios.</p>' : '';
150
+ const impact = meta ? `<p><strong>Impact:</strong> ${esc(meta.impact)}</p>` : '';
151
+ return `<div class="card" style="--c:${SEV_COLOR[f.riskLevel]}">
152
+ <div class="row"><h3><span class="pnum">${String(i + 1).padStart(2, '0')}</span>${esc(f.title)}</h3>${this.chip(f.riskLevel, f.riskLevel)}</div>
153
+ ${impact}${chained}<p><strong>Fix:</strong> ${esc(f.remediation)}</p></div>`;
154
+ }).join('');
155
+ return `${head}<p class="muted">Focus areas, highest impact first.</p>${items}`;
156
+ }
157
+ scenarios(chains, numStr) {
158
+ const items = chains.map((c) => `<div class="card scenario" style="--c:${SEV_COLOR[c.severity]}">
159
+ <div class="row"><h3>${esc(c.title)}</h3>${this.chip(c.severity, c.severity)}</div>
160
+ <p>${esc(c.narrative)}</p><p><strong>Breaks the chain:</strong> ${esc(c.remediation)}</p></div>`).join('');
161
+ return `${this.sectionHead(numStr, 'Attack Scenarios')}<p class="muted">How findings combine into real attack paths.</p>${items}`;
162
+ }
163
+ roadmapSection(roadmap, numStr) {
164
+ const tier = (label, sub, arr) => {
165
+ if (arr.length === 0)
166
+ return '';
167
+ const rows = arr.map((f) => `<li><span>${esc(f.title)}</span>${this.chip(f.riskLevel, f.riskLevel)}</li>`).join('');
168
+ return `<div class="tier"><h3>${esc(label)}</h3><span class="count">${arr.length} · ${esc(sub)}</span></div><ul class="tier-list">${rows}</ul>`;
169
+ };
170
+ return `${this.sectionHead(numStr, 'Remediation Roadmap')}
171
+ ${tier('Quick wins', '≤1 day', roadmap.quick)}
172
+ ${tier('Moderate', 'days', roadmap.moderate)}
173
+ ${tier('Projects', 'weeks', roadmap.project)}`;
174
+ }
175
+ worst(findings) {
176
+ return findings.slice().sort((a, b) => SEV_RANK[a.riskLevel] - SEV_RANK[b.riskLevel])[0]?.riskLevel;
177
+ }
178
+ matrixSection(matrix, numStr) {
179
+ const blocks = matrix.map((fm) => {
180
+ const rows = fm.rows.map((row) => {
181
+ const w = this.worst(row.findings);
182
+ const status = w
183
+ ? this.chip(w, `${row.findings.length} finding${row.findings.length === 1 ? '' : 's'}`)
184
+ : '<span class="muted">No findings detected</span>';
185
+ return `<tr><td class="cid">${esc(row.control.id)}</td><td>${esc(row.control.title)}</td><td class="st">${status}</td></tr>`;
186
+ }).join('');
187
+ return `<h3>${esc(FRAMEWORK_LABEL[fm.framework])} <span class="muted">· ${esc(fm.version)}</span></h3>
188
+ <table class="matrix"><thead><tr><th>Control</th><th>Requirement area</th><th>Status</th></tr></thead><tbody>${rows}</tbody></table>`;
189
+ }).join('');
190
+ return `${this.sectionHead(numStr, 'Compliance Coverage')}<p class="muted">Findings mapped to framework controls. “No findings detected” is not an attestation of compliance — see Scope &amp; Liability.</p>${blocks}`;
191
+ }
192
+ findingsAppendix(r, numStr) {
193
+ const rows = r.findings.map((f) => {
194
+ const tag = f.inconclusive ? this.chip('INFO', 'inconclusive') : f.passed ? this.chip('INFO', 'passed') : this.chip(f.riskLevel, f.riskLevel);
195
+ return `<div class="find"><div class="row"><h3>${esc(f.title)}</h3>${tag}</div>
196
+ <p>${esc(f.detail)}</p><p><strong>Remediation:</strong> ${esc(f.remediation)}</p></div>`;
197
+ }).join('');
198
+ return `${this.sectionHead(numStr, 'All Findings')}${rows}`;
199
+ }
200
+ footer(b) {
201
+ return `<footer><span class="label">Scope &amp; Liability</span>
202
+ Read-only, point-in-time configuration review — not a penetration test, not a code audit. The grade is a prioritisation aid, not a certification. Validate findings before remediation. © ${new Date().getFullYear()} ${esc(b.firmName)} · ${esc(b.contact)}</footer>`;
203
+ }
204
+ }
205
+ //# sourceMappingURL=ClientReportRenderer.js.map
@@ -0,0 +1,8 @@
1
+ import type { AuditDiff } from '../history/AuditDiff.js';
2
+ import type { DiffRenderer } from './DiffRenderer.js';
3
+ export declare class DiffHtmlRenderer implements DiffRenderer {
4
+ readonly format = "html";
5
+ readonly fileExtension = ".html";
6
+ render(diff: AuditDiff): string;
7
+ }
8
+ //# sourceMappingURL=DiffHtmlRenderer.d.ts.map
@@ -0,0 +1,164 @@
1
+ function esc(str) {
2
+ return str
3
+ .replace(/&/g, '&amp;')
4
+ .replace(/</g, '&lt;')
5
+ .replace(/>/g, '&gt;')
6
+ .replace(/"/g, '&quot;');
7
+ }
8
+ function fmtDate(d) {
9
+ return d.toISOString().replace('T', ' ').substring(0, 16);
10
+ }
11
+ const RISK_COLORS = {
12
+ CRITICAL: '#dc2626', HIGH: '#ea580c', MEDIUM: '#d97706', LOW: '#2563eb', INFO: '#64748b',
13
+ };
14
+ const CHANGE_LABELS = {
15
+ 'new': 'New', 'resolved': 'Resolved', 'severity-changed': 'Severity Changed', 'detail-changed': 'Detail Changed',
16
+ };
17
+ function renderFindingCard(change) {
18
+ const f = change.finding;
19
+ const typeColor = change.type === 'new' ? '#dc2626' : change.type === 'resolved' ? '#22c55e' : '#d97706';
20
+ const prevBadge = change.previous
21
+ ? `<span class="risk-badge" style="background:${RISK_COLORS[change.previous.riskLevel] ?? '#64748b'}">${esc(change.previous.riskLevel)}</span> → `
22
+ : '';
23
+ return `
24
+ <div class="finding-card" style="border-left-color:${typeColor}">
25
+ <div class="finding-header">
26
+ <span class="change-badge" style="background:${typeColor}">${CHANGE_LABELS[change.type] ?? change.type}</span>
27
+ ${prevBadge}<span class="risk-badge" style="background:${RISK_COLORS[f.riskLevel] ?? '#64748b'}">${esc(f.riskLevel)}</span>
28
+ <span class="finding-title">${esc(f.title)}</span>
29
+ <span class="finding-category">${esc(f.category)}</span>
30
+ </div>
31
+ ${change.type === 'detail-changed' && change.previous ? `
32
+ <div class="detail-diff">
33
+ <div class="diff-before"><strong>Before:</strong> ${esc(change.previous.detail)}</div>
34
+ <div class="diff-after"><strong>After:</strong> ${esc(f.detail)}</div>
35
+ </div>` : ''}
36
+ </div>`;
37
+ }
38
+ export class DiffHtmlRenderer {
39
+ format = 'html';
40
+ fileExtension = '.html';
41
+ render(diff) {
42
+ const { baseline, current } = diff;
43
+ const scoreDeltaStr = diff.scoreDelta >= 0 ? `+${diff.scoreDelta}` : `${diff.scoreDelta}`;
44
+ const scoreDeltaColor = diff.scoreDelta > 0 ? '#22c55e' : diff.scoreDelta < 0 ? '#dc2626' : '#8b949e';
45
+ const changeCounts = {
46
+ new: diff.findingChanges.filter((c) => c.type === 'new').length,
47
+ resolved: diff.findingChanges.filter((c) => c.type === 'resolved').length,
48
+ 'severity-changed': diff.findingChanges.filter((c) => c.type === 'severity-changed').length,
49
+ 'detail-changed': diff.findingChanges.filter((c) => c.type === 'detail-changed').length,
50
+ };
51
+ const sectionOrder = ['new', 'resolved', 'severity-changed', 'detail-changed', 'unchanged'];
52
+ const sections = sectionOrder.map((type) => {
53
+ const changes = diff.findingChanges.filter((c) => c.type === type);
54
+ if (changes.length === 0)
55
+ return '';
56
+ const sectionClass = type === 'unchanged' ? ' class="unchanged-section"' : '';
57
+ return `
58
+ <section${sectionClass}>
59
+ <h2>${CHANGE_LABELS[type] ?? type} (${changes.length})</h2>
60
+ ${changes.map(renderFindingCard).join('')}
61
+ </section>`;
62
+ }).join('');
63
+ const metricRows = diff.metricDeltas.map((d) => {
64
+ const color = d.direction === 'improved' ? '#22c55e' : d.direction === 'degraded' ? '#dc2626' : '#8b949e';
65
+ const arrow = d.delta > 0 ? '▲' : '▼';
66
+ const deltaStr = d.delta > 0 ? `+${d.delta}` : `${d.delta}`;
67
+ return `<tr>
68
+ <td>${esc(d.label)}</td>
69
+ <td style="text-align:right">${d.before}</td>
70
+ <td style="text-align:right">${d.after}</td>
71
+ <td style="text-align:right;color:${color};font-weight:700">${arrow} ${deltaStr}</td>
72
+ </tr>`;
73
+ }).join('');
74
+ const metricsSection = diff.metricDeltas.length > 0 ? `
75
+ <section>
76
+ <h2>Metric Changes</h2>
77
+ <table class="metric-table">
78
+ <thead><tr><th>Metric</th><th>Before</th><th>After</th><th>Change</th></tr></thead>
79
+ <tbody>${metricRows}</tbody>
80
+ </table>
81
+ </section>` : '';
82
+ return `<!DOCTYPE html>
83
+ <html lang="en">
84
+ <head>
85
+ <meta charset="UTF-8">
86
+ <meta name="viewport" content="width=device-width,initial-scale=1">
87
+ <title>SF Audit Diff — ${esc(baseline.orgName)}</title>
88
+ <style>
89
+ *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
90
+ body { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; background: #0d1117; color: #c9d1d9; max-width: 1000px; margin: 2rem auto; padding: 0 1.25rem 4rem; line-height: 1.6; }
91
+ h1 { color: #f0f6fc; font-size: 1.5rem; font-weight: 700; margin-bottom: 0.4rem; }
92
+ h2 { color: #e6edf3; font-size: 1.1rem; font-weight: 700; margin: 1.5rem 0 0.75rem; }
93
+ .meta { font-size: 0.8rem; color: #8b949e; display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin-bottom: 1.5rem; }
94
+ .scorecard { background: #161b22; border: 1px solid #30363d; border-radius: 12px; padding: 1.25rem 2rem; display: flex; gap: 2rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.5rem; }
95
+ .score-delta { font-size: 2.5rem; font-weight: 800; color: ${scoreDeltaColor}; line-height: 1; }
96
+ .grade-delta { font-size: 1.2rem; font-weight: 700; color: #c9d1d9; }
97
+ .summary-counts { display: flex; gap: 1rem; flex-wrap: wrap; }
98
+ .count-badge { background: #1c2128; border: 1px solid #30363d; border-radius: 8px; padding: 0.5rem 1rem; text-align: center; }
99
+ .count-badge .num { font-size: 1.5rem; font-weight: 800; display: block; }
100
+ .count-badge .lbl { font-size: 0.75rem; color: #8b949e; }
101
+ .finding-card { background: #161b22; border: 1px solid #30363d; border-left: 3px solid #30363d; border-radius: 8px; margin-bottom: 0.5rem; padding: 0.75rem 1rem; }
102
+ .finding-header { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
103
+ .change-badge { padding: 0.15rem 0.6rem; border-radius: 4px; font-size: 0.7rem; font-weight: 800; color: #fff; letter-spacing: 0.04em; }
104
+ .risk-badge { padding: 0.15rem 0.6rem; border-radius: 4px; font-size: 0.7rem; font-weight: 800; color: #fff; }
105
+ .finding-title { flex: 1; font-weight: 600; color: #e6edf3; font-size: 0.9rem; }
106
+ .finding-category { font-size: 0.75rem; color: #8b949e; }
107
+ .detail-diff { margin-top: 0.5rem; font-size: 0.82rem; display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
108
+ .diff-before { background: rgba(220,38,38,0.1); border: 1px solid rgba(220,38,38,0.3); border-radius: 4px; padding: 0.5rem; }
109
+ .diff-after { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); border-radius: 4px; padding: 0.5rem; }
110
+ .unchanged-section { opacity: 0.5; }
111
+ .metric-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
112
+ .metric-table th { background: #1c2128; color: #8b949e; text-align: left; padding: 0.4rem 0.75rem; border-bottom: 1px solid #30363d; font-weight: 600; }
113
+ .metric-table td { padding: 0.4rem 0.75rem; border-bottom: 1px solid #21262d; }
114
+ .metric-table tr:last-child td { border-bottom: none; }
115
+ section { margin-bottom: 2rem; }
116
+ </style>
117
+ </head>
118
+ <body>
119
+ <h1>Salesforce Audit Diff</h1>
120
+ <div class="meta">
121
+ <span>Org: <strong style="color:#c9d1d9">${esc(baseline.orgName)}</strong> (${esc(baseline.orgId)})</span>
122
+ <span>Baseline: ${fmtDate(baseline.generatedAt)}</span>
123
+ <span>Current: ${fmtDate(current.generatedAt)}</span>
124
+ </div>
125
+
126
+ <div class="scorecard">
127
+ <div>
128
+ <div class="score-delta">${scoreDeltaStr}</div>
129
+ <div style="font-size:0.8rem;color:#8b949e;margin-top:0.25rem">score change</div>
130
+ </div>
131
+ <div class="grade-delta">${esc(diff.gradeDelta)}</div>
132
+ <div class="summary-counts">
133
+ <div class="count-badge"><span class="num" style="color:#dc2626">${changeCounts.new}</span><span class="lbl">New</span></div>
134
+ <div class="count-badge"><span class="num" style="color:#22c55e">${changeCounts.resolved}</span><span class="lbl">Resolved</span></div>
135
+ <div class="count-badge"><span class="num" style="color:#d97706">${changeCounts['severity-changed']}</span><span class="lbl">Sev. Changed</span></div>
136
+ <div class="count-badge"><span class="num" style="color:#64748b">${changeCounts['detail-changed']}</span><span class="lbl">Detail Changed</span></div>
137
+ </div>
138
+ </div>
139
+
140
+ ${metricsSection}
141
+ ${sections}
142
+
143
+ <script>
144
+ // Toggle unchanged findings visibility
145
+ const unchanged = document.querySelector('.unchanged-section');
146
+ if (unchanged) {
147
+ const toggle = document.createElement('button');
148
+ toggle.textContent = 'Show Unchanged';
149
+ toggle.style.cssText = 'background:#1c2128;border:1px solid #30363d;color:#8b949e;padding:0.3rem 0.75rem;border-radius:20px;cursor:pointer;font-size:0.8rem;margin-bottom:0.75rem';
150
+ unchanged.insertBefore(toggle, unchanged.querySelector('h2').nextSibling);
151
+ let visible = false;
152
+ unchanged.querySelectorAll('.finding-card').forEach(c => c.style.display = 'none');
153
+ toggle.addEventListener('click', () => {
154
+ visible = !visible;
155
+ toggle.textContent = visible ? 'Hide Unchanged' : 'Show Unchanged';
156
+ unchanged.querySelectorAll('.finding-card').forEach(c => c.style.display = visible ? '' : 'none');
157
+ });
158
+ }
159
+ </script>
160
+ </body>
161
+ </html>`;
162
+ }
163
+ }
164
+ //# sourceMappingURL=DiffHtmlRenderer.js.map
@@ -0,0 +1,8 @@
1
+ import type { AuditDiff } from '../history/AuditDiff.js';
2
+ import type { DiffRenderer } from './DiffRenderer.js';
3
+ export declare class DiffJsonRenderer implements DiffRenderer {
4
+ readonly format = "json";
5
+ readonly fileExtension = ".json";
6
+ render(diff: AuditDiff): string;
7
+ }
8
+ //# sourceMappingURL=DiffJsonRenderer.d.ts.map