@cclabsnz/sf-audit 1.1.0 → 1.3.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 (133) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +168 -38
  3. package/lib/chains/namedChains.js +4 -4
  4. package/lib/checks/CheckEngine.js +1 -1
  5. package/lib/checks/impl/AnonymousApexAuditCheck.js +5 -5
  6. package/lib/checks/impl/ApexCrudFLSCheck.d.ts +1 -1
  7. package/lib/checks/impl/ApexCrudFLSCheck.js +4 -4
  8. package/lib/checks/impl/ApexLoggingCheck.js +10 -10
  9. package/lib/checks/impl/ApexRestEndpointCheck.js +5 -5
  10. package/lib/checks/impl/ApexSharingCheck.js +3 -3
  11. package/lib/checks/impl/ApiClientPermissionCheck.js +2 -2
  12. package/lib/checks/impl/CertificateExpiryCheck.js +1 -1
  13. package/lib/checks/impl/ConnectedAppInactivityCheck.d.ts +1 -1
  14. package/lib/checks/impl/ConnectedAppInactivityCheck.js +5 -5
  15. package/lib/checks/impl/ConnectedAppScopeCheck.d.ts +1 -1
  16. package/lib/checks/impl/ConnectedAppScopeCheck.js +4 -4
  17. package/lib/checks/impl/ConnectedAppsCheck.js +2 -2
  18. package/lib/checks/impl/ContentLinksCheck.js +6 -6
  19. package/lib/checks/impl/CorsAllowlistCheck.js +3 -3
  20. package/lib/checks/impl/CustomLabelsCredentialCheck.d.ts +1 -1
  21. package/lib/checks/impl/CustomLabelsCredentialCheck.js +7 -7
  22. package/lib/checks/impl/DataClassificationCheck.js +6 -6
  23. package/lib/checks/impl/DebugLogAccessCheck.js +6 -6
  24. package/lib/checks/impl/DeploymentIdentityCheck.js +8 -8
  25. package/lib/checks/impl/EmailSecurityCheck.d.ts +10 -0
  26. package/lib/checks/impl/EmailSecurityCheck.js +117 -0
  27. package/lib/checks/impl/EnhancedDomainsCheck.d.ts +1 -1
  28. package/lib/checks/impl/EnhancedDomainsCheck.js +6 -6
  29. package/lib/checks/impl/EscalationPermsCheck.js +2 -2
  30. package/lib/checks/impl/EventMonitoringCheck.js +6 -6
  31. package/lib/checks/impl/ExperienceCloudSiteCheck.js +3 -3
  32. package/lib/checks/impl/FailedLoginCheck.js +5 -5
  33. package/lib/checks/impl/FieldHistoryTrackingCheck.js +3 -3
  34. package/lib/checks/impl/FieldLevelSecurityCheck.js +2 -2
  35. package/lib/checks/impl/GuestExecutableApexCheck.d.ts +1 -1
  36. package/lib/checks/impl/GuestExecutableApexCheck.js +5 -5
  37. package/lib/checks/impl/GuestUserAccessCheck.js +5 -5
  38. package/lib/checks/impl/HealthCheckCheck.js +2 -2
  39. package/lib/checks/impl/HighAssuranceSessionCheck.js +4 -4
  40. package/lib/checks/impl/InstalledPackagesCheck.js +5 -5
  41. package/lib/checks/impl/IntegrationUsersCheck.js +5 -5
  42. package/lib/checks/impl/InternalUserMfaCheck.js +2 -2
  43. package/lib/checks/impl/IpRestrictionsCheck.js +3 -3
  44. package/lib/checks/impl/LegacyApiVersionCheck.js +1 -1
  45. package/lib/checks/impl/MfaEnforcementCheck.js +3 -3
  46. package/lib/checks/impl/MfaMethodStrengthCheck.js +3 -3
  47. package/lib/checks/impl/MfaRegistrationCheck.js +2 -2
  48. package/lib/checks/impl/MyDomainLoginPolicyCheck.d.ts +1 -1
  49. package/lib/checks/impl/MyDomainLoginPolicyCheck.js +9 -9
  50. package/lib/checks/impl/NamedCredentialsCheck.js +3 -3
  51. package/lib/checks/impl/OutboundMessagesCheck.d.ts +10 -0
  52. package/lib/checks/impl/OutboundMessagesCheck.js +88 -0
  53. package/lib/checks/impl/PasswordSessionPolicyCheck.js +3 -3
  54. package/lib/checks/impl/PermissionsCheck.js +3 -3
  55. package/lib/checks/impl/PrivilegedAccessCheck.d.ts +11 -0
  56. package/lib/checks/impl/PrivilegedAccessCheck.js +111 -0
  57. package/lib/checks/impl/PublicContentExposureCheck.d.ts +10 -0
  58. package/lib/checks/impl/PublicContentExposureCheck.js +98 -0
  59. package/lib/checks/impl/PublicGroupSharingCheck.js +1 -1
  60. package/lib/checks/impl/ReleaseUpdatesCheck.js +2 -2
  61. package/lib/checks/impl/RemoteSitesCheck.js +1 -1
  62. package/lib/checks/impl/ReportFolderAccessCheck.d.ts +1 -1
  63. package/lib/checks/impl/ReportFolderAccessCheck.js +4 -4
  64. package/lib/checks/impl/ScheduledApexCheck.js +1 -1
  65. package/lib/checks/impl/SeparationOfDutiesCheck.d.ts +11 -0
  66. package/lib/checks/impl/SeparationOfDutiesCheck.js +114 -0
  67. package/lib/checks/impl/SharingModelCheck.d.ts +1 -1
  68. package/lib/checks/impl/SharingModelCheck.js +8 -8
  69. package/lib/checks/impl/SiemIntegrationCheck.js +4 -4
  70. package/lib/checks/impl/SsoEnforcementCheck.js +5 -5
  71. package/lib/checks/impl/StandardProfilesCheck.js +2 -2
  72. package/lib/checks/impl/TransactionSecurityPolicyCheck.js +2 -2
  73. package/lib/checks/impl/TrustedIPRangesCheck.js +5 -5
  74. package/lib/checks/impl/VisualforceXssCheck.js +6 -6
  75. package/lib/checks/permCatalog.d.ts +15 -0
  76. package/lib/checks/permCatalog.js +42 -0
  77. package/lib/checks/registry.js +12 -0
  78. package/lib/commands/audit/diff.js +1 -1
  79. package/lib/commands/audit/security.d.ts +5 -0
  80. package/lib/commands/audit/security.js +33 -4
  81. package/lib/compliance/catalogs/hiso10029.d.ts +3 -0
  82. package/lib/compliance/catalogs/hiso10029.js +35 -0
  83. package/lib/compliance/catalogs/index.d.ts +4 -0
  84. package/lib/compliance/catalogs/index.js +21 -0
  85. package/lib/compliance/catalogs/iso27001.d.ts +3 -0
  86. package/lib/compliance/catalogs/iso27001.js +39 -0
  87. package/lib/compliance/catalogs/nzism.d.ts +3 -0
  88. package/lib/compliance/catalogs/nzism.js +31 -0
  89. package/lib/compliance/catalogs/owasp.d.ts +3 -0
  90. package/lib/compliance/catalogs/owasp.js +37 -0
  91. package/lib/compliance/catalogs/privacyAct.d.ts +3 -0
  92. package/lib/compliance/catalogs/privacyAct.js +17 -0
  93. package/lib/compliance/catalogs/sbs.d.ts +3 -0
  94. package/lib/compliance/catalogs/sbs.js +61 -0
  95. package/lib/compliance/catalogs/soc2.d.ts +3 -0
  96. package/lib/compliance/catalogs/soc2.js +42 -0
  97. package/lib/compliance/mapping.d.ts +2 -0
  98. package/lib/compliance/mapping.js +118 -0
  99. package/lib/compliance/resolve.d.ts +12 -0
  100. package/lib/compliance/resolve.js +49 -0
  101. package/lib/compliance/types.d.ts +13 -0
  102. package/lib/compliance/types.js +2 -0
  103. package/lib/context/AuditCache.d.ts +9 -0
  104. package/lib/findings/CheckMeta.d.ts +9 -0
  105. package/lib/findings/CheckMeta.js +72 -0
  106. package/lib/renderers/AuditRenderer.d.ts +2 -0
  107. package/lib/renderers/ClientReportRenderer.d.ts +29 -0
  108. package/lib/renderers/ClientReportRenderer.js +205 -0
  109. package/lib/renderers/DiffHtmlRenderer.js +1 -1
  110. package/lib/renderers/HistoryRenderer.js +1 -1
  111. package/lib/renderers/HtmlRenderer.js +4 -10
  112. package/lib/renderers/MarkdownRenderer.js +2 -2
  113. package/lib/renderers/html-utils.d.ts +2 -0
  114. package/lib/renderers/html-utils.js +8 -0
  115. package/lib/report/ComplianceMatrix.d.ts +19 -0
  116. package/lib/report/ComplianceMatrix.js +47 -0
  117. package/lib/report/ExecutivePriorities.d.ts +8 -0
  118. package/lib/report/ExecutivePriorities.js +22 -0
  119. package/lib/report/RemediationRoadmap.d.ts +9 -0
  120. package/lib/report/RemediationRoadmap.js +18 -0
  121. package/lib/report/branding.d.ts +18 -0
  122. package/lib/report/branding.js +19 -0
  123. package/lib/report/fonts.d.ts +2 -0
  124. package/lib/report/fonts.js +22 -0
  125. package/messages/audit.security.md +30 -2
  126. package/package.json +3 -1
  127. package/src/assets/fonts/dm-sans-italic-latin.woff2 +0 -0
  128. package/src/assets/fonts/dm-sans-normal-latin.woff2 +0 -0
  129. package/src/assets/fonts/dm-serif-display-italic-latin.woff2 +0 -0
  130. package/src/assets/fonts/dm-serif-display-normal-latin.woff2 +0 -0
  131. package/config/queries/soql.json +0 -24
  132. package/config/queries/tooling.json +0 -28
  133. package/config/scoring.json +0 -17
@@ -0,0 +1,9 @@
1
+ import type { Finding } from '../findings/Finding.js';
2
+ export interface Roadmap {
3
+ quick: Finding[];
4
+ moderate: Finding[];
5
+ project: Finding[];
6
+ }
7
+ /** Group active findings into effort tiers, risk-sorted within each. Unknown checkId → moderate. */
8
+ export declare function buildRoadmap(findings: Finding[]): Roadmap;
9
+ //# sourceMappingURL=RemediationRoadmap.d.ts.map
@@ -0,0 +1,18 @@
1
+ import { getCheckMeta } from '../findings/CheckMeta.js';
2
+ const RANK = { CRITICAL: 0, HIGH: 1, MEDIUM: 2, LOW: 3, INFO: 4 };
3
+ /** Group active findings into effort tiers, risk-sorted within each. Unknown checkId → moderate. */
4
+ export function buildRoadmap(findings) {
5
+ const out = { quick: [], moderate: [], project: [] };
6
+ for (const f of findings) {
7
+ if (f.passed || f.inconclusive)
8
+ continue;
9
+ const effort = (f.checkId && getCheckMeta(f.checkId)?.effort) || 'moderate';
10
+ out[effort].push(f);
11
+ }
12
+ const sort = (arr) => arr.sort((a, b) => RANK[a.riskLevel] - RANK[b.riskLevel]);
13
+ sort(out.quick);
14
+ sort(out.moderate);
15
+ sort(out.project);
16
+ return out;
17
+ }
18
+ //# sourceMappingURL=RemediationRoadmap.js.map
@@ -0,0 +1,18 @@
1
+ export interface Branding {
2
+ firmName: string;
3
+ primary: string;
4
+ ink: string;
5
+ bg: string;
6
+ bgAlt: string;
7
+ muted: string;
8
+ border: string;
9
+ fontDisplay: string;
10
+ fontBody: string;
11
+ contact: string;
12
+ logoPath?: string;
13
+ preparedFor?: string;
14
+ }
15
+ export declare const DEFAULT_BRANDING: Branding;
16
+ export type BrandingOverrides = Partial<Branding>;
17
+ export declare function resolveBranding(overrides: BrandingOverrides | undefined, preparedFor: string | undefined): Branding;
18
+ //# sourceMappingURL=branding.d.ts.map
@@ -0,0 +1,19 @@
1
+ export const DEFAULT_BRANDING = {
2
+ firmName: 'CloudCounsel Limited',
3
+ primary: '#3a5a82',
4
+ ink: '#1a1d24',
5
+ bg: '#faf6ef',
6
+ bgAlt: '#f7f7f2',
7
+ muted: '#636770',
8
+ border: '#e9e9e3',
9
+ fontDisplay: 'DM Serif Display',
10
+ fontBody: 'DM Sans',
11
+ contact: 'hello@cloudcounsel.co.nz',
12
+ };
13
+ export function resolveBranding(overrides, preparedFor) {
14
+ const merged = { ...DEFAULT_BRANDING, ...(overrides ?? {}) };
15
+ if (preparedFor)
16
+ merged.preparedFor = preparedFor;
17
+ return merged;
18
+ }
19
+ //# sourceMappingURL=branding.js.map
@@ -0,0 +1,2 @@
1
+ export declare function fontFaceCss(): string;
2
+ //# sourceMappingURL=fonts.d.ts.map
@@ -0,0 +1,22 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { dirname, join } from 'node:path';
4
+ const HERE = dirname(fileURLToPath(import.meta.url));
5
+ // Resolves to <packageRoot>/src/assets/fonts from both lib/report (compiled) and src/report (ts-jest).
6
+ const FONT_DIR = join(HERE, '..', '..', 'src', 'assets', 'fonts');
7
+ function dataUri(file) {
8
+ const buf = readFileSync(join(FONT_DIR, file));
9
+ return `data:font/woff2;base64,${buf.toString('base64')}`;
10
+ }
11
+ function face(family, style, file) {
12
+ return `@font-face{font-family: '${family}';font-style:${style};font-display:swap;src:url(${dataUri(file)}) format('woff2');}`;
13
+ }
14
+ export function fontFaceCss() {
15
+ return [
16
+ face('DM Sans', 'normal', 'dm-sans-normal-latin.woff2'),
17
+ face('DM Sans', 'italic', 'dm-sans-italic-latin.woff2'),
18
+ face('DM Serif Display', 'normal', 'dm-serif-display-normal-latin.woff2'),
19
+ face('DM Serif Display', 'italic', 'dm-serif-display-italic-latin.woff2'),
20
+ ].join('\n');
21
+ }
22
+ //# sourceMappingURL=fonts.js.map
@@ -1,6 +1,6 @@
1
1
  # Summary
2
2
 
3
- Run a comprehensive security audit against a Salesforce org.
3
+ Run a complete, read-only security audit against a Salesforce org.
4
4
 
5
5
  # Flags
6
6
 
@@ -10,7 +10,8 @@ The org to audit. Must be authenticated via `sf org login`.
10
10
 
11
11
  ## format
12
12
 
13
- Output format: html (default), md, or json.
13
+ Output format(s), comma-separated: `html` (default), `md`, `json`, or `executive`.
14
+ The `executive` format produces a branded, print-to-PDF client report.
14
15
 
15
16
  ## output
16
17
 
@@ -20,3 +21,30 @@ Directory to write the report file. Defaults to the current directory.
20
21
 
21
22
  Exit with code 1 if any finding is at or above this severity level.
22
23
  Options: CRITICAL, HIGH, MEDIUM, LOW
24
+
25
+ ## checks
26
+
27
+ Comma-separated check IDs to run instead of all checks (e.g. `hardcoded-credentials,apex-sharing`).
28
+ Run `sf audit list` to see available check IDs.
29
+
30
+ ## scoring-config
31
+
32
+ Path to a custom scoring config JSON file to override severity weights, per-check
33
+ weights, and grade thresholds. Merges with the built-in defaults.
34
+
35
+ ## prepared-for
36
+
37
+ Client name for the executive report cover line (executive format).
38
+
39
+ ## branding
40
+
41
+ Path to a `report-branding.json` to override the default branding (executive format).
42
+
43
+ ## top
44
+
45
+ Number of executive priorities to highlight (executive format). Defaults to 5.
46
+
47
+ ## frameworks
48
+
49
+ Compliance matrix scope for the executive report: `universal` (default), `nz`, `all`,
50
+ or a comma list of framework aliases (e.g. `owasp,iso,nzism`).
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@cclabsnz/sf-audit",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "Salesforce Security Audit — native sf plugin",
5
+ "license": "Apache-2.0",
5
6
  "type": "module",
6
7
  "main": "lib/index.js",
7
8
  "scripts": {
@@ -58,6 +59,7 @@
58
59
  "/lib",
59
60
  "/messages",
60
61
  "/config",
62
+ "/src/assets",
61
63
  "!/lib/**/*.map"
62
64
  ]
63
65
  }
@@ -1,24 +0,0 @@
1
- {
2
- "activeStandardUsers": {
3
- "api": "soql",
4
- "soql": "SELECT Id, Username, ProfileId FROM User WHERE IsActive = true AND UserType = 'Standard'",
5
- "description": "All active standard users — used by MFA, admin, and inactive checks"
6
- },
7
- "profileIpRanges": {
8
- "api": "soql",
9
- "soql": "SELECT ProfileId, StartAddress, EndAddress FROM ProfileLoginIpRange",
10
- "description": "Profile login IP ranges — not queryable in all org configurations",
11
- "fallbackOnError": true
12
- },
13
- "orgLimits": {
14
- "api": "rest",
15
- "path": "/limits",
16
- "description": "Org API governor limits — fetched via ctx.rest.get('/limits')"
17
- },
18
- "sobjectDescribe": {
19
- "api": "rest",
20
- "path": "/sobjects/{sobjectType}/describe/",
21
- "description": "SObject describe for OWD/sharing model — called per object via ctx.rest.get(). Used by SharingModelCheck.",
22
- "fallbackOnError": true
23
- }
24
- }
@@ -1,28 +0,0 @@
1
- {
2
- "apexClasses": {
3
- "api": "tooling",
4
- "soql": "SELECT Id, Name, Body, LengthWithoutComments, NamespacePrefix FROM ApexClass WHERE NamespacePrefix = null",
5
- "description": "All custom Apex classes — used by HardcodedCredentialsCheck (populates apexBodies cache) and ApexSharingCheck"
6
- },
7
- "activeFlows": {
8
- "api": "tooling",
9
- "soql": "SELECT Id, MasterLabel, ProcessType, Status, RunInMode FROM Flow WHERE Status = 'Active'",
10
- "description": "Active Flow versions — used by FlowSecurityCheck"
11
- },
12
- "connectedAppsBasic": {
13
- "api": "tooling",
14
- "soql": "SELECT Id, Name FROM ConnectedApplication",
15
- "description": "Connected App ID list — used by IpRestrictionsCheck to fetch per-record Metadata blobs"
16
- },
17
- "connectedAppDetail": {
18
- "api": "rest",
19
- "path": "tooling/sobjects/ConnectedApplication/{id}/",
20
- "description": "Per-record Connected App metadata — call via ctx.tooling.getRecord('ConnectedApplication', id).",
21
- "fallbackOnError": true
22
- },
23
- "connectedAppsStandard": {
24
- "api": "soql",
25
- "soql": "SELECT Id, Name, Status, StartUrl FROM ConnectedApplication",
26
- "description": "Connected Apps basic info — used by ConnectedAppsCheck via standard SOQL"
27
- }
28
- }
@@ -1,17 +0,0 @@
1
- {
2
- "riskScores": {
3
- "CRITICAL": 10,
4
- "HIGH": 7,
5
- "MEDIUM": 4,
6
- "LOW": 1,
7
- "INFO": 0
8
- },
9
- "checkWeights": {},
10
- "gradeThresholds": {
11
- "A": { "minScore": 85, "maxHigh": 0 },
12
- "B": { "minScore": 70, "maxHigh": 1 },
13
- "C": { "minScore": 55, "maxHigh": 3 },
14
- "D": { "minScore": 40, "maxCritical": 0 },
15
- "F": {}
16
- }
17
- }