@cclabsnz/sf-audit 1.19.0 → 1.20.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 +31 -0
- package/lib/apps/apiLogSource.js +3 -2
- package/lib/chains/AttackChain.d.ts +12 -0
- package/lib/chains/ChainEngine.js +12 -3
- package/lib/chains/namedChains.d.ts +72 -0
- package/lib/chains/namedChains.js +381 -207
- package/lib/checks/CheckEngine.js +5 -2
- package/lib/checks/impl/AgentActionSurfaceCheck.js +2 -13
- package/lib/checks/impl/AgentInventoryCheck.js +2 -15
- package/lib/checks/impl/ApexLoggingCheck.js +2 -0
- package/lib/checks/impl/GuestApiAccessCheck.js +2 -0
- package/lib/checks/impl/GuestUserAccessCheck.js +2 -0
- package/lib/checks/impl/UsersAndAdminsCheck.js +5 -5
- package/lib/checks/support/missingObject.js +2 -1
- package/lib/checks/support/schema.js +1 -1
- package/lib/commands/audit/incident/collect.js +2 -1
- package/lib/findings/Finding.d.ts +7 -0
- package/lib/incident/collect/orgErrors.js +3 -1
- package/lib/incident/collect/streamGuestLogs.js +3 -2
- package/lib/lib/apiErrorText.d.ts +8 -0
- package/lib/lib/apiErrorText.js +15 -0
- package/lib/renderers/AttackChainDagRenderer.d.ts +5 -1
- package/lib/renderers/AttackChainDagRenderer.js +16 -31
- package/lib/renderers/ClientReportRenderer.js +4 -1
- package/lib/renderers/HtmlRenderer.js +10 -2
- package/lib/renderers/MarkdownRenderer.js +61 -2
- package/lib/renderers/SarifRenderer.js +10 -2
- package/lib/threats/linddun.d.ts +3 -0
- package/lib/threats/linddun.js +40 -0
- package/lib/threats/resolve.d.ts +8 -0
- package/lib/threats/resolve.js +18 -0
- package/lib/threats/stride.d.ts +3 -0
- package/lib/threats/stride.js +120 -0
- package/lib/threats/types.d.ts +16 -0
- package/lib/threats/types.js +22 -0
- package/lib/threats/view.d.ts +27 -0
- package/lib/threats/view.js +51 -0
- package/package.json +3 -3
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// STRIDE category of each check, primary first (RULE-101). A check whose findings differ in kind
|
|
2
|
+
// sets `threats.stride` on those findings, which overrides this entry.
|
|
3
|
+
export const CHECK_STRIDE_MAP = {
|
|
4
|
+
// Identity and authentication
|
|
5
|
+
'login-session': ['S'],
|
|
6
|
+
'password-session-policy': ['S'],
|
|
7
|
+
'ip-restrictions': ['S'],
|
|
8
|
+
'trusted-ip-ranges': ['S'],
|
|
9
|
+
'sso-enforcement': ['S'],
|
|
10
|
+
'mfa-enforcement': ['S'],
|
|
11
|
+
'internal-user-mfa': ['S'],
|
|
12
|
+
'mfa-registration': ['S'],
|
|
13
|
+
'mfa-method-strength': ['S'],
|
|
14
|
+
'my-domain-login-policy': ['S'],
|
|
15
|
+
'high-assurance-session': ['S'],
|
|
16
|
+
'enhanced-domains': ['S'],
|
|
17
|
+
'session-hardening': ['S', 'T'],
|
|
18
|
+
'auth-providers': ['S'],
|
|
19
|
+
'auth-provider-registration-handler': ['S', 'E'],
|
|
20
|
+
'delegated-authentication-exposure': ['S'],
|
|
21
|
+
'oauth-device-and-asset-token-flows': ['S'],
|
|
22
|
+
'oauth-token-inventory': ['S'],
|
|
23
|
+
'connected-apps': ['S', 'E'],
|
|
24
|
+
'connected-app-scope': ['E', 'S'],
|
|
25
|
+
'connected-app-inactivity': ['S'],
|
|
26
|
+
'inactive-users': ['S'],
|
|
27
|
+
'certificate-expiry': ['D', 'S'],
|
|
28
|
+
'external-credentials': ['S', 'I'],
|
|
29
|
+
'api-client-permission': ['S', 'E'],
|
|
30
|
+
'soap-login-api-auth': ['S'],
|
|
31
|
+
'email-security': ['S', 'T'],
|
|
32
|
+
'org-wide-email-spoofing': ['S'],
|
|
33
|
+
'login-anomaly': ['S'],
|
|
34
|
+
'failed-login-detection': ['S', 'R'],
|
|
35
|
+
'health-check': ['S', 'E'],
|
|
36
|
+
// Privilege
|
|
37
|
+
'users-and-admins': ['E'],
|
|
38
|
+
'permissions': ['E'],
|
|
39
|
+
'standard-profiles': ['E'],
|
|
40
|
+
'escalation-perms': ['E'],
|
|
41
|
+
'privileged-access': ['E'],
|
|
42
|
+
'separation-of-duties': ['E'],
|
|
43
|
+
'delegated-administration-groups': ['E'],
|
|
44
|
+
'login-access-policy': ['E', 'R'],
|
|
45
|
+
'integration-users': ['E', 'S'],
|
|
46
|
+
'integration-least-privilege': ['E'],
|
|
47
|
+
'apex-sharing': ['E', 'I'],
|
|
48
|
+
'flows-without-sharing': ['E', 'I'],
|
|
49
|
+
'apex-crud-fls': ['E', 'I'],
|
|
50
|
+
'apex-rest-endpoint': ['E', 'I'],
|
|
51
|
+
'guest-executable-apex': ['E', 'I'],
|
|
52
|
+
'scheduled-apex': ['E'],
|
|
53
|
+
'anonymous-apex-audit': ['E', 'R'],
|
|
54
|
+
'platform-event-subscriber-context': ['E'],
|
|
55
|
+
'inbound-email-handler-exposure': ['E', 'S'],
|
|
56
|
+
'agent-inventory': ['E'],
|
|
57
|
+
'agent-user-privilege': ['E'],
|
|
58
|
+
// Data exposure
|
|
59
|
+
'sharing-model': ['I'],
|
|
60
|
+
'public-group-sharing': ['I'],
|
|
61
|
+
'field-level-security': ['I'],
|
|
62
|
+
'report-folder-access': ['I'],
|
|
63
|
+
'data-export-access': ['I'],
|
|
64
|
+
'data-classification': ['I'],
|
|
65
|
+
'encryption-coverage': ['I'],
|
|
66
|
+
'shield-tenant-secret-lifecycle': ['I'],
|
|
67
|
+
'sandbox-data-masking': ['I'],
|
|
68
|
+
'restriction-rules-integrity': ['I'],
|
|
69
|
+
'data-cloud-data-space-isolation': ['I'],
|
|
70
|
+
'external-account-hierarchy-exposure': ['I', 'E'],
|
|
71
|
+
'content-links': ['I'],
|
|
72
|
+
'public-content-exposure': ['I'],
|
|
73
|
+
'guest-user-access': ['I', 'T'],
|
|
74
|
+
'guest-object-exposure': ['I'],
|
|
75
|
+
'guest-site-options': ['I'],
|
|
76
|
+
'guest-record-access-policy': ['I'],
|
|
77
|
+
'guest-user-visibility': ['I'],
|
|
78
|
+
'guest-api-access': ['I', 'T'],
|
|
79
|
+
'experience-cloud-site': ['I', 'S'],
|
|
80
|
+
'classic-sites': ['I'],
|
|
81
|
+
'guest-traffic-anomaly': ['I', 'R'],
|
|
82
|
+
'debug-log-access': ['I'],
|
|
83
|
+
'hardcoded-credentials': ['I', 'S'],
|
|
84
|
+
'custom-settings': ['I'],
|
|
85
|
+
'custom-labels-credential': ['I'],
|
|
86
|
+
'named-credentials': ['I'],
|
|
87
|
+
'flow-http-callout-credential-bypass': ['I', 'S'],
|
|
88
|
+
'remote-sites': ['I'],
|
|
89
|
+
'outbound-messages': ['I'],
|
|
90
|
+
'cors-allowlist': ['I', 'T'],
|
|
91
|
+
'csp-trusted-sites': ['I', 'T'],
|
|
92
|
+
'agent-channel-exposure': ['I', 'E'],
|
|
93
|
+
'agent-query-reach': ['I'],
|
|
94
|
+
'agent-outbound-actions': ['I'],
|
|
95
|
+
'trusted-url-hygiene': ['I'],
|
|
96
|
+
'genai-prompt-template-grounding': ['I', 'T'],
|
|
97
|
+
// Integrity of code, components and deployments
|
|
98
|
+
'code-security': ['T', 'I'],
|
|
99
|
+
'visualforce-xss': ['T', 'S'],
|
|
100
|
+
'lightning-message-channel': ['T', 'I'],
|
|
101
|
+
'experience-csp': ['T', 'I'],
|
|
102
|
+
'installed-packages': ['T', 'E'],
|
|
103
|
+
'package-post-install-supply-chain': ['T', 'E'],
|
|
104
|
+
'deployment-identity': ['T', 'R'],
|
|
105
|
+
'release-updates': ['T'],
|
|
106
|
+
'legacy-api-version': ['T'],
|
|
107
|
+
'agent-action-surface': ['T', 'E'],
|
|
108
|
+
// Accountability and detection
|
|
109
|
+
'audit-trail': ['R'],
|
|
110
|
+
'field-history-tracking': ['R'],
|
|
111
|
+
'event-monitoring': ['R'],
|
|
112
|
+
'siem-integration': ['R'],
|
|
113
|
+
'apex-logging': ['R', 'I'],
|
|
114
|
+
'threat-detection': ['R'],
|
|
115
|
+
'transaction-security-policy': ['R'],
|
|
116
|
+
'agent-monitoring-coverage': ['R'],
|
|
117
|
+
// Availability
|
|
118
|
+
'api-limits': ['D'],
|
|
119
|
+
};
|
|
120
|
+
//# sourceMappingURL=stride.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Spoofing, Tampering, Repudiation, Information disclosure, Denial of service, Elevation of privilege. */
|
|
2
|
+
export type StrideCategory = 'S' | 'T' | 'R' | 'I' | 'D' | 'E';
|
|
3
|
+
/**
|
|
4
|
+
* LINDDUN (2023): Linking, Identifying, Non-repudiation, Detecting, Data disclosure,
|
|
5
|
+
* Unawareness & unintervenability, Non-compliance.
|
|
6
|
+
*/
|
|
7
|
+
export type LinddunCategory = 'L' | 'I' | 'Nr' | 'D' | 'DD' | 'U' | 'Nc';
|
|
8
|
+
export interface FindingThreats {
|
|
9
|
+
stride?: StrideCategory[];
|
|
10
|
+
linddun?: LinddunCategory[];
|
|
11
|
+
}
|
|
12
|
+
export declare const STRIDE_CATEGORIES: readonly StrideCategory[];
|
|
13
|
+
export declare const LINDDUN_CATEGORIES: readonly LinddunCategory[];
|
|
14
|
+
export declare const STRIDE_NAMES: Record<StrideCategory, string>;
|
|
15
|
+
export declare const LINDDUN_NAMES: Record<LinddunCategory, string>;
|
|
16
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Threat categories. These classify the harm a finding describes; they are not compliance
|
|
2
|
+
// controls and never enter the compliance catalog or matrix (RULE-100).
|
|
3
|
+
export const STRIDE_CATEGORIES = ['S', 'T', 'R', 'I', 'D', 'E'];
|
|
4
|
+
export const LINDDUN_CATEGORIES = ['L', 'I', 'Nr', 'D', 'DD', 'U', 'Nc'];
|
|
5
|
+
export const STRIDE_NAMES = {
|
|
6
|
+
S: 'Spoofing',
|
|
7
|
+
T: 'Tampering',
|
|
8
|
+
R: 'Repudiation',
|
|
9
|
+
I: 'Information disclosure',
|
|
10
|
+
D: 'Denial of service',
|
|
11
|
+
E: 'Elevation of privilege',
|
|
12
|
+
};
|
|
13
|
+
export const LINDDUN_NAMES = {
|
|
14
|
+
L: 'Linking',
|
|
15
|
+
I: 'Identifying',
|
|
16
|
+
Nr: 'Non-repudiation',
|
|
17
|
+
D: 'Detecting',
|
|
18
|
+
DD: 'Data disclosure',
|
|
19
|
+
U: 'Unawareness & unintervenability',
|
|
20
|
+
Nc: 'Non-compliance',
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Finding } from '../findings/Finding.js';
|
|
2
|
+
import { type LinddunCategory, type StrideCategory } from './types.js';
|
|
3
|
+
export type ThreatRowStatus = 'findings' | 'no-findings' | 'not-assessed-in-run' | 'not-covered';
|
|
4
|
+
export interface ThreatRow<C extends string> {
|
|
5
|
+
category: C;
|
|
6
|
+
name: string;
|
|
7
|
+
/** Active findings in this category: not passed, inconclusive, not assessed or waived. */
|
|
8
|
+
findings: Finding[];
|
|
9
|
+
/** Checks in this run whose map entry names the category. */
|
|
10
|
+
coveringChecks: number;
|
|
11
|
+
/** Of those, the checks that gathered evidence. */
|
|
12
|
+
assessedChecks: number;
|
|
13
|
+
status: ThreatRowStatus;
|
|
14
|
+
}
|
|
15
|
+
export interface ThreatView {
|
|
16
|
+
stride: ThreatRow<StrideCategory>[];
|
|
17
|
+
/** Present only when a privacy-tagged check ran. */
|
|
18
|
+
linddun?: ThreatRow<LinddunCategory>[];
|
|
19
|
+
/** Findings that are a repudiation gap and also log personal data once fixed (RULE-103). */
|
|
20
|
+
dualReadings: Finding[];
|
|
21
|
+
}
|
|
22
|
+
export declare const PRIVACY_COST_OF_LOGGING = "The logging this fix adds records personal data: decide what it captures, how long it is kept and who can read it.";
|
|
23
|
+
/** The threat view (RULE-104): coverage per category, never a pass. */
|
|
24
|
+
export declare function buildThreatView(findings: readonly Finding[]): ThreatView;
|
|
25
|
+
/** How a row reads in every output. Never "pass", "compliant" or "no threats". */
|
|
26
|
+
export declare function threatRowStatusText(row: ThreatRow<string>): string;
|
|
27
|
+
//# sourceMappingURL=view.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { CHECK_STRIDE_MAP } from './stride.js';
|
|
2
|
+
import { CHECK_LINDDUN_MAP } from './linddun.js';
|
|
3
|
+
import { LINDDUN_CATEGORIES, LINDDUN_NAMES, STRIDE_CATEGORIES, STRIDE_NAMES, } from './types.js';
|
|
4
|
+
export const PRIVACY_COST_OF_LOGGING = 'The logging this fix adds records personal data: decide what it captures, how long it is kept and who can read it.';
|
|
5
|
+
const isActive = (f) => !f.passed && !f.inconclusive && !f.notAssessed && !f.waived;
|
|
6
|
+
/** The threat view (RULE-104): coverage per category, never a pass. */
|
|
7
|
+
export function buildThreatView(findings) {
|
|
8
|
+
const assessed = new Map();
|
|
9
|
+
for (const f of findings) {
|
|
10
|
+
const id = f.checkId ?? f.id;
|
|
11
|
+
assessed.set(id, (assessed.get(id) ?? false) || !(f.inconclusive || f.notAssessed));
|
|
12
|
+
}
|
|
13
|
+
const active = findings.filter(isActive);
|
|
14
|
+
function rows(categories, names, map, of) {
|
|
15
|
+
return categories.map((category) => {
|
|
16
|
+
const covering = [...assessed.keys()].filter((id) => map[id]?.includes(category));
|
|
17
|
+
const assessedChecks = covering.filter((id) => assessed.get(id)).length;
|
|
18
|
+
const inCategory = active.filter((f) => of(f)?.includes(category));
|
|
19
|
+
const status = inCategory.length > 0 ? 'findings'
|
|
20
|
+
: assessedChecks > 0 ? 'no-findings'
|
|
21
|
+
: covering.length > 0 ? 'not-assessed-in-run'
|
|
22
|
+
: 'not-covered';
|
|
23
|
+
return { category, name: names[category], findings: inCategory, coveringChecks: covering.length, assessedChecks, status };
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const view = {
|
|
27
|
+
stride: rows(STRIDE_CATEGORIES, STRIDE_NAMES, CHECK_STRIDE_MAP, (f) => f.threats?.stride),
|
|
28
|
+
dualReadings: active.filter((f) => {
|
|
29
|
+
const linddun = f.threats?.linddun ?? [];
|
|
30
|
+
return (f.threats?.stride ?? []).includes('R') && (linddun.includes('Nr') || linddun.includes('D'));
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
33
|
+
if ([...assessed.keys()].some((id) => CHECK_LINDDUN_MAP[id])) {
|
|
34
|
+
view.linddun = rows(LINDDUN_CATEGORIES, LINDDUN_NAMES, CHECK_LINDDUN_MAP, (f) => f.threats?.linddun);
|
|
35
|
+
}
|
|
36
|
+
return view;
|
|
37
|
+
}
|
|
38
|
+
/** How a row reads in every output. Never "pass", "compliant" or "no threats". */
|
|
39
|
+
export function threatRowStatusText(row) {
|
|
40
|
+
switch (row.status) {
|
|
41
|
+
case 'findings':
|
|
42
|
+
return `${row.findings.length} finding${row.findings.length === 1 ? '' : 's'} (from ${row.assessedChecks} check${row.assessedChecks === 1 ? '' : 's'})`;
|
|
43
|
+
case 'no-findings':
|
|
44
|
+
return `no findings from ${row.assessedChecks} check${row.assessedChecks === 1 ? '' : 's'}`;
|
|
45
|
+
case 'not-assessed-in-run':
|
|
46
|
+
return 'not assessed in this run';
|
|
47
|
+
case 'not-covered':
|
|
48
|
+
return 'not assessed by this tool';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=view.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cclabsnz/sf-audit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
4
4
|
"description": "Read-only Salesforce security audit for the sf CLI: 109 checks, attack-chain correlation, A-F risk grading, compliance mapping, free EventLogFile capture, and Guest User Anomaly investigation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"salesforce",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"test:jest": "node --experimental-vm-modules node_modules/jest/bin/jest.js --passWithNoTests"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@cclabsnz/sf-core": "^0.
|
|
49
|
+
"@cclabsnz/sf-core": "^0.12.0",
|
|
50
50
|
"@oclif/core": "^5",
|
|
51
51
|
"@salesforce/core": "^9.3.0",
|
|
52
52
|
"@salesforce/sf-plugins-core": "^13",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"form-data": "^4.0.6",
|
|
113
113
|
"handlebars": "^4.7.9",
|
|
114
114
|
"brace-expansion": "^5.0.11",
|
|
115
|
-
"fast-uri@3": "^3.1.
|
|
115
|
+
"fast-uri@3": "^3.1.9",
|
|
116
116
|
"browserslist": "^4.28.7",
|
|
117
117
|
"@istanbuljs/load-nyc-config>js-yaml": "^4.1.1"
|
|
118
118
|
}
|