@cclabsnz/sf-audit 1.16.0 → 1.18.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/CHANGELOG.md +172 -1
- package/PERMISSIONS.md +139 -0
- package/README.md +98 -26
- package/config/scoring.sample.json +104 -5
- package/docs/permissionset/SF_Audit_ReadOnly.permissionset-meta.xml +54 -0
- package/lib/apps/analyzeApps.d.ts +8 -2
- package/lib/apps/analyzeApps.js +7 -2
- package/lib/apps/apiLogSource.d.ts +39 -0
- package/lib/apps/apiLogSource.js +75 -0
- package/lib/apps/appResolver.js +30 -4
- package/lib/apps/grantedAccess.js +16 -3
- package/lib/apps/leastPrivilege.d.ts +3 -1
- package/lib/apps/leastPrivilege.js +7 -3
- package/lib/apps/permissionSetGenerator.d.ts +22 -0
- package/lib/apps/permissionSetGenerator.js +100 -0
- package/lib/apps/types.d.ts +6 -0
- package/lib/apps/usageCollector.d.ts +7 -1
- package/lib/apps/usageCollector.js +57 -26
- package/lib/chains/CapabilityRegistry.js +26 -0
- package/lib/chains/ChainEngine.js +11 -1
- package/lib/chains/namedChains.js +130 -24
- package/lib/checks/CheckEngine.d.ts +3 -1
- package/lib/checks/CheckEngine.js +65 -26
- package/lib/checks/impl/AgentUserPrivilegeCheck.js +5 -4
- package/lib/checks/impl/AnonymousApexAuditCheck.js +41 -8
- package/lib/checks/impl/ApexCrudFLSCheck.js +45 -10
- package/lib/checks/impl/ApexSharingCheck.js +19 -26
- package/lib/checks/impl/ApiClientPermissionCheck.js +21 -5
- package/lib/checks/impl/AuditTrailCheck.js +23 -8
- package/lib/checks/impl/AuthProviderRegistrationHandlerCheck.d.ts +10 -0
- package/lib/checks/impl/AuthProviderRegistrationHandlerCheck.js +131 -0
- package/lib/checks/impl/CertificateExpiryCheck.js +2 -1
- package/lib/checks/impl/ConnectedAppScopeCheck.js +61 -5
- package/lib/checks/impl/ConnectedAppsCheck.js +60 -5
- package/lib/checks/impl/ContentLinksCheck.js +33 -9
- package/lib/checks/impl/CorsAllowlistCheck.js +3 -2
- package/lib/checks/impl/DataClassificationCheck.js +15 -13
- package/lib/checks/impl/DataCloudDataSpaceIsolationCheck.d.ts +10 -0
- package/lib/checks/impl/DataCloudDataSpaceIsolationCheck.js +116 -0
- package/lib/checks/impl/DebugLogAccessCheck.js +4 -4
- package/lib/checks/impl/DelegatedAdministrationGroupsCheck.d.ts +10 -0
- package/lib/checks/impl/DelegatedAdministrationGroupsCheck.js +76 -0
- package/lib/checks/impl/DelegatedAuthenticationExposureCheck.d.ts +10 -0
- package/lib/checks/impl/DelegatedAuthenticationExposureCheck.js +105 -0
- package/lib/checks/impl/DeploymentIdentityCheck.js +32 -5
- package/lib/checks/impl/EmailSecurityCheck.d.ts +1 -1
- package/lib/checks/impl/EmailSecurityCheck.js +14 -34
- package/lib/checks/impl/EncryptionCoverageCheck.js +21 -15
- package/lib/checks/impl/EnhancedDomainsCheck.js +17 -2
- package/lib/checks/impl/EscalationPermsCheck.d.ts +2 -0
- package/lib/checks/impl/EscalationPermsCheck.js +88 -21
- package/lib/checks/impl/ExperienceCloudSiteCheck.js +56 -5
- package/lib/checks/impl/ExternalAccountHierarchyExposureCheck.d.ts +10 -0
- package/lib/checks/impl/ExternalAccountHierarchyExposureCheck.js +65 -0
- package/lib/checks/impl/ExternalCredentialsCheck.js +6 -3
- package/lib/checks/impl/FailedLoginCheck.js +36 -9
- package/lib/checks/impl/FieldHistoryTrackingCheck.js +14 -11
- package/lib/checks/impl/FlowHttpCalloutCredentialBypassCheck.d.ts +10 -0
- package/lib/checks/impl/FlowHttpCalloutCredentialBypassCheck.js +115 -0
- package/lib/checks/impl/GenAiPromptTemplateGroundingCheck.d.ts +10 -0
- package/lib/checks/impl/GenAiPromptTemplateGroundingCheck.js +227 -0
- package/lib/checks/impl/GuestExecutableApexCheck.d.ts +1 -1
- package/lib/checks/impl/GuestExecutableApexCheck.js +105 -14
- package/lib/checks/impl/GuestRecordAccessPolicyCheck.js +52 -11
- package/lib/checks/impl/HardcodedCredentialsCheck.js +7 -2
- package/lib/checks/impl/HealthCheckCheck.js +1 -0
- package/lib/checks/impl/HighAssuranceSessionCheck.js +16 -11
- package/lib/checks/impl/InactiveUsersCheck.js +1 -1
- package/lib/checks/impl/InboundEmailHandlerExposureCheck.d.ts +10 -0
- package/lib/checks/impl/InboundEmailHandlerExposureCheck.js +136 -0
- package/lib/checks/impl/IntegrationLeastPrivilegeCheck.js +7 -6
- package/lib/checks/impl/InternalUserMfaCheck.js +26 -8
- package/lib/checks/impl/IpRestrictionsCheck.js +35 -16
- package/lib/checks/impl/LoginAccessPolicyCheck.js +5 -4
- package/lib/checks/impl/LoginAnomalyCheck.js +10 -7
- package/lib/checks/impl/LoginSessionCheck.js +2 -0
- package/lib/checks/impl/MfaEnforcementCheck.js +23 -6
- package/lib/checks/impl/MfaMethodStrengthCheck.js +18 -3
- package/lib/checks/impl/MfaRegistrationCheck.js +4 -3
- package/lib/checks/impl/MyDomainLoginPolicyCheck.js +23 -10
- package/lib/checks/impl/OauthDeviceAndAssetTokenFlowsCheck.d.ts +10 -0
- package/lib/checks/impl/OauthDeviceAndAssetTokenFlowsCheck.js +84 -0
- package/lib/checks/impl/OrgWideEmailSpoofingCheck.d.ts +10 -0
- package/lib/checks/impl/OrgWideEmailSpoofingCheck.js +106 -0
- package/lib/checks/impl/OutboundMessagesCheck.js +48 -6
- package/lib/checks/impl/PackagePostInstallSupplyChainCheck.d.ts +10 -0
- package/lib/checks/impl/PackagePostInstallSupplyChainCheck.js +89 -0
- package/lib/checks/impl/PlatformEventSubscriberContextCheck.d.ts +10 -0
- package/lib/checks/impl/PlatformEventSubscriberContextCheck.js +88 -0
- package/lib/checks/impl/PrivilegedAccessCheck.js +12 -5
- package/lib/checks/impl/ReleaseUpdatesCheck.js +18 -3
- package/lib/checks/impl/RemoteSitesCheck.js +4 -4
- package/lib/checks/impl/RestrictionRulesIntegrityCheck.d.ts +10 -0
- package/lib/checks/impl/RestrictionRulesIntegrityCheck.js +105 -0
- package/lib/checks/impl/SeparationOfDutiesCheck.js +14 -3
- package/lib/checks/impl/ShieldTenantSecretLifecycleCheck.d.ts +10 -0
- package/lib/checks/impl/ShieldTenantSecretLifecycleCheck.js +90 -0
- package/lib/checks/impl/SoapLoginApiAuthCheck.js +20 -8
- package/lib/checks/impl/SsoEnforcementCheck.js +16 -5
- package/lib/checks/impl/TransactionSecurityPolicyCheck.js +5 -5
- package/lib/checks/impl/TrustedIPRangesCheck.js +18 -9
- package/lib/checks/impl/UsersAndAdminsCheck.js +24 -4
- package/lib/checks/permCatalog.js +1 -1
- package/lib/checks/registry.js +30 -0
- package/lib/checks/support/apexAccess.d.ts +56 -0
- package/lib/checks/support/apexAccess.js +127 -0
- package/lib/checks/support/missingObject.d.ts +13 -0
- package/lib/checks/support/missingObject.js +37 -0
- package/lib/checks/support/schema.d.ts +17 -0
- package/lib/checks/support/schema.js +41 -0
- package/lib/commands/audit/apps.d.ts +1 -0
- package/lib/commands/audit/apps.js +86 -30
- package/lib/commands/audit/diff.js +2 -2
- package/lib/commands/audit/events/pull.js +3 -1
- package/lib/commands/audit/history.js +2 -2
- package/lib/commands/audit/incident/collect.js +3 -1
- package/lib/commands/audit/incident/report.js +2 -2
- package/lib/commands/audit/security.d.ts +3 -0
- package/lib/commands/audit/security.js +65 -10
- package/lib/commands/audit/timeline.js +2 -2
- package/lib/compliance/mapping.js +28 -7
- package/lib/findings/AuditResult.d.ts +10 -0
- package/lib/findings/CheckMeta.js +15 -0
- package/lib/findings/Finding.d.ts +4 -0
- package/lib/findings/ScoringConfig.d.ts +10 -8
- package/lib/findings/ScoringConfig.js +12 -5
- package/lib/findings/coverage.d.ts +34 -0
- package/lib/findings/coverage.js +42 -0
- package/lib/findings/exitCode.js +1 -1
- package/lib/findings/loadScoringConfig.js +51 -8
- package/lib/findings/scoring.js +61 -10
- package/lib/history/HistoryStore.js +9 -3
- package/lib/history/archivePolicy.d.ts +19 -0
- package/lib/history/archivePolicy.js +34 -0
- package/lib/incident/bundleIo.js +4 -3
- package/lib/incident/collect/collectBundle.d.ts +1 -1
- package/lib/incident/collect/collectBundle.js +4 -3
- package/lib/incident/collect/streamGuestLogs.d.ts +1 -1
- package/lib/incident/collect/streamGuestLogs.js +3 -2
- package/lib/incident/csv.js +4 -4
- package/lib/incident/render/evidence.js +3 -3
- package/lib/incident/render/html.js +2 -3
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/lib/packageInfo.d.ts +6 -0
- package/lib/lib/packageInfo.js +19 -0
- package/lib/preflight/permissionMap.d.ts +2 -20
- package/lib/preflight/permissionMap.js +2 -43
- package/lib/preflight/permissions.d.ts +25 -0
- package/lib/preflight/permissions.js +50 -0
- package/lib/renderers/AttackChainDagRenderer.d.ts +7 -0
- package/lib/renderers/AttackChainDagRenderer.js +139 -0
- package/lib/renderers/ClientReportRenderer.d.ts +2 -0
- package/lib/renderers/ClientReportRenderer.js +34 -6
- package/lib/renderers/DiffHtmlRenderer.js +2 -7
- package/lib/renderers/HistoryRenderer.js +19 -11
- package/lib/renderers/HtmlRenderer.js +23 -6
- package/lib/renderers/MarkdownRenderer.js +11 -1
- package/lib/renderers/SarifRenderer.d.ts +43 -0
- package/lib/renderers/SarifRenderer.js +250 -0
- package/lib/report/ExecutivePriorities.js +1 -1
- package/lib/report/RemediationRoadmap.d.ts +5 -1
- package/lib/report/RemediationRoadmap.js +6 -2
- package/lib/waivers/WaiverLoader.d.ts +28 -0
- package/lib/waivers/WaiverLoader.js +103 -0
- package/lib/waivers/WaiverModel.d.ts +32 -0
- package/lib/waivers/WaiverModel.js +28 -0
- package/lib/waivers/applyWaivers.d.ts +22 -0
- package/lib/waivers/applyWaivers.js +85 -0
- package/package.json +6 -4
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { isApiError } from '@cclabsnz/sf-core';
|
|
2
|
+
const cache = new WeakMap();
|
|
3
|
+
function isNotFound(err) {
|
|
4
|
+
if (isApiError(err) && (err.statusCode === 404 || /NOT_FOUND|INVALID_TYPE/i.test(err.errorCode)))
|
|
5
|
+
return true;
|
|
6
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
7
|
+
return /NOT_FOUND|requested resource does not exist|is not supported/i.test(msg);
|
|
8
|
+
}
|
|
9
|
+
/** The object's field names, or null when this API does not serve the object in this org. */
|
|
10
|
+
export function fieldsOf(ctx, object, api = 'soql') {
|
|
11
|
+
let perCtx = cache.get(ctx);
|
|
12
|
+
if (!perCtx) {
|
|
13
|
+
perCtx = new Map();
|
|
14
|
+
cache.set(ctx, perCtx);
|
|
15
|
+
}
|
|
16
|
+
const key = `${api}:${object}`;
|
|
17
|
+
let pending = perCtx.get(key);
|
|
18
|
+
if (!pending) {
|
|
19
|
+
const path = api === 'tooling' ? `/tooling/sobjects/${object}/describe` : `/sobjects/${object}/describe`;
|
|
20
|
+
pending = ctx.rest
|
|
21
|
+
.get(path)
|
|
22
|
+
.then((d) => new Set((d.fields ?? []).map((f) => f.name)))
|
|
23
|
+
.catch((err) => {
|
|
24
|
+
if (isNotFound(err))
|
|
25
|
+
return null;
|
|
26
|
+
throw err;
|
|
27
|
+
});
|
|
28
|
+
perCtx.set(key, pending);
|
|
29
|
+
}
|
|
30
|
+
return pending;
|
|
31
|
+
}
|
|
32
|
+
/** The subset of `wanted` the object has, in the order given. Empty when the object is absent. */
|
|
33
|
+
export async function presentFields(ctx, object, wanted, api = 'soql') {
|
|
34
|
+
const fields = await fieldsOf(ctx, object, api);
|
|
35
|
+
return fields ? wanted.filter((f) => fields.has(f)) : [];
|
|
36
|
+
}
|
|
37
|
+
/** True when the object has the field. */
|
|
38
|
+
export async function hasField(ctx, object, field, api = 'soql') {
|
|
39
|
+
return (await fieldsOf(ctx, object, api))?.has(field) ?? false;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -10,6 +10,7 @@ export default class AuditAppsCommand extends SfCommand<AppFinding[]> {
|
|
|
10
10
|
from: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
11
|
soak: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
12
|
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
'emit-permset': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
14
|
};
|
|
14
15
|
run(): Promise<AppFinding[]>;
|
|
15
16
|
}
|
|
@@ -1,62 +1,118 @@
|
|
|
1
|
-
import { readFileSync, readdirSync
|
|
1
|
+
import { readFileSync, readdirSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
4
4
|
import { resolveOrgInfo, buildAuditContext } from '../../lib/wire.js';
|
|
5
5
|
import { analyzeApps } from '../../apps/analyzeApps.js';
|
|
6
6
|
import { renderJson, renderMarkdown, renderTable } from '../../apps/renderApps.js';
|
|
7
|
+
import { emitPermissionSets } from '../../apps/permissionSetGenerator.js';
|
|
8
|
+
import { ApiLogListingError, assessLogCoverage, downloadApiLogs } from '../../apps/apiLogSource.js';
|
|
7
9
|
export default class AuditAppsCommand extends SfCommand {
|
|
8
10
|
static summary = 'Report connected apps that are granted more access than they use';
|
|
9
|
-
static description = 'Reads the RestApi
|
|
10
|
-
'against the access its run-as user is granted, and reports the over-grant per object and read/write bit, ' +
|
|
11
|
-
'plus a suggested least-privilege permission set. Read-only. "Used" is a lower bound
|
|
12
|
-
'
|
|
11
|
+
static description = 'Reads the RestApi, BulkApi2, and GraphQL EventLogFiles to see which objects each connected app actually touches, ' +
|
|
12
|
+
'compares that against the access its run-as user is granted, and reports the over-grant per object and read/write bit, ' +
|
|
13
|
+
'plus a suggested least-privilege permission set. Read-only. "Used" is a lower bound, so revoke recommendations ' +
|
|
14
|
+
'are suppressed below a soak window.';
|
|
13
15
|
static examples = [
|
|
14
16
|
'<%= config.bin %> <%= command.id %> --target-org myOrg --since 7',
|
|
15
17
|
'<%= config.bin %> <%= command.id %> --target-org myOrg --from ~/.sf/event-baseline/00Dxxx',
|
|
18
|
+
'<%= config.bin %> <%= command.id %> --target-org myOrg --emit-permset ./force-app/main/default/permissionsets',
|
|
16
19
|
'<%= config.bin %> <%= command.id %> --target-org myOrg --format json',
|
|
17
20
|
];
|
|
18
21
|
static flags = {
|
|
19
22
|
'target-org': Flags.requiredOrg(),
|
|
20
|
-
since: Flags.integer({ summary: 'Days of
|
|
21
|
-
from: Flags.string({ summary: 'Read
|
|
22
|
-
soak: Flags.integer({ summary: 'Minimum window (days) before asserting revoke recommendations.', default: 7 }),
|
|
23
|
+
since: Flags.integer({ summary: 'Days of API logs to analyze.', default: 7, min: 1, helpValue: '7' }),
|
|
24
|
+
from: Flags.string({ summary: 'Read API CSVs from a local events-pull baseline dir instead of downloading.', helpValue: './baseline' }),
|
|
25
|
+
soak: Flags.integer({ summary: 'Minimum window (days) before asserting revoke recommendations.', default: 7, min: 0 }),
|
|
23
26
|
format: Flags.string({ summary: 'Output format.', options: ['table', 'json', 'md'], default: 'table' }),
|
|
27
|
+
'emit-permset': Flags.string({
|
|
28
|
+
summary: 'Write a least-privilege .permissionset-meta.xml per app into this local directory. Nothing is deployed.',
|
|
29
|
+
helpValue: './permissionsets',
|
|
30
|
+
}),
|
|
24
31
|
};
|
|
25
32
|
async run() {
|
|
26
33
|
const { flags } = await this.parse(AuditAppsCommand);
|
|
27
|
-
|
|
34
|
+
// No pinned version: the org's own API version, so fields and objects added since an
|
|
35
|
+
// older release are visible. A pin at 62.0 hid every newer permission field.
|
|
36
|
+
const conn = flags['target-org'].getConnection();
|
|
28
37
|
const orgInfo = await resolveOrgInfo(conn);
|
|
29
38
|
const ctx = buildAuditContext(conn, orgInfo);
|
|
30
39
|
let restApiCsv = '';
|
|
40
|
+
let bulkApi2Csv = '';
|
|
41
|
+
let graphQlCsv = '';
|
|
42
|
+
let auraCsv = '';
|
|
43
|
+
let incompleteUsage;
|
|
31
44
|
if (flags.from) {
|
|
32
|
-
|
|
33
|
-
|
|
45
|
+
const readDirCsvs = (subDir) => {
|
|
46
|
+
const d = join(flags.from, subDir);
|
|
47
|
+
let names;
|
|
48
|
+
try {
|
|
49
|
+
names = readdirSync(d);
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
// A missing log-type folder just means that type was not pulled; anything else must surface.
|
|
53
|
+
if (e.code === 'ENOENT')
|
|
54
|
+
return '';
|
|
55
|
+
throw e;
|
|
56
|
+
}
|
|
57
|
+
return names
|
|
58
|
+
.filter((f) => f.endsWith('.csv'))
|
|
59
|
+
.map((f) => readFileSync(join(d, f), 'utf-8'))
|
|
60
|
+
.join('\n');
|
|
61
|
+
};
|
|
62
|
+
restApiCsv = readDirCsvs('RestApi');
|
|
63
|
+
bulkApi2Csv = readDirCsvs('BulkApi2');
|
|
64
|
+
graphQlCsv = readDirCsvs('GraphQlQueryExecution');
|
|
65
|
+
auraCsv = readDirCsvs('AuraRequest');
|
|
66
|
+
if (!restApiCsv && !bulkApi2Csv && !graphQlCsv && !auraCsv) {
|
|
67
|
+
this.error(`No API logs under ${flags.from}. Run "sf audit events pull" first, or drop --from to download.`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
let logs;
|
|
34
72
|
try {
|
|
35
|
-
|
|
73
|
+
logs = await downloadApiLogs(ctx, flags.since);
|
|
36
74
|
}
|
|
37
|
-
catch {
|
|
38
|
-
|
|
75
|
+
catch (e) {
|
|
76
|
+
// An unreadable EventLogFile must not become an empty, clean-looking report.
|
|
77
|
+
if (e instanceof ApiLogListingError)
|
|
78
|
+
this.error(e.message);
|
|
79
|
+
throw e;
|
|
39
80
|
}
|
|
81
|
+
const coverage = assessLogCoverage(logs, flags.since);
|
|
82
|
+
if (coverage.fatal)
|
|
83
|
+
this.error(coverage.fatal);
|
|
84
|
+
if (coverage.empty)
|
|
85
|
+
this.warn(coverage.empty);
|
|
86
|
+
if (coverage.incomplete) {
|
|
87
|
+
incompleteUsage = coverage.incomplete;
|
|
88
|
+
this.warn(`${incompleteUsage}; usage is incomplete and revoke recommendations are suppressed. First error: ${logs.failed[0].error}`);
|
|
89
|
+
}
|
|
90
|
+
restApiCsv = logs.csv.RestApi;
|
|
91
|
+
bulkApi2Csv = logs.csv.BulkApi2;
|
|
92
|
+
graphQlCsv = logs.csv.GraphQlQueryExecution;
|
|
93
|
+
auraCsv = logs.csv.AuraRequest;
|
|
40
94
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
95
|
+
const findings = await analyzeApps(restApiCsv, ctx.soql, {
|
|
96
|
+
since: flags.since,
|
|
97
|
+
soakDays: flags.soak,
|
|
98
|
+
bulkApi2Csv,
|
|
99
|
+
graphQlCsv,
|
|
100
|
+
auraCsv,
|
|
101
|
+
incompleteUsage,
|
|
102
|
+
});
|
|
103
|
+
if (flags['emit-permset']) {
|
|
104
|
+
// Local files only: nothing is deployed to the org.
|
|
105
|
+
const { written, skipped } = emitPermissionSets(findings, flags['emit-permset']);
|
|
106
|
+
this.log(`Emitted ${written.length} permission set file(s) into ${flags['emit-permset']}`);
|
|
107
|
+
if (skipped.length > 0) {
|
|
108
|
+
this.warn(`Skipped ${skipped.length} app(s) whose recommendation is not asserted (soak window, many interactive users, or incomplete logs): ` +
|
|
109
|
+
skipped.join(', '));
|
|
56
110
|
}
|
|
57
111
|
}
|
|
58
|
-
const findings = await analyzeApps(restApiCsv, ctx.soql, { since: flags.since, soakDays: flags.soak });
|
|
59
112
|
const out = flags.format === 'json' ? renderJson(findings) : flags.format === 'md' ? renderMarkdown(findings) : renderTable(findings);
|
|
113
|
+
// JSON carries the same flag in every finding's notes; the human formats get it as a header line.
|
|
114
|
+
if (incompleteUsage && flags.format !== 'json')
|
|
115
|
+
this.log(`INCOMPLETE: ${incompleteUsage}. "Used" undercounts; revoke recommendations suppressed.`);
|
|
60
116
|
this.log(out);
|
|
61
117
|
return findings;
|
|
62
118
|
}
|
|
@@ -52,14 +52,14 @@ export default class AuditDiffCommand extends SfCommand {
|
|
|
52
52
|
}
|
|
53
53
|
const baseTs = baseline.generatedAt.getTime();
|
|
54
54
|
const curTs = current.generatedAt.getTime();
|
|
55
|
-
fs.mkdirSync(flags.output, { recursive: true });
|
|
55
|
+
fs.mkdirSync(flags.output, { recursive: true }); // invariant:allow — user-facing report output destination
|
|
56
56
|
for (const format of formats) {
|
|
57
57
|
const renderer = DIFF_RENDERERS[format];
|
|
58
58
|
if (!renderer)
|
|
59
59
|
continue; // unreachable: validated above
|
|
60
60
|
const filename = `sf-audit-diff-${baseline.orgId}-${baseTs}-vs-${curTs}${renderer.fileExtension}`;
|
|
61
61
|
const outputPath = path.join(flags.output, filename);
|
|
62
|
-
fs.writeFileSync(outputPath, renderer.render(diff), 'utf-8');
|
|
62
|
+
fs.writeFileSync(outputPath, renderer.render(diff), 'utf-8'); // invariant:allow — user-facing report output destination
|
|
63
63
|
this.log(`Diff report written: ${outputPath}`);
|
|
64
64
|
}
|
|
65
65
|
const scoreDeltaStr = diff.scoreDelta >= 0 ? `+${diff.scoreDelta}` : `${diff.scoreDelta}`;
|
|
@@ -35,7 +35,9 @@ export default class AuditEventsPullCommand extends SfCommand {
|
|
|
35
35
|
};
|
|
36
36
|
async run() {
|
|
37
37
|
const { flags } = await this.parse(AuditEventsPullCommand);
|
|
38
|
-
|
|
38
|
+
// No pinned version: the org's own API version, so fields and objects added since an
|
|
39
|
+
// older release are visible. A pin at 62.0 hid every newer permission field.
|
|
40
|
+
const conn = flags['target-org'].getConnection();
|
|
39
41
|
const orgInfo = await resolveOrgInfo(conn);
|
|
40
42
|
const ctx = buildAuditContext(conn, orgInfo);
|
|
41
43
|
const store = new EventBaselineStore(flags.output);
|
|
@@ -50,8 +50,8 @@ export default class AuditHistoryCommand extends SfCommand {
|
|
|
50
50
|
this.log(renderer.renderTable(results));
|
|
51
51
|
const filename = `sf-audit-history-${orgId}-${Date.now()}.html`;
|
|
52
52
|
const outputPath = path.join(flags.output, filename);
|
|
53
|
-
fs.mkdirSync(flags.output, { recursive: true });
|
|
54
|
-
fs.writeFileSync(outputPath, renderer.renderHtml(results), 'utf-8');
|
|
53
|
+
fs.mkdirSync(flags.output, { recursive: true }); // invariant:allow — user-facing report output destination
|
|
54
|
+
fs.writeFileSync(outputPath, renderer.renderHtml(results), 'utf-8'); // invariant:allow — user-facing report output destination
|
|
55
55
|
this.log(`\nHistory report written: ${outputPath}`);
|
|
56
56
|
return results;
|
|
57
57
|
}
|
|
@@ -23,7 +23,9 @@ export default class AuditIncidentCollectCommand extends SfCommand {
|
|
|
23
23
|
};
|
|
24
24
|
async run() {
|
|
25
25
|
const { flags } = await this.parse(AuditIncidentCollectCommand);
|
|
26
|
-
|
|
26
|
+
// No pinned version: the org's own API version, so fields and objects added since an
|
|
27
|
+
// older release are visible. A pin at 62.0 hid every newer permission field.
|
|
28
|
+
const conn = flags['target-org'].getConnection();
|
|
27
29
|
const orgInfo = await resolveOrgInfo(conn);
|
|
28
30
|
const ctx = buildAuditContext(conn, orgInfo);
|
|
29
31
|
const dir = flags.output ?? path.join(defaultIncidentRoot(), orgInfo.id, new Date().toISOString().replace(/[:.]/g, '-'));
|
|
@@ -21,9 +21,9 @@ export async function writeReport(bundleDir, opts) {
|
|
|
21
21
|
if (opts.redact)
|
|
22
22
|
result = redactResult(result);
|
|
23
23
|
const ev = buildEvidence(result);
|
|
24
|
-
fs.mkdirSync(opts.outputDir, { recursive: true });
|
|
24
|
+
fs.mkdirSync(opts.outputDir, { recursive: true }); // invariant:allow — user-facing report output destination
|
|
25
25
|
const written = [];
|
|
26
|
-
const put = (name, body) => { const p = path.join(opts.outputDir, name); fs.writeFileSync(p, body); written.push(p); };
|
|
26
|
+
const put = (name, body) => { const p = path.join(opts.outputDir, name); fs.writeFileSync(p, body); written.push(p); }; // invariant:allow — user-facing report output destination
|
|
27
27
|
if (opts.formats.includes('html'))
|
|
28
28
|
put('incident-report.html', renderHtml(result, ev, opts.branding));
|
|
29
29
|
if (opts.formats.includes('md'))
|
|
@@ -9,6 +9,7 @@ export default class SecurityAuditCommand extends SfCommand<AuditResult | AuditD
|
|
|
9
9
|
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
11
|
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
waivers: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
13
|
'fail-on': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
14
|
digest: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
15
|
'fail-on-inconclusive': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
@@ -19,6 +20,8 @@ export default class SecurityAuditCommand extends SfCommand<AuditResult | AuditD
|
|
|
19
20
|
top: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
21
|
frameworks: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
22
|
'resolve-domains': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
23
|
+
'no-history': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
24
|
+
'keep-history': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
22
25
|
};
|
|
23
26
|
run(): Promise<AuditResult | AuditDigest>;
|
|
24
27
|
/** Resolve --checks to the checks to run, erroring on any unknown ID. */
|
|
@@ -6,18 +6,23 @@ import { CHECKS } from '../../checks/registry.js';
|
|
|
6
6
|
import { JsonRenderer } from '../../renderers/JsonRenderer.js';
|
|
7
7
|
import { HtmlRenderer } from '../../renderers/HtmlRenderer.js';
|
|
8
8
|
import { MarkdownRenderer } from '../../renderers/MarkdownRenderer.js';
|
|
9
|
+
import { SarifRenderer } from '../../renderers/SarifRenderer.js';
|
|
9
10
|
import { ClientReportRenderer } from '../../renderers/ClientReportRenderer.js';
|
|
10
11
|
import { resolveBranding } from '@cclabsnz/sf-core';
|
|
11
12
|
import { resolveFrameworks } from '../../compliance/resolve.js';
|
|
12
13
|
import { buildAuditContext, resolveOrgInfo } from '../../lib/wire.js';
|
|
13
14
|
import { loadScoringConfig } from '../../findings/loadScoringConfig.js';
|
|
14
15
|
import { HistoryStore } from '../../history/HistoryStore.js';
|
|
16
|
+
import { isCiEnvironment, shouldArchiveHistory } from '../../history/archivePolicy.js';
|
|
15
17
|
import { EXIT_FINDINGS, EXIT_INCONCLUSIVE, resolveExitCode, violationsFor } from '../../findings/exitCode.js';
|
|
16
18
|
import { buildDigest } from '../../findings/digest.js';
|
|
19
|
+
import { WaiverLoader, DEFAULT_WAIVER_FILE } from '../../waivers/WaiverLoader.js';
|
|
20
|
+
import { coverageSummary, coverageAdvice } from '../../findings/coverage.js';
|
|
17
21
|
const RENDERERS = {
|
|
18
22
|
html: new HtmlRenderer(),
|
|
19
23
|
md: new MarkdownRenderer(),
|
|
20
24
|
json: new JsonRenderer(),
|
|
25
|
+
sarif: new SarifRenderer(),
|
|
21
26
|
};
|
|
22
27
|
export default class SecurityAuditCommand extends SfCommand {
|
|
23
28
|
static summary = 'Run a comprehensive security audit against a Salesforce org';
|
|
@@ -26,12 +31,13 @@ export default class SecurityAuditCommand extends SfCommand {
|
|
|
26
31
|
'<%= config.bin %> <%= command.id %> --target-org myOrg',
|
|
27
32
|
'<%= config.bin %> <%= command.id %> --target-org myOrg --format json --output ./reports',
|
|
28
33
|
'<%= config.bin %> <%= command.id %> --target-org myOrg --fail-on HIGH',
|
|
34
|
+
'<%= config.bin %> <%= command.id %> --target-org myOrg --format sarif --output ./reports',
|
|
29
35
|
];
|
|
30
36
|
static flags = {
|
|
31
37
|
'target-org': Flags.requiredOrg(),
|
|
32
38
|
format: Flags.string({
|
|
33
39
|
char: 'f',
|
|
34
|
-
summary: 'Output format(s), comma-separated: html, md, json, executive',
|
|
40
|
+
summary: 'Output format(s), comma-separated: html, md, json, executive, sarif',
|
|
35
41
|
default: 'html',
|
|
36
42
|
}),
|
|
37
43
|
output: Flags.string({
|
|
@@ -39,6 +45,10 @@ export default class SecurityAuditCommand extends SfCommand {
|
|
|
39
45
|
summary: 'Directory to write the report. Defaults to current directory.',
|
|
40
46
|
default: '.',
|
|
41
47
|
}),
|
|
48
|
+
waivers: Flags.string({
|
|
49
|
+
summary: `Accepted-risk waivers file. Defaults to ${DEFAULT_WAIVER_FILE} in the working directory when present.`,
|
|
50
|
+
helpValue: `./${DEFAULT_WAIVER_FILE}`,
|
|
51
|
+
}),
|
|
42
52
|
'fail-on': Flags.string({
|
|
43
53
|
summary: 'Exit with code 1 if any finding is at or above this severity.',
|
|
44
54
|
options: ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'],
|
|
@@ -78,6 +88,17 @@ export default class SecurityAuditCommand extends SfCommand {
|
|
|
78
88
|
summary: 'Make outbound DNS queries from this machine to verify CSP trusted domains resolve. Off by default; default runs contact only the target org.',
|
|
79
89
|
default: false,
|
|
80
90
|
}),
|
|
91
|
+
// Named as a positive flag, not `history` with allowNo: archiving is on by default
|
|
92
|
+
// locally but off by default in CI, so a single tri-state boolean would hide which
|
|
93
|
+
// default applied. oclif matches the literal flag name before trying negation.
|
|
94
|
+
'no-history': Flags.boolean({
|
|
95
|
+
summary: 'Do not archive this run to ~/.sf/audit-history/. Implied in CI unless --keep-history is set.',
|
|
96
|
+
default: false,
|
|
97
|
+
}),
|
|
98
|
+
'keep-history': Flags.boolean({
|
|
99
|
+
summary: 'Archive this run to ~/.sf/audit-history/ even in CI. Overrides --no-history.',
|
|
100
|
+
default: false,
|
|
101
|
+
}),
|
|
81
102
|
};
|
|
82
103
|
async run() {
|
|
83
104
|
const { flags } = await this.parse(SecurityAuditCommand);
|
|
@@ -86,21 +107,36 @@ export default class SecurityAuditCommand extends SfCommand {
|
|
|
86
107
|
// no report after the (potentially long) run completes.
|
|
87
108
|
const checksToRun = this.resolveChecks(flags.checks);
|
|
88
109
|
const formats = this.resolveFormats(flags.format);
|
|
89
|
-
|
|
110
|
+
// No pinned version: the org's own API version, so fields and objects added since an
|
|
111
|
+
// older release are visible. A pin at 62.0 hid every newer permission field.
|
|
112
|
+
const conn = flags['target-org'].getConnection();
|
|
90
113
|
const orgInfo = await resolveOrgInfo(conn);
|
|
91
114
|
const ctx = buildAuditContext(conn, orgInfo, {
|
|
92
115
|
resolveDomains: flags['resolve-domains'],
|
|
93
116
|
});
|
|
94
117
|
const knownCheckIds = new Set(CHECKS.map((c) => c.id));
|
|
95
118
|
const scoringConfig = loadScoringConfig(flags['scoring-config'], knownCheckIds, (msg) => this.warn(msg));
|
|
119
|
+
let waiverLoader;
|
|
120
|
+
try {
|
|
121
|
+
waiverLoader = WaiverLoader.load(flags.waivers);
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
this.error(err instanceof Error ? err.message : String(err), { exit: 2 });
|
|
125
|
+
}
|
|
126
|
+
if (waiverLoader.source) {
|
|
127
|
+
this.log(`Waivers: ${waiverLoader.activeWaivers.length} active, ${waiverLoader.expiredWaivers.length} expired, from ${waiverLoader.source}`);
|
|
128
|
+
if (waiverLoader.expiredWaivers.length > 0) {
|
|
129
|
+
this.warn(`${waiverLoader.expiredWaivers.length} waiver(s) have expired; the findings they covered count again.`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
96
132
|
this.log(`Auditing org: ${orgInfo.name} (${orgInfo.id})`);
|
|
97
133
|
if (flags.checks)
|
|
98
134
|
this.log(`Running ${checksToRun.length} of ${CHECKS.length} checks`);
|
|
99
|
-
const engine = new CheckEngine(checksToRun, ctx, scoringConfig);
|
|
135
|
+
const engine = new CheckEngine(checksToRun, ctx, scoringConfig, waiverLoader);
|
|
100
136
|
const result = await engine.run((current, total, checkName) => {
|
|
101
137
|
this.log(`[${String(current).padStart(2)}/${total}] ${checkName}`);
|
|
102
138
|
});
|
|
103
|
-
fs.mkdirSync(flags.output, { recursive: true });
|
|
139
|
+
fs.mkdirSync(flags.output, { recursive: true }); // invariant:allow — user-facing report output destination
|
|
104
140
|
for (const format of formats) {
|
|
105
141
|
const renderer = this.rendererFor(format, flags);
|
|
106
142
|
if (!renderer)
|
|
@@ -109,12 +145,16 @@ export default class SecurityAuditCommand extends SfCommand {
|
|
|
109
145
|
const prefix = renderer.filenamePrefix ?? 'sf-audit';
|
|
110
146
|
const filename = `${prefix}-${orgInfo.id}-${Date.now()}${renderer.fileExtension}`;
|
|
111
147
|
const outputPath = path.join(flags.output, filename);
|
|
112
|
-
fs.writeFileSync(outputPath, output, 'utf-8');
|
|
148
|
+
fs.writeFileSync(outputPath, output, 'utf-8'); // invariant:allow — user-facing report output destination
|
|
113
149
|
this.log(`\nReport written: ${outputPath}`);
|
|
114
150
|
}
|
|
115
|
-
// Auto-archive
|
|
116
|
-
|
|
117
|
-
|
|
151
|
+
// Auto-archive a copy for history tracking, except in CI or when suppressed.
|
|
152
|
+
if (shouldArchiveHistory(flags)) {
|
|
153
|
+
new HistoryStore().archive(result);
|
|
154
|
+
}
|
|
155
|
+
else if (!flags['no-history'] && isCiEnvironment()) {
|
|
156
|
+
this.log('\nHistory archive skipped: CI detected. Pass --keep-history to archive this run.');
|
|
157
|
+
}
|
|
118
158
|
this.log('');
|
|
119
159
|
this.printSummary(result);
|
|
120
160
|
this.log('');
|
|
@@ -146,7 +186,7 @@ export default class SecurityAuditCommand extends SfCommand {
|
|
|
146
186
|
}
|
|
147
187
|
/** Resolve --format to a validated list, erroring on any unknown format. */
|
|
148
188
|
resolveFormats(raw) {
|
|
149
|
-
const valid = ['html', 'md', 'json', 'executive'];
|
|
189
|
+
const valid = ['html', 'md', 'json', 'executive', 'sarif'];
|
|
150
190
|
const formats = raw.split(',').map((f) => f.trim()).filter(Boolean);
|
|
151
191
|
const bad = formats.filter((f) => !valid.includes(f));
|
|
152
192
|
if (bad.length > 0 || formats.length === 0) {
|
|
@@ -168,7 +208,7 @@ export default class SecurityAuditCommand extends SfCommand {
|
|
|
168
208
|
}
|
|
169
209
|
printSummary(result) {
|
|
170
210
|
const levels = ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'];
|
|
171
|
-
const counts = Object.fromEntries(levels.map((l) => [l, result.findings.filter((f) => f.riskLevel === l).length]));
|
|
211
|
+
const counts = Object.fromEntries(levels.map((l) => [l, result.findings.filter((f) => f.riskLevel === l && !f.waived).length]));
|
|
172
212
|
this.log('─────────────────────────────');
|
|
173
213
|
this.log(' Audit Summary');
|
|
174
214
|
this.log('─────────────────────────────');
|
|
@@ -177,6 +217,21 @@ export default class SecurityAuditCommand extends SfCommand {
|
|
|
177
217
|
}
|
|
178
218
|
this.log('─────────────────────────────');
|
|
179
219
|
this.log(` Score: ${result.healthScore}/100 Grade: ${result.grade}`);
|
|
220
|
+
if (result.gradeReason)
|
|
221
|
+
this.log(` Why: ${result.gradeReason}`);
|
|
222
|
+
if (result.coverage) {
|
|
223
|
+
this.log(` ${coverageSummary(result.coverage)}`);
|
|
224
|
+
if (result.coverage.notAssessed.length > 0) {
|
|
225
|
+
this.log(` Not assessed: ${result.coverage.notAssessed.join(', ')}`);
|
|
226
|
+
this.log(` ${coverageAdvice(result.coverage)}`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (result.waivedFindings && result.waivedFindings.length > 0) {
|
|
230
|
+
this.log('─────────────────────────────');
|
|
231
|
+
this.log(` Waived (accepted risk): ${result.waivedFindings.length} finding(s)`);
|
|
232
|
+
for (const wf of result.waivedFindings)
|
|
233
|
+
this.log(` [WAIVED] ${wf.title}`);
|
|
234
|
+
}
|
|
180
235
|
this.log('─────────────────────────────');
|
|
181
236
|
}
|
|
182
237
|
/**
|
|
@@ -138,11 +138,11 @@ export default class AuditTimelineCommand extends SfCommand {
|
|
|
138
138
|
coverage,
|
|
139
139
|
};
|
|
140
140
|
const formats = new Set(flags.format.split(',').map((f) => f.trim().toLowerCase()).filter(Boolean));
|
|
141
|
-
fs.mkdirSync(flags.output, { recursive: true });
|
|
141
|
+
fs.mkdirSync(flags.output, { recursive: true }); // invariant:allow — user-facing report output destination
|
|
142
142
|
const written = [];
|
|
143
143
|
const write = (name, body) => {
|
|
144
144
|
const target = path.join(flags.output, name);
|
|
145
|
-
fs.writeFileSync(target, body, 'utf-8');
|
|
145
|
+
fs.writeFileSync(target, body, 'utf-8'); // invariant:allow — user-facing report output destination
|
|
146
146
|
written.push(target);
|
|
147
147
|
};
|
|
148
148
|
if (formats.has('csv'))
|
|
@@ -115,6 +115,21 @@ const BASE_CHECK_CONTROL_MAP = {
|
|
|
115
115
|
// injected payload leaves by (LLM05) and an action taken without human approval (LLM06).
|
|
116
116
|
'agent-query-reach': ['OWASP-A01', 'SOC2-CC6.3', 'ISO-A.8.3', 'LLM06', 'LLM02'],
|
|
117
117
|
'agent-outbound-actions': ['OWASP-A01', 'SOC2-CC6.6', 'ISO-A.8.3', 'LLM05', 'LLM06'],
|
|
118
|
+
// 14 New Checks
|
|
119
|
+
'genai-prompt-template-grounding': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.8.3', 'LLM02', 'LLM06'],
|
|
120
|
+
'data-cloud-data-space-isolation': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.8.3'],
|
|
121
|
+
'platform-event-subscriber-context': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.8.3'],
|
|
122
|
+
'flow-http-callout-credential-bypass': ['OWASP-A02', 'OWASP-A10', 'SOC2-CC6.7', 'ISO-A.8.3'],
|
|
123
|
+
'oauth-device-and-asset-token-flows': ['OWASP-A07', 'SOC2-CC6.1', 'ISO-A.8.3', 'SBS-OAUTH-001'],
|
|
124
|
+
'delegated-authentication-exposure': ['OWASP-A07', 'SOC2-CC6.1', 'ISO-A.8.3', 'SBS-AUTH-001'],
|
|
125
|
+
'delegated-administration-groups': ['OWASP-A01', 'SOC2-CC6.3', 'ISO-A.5.18', 'SBS-ACS-004'],
|
|
126
|
+
'auth-provider-registration-handler': ['OWASP-A01', 'OWASP-A07', 'SOC2-CC6.1', 'ISO-A.8.3'],
|
|
127
|
+
'inbound-email-handler-exposure': ['OWASP-A01', 'OWASP-A05', 'SOC2-CC6.6', 'ISO-A.5.14'],
|
|
128
|
+
'org-wide-email-spoofing': ['OWASP-A05', 'SOC2-CC6.6', 'ISO-A.5.14'],
|
|
129
|
+
'external-account-hierarchy-exposure': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.8.3', 'SBS-CPORTAL-003'],
|
|
130
|
+
'restriction-rules-integrity': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.8.3'],
|
|
131
|
+
'package-post-install-supply-chain': ['OWASP-A06', 'OWASP-A08', 'SOC2-CC9.2', 'ISO-A.8.25'],
|
|
132
|
+
'shield-tenant-secret-lifecycle': ['OWASP-A02', 'SOC2-CC6.1', 'ISO-A.8.24'],
|
|
118
133
|
};
|
|
119
134
|
// Domain groupings. Each check belongs to exactly one domain, and a domain's control ids are
|
|
120
135
|
// layered onto every base entry in it. Shared by the NZ pack and the HIPAA/GDPR crosswalk below
|
|
@@ -128,26 +143,31 @@ const DOMAIN = {
|
|
|
128
143
|
'public-content-exposure', 'privileged-access', 'separation-of-duties',
|
|
129
144
|
'guest-object-exposure', 'guest-site-options', 'guest-record-access-policy',
|
|
130
145
|
'login-access-policy', 'data-export-access', 'classic-sites', 'guest-api-access',
|
|
131
|
-
'guest-user-visibility'
|
|
146
|
+
'guest-user-visibility', 'data-cloud-data-space-isolation', 'platform-event-subscriber-context',
|
|
147
|
+
'delegated-administration-groups', 'external-account-hierarchy-exposure', 'restriction-rules-integrity'],
|
|
132
148
|
authentication: ['login-session', 'ip-restrictions', 'password-session-policy', 'sso-enforcement', 'mfa-enforcement',
|
|
133
149
|
'trusted-ip-ranges', 'my-domain-login-policy', 'high-assurance-session', 'internal-user-mfa',
|
|
134
150
|
'mfa-registration', 'mfa-method-strength', 'failed-login-detection', 'enhanced-domains',
|
|
135
|
-
'auth-providers'
|
|
136
|
-
|
|
151
|
+
'auth-providers', 'oauth-device-and-asset-token-flows', 'delegated-authentication-exposure',
|
|
152
|
+
'auth-provider-registration-handler'],
|
|
153
|
+
crypto: ['named-credentials', 'hardcoded-credentials', 'custom-settings', 'certificate-expiry', 'custom-labels-credential', 'external-credentials', 'encryption-coverage',
|
|
154
|
+
'shield-tenant-secret-lifecycle'],
|
|
137
155
|
logging: ['audit-trail', 'apex-logging', 'event-monitoring', 'siem-integration', 'anonymous-apex-audit',
|
|
138
156
|
'debug-log-access', 'transaction-security-policy', 'threat-detection', 'guest-traffic-anomaly',
|
|
139
157
|
'login-anomaly'],
|
|
140
|
-
devSecurity: ['code-security', 'visualforce-xss', 'scheduled-apex', 'lightning-message-channel'],
|
|
158
|
+
devSecurity: ['code-security', 'visualforce-xss', 'scheduled-apex', 'lightning-message-channel', 'flow-http-callout-credential-bypass'],
|
|
141
159
|
network: ['remote-sites', 'csp-trusted-sites', 'connected-apps', 'connected-app-scope', 'connected-app-inactivity', 'oauth-token-inventory', 'cors-allowlist',
|
|
142
|
-
'email-security', 'outbound-messages', 'experience-csp'],
|
|
160
|
+
'email-security', 'outbound-messages', 'experience-csp', 'inbound-email-handler-exposure', 'org-wide-email-spoofing'],
|
|
143
161
|
dataGovernance: ['data-classification', 'field-history-tracking', 'sandbox-data-masking'],
|
|
144
|
-
configGovernance: ['health-check', 'api-limits', 'release-updates', 'legacy-api-version', 'installed-packages', 'deployment-identity', 'session-hardening'
|
|
162
|
+
configGovernance: ['health-check', 'api-limits', 'release-updates', 'legacy-api-version', 'installed-packages', 'deployment-identity', 'session-hardening',
|
|
163
|
+
'package-post-install-supply-chain'],
|
|
145
164
|
accountLifecycle: ['inactive-users'],
|
|
146
165
|
// Agentforce / GenAI. The NZ pack does not map these (HISO/NZISM predate agentic platforms and
|
|
147
166
|
// have no chapter that fits); HIPAA and GDPR do, because an over-privileged agent user reading
|
|
148
167
|
// PHI or personal data is squarely an access-control and security-of-processing question.
|
|
149
168
|
aiAgents: ['agent-inventory', 'agent-user-privilege', 'agent-action-surface', 'agent-channel-exposure',
|
|
150
|
-
'agent-monitoring-coverage', 'trusted-url-hygiene', 'agent-query-reach', 'agent-outbound-actions'
|
|
169
|
+
'agent-monitoring-coverage', 'trusted-url-hygiene', 'agent-query-reach', 'agent-outbound-actions',
|
|
170
|
+
'genai-prompt-template-grounding'],
|
|
151
171
|
};
|
|
152
172
|
// NZ pack crosswalk — HISO/NZISM are domain/chapter-level; Privacy Act IPPs are statute-level.
|
|
153
173
|
const NZ_CROSSWALK = [
|
|
@@ -219,6 +239,7 @@ const REGULATORY_PRECISE = {
|
|
|
219
239
|
'trusted-url-hygiene': ['HIPAA-164.312(e)(1)', 'GDPR-Art44'],
|
|
220
240
|
'agent-query-reach': ['HIPAA-164.312(a)(1)', 'HIPAA-164.308(a)(4)', 'GDPR-Art25', 'GDPR-Art5(1)(f)'],
|
|
221
241
|
'agent-outbound-actions': ['HIPAA-164.312(e)(1)', 'GDPR-Art25', 'GDPR-Art32(1)(b)'],
|
|
242
|
+
'genai-prompt-template-grounding': ['HIPAA-164.312(a)(1)', 'HIPAA-164.308(a)(4)', 'GDPR-Art25', 'GDPR-Art5(1)(f)', 'GDPR-Art32(1)(b)'],
|
|
222
243
|
};
|
|
223
244
|
function buildCheckControlMap() {
|
|
224
245
|
const map = {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Finding } from './Finding.js';
|
|
2
2
|
import type { OrgMetrics } from '@cclabsnz/sf-core';
|
|
3
3
|
import type { AttackChain } from '../chains/AttackChain.js';
|
|
4
|
+
import type { EvidenceCoverage } from './coverage.js';
|
|
4
5
|
export interface AuditResult {
|
|
5
6
|
generatedAt: Date;
|
|
6
7
|
orgId: string;
|
|
@@ -13,6 +14,15 @@ export interface AuditResult {
|
|
|
13
14
|
metrics: OrgMetrics;
|
|
14
15
|
healthScore: number;
|
|
15
16
|
grade: 'A' | 'B' | 'C' | 'D' | 'F';
|
|
17
|
+
/** What set the grade, e.g. "F: 2 CRITICAL findings (D allows none)". Absent on results stored by older versions. */
|
|
18
|
+
gradeReason?: string;
|
|
16
19
|
attackChains?: AttackChain[];
|
|
20
|
+
/** Findings covered by an approved waiver, also present in `findings` with `waived: true`. */
|
|
21
|
+
waivedFindings?: Finding[];
|
|
22
|
+
/** How much of the audit gathered evidence, and whether that capped the grade. */
|
|
23
|
+
coverage?: EvidenceCoverage & {
|
|
24
|
+
/** True when coverage fell below the bar and the grade was lowered from A to B. */
|
|
25
|
+
gradeCapped: boolean;
|
|
26
|
+
};
|
|
17
27
|
}
|
|
18
28
|
//# sourceMappingURL=AuditResult.d.ts.map
|
|
@@ -94,6 +94,21 @@ export const CHECK_META = {
|
|
|
94
94
|
'agent-query-reach': { effort: 'moderate', impact: 'The General CRM topic and Query Records action let an injected prompt choose which object to query, so one poisoned lead or case can read any object the run-as user can see: the SalesBleed read path.' },
|
|
95
95
|
'agent-outbound-actions': { effort: 'quick', impact: 'Slack, email and external-service actions with no user confirmation give an injected prompt a ready way to send data out of the org: the PipeLeak and SalesBleed exit path.' },
|
|
96
96
|
'trusted-url-hygiene': { effort: 'quick', impact: 'A non-Salesforce CSP-trusted domain that has lapsed or been parked is an allowlisted exfiltration channel: whoever re-registers it can receive prompt-injected data from Lightning and Agentforce output — the exact ForcedLeak exfil vector.' },
|
|
97
|
+
// 14 New Checks
|
|
98
|
+
'genai-prompt-template-grounding': { effort: 'moderate', impact: 'Prompt templates grounded in system-mode Flows or without-sharing Apex bypass user sharing, allowing low-privilege users to extract restricted records through AI prompts.' },
|
|
99
|
+
'data-cloud-data-space-isolation': { effort: 'moderate', impact: 'Default Data Space over-sharing flattens Salesforce OWD record security, exposing sensitive customer data across integrations and partner users.' },
|
|
100
|
+
'platform-event-subscriber-context': { effort: 'moderate', impact: 'Platform events published by low-trust or guest users trigger subscriber Apex running as Automated Process or Admin, creating a direct privilege escalation bridge.' },
|
|
101
|
+
'flow-http-callout-credential-bypass': { effort: 'quick', impact: 'Declarative Flow HTTP callouts storing API keys or bearer tokens in formulas bypass Named Credentials and leak secrets in outbound integrations.' },
|
|
102
|
+
'oauth-device-and-asset-token-flows': { effort: 'quick', impact: 'Global OAuth Device Flow and password flows remain open to device-code phishing and credential replay, circumventing SSO and MFA protections.' },
|
|
103
|
+
'delegated-authentication-exposure': { effort: 'moderate', impact: 'Delegated Authentication over insecure endpoints or assigned to admins allows attackers who compromise the gateway to authenticate as any admin user.' },
|
|
104
|
+
'delegated-administration-groups': { effort: 'moderate', impact: 'Delegated Admin groups grant shadow-admin capabilities (user management, login-as, permission set assignment) completely invisible to standard permission set queries.' },
|
|
105
|
+
'auth-provider-registration-handler': { effort: 'moderate', impact: 'Auth Provider registration handlers running as Admin that match users solely on unverified email addresses allow pre-authentication account takeover.' },
|
|
106
|
+
'inbound-email-handler-exposure': { effort: 'quick', impact: 'Inbound email handlers accepting unauthenticated messages without SPF/DKIM verification execute Apex under privileged users from anonymous incoming email.' },
|
|
107
|
+
'org-wide-email-spoofing': { effort: 'quick', impact: 'Org-wide email addresses open to all profiles without active DKIM keys allow unauthorized internal users or flows to send spoofed emails directly from Salesforce.' },
|
|
108
|
+
'external-account-hierarchy-exposure': { effort: 'moderate', impact: 'Partner Super User access and external account hierarchies bypass private external OWD, exposing horizontal and upward record visibility to portal users.' },
|
|
109
|
+
'restriction-rules-integrity': { effort: 'quick', impact: 'Inactive or conflicting Restriction Rules silently expose underlying records on public objects and create non-deterministic security evaluation.' },
|
|
110
|
+
'package-post-install-supply-chain': { effort: 'moderate', impact: 'Managed packages with post-install scripts execute unattended arbitrary Apex with full privileges during push upgrades, introducing supply-chain risks.' },
|
|
111
|
+
'shield-tenant-secret-lifecycle': { effort: 'quick', impact: 'Unrotated Shield tenant encryption secrets exceed annual lifecycle standards, leaving data-at-rest vulnerable to compliance and cryptographic audit findings.' },
|
|
97
112
|
};
|
|
98
113
|
export function getCheckMeta(id) {
|
|
99
114
|
return CHECK_META[id];
|
|
@@ -44,5 +44,9 @@ export interface Finding {
|
|
|
44
44
|
grants?: Capability[];
|
|
45
45
|
requires?: Capability[];
|
|
46
46
|
};
|
|
47
|
+
/** Covered by an approved, unexpired waiver: excluded from the score and from --fail-on. */
|
|
48
|
+
waived?: boolean;
|
|
49
|
+
/** The check that produced this finding could not run or gather any evidence. */
|
|
50
|
+
notAssessed?: boolean;
|
|
47
51
|
}
|
|
48
52
|
//# sourceMappingURL=Finding.d.ts.map
|