@cclabsnz/sf-audit 1.6.0 → 1.7.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 (182) hide show
  1. package/README.md +110 -1
  2. package/lib/apps/analyzeApps.d.ts +1 -1
  3. package/lib/apps/appResolver.d.ts +1 -1
  4. package/lib/apps/grantedAccess.d.ts +1 -1
  5. package/lib/chains/AttackChain.d.ts +1 -1
  6. package/lib/chains/namedChains.d.ts +1 -1
  7. package/lib/checks/CheckEngine.d.ts +1 -1
  8. package/lib/checks/SecurityCheck.d.ts +3 -3
  9. package/lib/checks/impl/AgentActionSurfaceCheck.d.ts +1 -1
  10. package/lib/checks/impl/AgentActionSurfaceCheck.js +1 -1
  11. package/lib/checks/impl/AgentChannelExposureCheck.d.ts +1 -1
  12. package/lib/checks/impl/AgentInventoryCheck.d.ts +1 -1
  13. package/lib/checks/impl/AgentInventoryCheck.js +1 -1
  14. package/lib/checks/impl/AgentMonitoringCoverageCheck.d.ts +1 -1
  15. package/lib/checks/impl/AgentUserPrivilegeCheck.d.ts +1 -1
  16. package/lib/checks/impl/AnonymousApexAuditCheck.d.ts +1 -1
  17. package/lib/checks/impl/ApexCrudFLSCheck.d.ts +1 -1
  18. package/lib/checks/impl/ApexLoggingCheck.d.ts +1 -1
  19. package/lib/checks/impl/ApexRestEndpointCheck.d.ts +1 -1
  20. package/lib/checks/impl/ApexSharingCheck.d.ts +1 -1
  21. package/lib/checks/impl/ApexSharingCheck.js +3 -2
  22. package/lib/checks/impl/ApiClientPermissionCheck.d.ts +1 -1
  23. package/lib/checks/impl/ApiLimitsCheck.d.ts +1 -1
  24. package/lib/checks/impl/AuditTrailCheck.d.ts +1 -1
  25. package/lib/checks/impl/AuthProvidersCheck.d.ts +1 -1
  26. package/lib/checks/impl/CertificateExpiryCheck.d.ts +1 -1
  27. package/lib/checks/impl/ClassicSitesCheck.d.ts +1 -1
  28. package/lib/checks/impl/CodeSecurityCheck.d.ts +1 -1
  29. package/lib/checks/impl/CodeSecurityCheck.js +5 -5
  30. package/lib/checks/impl/ConnectedAppInactivityCheck.d.ts +1 -1
  31. package/lib/checks/impl/ConnectedAppScopeCheck.d.ts +1 -1
  32. package/lib/checks/impl/ConnectedAppsCheck.d.ts +1 -1
  33. package/lib/checks/impl/ContentLinksCheck.d.ts +1 -1
  34. package/lib/checks/impl/CorsAllowlistCheck.d.ts +1 -1
  35. package/lib/checks/impl/CspTrustedSitesCheck.d.ts +1 -1
  36. package/lib/checks/impl/CustomLabelsCredentialCheck.d.ts +1 -1
  37. package/lib/checks/impl/CustomSettingsCheck.d.ts +1 -1
  38. package/lib/checks/impl/DataClassificationCheck.d.ts +1 -1
  39. package/lib/checks/impl/DataExportAccessCheck.d.ts +1 -1
  40. package/lib/checks/impl/DebugLogAccessCheck.d.ts +1 -1
  41. package/lib/checks/impl/DeploymentIdentityCheck.d.ts +1 -1
  42. package/lib/checks/impl/EmailSecurityCheck.d.ts +1 -1
  43. package/lib/checks/impl/EncryptionCoverageCheck.d.ts +1 -1
  44. package/lib/checks/impl/EnhancedDomainsCheck.d.ts +1 -1
  45. package/lib/checks/impl/EnhancedDomainsCheck.js +18 -4
  46. package/lib/checks/impl/EscalationPermsCheck.d.ts +1 -1
  47. package/lib/checks/impl/EventMonitoringCheck.d.ts +1 -1
  48. package/lib/checks/impl/EventMonitoringCheck.js +1 -1
  49. package/lib/checks/impl/ExperienceCloudSiteCheck.d.ts +1 -1
  50. package/lib/checks/impl/ExperienceCspCheck.d.ts +1 -1
  51. package/lib/checks/impl/ExternalCredentialsCheck.d.ts +1 -1
  52. package/lib/checks/impl/FailedLoginCheck.d.ts +1 -1
  53. package/lib/checks/impl/FieldHistoryTrackingCheck.d.ts +1 -1
  54. package/lib/checks/impl/FieldLevelSecurityCheck.d.ts +1 -1
  55. package/lib/checks/impl/FlowsWithoutSharingCheck.d.ts +1 -1
  56. package/lib/checks/impl/FlowsWithoutSharingCheck.js +10 -9
  57. package/lib/checks/impl/GuestApiAccessCheck.d.ts +1 -1
  58. package/lib/checks/impl/GuestExecutableApexCheck.d.ts +1 -1
  59. package/lib/checks/impl/GuestExecutableApexCheck.js +4 -3
  60. package/lib/checks/impl/GuestObjectExposureCheck.d.ts +1 -1
  61. package/lib/checks/impl/GuestRecordAccessPolicyCheck.d.ts +1 -1
  62. package/lib/checks/impl/GuestSiteOptionsCheck.d.ts +1 -1
  63. package/lib/checks/impl/GuestTrafficAnomalyCheck.d.ts +1 -1
  64. package/lib/checks/impl/GuestTrafficAnomalyCheck.js +1 -1
  65. package/lib/checks/impl/GuestUserAccessCheck.d.ts +1 -1
  66. package/lib/checks/impl/HardcodedCredentialsCheck.d.ts +1 -1
  67. package/lib/checks/impl/HardcodedCredentialsCheck.js +8 -1
  68. package/lib/checks/impl/HealthCheckCheck.d.ts +1 -1
  69. package/lib/checks/impl/HighAssuranceSessionCheck.d.ts +1 -1
  70. package/lib/checks/impl/InactiveUsersCheck.d.ts +1 -1
  71. package/lib/checks/impl/InstalledPackagesCheck.d.ts +1 -1
  72. package/lib/checks/impl/IntegrationUsersCheck.d.ts +1 -1
  73. package/lib/checks/impl/InternalUserMfaCheck.d.ts +1 -1
  74. package/lib/checks/impl/IpRestrictionsCheck.d.ts +1 -1
  75. package/lib/checks/impl/LegacyApiVersionCheck.d.ts +1 -1
  76. package/lib/checks/impl/LoginAccessPolicyCheck.d.ts +1 -1
  77. package/lib/checks/impl/LoginAnomalyCheck.d.ts +1 -1
  78. package/lib/checks/impl/LoginSessionCheck.d.ts +1 -1
  79. package/lib/checks/impl/MfaEnforcementCheck.d.ts +1 -1
  80. package/lib/checks/impl/MfaMethodStrengthCheck.d.ts +1 -1
  81. package/lib/checks/impl/MfaRegistrationCheck.d.ts +1 -1
  82. package/lib/checks/impl/MyDomainLoginPolicyCheck.d.ts +1 -1
  83. package/lib/checks/impl/NamedCredentialsCheck.d.ts +1 -1
  84. package/lib/checks/impl/NamedCredentialsCheck.js +7 -6
  85. package/lib/checks/impl/OutboundMessagesCheck.d.ts +1 -1
  86. package/lib/checks/impl/PasswordSessionPolicyCheck.d.ts +2 -2
  87. package/lib/checks/impl/PermissionsCheck.d.ts +1 -1
  88. package/lib/checks/impl/PrivilegedAccessCheck.d.ts +1 -1
  89. package/lib/checks/impl/PublicContentExposureCheck.d.ts +1 -1
  90. package/lib/checks/impl/PublicGroupSharingCheck.d.ts +1 -1
  91. package/lib/checks/impl/ReleaseUpdatesCheck.d.ts +1 -1
  92. package/lib/checks/impl/RemoteSitesCheck.d.ts +1 -1
  93. package/lib/checks/impl/ReportFolderAccessCheck.d.ts +1 -1
  94. package/lib/checks/impl/SandboxDataMaskingCheck.d.ts +1 -1
  95. package/lib/checks/impl/ScheduledApexCheck.d.ts +1 -1
  96. package/lib/checks/impl/SeparationOfDutiesCheck.d.ts +1 -1
  97. package/lib/checks/impl/SessionHardeningCheck.d.ts +1 -1
  98. package/lib/checks/impl/SharingModelCheck.d.ts +1 -1
  99. package/lib/checks/impl/SiemIntegrationCheck.d.ts +1 -1
  100. package/lib/checks/impl/SsoEnforcementCheck.d.ts +1 -1
  101. package/lib/checks/impl/StandardProfilesCheck.d.ts +1 -1
  102. package/lib/checks/impl/ThreatDetectionCheck.d.ts +1 -1
  103. package/lib/checks/impl/TransactionSecurityPolicyCheck.d.ts +1 -1
  104. package/lib/checks/impl/TrustedIPRangesCheck.d.ts +1 -1
  105. package/lib/checks/impl/TrustedUrlHygieneCheck.d.ts +1 -1
  106. package/lib/checks/impl/UsersAndAdminsCheck.d.ts +1 -1
  107. package/lib/checks/impl/VisualforceXssCheck.d.ts +1 -1
  108. package/lib/commands/audit/events/pull.d.ts +1 -1
  109. package/lib/commands/audit/events/pull.js +3 -3
  110. package/lib/commands/audit/security.js +3 -1
  111. package/lib/findings/AuditResult.d.ts +1 -1
  112. package/lib/findings/Finding.d.ts +1 -1
  113. package/lib/findings/ScoringConfig.d.ts +9 -217
  114. package/lib/findings/scoring.d.ts +2 -2
  115. package/lib/findings/scoring.js +1 -1
  116. package/lib/history/AuditDiff.d.ts +1 -1
  117. package/lib/history/metricMeta.d.ts +1 -1
  118. package/lib/index.d.ts +2 -2
  119. package/lib/lib/wire.d.ts +6 -6
  120. package/lib/lib/wire.js +4 -4
  121. package/lib/renderers/ClientReportRenderer.d.ts +1 -1
  122. package/lib/renderers/ClientReportRenderer.js +6 -3
  123. package/lib/renderers/HistoryRenderer.js +2 -1
  124. package/lib/renderers/HtmlRenderer.js +3 -4
  125. package/lib/renderers/MarkdownRenderer.js +1 -1
  126. package/lib/renderers/chartAsset.d.ts +12 -0
  127. package/lib/renderers/chartAsset.js +25 -0
  128. package/package.json +26 -28
  129. package/lib/api/ApiError.d.ts +0 -6
  130. package/lib/api/ApiError.js +0 -6
  131. package/lib/api/MetadataClient.d.ts +0 -4
  132. package/lib/api/MetadataClient.js +0 -2
  133. package/lib/api/MetadataClientImpl.d.ts +0 -8
  134. package/lib/api/MetadataClientImpl.js +0 -22
  135. package/lib/api/RestClient.d.ts +0 -6
  136. package/lib/api/RestClient.js +0 -2
  137. package/lib/api/RestClientImpl.d.ts +0 -10
  138. package/lib/api/RestClientImpl.js +0 -45
  139. package/lib/api/SoqlClient.d.ts +0 -10
  140. package/lib/api/SoqlClient.js +0 -2
  141. package/lib/api/SoqlClientImpl.d.ts +0 -9
  142. package/lib/api/SoqlClientImpl.js +0 -19
  143. package/lib/api/ToolingClient.d.ts +0 -5
  144. package/lib/api/ToolingClient.js +0 -2
  145. package/lib/api/ToolingClientImpl.d.ts +0 -10
  146. package/lib/api/ToolingClientImpl.js +0 -29
  147. package/lib/api/index.d.ts +0 -9
  148. package/lib/api/index.js +0 -5
  149. package/lib/checks/eventLogAccess.d.ts +0 -14
  150. package/lib/checks/eventLogAccess.js +0 -33
  151. package/lib/context/AuditCache.d.ts +0 -78
  152. package/lib/context/AuditCache.js +0 -2
  153. package/lib/context/AuditContext.d.ts +0 -19
  154. package/lib/context/AuditContext.js +0 -2
  155. package/lib/context/OrgInfo.d.ts +0 -9
  156. package/lib/context/OrgInfo.js +0 -2
  157. package/lib/context/OrgMetrics.d.ts +0 -20
  158. package/lib/context/OrgMetrics.js +0 -20
  159. package/lib/events/EventBaselineStore.d.ts +0 -16
  160. package/lib/events/EventBaselineStore.js +0 -55
  161. package/lib/events/eventLogQuery.d.ts +0 -21
  162. package/lib/events/eventLogQuery.js +0 -34
  163. package/lib/events/pullEventLogs.d.ts +0 -51
  164. package/lib/events/pullEventLogs.js +0 -79
  165. package/lib/findings/ComplianceMapping.d.ts +0 -3
  166. package/lib/findings/ComplianceMapping.js +0 -75
  167. package/lib/findings/RiskLevel.d.ts +0 -3
  168. package/lib/findings/RiskLevel.js +0 -2
  169. package/lib/queries/QueryDefinition.d.ts +0 -48
  170. package/lib/queries/QueryDefinition.js +0 -11
  171. package/lib/queries/QueryRegistry.d.ts +0 -13
  172. package/lib/queries/QueryRegistry.js +0 -93
  173. package/lib/renderers/html-utils.d.ts +0 -2
  174. package/lib/renderers/html-utils.js +0 -8
  175. package/lib/report/branding.d.ts +0 -18
  176. package/lib/report/branding.js +0 -19
  177. package/lib/report/fonts.d.ts +0 -2
  178. package/lib/report/fonts.js +0 -22
  179. package/src/assets/fonts/dm-sans-italic-latin.woff2 +0 -0
  180. package/src/assets/fonts/dm-sans-normal-latin.woff2 +0 -0
  181. package/src/assets/fonts/dm-serif-display-italic-latin.woff2 +0 -0
  182. package/src/assets/fonts/dm-serif-display-normal-latin.woff2 +0 -0
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class FlowsWithoutSharingCheck implements SecurityCheck {
4
4
  readonly id = "flows-without-sharing";
@@ -1,3 +1,4 @@
1
+ import { FlowRepository } from '@cclabsnz/sf-core';
1
2
  export class FlowsWithoutSharingCheck {
2
3
  id = 'flows-without-sharing';
3
4
  name = 'Flows Without Sharing Context';
@@ -6,12 +7,12 @@ export class FlowsWithoutSharingCheck {
6
7
  async run(ctx) {
7
8
  const findings = [];
8
9
  const baseUrl = ctx.orgInfo.instanceUrl;
9
- const flows = await ctx.tooling.query("SELECT Id, MasterLabel, ProcessType, Status, RunInMode FROM Flow WHERE Status = 'Active'");
10
+ const flows = await new FlowRepository(ctx.soql, ctx.tooling).listActiveVersions();
10
11
  const total = flows.length;
11
- const autolaunchedWithoutSharing = flows.filter((f) => f.ProcessType === 'AutoLaunchedFlow' &&
12
- (f.RunInMode === 'DefaultMode' || f.RunInMode === null));
13
- const screenWithoutSharing = flows.filter((f) => f.ProcessType === 'Flow' &&
14
- (f.RunInMode === 'DefaultMode' || f.RunInMode === null));
12
+ const autolaunchedWithoutSharing = flows.filter((f) => f.processType === 'AutoLaunchedFlow' &&
13
+ (f.runInMode === 'DefaultMode' || f.runInMode === null));
14
+ const screenWithoutSharing = flows.filter((f) => f.processType === 'Flow' &&
15
+ (f.runInMode === 'DefaultMode' || f.runInMode === null));
15
16
  if (autolaunchedWithoutSharing.length > 0) {
16
17
  const count = autolaunchedWithoutSharing.length;
17
18
  findings.push({
@@ -20,8 +21,8 @@ export class FlowsWithoutSharingCheck {
20
21
  riskLevel: 'HIGH',
21
22
  title: `${count} autolaunched flow(s) run without user sharing context`,
22
23
  affectedItems: autolaunchedWithoutSharing.map((f) => ({
23
- label: f.MasterLabel,
24
- url: `${baseUrl}/builder_platform_interaction/flowBuilder.app?flowId=${f.Id}`,
24
+ label: f.masterLabel,
25
+ url: `${baseUrl}/builder_platform_interaction/flowBuilder.app?flowId=${f.id}`,
25
26
  note: 'Set "Run Flow As" to "User" or document why system context is required',
26
27
  })),
27
28
  detail: "Autolaunched flows running in Default Mode execute with system-level data access, ignoring the triggering user's record visibility.",
@@ -36,8 +37,8 @@ export class FlowsWithoutSharingCheck {
36
37
  riskLevel: 'MEDIUM',
37
38
  title: `${count} screen flow(s) run without user sharing context`,
38
39
  affectedItems: screenWithoutSharing.map((f) => ({
39
- label: f.MasterLabel,
40
- url: `${baseUrl}/builder_platform_interaction/flowBuilder.app?flowId=${f.Id}`,
40
+ label: f.masterLabel,
41
+ url: `${baseUrl}/builder_platform_interaction/flowBuilder.app?flowId=${f.id}`,
41
42
  note: 'Review and set "Run Flow As" to "User" where appropriate',
42
43
  })),
43
44
  detail: "Screen flows in Default Mode may allow users to view or modify records they wouldn't normally have access to.",
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  /**
4
4
  * Flags guest (unauthenticated) users whose profile/permission-sets grant API or
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class GuestExecutableApexCheck implements SecurityCheck {
4
4
  readonly id = "guest-executable-apex";
@@ -1,3 +1,4 @@
1
+ import { ApexRepository } from '@cclabsnz/sf-core';
1
2
  const WITHOUT_SHARING = /\bwithout\s+sharing\b/i;
2
3
  const WITH_SHARING = /\bwith\s+sharing\b/i;
3
4
  export class GuestExecutableApexCheck {
@@ -40,9 +41,9 @@ export class GuestExecutableApexCheck {
40
41
  });
41
42
  return { findings };
42
43
  }
43
- const idList = classIds.map((id) => `'${id}'`).join(', ');
44
- const names = await ctx.tooling.query(`SELECT Id, Name FROM ApexClass WHERE Id IN (${idList})`);
45
- const nameById = new Map(names.map((n) => [n.Id, n.Name]));
44
+ // Ids are validated inside the repository: one malformed value in an IN(...) clause
45
+ // fails the whole query with "invalid ID field", losing every good row with it.
46
+ const nameById = await new ApexRepository(ctx.tooling).namesByIds(classIds);
46
47
  const bodies = ctx.cache.apexBodies ?? [];
47
48
  const bodyByName = new Map(bodies.map((b) => [b.name, b.body]));
48
49
  const unprotected = [];
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  /**
4
4
  * Detects every object an unauthenticated guest can READ IN BULK. Unlike
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  /**
4
4
  * Verifies the PREVENTIVE guardrail that stops the guest-ownership-defeats-OWD
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  /**
4
4
  * Flags two Experience Cloud Network settings that widen the unauthenticated
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class GuestTrafficAnomalyCheck implements SecurityCheck {
4
4
  readonly id = "guest-traffic-anomaly";
@@ -1,4 +1,4 @@
1
- import { classifyEventLogAccessError } from '../eventLogAccess.js';
1
+ import { classifyEventLogAccessError } from '@cclabsnz/sf-core';
2
2
  // EventLogFile types that carry unauthenticated guest request traffic. Sites is
3
3
  // the primary guest-page channel; AuraRequest and GraphQlQueryExecution are the
4
4
  // data-access vectors abused for recon and bulk read.
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class GuestUserAccessCheck implements SecurityCheck {
4
4
  readonly id = "guest-user-access";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class HardcodedCredentialsCheck implements SecurityCheck {
4
4
  readonly id = "hardcoded-credentials";
@@ -1,3 +1,4 @@
1
+ import { ApexRepository } from '@cclabsnz/sf-core';
1
2
  const HIGH_RISK_PATTERNS = [
2
3
  /Bearer\s+[A-Za-z0-9\-_.~+/]{20,}=*/gi, // Bearer tokens (min length to avoid test stubs)
3
4
  /Basic\s+[A-Za-z0-9+/]{20,}=*/gi, // Basic auth (min length)
@@ -31,7 +32,13 @@ export class HardcodedCredentialsCheck {
31
32
  const findings = [];
32
33
  const baseUrl = ctx.orgInfo.instanceUrl;
33
34
  const apexClassesUrl = `${baseUrl}/lightning/setup/ApexClasses/home`;
34
- const records = await ctx.tooling.query('SELECT Id, Name, Body, LengthWithoutComments, NamespacePrefix FROM ApexClass WHERE NamespacePrefix = null');
35
+ const records = (await new ApexRepository(ctx.tooling).listClasses({ excludeManaged: true })).map((c) => ({
36
+ Id: c.name,
37
+ Name: c.name,
38
+ Body: c.body ?? '',
39
+ LengthWithoutComments: (c.body ?? '').length,
40
+ NamespacePrefix: c.namespace,
41
+ }));
35
42
  // Cache apex bodies for downstream checks — exclude test classes and filter null bodies
36
43
  const nonTestRecords = records.filter((r) => !IS_TEST_CLASS.test(r.Body ?? ''));
37
44
  ctx.cache.apexBodies = nonTestRecords.map((r) => ({ name: r.Name, body: r.Body ?? '' }));
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class HealthCheckCheck implements SecurityCheck {
4
4
  readonly id = "health-check";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class HighAssuranceSessionCheck implements SecurityCheck {
4
4
  readonly id = "high-assurance-session";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class InactiveUsersCheck implements SecurityCheck {
4
4
  readonly id = "inactive-users";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class InstalledPackagesCheck implements SecurityCheck {
4
4
  readonly id = "installed-packages";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class IntegrationUsersCheck implements SecurityCheck {
4
4
  readonly id = "integration-users";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class InternalUserMfaCheck implements SecurityCheck {
4
4
  readonly id = "internal-user-mfa";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class IpRestrictionsCheck implements SecurityCheck {
4
4
  readonly id = "ip-restrictions";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class LegacyApiVersionCheck implements SecurityCheck {
4
4
  readonly id = "legacy-api-version";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  /**
4
4
  * Surfaces impersonation / delegated-administration paths that bypass a user's
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  /**
4
4
  * Complements `failed-login-detection` (which only sees failures) by looking at
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class LoginSessionCheck implements SecurityCheck {
4
4
  readonly id = "login-session";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class MfaEnforcementCheck implements SecurityCheck {
4
4
  readonly id = "mfa-enforcement";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class MfaMethodStrengthCheck implements SecurityCheck {
4
4
  readonly id = "mfa-method-strength";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class MfaRegistrationCheck implements SecurityCheck {
4
4
  readonly id = "mfa-registration";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class MyDomainLoginPolicyCheck implements SecurityCheck {
4
4
  readonly id = "my-domain-login-policy";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class NamedCredentialsCheck implements SecurityCheck {
4
4
  readonly id = "named-credentials";
@@ -1,3 +1,4 @@
1
+ import { ApexRepository } from '@cclabsnz/sf-core';
1
2
  export class NamedCredentialsCheck {
2
3
  id = 'named-credentials';
3
4
  name = 'Named Credentials';
@@ -12,7 +13,7 @@ export class NamedCredentialsCheck {
12
13
  const records = await ctx.tooling.query('SELECT Id, MasterLabel, DeveloperName, Endpoint, PrincipalType FROM NamedCredential');
13
14
  const count = records.length;
14
15
  // Cache the endpoints for use by HardcodedCredentialsCheck
15
- ctx.cache.namedCredentialEndpoints = records.map((r) => r.Endpoint);
16
+ ctx.cache.namedCredentialEndpoints = records.map((r) => r.Endpoint).filter((e) => !!e);
16
17
  if (count === 0) {
17
18
  findings.push({
18
19
  id: 'named-credentials-none',
@@ -29,8 +30,8 @@ export class NamedCredentialsCheck {
29
30
  let apexBodies = ctx.cache.apexBodies ?? [];
30
31
  if (apexBodies.length === 0) {
31
32
  try {
32
- const apexRecords = await ctx.tooling.query('SELECT Name, Body FROM ApexClass WHERE NamespacePrefix = null');
33
- apexBodies = apexRecords.map((r) => ({ name: r.Name, body: r.Body ?? '' }));
33
+ const apexRecords = await new ApexRepository(ctx.tooling).listClasses({ excludeManaged: true });
34
+ apexBodies = apexRecords.map((r) => ({ name: r.name, body: r.body ?? '' }));
34
35
  }
35
36
  catch {
36
37
  // If we can't scan Apex, emit inventory only
@@ -44,7 +45,7 @@ export class NamedCredentialsCheck {
44
45
  affectedItems: records.map((r) => ({
45
46
  label: r.MasterLabel,
46
47
  url: setupUrl,
47
- note: r.Endpoint,
48
+ note: r.Endpoint ?? '(no endpoint — External Credential)',
48
49
  })),
49
50
  });
50
51
  return { findings, metrics: { namedCredentialsCount: count, unusedNamedCredentialsCount: 0 } };
@@ -69,7 +70,7 @@ export class NamedCredentialsCheck {
69
70
  affectedItems: records.map((r) => ({
70
71
  label: r.MasterLabel,
71
72
  url: setupUrl,
72
- note: r.Endpoint,
73
+ note: r.Endpoint ?? '(no endpoint — External Credential)',
73
74
  })),
74
75
  });
75
76
  // Flag unused credentials
@@ -89,7 +90,7 @@ export class NamedCredentialsCheck {
89
90
  });
90
91
  }
91
92
  // SBS-INT-003: flag plaintext HTTP endpoints — credentials transmitted unencrypted in transit.
92
- const httpEndpoints = records.filter((r) => r.Endpoint.startsWith('http://'));
93
+ const httpEndpoints = records.filter((r) => r.Endpoint?.startsWith('http://') ?? false);
93
94
  if (httpEndpoints.length > 0) {
94
95
  findings.push({
95
96
  id: 'named-credentials-http-endpoint',
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class OutboundMessagesCheck implements SecurityCheck {
4
4
  readonly id = "outbound-messages";
@@ -1,6 +1,6 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
- import type { AuditCache } from '../../context/AuditCache.js';
3
+ import type { AuditCache } from '@cclabsnz/sf-core';
4
4
  export declare class PasswordSessionPolicyCheck implements SecurityCheck {
5
5
  readonly id = "password-session-policy";
6
6
  readonly name = "Password and Session Policy";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class PermissionsCheck implements SecurityCheck {
4
4
  readonly id = "permissions";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class PrivilegedAccessCheck implements SecurityCheck {
4
4
  readonly id = "privileged-access";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class PublicContentExposureCheck implements SecurityCheck {
4
4
  readonly id = "public-content-exposure";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class PublicGroupSharingCheck implements SecurityCheck {
4
4
  readonly id = "public-group-sharing";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class ReleaseUpdatesCheck implements SecurityCheck {
4
4
  readonly id = "release-updates";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class RemoteSitesCheck implements SecurityCheck {
4
4
  readonly id = "remote-sites";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class ReportFolderAccessCheck implements SecurityCheck {
4
4
  readonly id = "report-folder-access";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  /**
4
4
  * Advisory for sandboxes: production data copied into a sandbox and left unmasked
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class ScheduledApexCheck implements SecurityCheck {
4
4
  readonly id = "scheduled-apex";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class SeparationOfDutiesCheck implements SecurityCheck {
4
4
  readonly id = "separation-of-duties";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  /**
4
4
  * Re-slices the Health Check risk set (populated by HealthCheckCheck, so no extra
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class SharingModelCheck implements SecurityCheck {
4
4
  readonly id = "sharing-model";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class SiemIntegrationCheck implements SecurityCheck {
4
4
  readonly id = "siem-integration";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class SsoEnforcementCheck implements SecurityCheck {
4
4
  readonly id = "sso-enforcement";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class StandardProfilesCheck implements SecurityCheck {
4
4
  readonly id = "standard-profiles";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  /**
4
4
  * Verifies that Threat Detection event storage (especially Guest User Anomaly) is
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class TransactionSecurityPolicyCheck implements SecurityCheck {
4
4
  readonly id = "transaction-security-policy";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class TrustedIPRangesCheck implements SecurityCheck {
4
4
  readonly id = "trusted-ip-ranges";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class TrustedUrlHygieneCheck implements SecurityCheck {
4
4
  readonly id = "trusted-url-hygiene";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class UsersAndAdminsCheck implements SecurityCheck {
4
4
  readonly id = "users-and-admins";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class VisualforceXssCheck implements SecurityCheck {
4
4
  readonly id = "visualforce-xss";
@@ -1,5 +1,5 @@
1
1
  import { SfCommand } from '@salesforce/sf-plugins-core';
2
- import { type EventsPullResult } from '../../../events/pullEventLogs.js';
2
+ import { type EventsPullResult } from '@cclabsnz/sf-core';
3
3
  export default class AuditEventsPullCommand extends SfCommand<EventsPullResult> {
4
4
  static summary: string;
5
5
  static description: string;
@@ -1,9 +1,9 @@
1
1
  // src/commands/audit/events/pull.ts
2
2
  import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
3
3
  import { buildAuditContext, resolveOrgInfo } from '../../../lib/wire.js';
4
- import { EventBaselineStore } from '../../../events/EventBaselineStore.js';
5
- import { pullEventLogs } from '../../../events/pullEventLogs.js';
6
- import { sanitizeTypes } from '../../../events/eventLogQuery.js';
4
+ import { EventBaselineStore } from '@cclabsnz/sf-core';
5
+ import { pullEventLogs } from '@cclabsnz/sf-core';
6
+ import { sanitizeTypes } from '@cclabsnz/sf-core';
7
7
  export default class AuditEventsPullCommand extends SfCommand {
8
8
  static summary = 'Capture free EventLogFile daily logs to local disk';
9
9
  static description = 'Downloads the org\'s free (Daily-interval) EventLogFile CSV logs to ~/.sf/event-baseline/{orgId} so they ' +
@@ -7,7 +7,7 @@ import { JsonRenderer } from '../../renderers/JsonRenderer.js';
7
7
  import { HtmlRenderer } from '../../renderers/HtmlRenderer.js';
8
8
  import { MarkdownRenderer } from '../../renderers/MarkdownRenderer.js';
9
9
  import { ClientReportRenderer } from '../../renderers/ClientReportRenderer.js';
10
- import { resolveBranding } from '../../report/branding.js';
10
+ import { resolveBranding } from '@cclabsnz/sf-core';
11
11
  import { resolveFrameworks } from '../../compliance/resolve.js';
12
12
  import { buildAuditContext, resolveOrgInfo } from '../../lib/wire.js';
13
13
  import { loadScoringConfig } from '../../findings/loadScoringConfig.js';
@@ -107,6 +107,8 @@ export default class SecurityAuditCommand extends SfCommand {
107
107
  store.archive(result);
108
108
  this.log('');
109
109
  this.printSummary(result);
110
+ this.log('');
111
+ this.log(' Deep dives: https://softwareinsights.dev · Remediation help: https://cloudcounsel.co.nz');
110
112
  if (flags['fail-on']) {
111
113
  this.handleFailOn(result, flags['fail-on']);
112
114
  }
@@ -1,5 +1,5 @@
1
1
  import type { Finding } from './Finding.js';
2
- import type { OrgMetrics } from '../context/OrgMetrics.js';
2
+ import type { OrgMetrics } from '@cclabsnz/sf-core';
3
3
  import type { AttackChain } from '../chains/AttackChain.js';
4
4
  export interface AuditResult {
5
5
  generatedAt: Date;
@@ -1,4 +1,4 @@
1
- import type { RiskLevel } from './RiskLevel.js';
1
+ import type { RiskLevel } from '@cclabsnz/sf-core';
2
2
  import type { Capability } from '../chains/Capability.js';
3
3
  export interface AffectedItem {
4
4
  label: string;