@cclabsnz/sf-audit 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -0
- package/lib/api/ToolingClientImpl.js +5 -2
- package/lib/chains/AttackChain.d.ts +20 -0
- package/lib/chains/AttackChain.js +2 -0
- package/lib/chains/Capability.d.ts +7 -0
- package/lib/chains/Capability.js +11 -0
- package/lib/chains/CapabilityRegistry.d.ts +18 -0
- package/lib/chains/CapabilityRegistry.js +53 -0
- package/lib/chains/ChainEngine.d.ts +13 -0
- package/lib/chains/ChainEngine.js +137 -0
- package/lib/chains/namedChains.d.ts +14 -0
- package/lib/chains/namedChains.js +99 -0
- package/lib/checks/CheckEngine.js +33 -5
- package/lib/checks/impl/AnonymousApexAuditCheck.d.ts +10 -0
- package/lib/checks/impl/AnonymousApexAuditCheck.js +106 -0
- package/lib/checks/impl/ApexCrudFLSCheck.d.ts +11 -0
- package/lib/checks/impl/ApexCrudFLSCheck.js +98 -0
- package/lib/checks/impl/ApexLoggingCheck.d.ts +11 -0
- package/lib/checks/impl/ApexLoggingCheck.js +124 -0
- package/lib/checks/impl/ApexRestEndpointCheck.d.ts +11 -0
- package/lib/checks/impl/ApexRestEndpointCheck.js +94 -0
- package/lib/checks/impl/ApexSharingCheck.js +29 -0
- package/lib/checks/impl/ApiClientPermissionCheck.d.ts +10 -0
- package/lib/checks/impl/ApiClientPermissionCheck.js +59 -0
- package/lib/checks/impl/AuditTrailCheck.js +29 -0
- package/lib/checks/impl/CertificateExpiryCheck.d.ts +10 -0
- package/lib/checks/impl/CertificateExpiryCheck.js +123 -0
- package/lib/checks/impl/CodeSecurityCheck.d.ts +2 -1
- package/lib/checks/impl/CodeSecurityCheck.js +46 -6
- package/lib/checks/impl/ConnectedAppInactivityCheck.d.ts +11 -0
- package/lib/checks/impl/ConnectedAppInactivityCheck.js +86 -0
- package/lib/checks/impl/ConnectedAppScopeCheck.d.ts +10 -0
- package/lib/checks/impl/ConnectedAppScopeCheck.js +125 -0
- package/lib/checks/impl/ConnectedAppsCheck.d.ts +1 -0
- package/lib/checks/impl/ConnectedAppsCheck.js +37 -2
- package/lib/checks/impl/ContentLinksCheck.d.ts +10 -0
- package/lib/checks/impl/ContentLinksCheck.js +115 -0
- package/lib/checks/impl/CorsAllowlistCheck.d.ts +10 -0
- package/lib/checks/impl/CorsAllowlistCheck.js +80 -0
- package/lib/checks/impl/CspTrustedSitesCheck.d.ts +10 -0
- package/lib/checks/impl/CspTrustedSitesCheck.js +55 -0
- package/lib/checks/impl/CustomLabelsCredentialCheck.d.ts +10 -0
- package/lib/checks/impl/CustomLabelsCredentialCheck.js +97 -0
- package/lib/checks/impl/DataClassificationCheck.d.ts +10 -0
- package/lib/checks/impl/DataClassificationCheck.js +112 -0
- package/lib/checks/impl/DebugLogAccessCheck.d.ts +10 -0
- package/lib/checks/impl/DebugLogAccessCheck.js +81 -0
- package/lib/checks/impl/DeploymentIdentityCheck.d.ts +11 -0
- package/lib/checks/impl/DeploymentIdentityCheck.js +144 -0
- package/lib/checks/impl/EnhancedDomainsCheck.d.ts +10 -0
- package/lib/checks/impl/EnhancedDomainsCheck.js +84 -0
- package/lib/checks/impl/EscalationPermsCheck.d.ts +10 -0
- package/lib/checks/impl/EscalationPermsCheck.js +77 -0
- package/lib/checks/impl/EventMonitoringCheck.d.ts +11 -0
- package/lib/checks/impl/EventMonitoringCheck.js +84 -0
- package/lib/checks/impl/ExperienceCloudSiteCheck.d.ts +10 -0
- package/lib/checks/impl/ExperienceCloudSiteCheck.js +91 -0
- package/lib/checks/impl/FailedLoginCheck.d.ts +10 -0
- package/lib/checks/impl/FailedLoginCheck.js +122 -0
- package/lib/checks/impl/FieldHistoryTrackingCheck.d.ts +10 -0
- package/lib/checks/impl/FieldHistoryTrackingCheck.js +70 -0
- package/lib/checks/impl/FieldLevelSecurityCheck.js +28 -18
- package/lib/checks/impl/GuestExecutableApexCheck.d.ts +11 -0
- package/lib/checks/impl/GuestExecutableApexCheck.js +93 -0
- package/lib/checks/impl/GuestUserAccessCheck.js +74 -66
- package/lib/checks/impl/HardcodedCredentialsCheck.js +2 -2
- package/lib/checks/impl/HighAssuranceSessionCheck.d.ts +10 -0
- package/lib/checks/impl/HighAssuranceSessionCheck.js +103 -0
- package/lib/checks/impl/InactiveUsersCheck.js +38 -19
- package/lib/checks/impl/InstalledPackagesCheck.d.ts +10 -0
- package/lib/checks/impl/InstalledPackagesCheck.js +94 -0
- package/lib/checks/impl/IntegrationUsersCheck.d.ts +10 -0
- package/lib/checks/impl/IntegrationUsersCheck.js +108 -0
- package/lib/checks/impl/InternalUserMfaCheck.d.ts +10 -0
- package/lib/checks/impl/InternalUserMfaCheck.js +81 -0
- package/lib/checks/impl/IpRestrictionsCheck.js +86 -23
- package/lib/checks/impl/LegacyApiVersionCheck.d.ts +10 -0
- package/lib/checks/impl/LegacyApiVersionCheck.js +91 -0
- package/lib/checks/impl/MfaEnforcementCheck.d.ts +10 -0
- package/lib/checks/impl/MfaEnforcementCheck.js +76 -0
- package/lib/checks/impl/MfaMethodStrengthCheck.d.ts +11 -0
- package/lib/checks/impl/MfaMethodStrengthCheck.js +116 -0
- package/lib/checks/impl/MfaRegistrationCheck.d.ts +11 -0
- package/lib/checks/impl/MfaRegistrationCheck.js +95 -0
- package/lib/checks/impl/MyDomainLoginPolicyCheck.d.ts +10 -0
- package/lib/checks/impl/MyDomainLoginPolicyCheck.js +105 -0
- package/lib/checks/impl/NamedCredentialsCheck.js +37 -2
- package/lib/checks/impl/PermissionsCheck.js +67 -14
- package/lib/checks/impl/PublicGroupSharingCheck.js +20 -9
- package/lib/checks/impl/ReleaseUpdatesCheck.d.ts +10 -0
- package/lib/checks/impl/ReleaseUpdatesCheck.js +106 -0
- package/lib/checks/impl/ReportFolderAccessCheck.d.ts +10 -0
- package/lib/checks/impl/ReportFolderAccessCheck.js +54 -0
- package/lib/checks/impl/ScheduledApexCheck.d.ts +1 -0
- package/lib/checks/impl/ScheduledApexCheck.js +3 -0
- package/lib/checks/impl/SharingModelCheck.d.ts +1 -1
- package/lib/checks/impl/SharingModelCheck.js +103 -32
- package/lib/checks/impl/SiemIntegrationCheck.d.ts +11 -0
- package/lib/checks/impl/SiemIntegrationCheck.js +102 -0
- package/lib/checks/impl/SsoEnforcementCheck.d.ts +10 -0
- package/lib/checks/impl/SsoEnforcementCheck.js +90 -0
- package/lib/checks/impl/StandardProfilesCheck.d.ts +10 -0
- package/lib/checks/impl/StandardProfilesCheck.js +68 -0
- package/lib/checks/impl/TransactionSecurityPolicyCheck.d.ts +10 -0
- package/lib/checks/impl/TransactionSecurityPolicyCheck.js +62 -0
- package/lib/checks/impl/TrustedIPRangesCheck.d.ts +10 -0
- package/lib/checks/impl/TrustedIPRangesCheck.js +106 -0
- package/lib/checks/impl/UsersAndAdminsCheck.js +50 -20
- package/lib/checks/impl/VisualforceXssCheck.d.ts +11 -0
- package/lib/checks/impl/VisualforceXssCheck.js +150 -0
- package/lib/checks/registry.js +97 -12
- package/lib/commands/audit/diff.d.ts +17 -0
- package/lib/commands/audit/diff.js +76 -0
- package/lib/commands/audit/history.d.ts +15 -0
- package/lib/commands/audit/history.js +59 -0
- package/lib/commands/audit/security.js +6 -6
- package/lib/context/AuditCache.d.ts +20 -0
- package/lib/context/AuditContext.d.ts +0 -2
- package/lib/findings/AuditResult.d.ts +3 -0
- package/lib/findings/ComplianceMapping.d.ts +3 -0
- package/lib/findings/ComplianceMapping.js +75 -0
- package/lib/findings/Finding.d.ts +20 -0
- package/lib/findings/loadScoringConfig.js +9 -2
- package/lib/findings/scoring.d.ts +2 -1
- package/lib/findings/scoring.js +20 -7
- package/lib/history/AuditDiff.d.ts +26 -0
- package/lib/history/AuditDiff.js +2 -0
- package/lib/history/DiffEngine.d.ts +4 -0
- package/lib/history/DiffEngine.js +61 -0
- package/lib/history/HistoryStore.d.ts +11 -0
- package/lib/history/HistoryStore.js +56 -0
- package/lib/history/metricMeta.d.ts +9 -0
- package/lib/history/metricMeta.js +28 -0
- package/lib/index.d.ts +7 -1
- package/lib/index.js +2 -1
- package/lib/lib/wire.d.ts +1 -2
- package/lib/lib/wire.js +1 -2
- package/lib/renderers/DiffHtmlRenderer.d.ts +8 -0
- package/lib/renderers/DiffHtmlRenderer.js +164 -0
- package/lib/renderers/DiffJsonRenderer.d.ts +8 -0
- package/lib/renderers/DiffJsonRenderer.js +8 -0
- package/lib/renderers/DiffRenderer.d.ts +7 -0
- package/lib/renderers/DiffRenderer.js +2 -0
- package/lib/renderers/HistoryRenderer.d.ts +6 -0
- package/lib/renderers/HistoryRenderer.js +140 -0
- package/lib/renderers/HtmlRenderer.d.ts +1 -0
- package/lib/renderers/HtmlRenderer.js +354 -54
- package/lib/renderers/MarkdownRenderer.js +34 -1
- package/package.json +3 -3
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
export class MyDomainLoginPolicyCheck {
|
|
2
|
+
id = 'my-domain-login-policy';
|
|
3
|
+
name = 'My Domain Login Policy';
|
|
4
|
+
category = 'Authentication';
|
|
5
|
+
description = 'Checks that My Domain is configured and login from login.salesforce.com is prevented — stops SSO bypass';
|
|
6
|
+
async run(ctx) {
|
|
7
|
+
const findings = [];
|
|
8
|
+
const baseUrl = ctx.orgInfo.instanceUrl;
|
|
9
|
+
const ssoSetupUrl = `${baseUrl}/lightning/setup/SingleSignOn/home`;
|
|
10
|
+
const domainSetupUrl = `${baseUrl}/lightning/setup/MyDomain/home`;
|
|
11
|
+
// Q1 (SOQL): check if My Domain is configured
|
|
12
|
+
const orgResult = await ctx.soql.query(`SELECT MyDomain, IsSandbox FROM Organization LIMIT 1`);
|
|
13
|
+
const org = orgResult.records[0];
|
|
14
|
+
const myDomain = org?.MyDomain ?? null;
|
|
15
|
+
const isSandbox = org?.IsSandbox ?? false;
|
|
16
|
+
if (!myDomain) {
|
|
17
|
+
findings.push({
|
|
18
|
+
id: 'my-domain-not-configured',
|
|
19
|
+
category: this.category,
|
|
20
|
+
riskLevel: isSandbox ? 'MEDIUM' : 'HIGH',
|
|
21
|
+
title: 'My Domain is not configured',
|
|
22
|
+
detail: `My Domain is required to enforce SSO and to control the login experience. Without My Domain, users can authenticate directly via \`login.salesforce.com\` bypassing any identity provider restrictions. My Domain is also a prerequisite for Lightning Experience, SSO, and Enhanced Domains.`,
|
|
23
|
+
remediation: 'Configure My Domain in Setup → My Domain. After deployment, set the login policy to "Prevent login from login.salesforce.com" to ensure all logins go through your identity provider.',
|
|
24
|
+
affectedItems: [{ label: 'My Domain Setup', url: domainSetupUrl, note: 'My Domain not configured — required for SSO enforcement' }],
|
|
25
|
+
});
|
|
26
|
+
return { findings };
|
|
27
|
+
}
|
|
28
|
+
findings.push({
|
|
29
|
+
id: 'my-domain-configured',
|
|
30
|
+
category: this.category,
|
|
31
|
+
riskLevel: 'INFO',
|
|
32
|
+
title: `My Domain configured: ${myDomain}`,
|
|
33
|
+
detail: `The org has a custom My Domain (${myDomain}) configured, which is a prerequisite for SSO enforcement and Enhanced Domains.`,
|
|
34
|
+
remediation: 'Verify the login policy in Setup → My Domain prevents login from login.salesforce.com.',
|
|
35
|
+
});
|
|
36
|
+
// Q2 (Tooling): check AuthConfig for login options.
|
|
37
|
+
// If AuthOptionsUsernamePassword is false in the AuthConfig for the org domain,
|
|
38
|
+
// users cannot log in with Salesforce credentials — they must go through SSO.
|
|
39
|
+
try {
|
|
40
|
+
const authConfigs = await ctx.tooling.query(`SELECT DeveloperName, AuthOptionsSaml, AuthOptionsUsernamePassword, IsDisabled
|
|
41
|
+
FROM AuthConfig
|
|
42
|
+
WHERE IsDisabled = false`);
|
|
43
|
+
if (authConfigs.length === 0) {
|
|
44
|
+
findings.push({
|
|
45
|
+
id: 'my-domain-auth-config-empty',
|
|
46
|
+
category: this.category,
|
|
47
|
+
riskLevel: 'MEDIUM',
|
|
48
|
+
title: 'No active AuthConfig found — My Domain login policy unverified',
|
|
49
|
+
detail: 'The My Domain login policy (which controls whether users can log in with Salesforce credentials or must use SSO) could not be read from AuthConfig. The login policy may allow credential-based login even when SSO is configured.',
|
|
50
|
+
remediation: 'Manually verify in Setup → My Domain → Authentication Configuration that "Prevent Login from login.salesforce.com" is enabled.',
|
|
51
|
+
affectedItems: [{ label: myDomain, url: domainSetupUrl, note: 'Verify authentication configuration manually' }],
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// An AuthConfig where AuthOptionsUsernamePassword = true means password login is allowed
|
|
56
|
+
const passwordAllowed = authConfigs.filter((c) => c.AuthOptionsUsernamePassword);
|
|
57
|
+
const ssoEnforced = authConfigs.filter((c) => !c.AuthOptionsUsernamePassword && c.AuthOptionsSaml);
|
|
58
|
+
if (passwordAllowed.length > 0) {
|
|
59
|
+
findings.push({
|
|
60
|
+
id: 'my-domain-password-login-allowed',
|
|
61
|
+
category: this.category,
|
|
62
|
+
riskLevel: 'HIGH',
|
|
63
|
+
title: 'My Domain allows username-password login — SSO not enforced',
|
|
64
|
+
detail: `The AuthConfig for this org allows users to log in with Salesforce username and password, meaning SSO via your identity provider is not the only authentication path. Users can bypass SSO (and its MFA, conditional access, and session controls) by using direct credentials. Affected authentication configuration(s): ${passwordAllowed.map((c) => c.DeveloperName).join(', ')}.`,
|
|
65
|
+
remediation: 'In Setup → My Domain → Authentication Configuration, disable "Login Page" (Salesforce credentials) as an authentication option. Ensure SAML/SSO is the only allowed method. Also enable "Prevent Login from login.salesforce.com" in My Domain settings.',
|
|
66
|
+
affectedItems: passwordAllowed.map((c) => ({
|
|
67
|
+
label: c.DeveloperName,
|
|
68
|
+
url: domainSetupUrl,
|
|
69
|
+
note: 'AuthOptionsUsernamePassword = true — disable password login to enforce SSO',
|
|
70
|
+
})),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if (ssoEnforced.length > 0 && passwordAllowed.length === 0) {
|
|
74
|
+
findings.push({
|
|
75
|
+
id: 'my-domain-sso-enforced',
|
|
76
|
+
category: this.category,
|
|
77
|
+
riskLevel: 'LOW',
|
|
78
|
+
passed: true,
|
|
79
|
+
title: 'My Domain is configured to require SSO — password login disabled',
|
|
80
|
+
detail: `The AuthConfig for this org has SAML enabled and password login disabled, indicating SSO is enforced via My Domain. Users cannot log in with Salesforce credentials — they must authenticate through the configured identity provider.`,
|
|
81
|
+
remediation: 'Verify that the SAML configuration points to the correct identity provider and that the IdP enforces MFA.',
|
|
82
|
+
affectedItems: ssoEnforced.map((c) => ({
|
|
83
|
+
label: c.DeveloperName,
|
|
84
|
+
url: ssoSetupUrl,
|
|
85
|
+
note: 'SAML only — password login disabled',
|
|
86
|
+
})),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
findings.push({
|
|
93
|
+
id: 'my-domain-auth-config-inaccessible',
|
|
94
|
+
category: this.category,
|
|
95
|
+
riskLevel: 'MEDIUM',
|
|
96
|
+
inconclusive: true,
|
|
97
|
+
title: 'My Domain login policy could not be verified — AuthConfig not accessible',
|
|
98
|
+
detail: 'The Tooling API AuthConfig query was not accessible. The My Domain login policy (credential login vs SSO-only) cannot be automatically verified.',
|
|
99
|
+
remediation: 'Manually verify in Setup → My Domain → Authentication Configuration that "Login Page" is disabled and "Prevent Login from login.salesforce.com" is enabled.',
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return { findings };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=MyDomainLoginPolicyCheck.js.map
|
|
@@ -8,8 +8,8 @@ export class NamedCredentialsCheck {
|
|
|
8
8
|
const findings = [];
|
|
9
9
|
const baseUrl = ctx.orgInfo.instanceUrl;
|
|
10
10
|
const setupUrl = `${baseUrl}/lightning/setup/NamedCredential/home`;
|
|
11
|
-
//
|
|
12
|
-
const records = await ctx.tooling.query('SELECT Id, MasterLabel, DeveloperName, Endpoint FROM NamedCredential');
|
|
11
|
+
// Single Tooling query — PrincipalType lets us flag anonymous (no-auth) credentials
|
|
12
|
+
const records = await ctx.tooling.query('SELECT Id, MasterLabel, DeveloperName, Endpoint, PrincipalType FROM NamedCredential');
|
|
13
13
|
const count = records.length;
|
|
14
14
|
// Cache the endpoints for use by HardcodedCredentialsCheck
|
|
15
15
|
ctx.cache.namedCredentialEndpoints = records.map((r) => r.Endpoint);
|
|
@@ -88,6 +88,41 @@ export class NamedCredentialsCheck {
|
|
|
88
88
|
})),
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
+
// SBS-INT-003: flag plaintext HTTP endpoints — credentials transmitted unencrypted in transit.
|
|
92
|
+
const httpEndpoints = records.filter((r) => r.Endpoint.startsWith('http://'));
|
|
93
|
+
if (httpEndpoints.length > 0) {
|
|
94
|
+
findings.push({
|
|
95
|
+
id: 'named-credentials-http-endpoint',
|
|
96
|
+
category: this.category,
|
|
97
|
+
riskLevel: 'HIGH',
|
|
98
|
+
title: `${httpEndpoints.length} named credential(s) use plaintext HTTP endpoints`,
|
|
99
|
+
detail: 'Named credentials pointing to http:// endpoints transmit authentication tokens and data over an unencrypted channel, exposing them to interception. SBS-INT-003 requires inventory and justification of all named credential endpoints.',
|
|
100
|
+
remediation: 'Update each credential to use an https:// endpoint. If the target service does not support HTTPS, escalate to the vendor.',
|
|
101
|
+
affectedItems: httpEndpoints.map((r) => ({
|
|
102
|
+
label: r.MasterLabel,
|
|
103
|
+
url: setupUrl,
|
|
104
|
+
note: `${r.Endpoint} — migrate to HTTPS`,
|
|
105
|
+
})),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
// Flag anonymous (no-auth) named credentials: PrincipalType = 'Anonymous' means no credentials
|
|
109
|
+
// are sent to the endpoint, which may indicate misconfiguration for authenticated services.
|
|
110
|
+
const anonymousCreds = records.filter((r) => r.PrincipalType === 'Anonymous');
|
|
111
|
+
if (anonymousCreds.length > 0) {
|
|
112
|
+
findings.push({
|
|
113
|
+
id: 'named-credentials-anonymous',
|
|
114
|
+
category: this.category,
|
|
115
|
+
riskLevel: 'LOW',
|
|
116
|
+
title: `${anonymousCreds.length} named credential(s) use anonymous (no-auth) principal type`,
|
|
117
|
+
detail: 'Named credentials with PrincipalType "Anonymous" send no authentication to the external endpoint. This is acceptable for public APIs but should be reviewed to confirm no sensitive data is exchanged without authentication.',
|
|
118
|
+
remediation: 'Confirm that anonymous named credentials only point to fully public APIs. If any exchange sensitive data, configure Named User or Per-User OAuth authentication.',
|
|
119
|
+
affectedItems: anonymousCreds.map((r) => ({
|
|
120
|
+
label: r.MasterLabel,
|
|
121
|
+
url: setupUrl,
|
|
122
|
+
note: `${r.Endpoint} — verify that no authentication is required`,
|
|
123
|
+
})),
|
|
124
|
+
});
|
|
125
|
+
}
|
|
91
126
|
return {
|
|
92
127
|
findings,
|
|
93
128
|
metrics: {
|
|
@@ -47,22 +47,36 @@ export class PermissionsCheck {
|
|
|
47
47
|
detail: 'A large number of permission sets increases administrative complexity and makes it harder to audit access effectively.',
|
|
48
48
|
remediation: 'Review and consolidate permission sets. Excessive numbers increase administrative complexity and expand the attack surface.',
|
|
49
49
|
});
|
|
50
|
-
// Unassigned custom permission sets — exclude direct assignments AND membership in a permission set group
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
// Unassigned custom permission sets — exclude direct assignments AND membership in a permission set group.
|
|
51
|
+
// The double NOT IN semi-join is governor-limited to 2,000 records per subquery; wrap in try-catch.
|
|
52
|
+
try {
|
|
53
|
+
const unassignedResult = await ctx.soql.query('SELECT Id, Name FROM PermissionSet WHERE IsCustom = true AND Id NOT IN (SELECT PermissionSetId FROM PermissionSetAssignment) AND Id NOT IN (SELECT PermissionSetId FROM PermissionSetGroupComponent)');
|
|
54
|
+
const unassignedSets = unassignedResult.records;
|
|
55
|
+
const unassignedCount = unassignedSets.length;
|
|
56
|
+
if (unassignedCount > 0) {
|
|
57
|
+
findings.push({
|
|
58
|
+
id: 'permissions-unassigned-sets',
|
|
59
|
+
category: this.category,
|
|
60
|
+
riskLevel: 'LOW',
|
|
61
|
+
title: `${unassignedCount} permission set(s) are defined but never assigned`,
|
|
62
|
+
detail: 'Permission sets that are defined but never assigned to any user (directly or via a permission set group) represent configuration bloat and may indicate outdated or orphaned access configurations.',
|
|
63
|
+
remediation: 'Unused permission sets should be reviewed and deleted to reduce configuration bloat.',
|
|
64
|
+
affectedItems: unassignedSets.map((r) => ({
|
|
65
|
+
label: r.Name,
|
|
66
|
+
url: `${baseUrl}/${r.Id}`,
|
|
67
|
+
})),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
55
72
|
findings.push({
|
|
56
|
-
id: 'permissions-unassigned-
|
|
73
|
+
id: 'permissions-unassigned-inconclusive',
|
|
57
74
|
category: this.category,
|
|
58
|
-
riskLevel: '
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
label: r.Name,
|
|
64
|
-
url: `${baseUrl}/${r.Id}`,
|
|
65
|
-
})),
|
|
75
|
+
riskLevel: 'INFO',
|
|
76
|
+
inconclusive: true,
|
|
77
|
+
title: 'Unassigned permission set check could not be completed',
|
|
78
|
+
detail: 'The semi-join query to identify unassigned permission sets failed — this can occur in orgs with very large numbers of permission set assignments (governor limit on semi-join subqueries). Review orphaned permission sets manually.',
|
|
79
|
+
remediation: 'In Setup → Permission Sets, sort by Last Modified and review sets that appear to have no user assignments.',
|
|
66
80
|
});
|
|
67
81
|
}
|
|
68
82
|
// Custom profile count: exclude known standard Salesforce profiles by name.
|
|
@@ -80,6 +94,45 @@ export class PermissionsCheck {
|
|
|
80
94
|
remediation: 'Consider migrating access control from profiles to permission sets for more granular and auditable access management.',
|
|
81
95
|
});
|
|
82
96
|
}
|
|
97
|
+
// SBS-ACS-002: every entity granting API Enabled requires documented justification.
|
|
98
|
+
// One query for all PS/profiles granting it — we report the granting entities, not every assignment.
|
|
99
|
+
const apiEnabledPs = await ctx.soql.query('SELECT Id, Name, IsOwnedByProfile FROM PermissionSet WHERE PermissionsApiEnabled = true AND IsCustom = true');
|
|
100
|
+
const apiEnabledSets = apiEnabledPs.records;
|
|
101
|
+
if (apiEnabledSets.length > 0) {
|
|
102
|
+
const profileGrantors = apiEnabledSets.filter((r) => r.IsOwnedByProfile);
|
|
103
|
+
const psGrantors = apiEnabledSets.filter((r) => !r.IsOwnedByProfile);
|
|
104
|
+
findings.push({
|
|
105
|
+
id: 'permissions-api-enabled',
|
|
106
|
+
category: this.category,
|
|
107
|
+
riskLevel: profileGrantors.length > 0 ? 'HIGH' : 'MEDIUM',
|
|
108
|
+
title: `${apiEnabledSets.length} custom profile(s)/permission set(s) grant the API Enabled permission`,
|
|
109
|
+
detail: 'SBS-ACS-002 requires documented business or technical justification for every profile, permission set, or group granting API Enabled. Undocumented API access increases the attack surface for data exfiltration via the REST/SOAP APIs.',
|
|
110
|
+
remediation: 'Review each entry in the system of record. Remove API Enabled from profiles/sets where it is not required. Prefer permission sets over profiles for this permission.',
|
|
111
|
+
affectedItems: [
|
|
112
|
+
...profileGrantors.map((r) => ({
|
|
113
|
+
label: r.Name,
|
|
114
|
+
url: `${baseUrl}/${r.Id}`,
|
|
115
|
+
note: 'Granted via Profile — prefer moving to a permission set for finer control',
|
|
116
|
+
})),
|
|
117
|
+
...psGrantors.map((r) => ({
|
|
118
|
+
label: r.Name,
|
|
119
|
+
url: `${baseUrl}/${r.Id}`,
|
|
120
|
+
note: 'Permission Set — document justification in system of record',
|
|
121
|
+
})),
|
|
122
|
+
],
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
findings.push({
|
|
127
|
+
id: 'permissions-api-enabled-ok',
|
|
128
|
+
category: this.category,
|
|
129
|
+
riskLevel: 'LOW',
|
|
130
|
+
passed: true,
|
|
131
|
+
title: 'No custom profiles or permission sets broadly grant API Enabled',
|
|
132
|
+
detail: 'API Enabled is not granted by any custom profile or permission set. Standard profiles may still grant it.',
|
|
133
|
+
remediation: 'Continue monitoring as new permission sets and profiles are created.',
|
|
134
|
+
});
|
|
135
|
+
}
|
|
83
136
|
return {
|
|
84
137
|
findings,
|
|
85
138
|
metrics: {
|
|
@@ -22,18 +22,29 @@ export class PublicGroupSharingCheck {
|
|
|
22
22
|
});
|
|
23
23
|
return { findings };
|
|
24
24
|
}
|
|
25
|
+
// One query per share table with IN clause — reduces G×4 queries to 4 regardless of group count
|
|
26
|
+
const groupIdList = groups.map((g) => `'${g.Id}'`).join(', ');
|
|
27
|
+
const groupNameMap = new Map(groups.map((g) => [g.Id, g.Name]));
|
|
25
28
|
const exposures = [];
|
|
26
|
-
for (const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
for (const shareTable of SHARE_TABLES) {
|
|
30
|
+
try {
|
|
31
|
+
const result = await ctx.soql.query(`SELECT UserOrGroupId, COUNT(Id) cnt
|
|
32
|
+
FROM ${shareTable}
|
|
33
|
+
WHERE UserOrGroupId IN (${groupIdList})
|
|
34
|
+
AND RowCause = 'SharingRule'
|
|
35
|
+
GROUP BY UserOrGroupId`);
|
|
36
|
+
for (const r of result.records) {
|
|
37
|
+
if (r.cnt > 0) {
|
|
38
|
+
exposures.push({
|
|
39
|
+
shareTable,
|
|
40
|
+
groupName: groupNameMap.get(r.UserOrGroupId) ?? r.UserOrGroupId,
|
|
41
|
+
count: r.cnt,
|
|
42
|
+
});
|
|
32
43
|
}
|
|
33
44
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// Object may not exist or not be accessible — skip silently
|
|
37
48
|
}
|
|
38
49
|
}
|
|
39
50
|
if (exposures.length > 0) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AuditContext } from '../../context/AuditContext.js';
|
|
2
|
+
import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
|
|
3
|
+
export declare class ReleaseUpdatesCheck implements SecurityCheck {
|
|
4
|
+
readonly id = "release-updates";
|
|
5
|
+
readonly name = "Pending Release Updates";
|
|
6
|
+
readonly category = "Platform Hygiene";
|
|
7
|
+
readonly description = "Flags Salesforce release updates (Critical Updates) that are pending activation, especially those past their auto-activation date";
|
|
8
|
+
run(ctx: AuditContext): Promise<CheckResult>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=ReleaseUpdatesCheck.d.ts.map
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export class ReleaseUpdatesCheck {
|
|
2
|
+
id = 'release-updates';
|
|
3
|
+
name = 'Pending Release Updates';
|
|
4
|
+
category = 'Platform Hygiene';
|
|
5
|
+
description = 'Flags Salesforce release updates (Critical Updates) that are pending activation, especially those past their auto-activation date';
|
|
6
|
+
async run(ctx) {
|
|
7
|
+
const findings = [];
|
|
8
|
+
const setupUrl = `${ctx.orgInfo.instanceUrl}/lightning/setup/ReleaseUpdates/home`;
|
|
9
|
+
const today = new Date();
|
|
10
|
+
let pendingUpdates = [];
|
|
11
|
+
try {
|
|
12
|
+
pendingUpdates = await ctx.tooling.query('SELECT Id, Name, Description, AutoActivationDate, IsEnabled FROM CriticalUpdate WHERE IsEnabled = false');
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
findings.push({
|
|
16
|
+
id: 'release-updates-inconclusive',
|
|
17
|
+
category: this.category,
|
|
18
|
+
riskLevel: 'INFO',
|
|
19
|
+
inconclusive: true,
|
|
20
|
+
title: 'Pending release updates check could not be completed',
|
|
21
|
+
detail: 'The CriticalUpdate Tooling API object was not accessible — this can occur if the audit user lacks the "Customize Application" permission or if the org is on a restricted edition.',
|
|
22
|
+
remediation: 'Review pending Release Updates manually in Setup → Release Updates.',
|
|
23
|
+
});
|
|
24
|
+
return { findings };
|
|
25
|
+
}
|
|
26
|
+
if (pendingUpdates.length === 0) {
|
|
27
|
+
findings.push({
|
|
28
|
+
id: 'release-updates-ok',
|
|
29
|
+
category: this.category,
|
|
30
|
+
riskLevel: 'LOW',
|
|
31
|
+
passed: true,
|
|
32
|
+
title: 'All Salesforce release updates are enabled',
|
|
33
|
+
detail: 'No pending release updates were found. The org is current with all platform changes Salesforce has made available.',
|
|
34
|
+
remediation: 'After each Salesforce release (3× per year), review Release Updates in Setup to enable new updates promptly.',
|
|
35
|
+
});
|
|
36
|
+
return { findings };
|
|
37
|
+
}
|
|
38
|
+
const overdueUpdates = [];
|
|
39
|
+
const upcomingUpdates = [];
|
|
40
|
+
const deferredUpdates = [];
|
|
41
|
+
for (const update of pendingUpdates) {
|
|
42
|
+
if (!update.AutoActivationDate) {
|
|
43
|
+
deferredUpdates.push(update);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const autoDate = new Date(update.AutoActivationDate);
|
|
47
|
+
const daysUntil = (autoDate.getTime() - today.getTime()) / (1000 * 60 * 60 * 24);
|
|
48
|
+
if (daysUntil < 0) {
|
|
49
|
+
overdueUpdates.push(update);
|
|
50
|
+
}
|
|
51
|
+
else if (daysUntil <= 90) {
|
|
52
|
+
upcomingUpdates.push(update);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
deferredUpdates.push(update);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (overdueUpdates.length > 0) {
|
|
59
|
+
findings.push({
|
|
60
|
+
id: 'release-updates-overdue',
|
|
61
|
+
category: this.category,
|
|
62
|
+
riskLevel: 'HIGH',
|
|
63
|
+
title: `${overdueUpdates.length} release update(s) are past their auto-activation date and still not enabled`,
|
|
64
|
+
detail: 'These updates were scheduled for automatic activation by Salesforce but remain disabled. Running without them may leave the org exposed to security issues or deprecated behaviors that Salesforce has already addressed. In some cases Salesforce may have already force-activated them — verify current status in Setup.',
|
|
65
|
+
remediation: 'Enable these updates immediately in Setup → Release Updates. Test each one in a sandbox first. Check whether Salesforce has already force-activated any of these entries, in which case they may already be enforced despite showing as disabled.',
|
|
66
|
+
affectedItems: overdueUpdates.map((u) => ({
|
|
67
|
+
label: u.Name,
|
|
68
|
+
url: setupUrl,
|
|
69
|
+
note: `Auto-activation was: ${u.AutoActivationDate.split('T')[0]}`,
|
|
70
|
+
})),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if (upcomingUpdates.length > 0) {
|
|
74
|
+
findings.push({
|
|
75
|
+
id: 'release-updates-upcoming',
|
|
76
|
+
category: this.category,
|
|
77
|
+
riskLevel: 'MEDIUM',
|
|
78
|
+
title: `${upcomingUpdates.length} release update(s) will be auto-activated by Salesforce within 90 days`,
|
|
79
|
+
detail: 'These updates are scheduled for automatic activation in the near term. Enabling them proactively allows time to identify and resolve any functional impact before Salesforce forces the change.',
|
|
80
|
+
remediation: 'Enable and test each update in a sandbox before its auto-activation date. Coordinate with development and QA teams to catch any regressions before the forced activation window.',
|
|
81
|
+
affectedItems: upcomingUpdates.map((u) => ({
|
|
82
|
+
label: u.Name,
|
|
83
|
+
url: setupUrl,
|
|
84
|
+
note: `Auto-activates: ${u.AutoActivationDate.split('T')[0]}`,
|
|
85
|
+
})),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if (deferredUpdates.length > 0) {
|
|
89
|
+
findings.push({
|
|
90
|
+
id: 'release-updates-deferred',
|
|
91
|
+
category: this.category,
|
|
92
|
+
riskLevel: 'INFO',
|
|
93
|
+
title: `${deferredUpdates.length} release update(s) are pending with no imminent deadline`,
|
|
94
|
+
detail: 'These updates are available but have no near-term auto-activation date. They should still be reviewed and enabled where applicable to stay ahead of eventual enforcement.',
|
|
95
|
+
remediation: 'Review each update in Setup → Release Updates. Enable updates that apply to your configuration and test in a sandbox before rolling out to production.',
|
|
96
|
+
affectedItems: deferredUpdates.map((u) => ({
|
|
97
|
+
label: u.Name,
|
|
98
|
+
url: setupUrl,
|
|
99
|
+
note: u.AutoActivationDate ? `Auto-activates: ${u.AutoActivationDate.split('T')[0]}` : 'No auto-activation date',
|
|
100
|
+
})),
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return { findings };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=ReleaseUpdatesCheck.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AuditContext } from '../../context/AuditContext.js';
|
|
2
|
+
import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
|
|
3
|
+
export declare class ReportFolderAccessCheck implements SecurityCheck {
|
|
4
|
+
readonly id = "report-folder-access";
|
|
5
|
+
readonly name = "Report Folder Public Access";
|
|
6
|
+
readonly category = "Data Access Control";
|
|
7
|
+
readonly description = "Checks for Report folders with Public access \u2014 any authenticated user can view all reports and their data";
|
|
8
|
+
run(ctx: AuditContext): Promise<CheckResult>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=ReportFolderAccessCheck.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export class ReportFolderAccessCheck {
|
|
2
|
+
id = 'report-folder-access';
|
|
3
|
+
name = 'Report Folder Public Access';
|
|
4
|
+
category = 'Data Access Control';
|
|
5
|
+
description = 'Checks for Report folders with Public access — any authenticated user can view all reports and their data';
|
|
6
|
+
async run(ctx) {
|
|
7
|
+
const findings = [];
|
|
8
|
+
const baseUrl = ctx.orgInfo.instanceUrl;
|
|
9
|
+
const setupUrl = `${baseUrl}/lightning/o/Report/home`;
|
|
10
|
+
let publicFolders;
|
|
11
|
+
try {
|
|
12
|
+
publicFolders = await ctx.soql.queryAll(`SELECT Id, Name, DeveloperName, AccessType FROM Folder WHERE Type = 'Report' AND AccessType = 'Public'`);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
findings.push({
|
|
16
|
+
id: 'report-folder-access-inaccessible',
|
|
17
|
+
category: this.category,
|
|
18
|
+
riskLevel: 'INFO',
|
|
19
|
+
inconclusive: true,
|
|
20
|
+
title: 'Report folder configuration could not be queried',
|
|
21
|
+
detail: 'The Folder SOQL query was not accessible. This may indicate the audit user lacks access to folder metadata.',
|
|
22
|
+
remediation: 'Grant "View Setup and Configuration" or "Manage Public Reports" to the audit user and re-run.',
|
|
23
|
+
});
|
|
24
|
+
return { findings };
|
|
25
|
+
}
|
|
26
|
+
if (publicFolders.length === 0) {
|
|
27
|
+
findings.push({
|
|
28
|
+
id: 'report-folder-access-ok',
|
|
29
|
+
category: this.category,
|
|
30
|
+
riskLevel: 'LOW',
|
|
31
|
+
passed: true,
|
|
32
|
+
title: 'No Report folders have Public access',
|
|
33
|
+
detail: 'All Report folders are restricted to specific users, roles, or groups. No folder exposes reports to all authenticated users.',
|
|
34
|
+
remediation: 'Continue reviewing report folder permissions as new reports and folders are created. Ensure sensitive reports are in Private or Shared folders with explicit access grants.',
|
|
35
|
+
});
|
|
36
|
+
return { findings };
|
|
37
|
+
}
|
|
38
|
+
findings.push({
|
|
39
|
+
id: 'report-folder-access-public',
|
|
40
|
+
category: this.category,
|
|
41
|
+
riskLevel: 'HIGH',
|
|
42
|
+
title: `${publicFolders.length} Report folder(s) are publicly accessible to all users`,
|
|
43
|
+
detail: `Public Report folders are accessible to every authenticated Salesforce user — including over-permissioned integration accounts, recently activated users, and attackers who have compromised any credential. Reports frequently contain cross-object joins, aggregate data, and sensitive field values that bypass field-level security (FLS does not apply to report results in all configurations). An attacker with basic login access who can open a public report folder can exfiltrate bulk data from Account, Contact, Opportunity, and other sensitive objects by running or exporting the reports inside. This is a common path for mass data exfiltration that bypasses record-level security controls.`,
|
|
44
|
+
remediation: 'Change Public Report folders to Private or Shared. For Shared folders, explicitly list the users, roles, or groups that need access. Audit the content of public folders to understand the data exposure — any report in a public folder may have been accessed by any user. Consider enabling Report Snapshot auditing and restricting the "Export Reports" permission for broad user groups.',
|
|
45
|
+
affectedItems: publicFolders.map((f) => ({
|
|
46
|
+
label: f.Name ?? f.DeveloperName ?? f.Id,
|
|
47
|
+
url: setupUrl,
|
|
48
|
+
note: `AccessType: Public — ${publicFolders.length} folder(s) expose reports to all users`,
|
|
49
|
+
})),
|
|
50
|
+
});
|
|
51
|
+
return { findings };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=ReportFolderAccessCheck.js.map
|
|
@@ -5,6 +5,7 @@ export declare class ScheduledApexCheck implements SecurityCheck {
|
|
|
5
5
|
readonly name = "Scheduled and Batch Apex";
|
|
6
6
|
readonly category = "Code Security";
|
|
7
7
|
readonly description = "Lists active scheduled and batch Apex jobs running in the org";
|
|
8
|
+
readonly populatesCache: readonly ["scheduledApexClassNames"];
|
|
8
9
|
run(ctx: AuditContext): Promise<CheckResult>;
|
|
9
10
|
}
|
|
10
11
|
//# sourceMappingURL=ScheduledApexCheck.d.ts.map
|
|
@@ -3,6 +3,7 @@ export class ScheduledApexCheck {
|
|
|
3
3
|
name = 'Scheduled and Batch Apex';
|
|
4
4
|
category = 'Code Security';
|
|
5
5
|
description = 'Lists active scheduled and batch Apex jobs running in the org';
|
|
6
|
+
populatesCache = ['scheduledApexClassNames'];
|
|
6
7
|
async run(ctx) {
|
|
7
8
|
const findings = [];
|
|
8
9
|
const baseUrl = ctx.orgInfo.instanceUrl;
|
|
@@ -16,6 +17,8 @@ export class ScheduledApexCheck {
|
|
|
16
17
|
AND Status NOT IN ('Aborted', 'Failed', 'Completed')
|
|
17
18
|
`);
|
|
18
19
|
const totalJobs = jobs.length;
|
|
20
|
+
// Cache class names for ApexLoggingCheck and SiemIntegrationCheck — free, no extra query
|
|
21
|
+
ctx.cache.scheduledApexClassNames = jobs.map((j) => j.ApexClass.Name);
|
|
19
22
|
// If there are jobs, get creator profiles
|
|
20
23
|
let creatorMap = {};
|
|
21
24
|
if (jobs.length > 0) {
|
|
@@ -4,7 +4,7 @@ export declare class SharingModelCheck implements SecurityCheck {
|
|
|
4
4
|
readonly id = "sharing-model";
|
|
5
5
|
readonly name = "Org-Wide Defaults (OWD) Sharing Model";
|
|
6
6
|
readonly category = "Data Access Control";
|
|
7
|
-
readonly description = "Checks OWD sharing settings for Account, Contact, Opportunity, Case, and Lead";
|
|
7
|
+
readonly description = "Checks OWD sharing settings for Account, Contact, Opportunity, Case, and Lead \u2014 both internal and external (portal) sharing models";
|
|
8
8
|
run(ctx: AuditContext): Promise<CheckResult>;
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=SharingModelCheck.d.ts.map
|