@cclabsnz/sf-audit 1.8.2 → 1.10.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 +221 -0
- package/README.md +144 -756
- package/lib/chains/CapabilityRegistry.d.ts +6 -2
- package/lib/chains/CapabilityRegistry.js +48 -2
- package/lib/chains/namedChains.js +140 -7
- package/lib/checks/impl/AgentChannelExposureCheck.js +52 -10
- package/lib/checks/impl/ApexCrudFLSCheck.js +3 -3
- package/lib/checks/impl/ApexRestEndpointCheck.js +0 -3
- package/lib/checks/impl/CustomLabelsCredentialCheck.js +1 -1
- package/lib/checks/impl/DataClassificationCheck.js +15 -1
- package/lib/checks/impl/FailedLoginCheck.js +16 -1
- package/lib/checks/impl/FieldLevelSecurityCheck.js +29 -16
- package/lib/checks/impl/GuestUserVisibilityCheck.d.ts +35 -0
- package/lib/checks/impl/GuestUserVisibilityCheck.js +168 -0
- package/lib/checks/impl/HardcodedCredentialsCheck.js +0 -1
- package/lib/checks/impl/HealthCheckCheck.js +1 -3
- package/lib/checks/impl/IntegrationLeastPrivilegeCheck.d.ts +42 -0
- package/lib/checks/impl/IntegrationLeastPrivilegeCheck.js +467 -0
- package/lib/checks/impl/IntegrationUsersCheck.js +48 -52
- package/lib/checks/impl/InternalUserMfaCheck.js +0 -1
- package/lib/checks/impl/IpRestrictionsCheck.js +39 -5
- package/lib/checks/impl/PublicGroupSharingCheck.js +21 -2
- package/lib/checks/impl/ScheduledApexCheck.js +0 -1
- package/lib/checks/impl/SoapLoginApiAuthCheck.d.ts +10 -0
- package/lib/checks/impl/SoapLoginApiAuthCheck.js +151 -0
- package/lib/checks/impl/SsoEnforcementCheck.js +0 -1
- package/lib/checks/impl/TrustedUrlHygieneCheck.js +3 -1
- package/lib/checks/registry.js +4 -0
- package/lib/checks/support/integrationAccounts.d.ts +35 -0
- package/lib/checks/support/integrationAccounts.js +209 -0
- package/lib/commands/audit/preflight.d.ts +13 -0
- package/lib/commands/audit/preflight.js +56 -0
- package/lib/commands/audit/security.d.ts +16 -3
- package/lib/commands/audit/security.js +40 -10
- package/lib/compliance/catalogs/gdpr.d.ts +3 -0
- package/lib/compliance/catalogs/gdpr.js +54 -0
- package/lib/compliance/catalogs/hipaa.d.ts +3 -0
- package/lib/compliance/catalogs/hipaa.js +97 -0
- package/lib/compliance/catalogs/index.js +4 -0
- package/lib/compliance/mapping.js +111 -36
- package/lib/findings/CheckMeta.js +2 -0
- package/lib/findings/digest.d.ts +50 -0
- package/lib/findings/digest.js +56 -0
- package/lib/findings/exitCode.d.ts +28 -0
- package/lib/findings/exitCode.js +46 -0
- package/lib/findings/loadScoringConfig.js +5 -5
- package/lib/preflight/permissionMap.d.ts +47 -0
- package/lib/preflight/permissionMap.js +84 -0
- package/lib/preflight/readPermissions.d.ts +11 -0
- package/lib/preflight/readPermissions.js +20 -0
- package/lib/renderers/HtmlRenderer.js +1 -1
- package/messages/audit.security.md +6 -0
- package/package.json +5 -3
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { RiskLevel } from '@cclabsnz/sf-core';
|
|
2
|
+
import type { AttackChain } from '../chains/AttackChain.js';
|
|
3
|
+
import type { AuditResult } from './AuditResult.js';
|
|
4
|
+
export interface DigestFinding {
|
|
5
|
+
checkId?: string;
|
|
6
|
+
riskLevel: RiskLevel;
|
|
7
|
+
title: string;
|
|
8
|
+
remediation: string;
|
|
9
|
+
complianceTags?: string[];
|
|
10
|
+
/** Total affected items. Present only when the finding named any. */
|
|
11
|
+
affectedCount?: number;
|
|
12
|
+
/** First few affected labels, for orientation. Never the whole list. */
|
|
13
|
+
affectedSample?: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface DigestInconclusive {
|
|
16
|
+
checkId?: string;
|
|
17
|
+
title: string;
|
|
18
|
+
}
|
|
19
|
+
export interface DigestCounts {
|
|
20
|
+
critical: number;
|
|
21
|
+
high: number;
|
|
22
|
+
medium: number;
|
|
23
|
+
low: number;
|
|
24
|
+
info: number;
|
|
25
|
+
passed: number;
|
|
26
|
+
inconclusive: number;
|
|
27
|
+
}
|
|
28
|
+
export interface AuditDigest {
|
|
29
|
+
orgId: string;
|
|
30
|
+
orgName: string;
|
|
31
|
+
isSandbox: boolean;
|
|
32
|
+
generatedAt: Date;
|
|
33
|
+
healthScore: number;
|
|
34
|
+
grade: AuditResult['grade'];
|
|
35
|
+
counts: DigestCounts;
|
|
36
|
+
findings: DigestFinding[];
|
|
37
|
+
inconclusive: DigestInconclusive[];
|
|
38
|
+
attackChains: AttackChain[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A token-cheap view of an audit, for callers that reason over the result rather
|
|
42
|
+
* than read it.
|
|
43
|
+
*
|
|
44
|
+
* Passing checks are counted but not listed, `detail` prose is dropped in favour of
|
|
45
|
+
* `remediation`, and affected-item lists — which are unbounded and dominate a large
|
|
46
|
+
* org's report — collapse to a count plus a short sample. Attack chains survive
|
|
47
|
+
* intact: there are few of them and they carry the analysis.
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildDigest(result: AuditResult): AuditDigest;
|
|
50
|
+
//# sourceMappingURL=digest.d.ts.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** How many affected-item labels to keep before falling back to a bare count. */
|
|
2
|
+
const SAMPLE_LIMIT = 3;
|
|
3
|
+
const isActive = (f) => f.passed !== true && f.inconclusive !== true;
|
|
4
|
+
function toDigestFinding(f) {
|
|
5
|
+
const out = {
|
|
6
|
+
checkId: f.checkId,
|
|
7
|
+
riskLevel: f.riskLevel,
|
|
8
|
+
title: f.title,
|
|
9
|
+
remediation: f.remediation,
|
|
10
|
+
};
|
|
11
|
+
if (f.complianceTags !== undefined)
|
|
12
|
+
out.complianceTags = f.complianceTags;
|
|
13
|
+
if (f.affectedItems !== undefined && f.affectedItems.length > 0) {
|
|
14
|
+
out.affectedCount = f.affectedItems.length;
|
|
15
|
+
out.affectedSample = f.affectedItems.slice(0, SAMPLE_LIMIT).map((i) => i.label);
|
|
16
|
+
}
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
function countBy(findings) {
|
|
20
|
+
const counts = { critical: 0, high: 0, medium: 0, low: 0, info: 0, passed: 0, inconclusive: 0 };
|
|
21
|
+
for (const f of findings) {
|
|
22
|
+
if (f.passed === true)
|
|
23
|
+
counts.passed += 1;
|
|
24
|
+
else if (f.inconclusive === true)
|
|
25
|
+
counts.inconclusive += 1;
|
|
26
|
+
else
|
|
27
|
+
counts[f.riskLevel.toLowerCase()] += 1;
|
|
28
|
+
}
|
|
29
|
+
return counts;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A token-cheap view of an audit, for callers that reason over the result rather
|
|
33
|
+
* than read it.
|
|
34
|
+
*
|
|
35
|
+
* Passing checks are counted but not listed, `detail` prose is dropped in favour of
|
|
36
|
+
* `remediation`, and affected-item lists — which are unbounded and dominate a large
|
|
37
|
+
* org's report — collapse to a count plus a short sample. Attack chains survive
|
|
38
|
+
* intact: there are few of them and they carry the analysis.
|
|
39
|
+
*/
|
|
40
|
+
export function buildDigest(result) {
|
|
41
|
+
return {
|
|
42
|
+
orgId: result.orgId,
|
|
43
|
+
orgName: result.orgName,
|
|
44
|
+
isSandbox: result.isSandbox,
|
|
45
|
+
generatedAt: result.generatedAt,
|
|
46
|
+
healthScore: result.healthScore,
|
|
47
|
+
grade: result.grade,
|
|
48
|
+
counts: countBy(result.findings),
|
|
49
|
+
findings: result.findings.filter(isActive).map(toDigestFinding),
|
|
50
|
+
inconclusive: result.findings
|
|
51
|
+
.filter((f) => f.inconclusive === true)
|
|
52
|
+
.map((f) => ({ checkId: f.checkId, title: f.title })),
|
|
53
|
+
attackChains: result.attackChains ?? [],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=digest.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RiskLevel } from '@cclabsnz/sf-core';
|
|
2
|
+
import type { Finding } from './Finding.js';
|
|
3
|
+
/** Audit completed; nothing the caller asked to fail on. */
|
|
4
|
+
export declare const EXIT_OK = 0;
|
|
5
|
+
/** Findings at or above the --fail-on threshold. */
|
|
6
|
+
export declare const EXIT_FINDINGS = 1;
|
|
7
|
+
/** Audit ran, but checks could not gather evidence. Only when --fail-on-inconclusive is set. */
|
|
8
|
+
export declare const EXIT_INCONCLUSIVE = 3;
|
|
9
|
+
export interface ExitOptions {
|
|
10
|
+
failOn?: RiskLevel;
|
|
11
|
+
failOnInconclusive?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Findings at or above `failOn`.
|
|
15
|
+
*
|
|
16
|
+
* Ranks are compared only after confirming the level is gateable. Testing
|
|
17
|
+
* `ORDER.indexOf(level) <= threshold` alone treats INFO (index -1) as more severe
|
|
18
|
+
* than CRITICAL, which made every passing check a violation.
|
|
19
|
+
*/
|
|
20
|
+
export declare function violationsFor(findings: Finding[], failOn: RiskLevel): Finding[];
|
|
21
|
+
/**
|
|
22
|
+
* The process exit code for a completed audit.
|
|
23
|
+
*
|
|
24
|
+
* A definite finding outranks unknown coverage: when both apply the caller gets
|
|
25
|
+
* EXIT_FINDINGS, and the inconclusive count is still carried in the report body.
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveExitCode(findings: Finding[], opts: ExitOptions): number;
|
|
28
|
+
//# sourceMappingURL=exitCode.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Audit completed; nothing the caller asked to fail on. */
|
|
2
|
+
export const EXIT_OK = 0;
|
|
3
|
+
/** Findings at or above the --fail-on threshold. */
|
|
4
|
+
export const EXIT_FINDINGS = 1;
|
|
5
|
+
/** Audit ran, but checks could not gather evidence. Only when --fail-on-inconclusive is set. */
|
|
6
|
+
export const EXIT_INCONCLUSIVE = 3;
|
|
7
|
+
/**
|
|
8
|
+
* Severity order, most severe first. INFO is deliberately absent: it is not a
|
|
9
|
+
* severity a caller can gate on, it is the level carried by passing and
|
|
10
|
+
* inconclusive findings.
|
|
11
|
+
*/
|
|
12
|
+
const ORDER = ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'];
|
|
13
|
+
/**
|
|
14
|
+
* Findings at or above `failOn`.
|
|
15
|
+
*
|
|
16
|
+
* Ranks are compared only after confirming the level is gateable. Testing
|
|
17
|
+
* `ORDER.indexOf(level) <= threshold` alone treats INFO (index -1) as more severe
|
|
18
|
+
* than CRITICAL, which made every passing check a violation.
|
|
19
|
+
*/
|
|
20
|
+
export function violationsFor(findings, failOn) {
|
|
21
|
+
const threshold = ORDER.indexOf(failOn);
|
|
22
|
+
if (threshold < 0)
|
|
23
|
+
return [];
|
|
24
|
+
return findings.filter((f) => {
|
|
25
|
+
if (f.passed === true || f.inconclusive === true)
|
|
26
|
+
return false;
|
|
27
|
+
const rank = ORDER.indexOf(f.riskLevel);
|
|
28
|
+
return rank >= 0 && rank <= threshold;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The process exit code for a completed audit.
|
|
33
|
+
*
|
|
34
|
+
* A definite finding outranks unknown coverage: when both apply the caller gets
|
|
35
|
+
* EXIT_FINDINGS, and the inconclusive count is still carried in the report body.
|
|
36
|
+
*/
|
|
37
|
+
export function resolveExitCode(findings, opts) {
|
|
38
|
+
if (opts.failOn !== undefined && violationsFor(findings, opts.failOn).length > 0) {
|
|
39
|
+
return EXIT_FINDINGS;
|
|
40
|
+
}
|
|
41
|
+
if (opts.failOnInconclusive === true && findings.some((f) => f.inconclusive === true)) {
|
|
42
|
+
return EXIT_INCONCLUSIVE;
|
|
43
|
+
}
|
|
44
|
+
return EXIT_OK;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=exitCode.js.map
|
|
@@ -33,11 +33,11 @@ export function loadScoringConfig(filePath, knownCheckIds, warn) {
|
|
|
33
33
|
riskScores: validated.riskScores ?? DEFAULT_SCORING_CONFIG.riskScores,
|
|
34
34
|
checkWeights: safeCheckWeights,
|
|
35
35
|
gradeThresholds: {
|
|
36
|
-
A: { ...DEFAULT_SCORING_CONFIG.gradeThresholds.A, ...
|
|
37
|
-
B: { ...DEFAULT_SCORING_CONFIG.gradeThresholds.B, ...
|
|
38
|
-
C: { ...DEFAULT_SCORING_CONFIG.gradeThresholds.C, ...
|
|
39
|
-
D: { ...DEFAULT_SCORING_CONFIG.gradeThresholds.D, ...
|
|
40
|
-
F: { ...DEFAULT_SCORING_CONFIG.gradeThresholds.F, ...
|
|
36
|
+
A: { ...DEFAULT_SCORING_CONFIG.gradeThresholds.A, ...validated.gradeThresholds?.A },
|
|
37
|
+
B: { ...DEFAULT_SCORING_CONFIG.gradeThresholds.B, ...validated.gradeThresholds?.B },
|
|
38
|
+
C: { ...DEFAULT_SCORING_CONFIG.gradeThresholds.C, ...validated.gradeThresholds?.C },
|
|
39
|
+
D: { ...DEFAULT_SCORING_CONFIG.gradeThresholds.D, ...validated.gradeThresholds?.D },
|
|
40
|
+
F: { ...DEFAULT_SCORING_CONFIG.gradeThresholds.F, ...validated.gradeThresholds?.F },
|
|
41
41
|
},
|
|
42
42
|
};
|
|
43
43
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AuditCache } from '@cclabsnz/sf-core';
|
|
2
|
+
import type { SecurityCheck } from '../checks/SecurityCheck.js';
|
|
3
|
+
export type AuditPermission = 'ApiEnabled' | 'ViewSetup' | 'ViewAllUsers' | 'ViewHealthCheckScreen' | 'AuthorApex' | 'ViewEventLogFiles';
|
|
4
|
+
export interface PermissionSpec {
|
|
5
|
+
/** Field on UserPermissionAccess carrying the effective grant. */
|
|
6
|
+
readonly field: string;
|
|
7
|
+
readonly label: string;
|
|
8
|
+
/** What the audit loses without it. */
|
|
9
|
+
readonly impact: string;
|
|
10
|
+
/**
|
|
11
|
+
* Cache keys whose producers and consumers need this permission. The affected
|
|
12
|
+
* check list is derived from the registry via these keys rather than hand-written,
|
|
13
|
+
* so a check added later is covered without touching this file.
|
|
14
|
+
*
|
|
15
|
+
* Empty for permissions too broad to attribute to specific checks.
|
|
16
|
+
*/
|
|
17
|
+
readonly cacheKeys: ReadonlyArray<keyof AuditCache>;
|
|
18
|
+
/** The audit cannot run at all without this. */
|
|
19
|
+
readonly blocking?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare const AUDIT_PERMISSIONS: Readonly<Record<AuditPermission, PermissionSpec>>;
|
|
22
|
+
export interface MissingPermission {
|
|
23
|
+
permission: AuditPermission;
|
|
24
|
+
label: string;
|
|
25
|
+
impact: string;
|
|
26
|
+
blocking: boolean;
|
|
27
|
+
affectedChecks: string[];
|
|
28
|
+
}
|
|
29
|
+
export interface PreflightResult {
|
|
30
|
+
canRun: boolean;
|
|
31
|
+
granted: AuditPermission[];
|
|
32
|
+
missing: MissingPermission[];
|
|
33
|
+
/** Checks expected to produce a verdict. */
|
|
34
|
+
willRun: number;
|
|
35
|
+
/** Checks expected to return inconclusive, deduplicated across permissions. */
|
|
36
|
+
willBeInconclusive: string[];
|
|
37
|
+
}
|
|
38
|
+
/** Check ids that need `permission`, derived from the registry's declared cache wiring. */
|
|
39
|
+
export declare function checksRequiring(permission: AuditPermission, checks?: readonly SecurityCheck[]): string[];
|
|
40
|
+
/**
|
|
41
|
+
* What this audit user will and will not be able to establish, before spending a run.
|
|
42
|
+
*
|
|
43
|
+
* The tool can only report a permission gap after the audit has already come back
|
|
44
|
+
* blind; this answers the same question up front, when it is still cheap to fix.
|
|
45
|
+
*/
|
|
46
|
+
export declare function buildPreflight(granted: Record<AuditPermission, boolean>, checks?: readonly SecurityCheck[]): PreflightResult;
|
|
47
|
+
//# sourceMappingURL=permissionMap.d.ts.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { CHECKS } from '../checks/registry.js';
|
|
2
|
+
export const AUDIT_PERMISSIONS = {
|
|
3
|
+
ApiEnabled: {
|
|
4
|
+
field: 'PermissionsApiEnabled',
|
|
5
|
+
label: 'API Enabled',
|
|
6
|
+
impact: 'All access is via SOQL/Tooling/REST. Without it the audit cannot run at all.',
|
|
7
|
+
cacheKeys: [],
|
|
8
|
+
blocking: true,
|
|
9
|
+
},
|
|
10
|
+
ViewSetup: {
|
|
11
|
+
field: 'PermissionsViewSetup',
|
|
12
|
+
label: 'View Setup and Configuration',
|
|
13
|
+
impact: 'Reads the bulk of the surface — connected apps, remote sites, CSP, named credentials, auth config, ' +
|
|
14
|
+
'Experience sites, and Tooling metadata. Most setup and configuration checks return inconclusive without it.',
|
|
15
|
+
cacheKeys: [],
|
|
16
|
+
},
|
|
17
|
+
ViewAllUsers: {
|
|
18
|
+
field: 'PermissionsViewAllUsers',
|
|
19
|
+
label: 'View All Users',
|
|
20
|
+
impact: 'Enumerates every User, PermissionSetAssignment and TwoFactorInfo org-wide. Without it the user, ' +
|
|
21
|
+
'admin and MFA checks under-count and miss accounts outside the role hierarchy.',
|
|
22
|
+
cacheKeys: ['mfaRegistrations', 'effectivePermissions'],
|
|
23
|
+
},
|
|
24
|
+
ViewHealthCheckScreen: {
|
|
25
|
+
field: 'PermissionsViewHealthCheck',
|
|
26
|
+
label: 'View Health Check',
|
|
27
|
+
impact: 'Reads SecurityHealthCheck and its risks. Health Check and password/session baselines are inconclusive without it.',
|
|
28
|
+
cacheKeys: ['healthCheckRisks'],
|
|
29
|
+
},
|
|
30
|
+
AuthorApex: {
|
|
31
|
+
field: 'PermissionsAuthorApex',
|
|
32
|
+
label: 'Author Apex (read-only use)',
|
|
33
|
+
impact: 'The only standard gate exposing ApexClass/ApexTrigger/ApexPage Body via the Tooling API. ' +
|
|
34
|
+
'Grants no ability to modify org data. The code-security checks are inconclusive without it.',
|
|
35
|
+
cacheKeys: ['apexBodies', 'vfPageBodies'],
|
|
36
|
+
},
|
|
37
|
+
ViewEventLogFiles: {
|
|
38
|
+
field: 'PermissionsViewEventLogFiles',
|
|
39
|
+
label: 'View Event Log Files',
|
|
40
|
+
impact: 'Reads EventLogFile. Whether login and API activity is monitored cannot be established without it.',
|
|
41
|
+
cacheKeys: ['eventLogSummary'],
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
const usesKey = (check, key) => (check.dependsOnCache?.includes(key) ?? false) || (check.populatesCache?.includes(key) ?? false);
|
|
45
|
+
/** Check ids that need `permission`, derived from the registry's declared cache wiring. */
|
|
46
|
+
export function checksRequiring(permission, checks = CHECKS) {
|
|
47
|
+
const { cacheKeys } = AUDIT_PERMISSIONS[permission];
|
|
48
|
+
if (cacheKeys.length === 0)
|
|
49
|
+
return [];
|
|
50
|
+
return checks.filter((c) => cacheKeys.some((k) => usesKey(c, k))).map((c) => c.id);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* What this audit user will and will not be able to establish, before spending a run.
|
|
54
|
+
*
|
|
55
|
+
* The tool can only report a permission gap after the audit has already come back
|
|
56
|
+
* blind; this answers the same question up front, when it is still cheap to fix.
|
|
57
|
+
*/
|
|
58
|
+
export function buildPreflight(granted, checks = CHECKS) {
|
|
59
|
+
const permissions = Object.keys(AUDIT_PERMISSIONS);
|
|
60
|
+
const missing = [];
|
|
61
|
+
const inconclusive = new Set();
|
|
62
|
+
for (const permission of permissions) {
|
|
63
|
+
if (granted[permission])
|
|
64
|
+
continue;
|
|
65
|
+
const spec = AUDIT_PERMISSIONS[permission];
|
|
66
|
+
const affectedChecks = checksRequiring(permission, checks);
|
|
67
|
+
affectedChecks.forEach((id) => inconclusive.add(id));
|
|
68
|
+
missing.push({
|
|
69
|
+
permission,
|
|
70
|
+
label: spec.label,
|
|
71
|
+
impact: spec.impact,
|
|
72
|
+
blocking: spec.blocking === true,
|
|
73
|
+
affectedChecks,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
canRun: !missing.some((m) => m.blocking),
|
|
78
|
+
granted: permissions.filter((p) => granted[p]),
|
|
79
|
+
missing,
|
|
80
|
+
willRun: checks.length - inconclusive.size,
|
|
81
|
+
willBeInconclusive: [...inconclusive],
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=permissionMap.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SoqlClient } from '@cclabsnz/sf-core';
|
|
2
|
+
import { type AuditPermission } from './permissionMap.js';
|
|
3
|
+
/**
|
|
4
|
+
* The running user's *effective* permissions — profile unioned with every assigned
|
|
5
|
+
* permission set — in one read.
|
|
6
|
+
*
|
|
7
|
+
* UserPermissionAccess returns exactly one row scoped to the caller, so this needs no
|
|
8
|
+
* assignment join and no aggregation. Read-only, like everything else here.
|
|
9
|
+
*/
|
|
10
|
+
export declare function readEffectivePermissions(soql: SoqlClient): Promise<Record<AuditPermission, boolean>>;
|
|
11
|
+
//# sourceMappingURL=readPermissions.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AUDIT_PERMISSIONS } from './permissionMap.js';
|
|
2
|
+
/**
|
|
3
|
+
* The running user's *effective* permissions — profile unioned with every assigned
|
|
4
|
+
* permission set — in one read.
|
|
5
|
+
*
|
|
6
|
+
* UserPermissionAccess returns exactly one row scoped to the caller, so this needs no
|
|
7
|
+
* assignment join and no aggregation. Read-only, like everything else here.
|
|
8
|
+
*/
|
|
9
|
+
export async function readEffectivePermissions(soql) {
|
|
10
|
+
const permissions = Object.keys(AUDIT_PERMISSIONS);
|
|
11
|
+
const fields = permissions.map((p) => AUDIT_PERMISSIONS[p].field);
|
|
12
|
+
const result = await soql.query(`SELECT ${fields.join(', ')} FROM UserPermissionAccess`);
|
|
13
|
+
const row = result.records[0] ?? {};
|
|
14
|
+
const granted = {};
|
|
15
|
+
for (const permission of permissions) {
|
|
16
|
+
granted[permission] = row[AUDIT_PERMISSIONS[permission].field] === true;
|
|
17
|
+
}
|
|
18
|
+
return granted;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=readPermissions.js.map
|
|
@@ -165,7 +165,7 @@ export class HtmlRenderer {
|
|
|
165
165
|
.map((c) => {
|
|
166
166
|
const conf = c.confidence === 'named' ? '' : ' (potential)';
|
|
167
167
|
const steps = c.steps
|
|
168
|
-
.map((s
|
|
168
|
+
.map((s) => `<li><strong>${escStr(s.title ?? s.findingId)}</strong> (${escStr(s.severity ?? '—')}): grants <code>${escStr(s.capability)}</code></li>`)
|
|
169
169
|
.join('');
|
|
170
170
|
return `<div class="attack-chain severity-${c.severity.toLowerCase()}">
|
|
171
171
|
<h3>[${escStr(c.severity)}] ${escStr(c.title)}${conf}</h3>
|
|
@@ -22,6 +22,12 @@ Directory to write the report file. Defaults to the current directory.
|
|
|
22
22
|
Exit with code 1 if any finding is at or above this severity level.
|
|
23
23
|
Options: CRITICAL, HIGH, MEDIUM, LOW
|
|
24
24
|
|
|
25
|
+
## fail-on-inconclusive
|
|
26
|
+
|
|
27
|
+
Exit with code 3 if any check could not gather evidence because the audit user lacked
|
|
28
|
+
the required permission. Off by default, so existing pipelines are unaffected. A finding
|
|
29
|
+
at or above `--fail-on` takes precedence and still exits 1.
|
|
30
|
+
|
|
25
31
|
## checks
|
|
26
32
|
|
|
27
33
|
Comma-separated check IDs to run instead of all checks (e.g. `hardcoded-credentials,apex-sharing`).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cclabsnz/sf-audit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Read-only Salesforce security audit for the sf CLI: 88 checks, attack-chain correlation, A-F risk grading, and compliance mapping to OWASP, SOC 2, ISO 27001, NZISM and more.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"salesforce",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"clean": "rm -rf lib",
|
|
34
34
|
"prepare": "git config core.hooksPath .githooks 2>/dev/null || true",
|
|
35
35
|
"typecheck": "tsc -p tsconfig.test.json",
|
|
36
|
+
"lint": "oxlint src test",
|
|
36
37
|
"test:jest": "node --experimental-vm-modules node_modules/jest/bin/jest.js --passWithNoTests"
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
@@ -50,7 +51,7 @@
|
|
|
50
51
|
"@types/jest": "^30",
|
|
51
52
|
"@types/node": "^26",
|
|
52
53
|
"jest": "^30",
|
|
53
|
-
"
|
|
54
|
+
"oxlint": "^1.79.0",
|
|
54
55
|
"typescript": "^7.0.2"
|
|
55
56
|
},
|
|
56
57
|
"repository": {
|
|
@@ -87,6 +88,7 @@
|
|
|
87
88
|
},
|
|
88
89
|
"files": [
|
|
89
90
|
"/lib",
|
|
91
|
+
"/CHANGELOG.md",
|
|
90
92
|
"/messages",
|
|
91
93
|
"/config",
|
|
92
94
|
"!/lib/**/*.map"
|
|
@@ -97,7 +99,7 @@
|
|
|
97
99
|
"js-yaml@3": "^3.15.1",
|
|
98
100
|
"handlebars": "^4.7.9",
|
|
99
101
|
"brace-expansion": "^5.0.9",
|
|
100
|
-
"fast-uri@3": "^3.1.
|
|
102
|
+
"fast-uri@3": "^3.1.6"
|
|
101
103
|
}
|
|
102
104
|
}
|
|
103
105
|
}
|