@j-schreiber/sf-cli-security-audit 0.6.0 → 0.7.1
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 +39 -2
- package/lib/commands/org/audit/init.js +2 -1
- package/lib/commands/org/audit/init.js.map +1 -1
- package/lib/commands/org/audit/run.js +10 -4
- package/lib/commands/org/audit/run.js.map +1 -1
- package/lib/commands/org/scan/user-perms.js +1 -2
- package/lib/commands/org/scan/user-perms.js.map +1 -1
- package/lib/libs/conf-init/auditConfig.js +5 -4
- package/lib/libs/conf-init/auditConfig.js.map +1 -1
- package/lib/libs/conf-init/policyConfigs.d.ts +7 -1
- package/lib/libs/conf-init/policyConfigs.js +29 -3
- package/lib/libs/conf-init/policyConfigs.js.map +1 -1
- package/lib/libs/conf-init/presets/loose.js +16 -0
- package/lib/libs/conf-init/presets/loose.js.map +1 -1
- package/lib/libs/conf-init/presets/strict.js +17 -0
- package/lib/libs/conf-init/presets/strict.js.map +1 -1
- package/lib/libs/{policies → core}/auditRun.d.ts +4 -4
- package/lib/libs/{policies → core}/auditRun.js +8 -14
- package/lib/libs/core/auditRun.js.map +1 -0
- package/lib/libs/core/constants.d.ts +5 -0
- package/lib/libs/core/constants.js +10 -0
- package/lib/libs/core/constants.js.map +1 -1
- package/lib/libs/core/file-mgmt/auditConfigFileManager.d.ts +4 -2
- package/lib/libs/core/file-mgmt/auditConfigFileManager.js +38 -51
- package/lib/libs/core/file-mgmt/auditConfigFileManager.js.map +1 -1
- package/lib/libs/core/file-mgmt/schema.d.ts +33 -11
- package/lib/libs/core/file-mgmt/schema.js +24 -1
- package/lib/libs/core/file-mgmt/schema.js.map +1 -1
- package/lib/libs/core/policies/connectedAppPolicy.d.ts +10 -0
- package/lib/libs/{policies → core/policies}/connectedAppPolicy.js +4 -4
- package/lib/libs/core/policies/connectedAppPolicy.js.map +1 -0
- package/lib/libs/core/policies/permissionSetPolicy.d.ts +11 -0
- package/lib/libs/{policies → core/policies}/permissionSetPolicy.js +4 -4
- package/lib/libs/core/policies/permissionSetPolicy.js.map +1 -0
- package/lib/libs/{policies → core/policies}/policy.d.ts +11 -11
- package/lib/libs/{policies → core/policies}/policy.js +5 -0
- package/lib/libs/core/policies/policy.js.map +1 -0
- package/lib/libs/core/policies/profilePolicy.d.ts +11 -0
- package/lib/libs/{policies → core/policies}/profilePolicy.js +4 -4
- package/lib/libs/core/policies/profilePolicy.js.map +1 -0
- package/lib/libs/{policies → core/policies}/salesforceStandardTypes.d.ts +14 -0
- package/lib/libs/core/policies/salesforceStandardTypes.js.map +1 -0
- package/lib/libs/core/policies/userPolicy.d.ts +11 -0
- package/lib/libs/core/policies/userPolicy.js +104 -0
- package/lib/libs/core/policies/userPolicy.js.map +1 -0
- package/lib/libs/core/policyRegistry.d.ts +23 -0
- package/lib/libs/core/policyRegistry.js +38 -0
- package/lib/libs/core/policyRegistry.js.map +1 -0
- package/lib/libs/core/registries/ruleRegistry.d.ts +1 -3
- package/lib/libs/core/registries/ruleRegistry.js +1 -1
- package/lib/libs/core/registries/ruleRegistry.js.map +1 -1
- package/lib/libs/core/registries/rules/noInactiveUsers.d.ts +9 -0
- package/lib/libs/core/registries/rules/noInactiveUsers.js +44 -0
- package/lib/libs/core/registries/rules/noInactiveUsers.js.map +1 -0
- package/lib/libs/core/registries/rules/noOtherApexApiLogins.d.ts +7 -0
- package/lib/libs/core/registries/rules/noOtherApexApiLogins.js +24 -0
- package/lib/libs/core/registries/rules/noOtherApexApiLogins.js.map +1 -0
- package/lib/libs/core/registries/rules/policyRule.d.ts +6 -1
- package/lib/libs/core/registries/rules/policyRule.js +12 -0
- package/lib/libs/core/registries/rules/policyRule.js.map +1 -1
- package/lib/libs/core/registries/types.d.ts +2 -0
- package/lib/libs/core/registries/types.js +2 -0
- package/lib/libs/core/registries/types.js.map +1 -1
- package/lib/libs/core/registries/users.d.ts +26 -0
- package/lib/libs/core/registries/users.js +10 -0
- package/lib/libs/core/registries/users.js.map +1 -0
- package/lib/libs/core/result-types.d.ts +2 -1
- package/lib/libs/core/utils.d.ts +7 -0
- package/lib/libs/core/utils.js +12 -0
- package/lib/libs/core/utils.js.map +1 -1
- package/lib/ux/auditRunMultiStage.d.ts +1 -1
- package/lib/ux/auditRunMultiStage.js +22 -19
- package/lib/ux/auditRunMultiStage.js.map +1 -1
- package/messages/org.audit.init.md +3 -3
- package/messages/org.audit.run.md +11 -3
- package/messages/org.scan.user-perms.md +8 -10
- package/messages/policies.general.md +4 -0
- package/messages/rules.users.md +11 -0
- package/oclif.manifest.json +12 -12
- package/package.json +1 -1
- package/lib/libs/policies/auditRun.js.map +0 -1
- package/lib/libs/policies/connectedAppPolicy.d.ts +0 -9
- package/lib/libs/policies/connectedAppPolicy.js.map +0 -1
- package/lib/libs/policies/permissionSetPolicy.d.ts +0 -10
- package/lib/libs/policies/permissionSetPolicy.js.map +0 -1
- package/lib/libs/policies/policy.js.map +0 -1
- package/lib/libs/policies/profilePolicy.d.ts +0 -10
- package/lib/libs/policies/profilePolicy.js.map +0 -1
- package/lib/libs/policies/salesforceStandardTypes.js.map +0 -1
- /package/lib/libs/{policies → core/policies}/salesforceStandardTypes.js +0 -0
|
@@ -2,8 +2,9 @@ import path from 'node:path';
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import yaml from 'js-yaml';
|
|
4
4
|
import { Messages } from '@salesforce/core';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { isEmpty } from '../utils.js';
|
|
6
|
+
import { classificationDefs, policyDefs } from '../policyRegistry.js';
|
|
7
|
+
import { throwAsSfError, } from './schema.js';
|
|
7
8
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
8
9
|
const messages = Messages.loadMessages('@j-schreiber/sf-cli-security-audit', 'org.audit.run');
|
|
9
10
|
/**
|
|
@@ -32,31 +33,8 @@ export default class AuditConfigFileManager {
|
|
|
32
33
|
directoryStructure;
|
|
33
34
|
constructor() {
|
|
34
35
|
this.directoryStructure = {
|
|
35
|
-
policies:
|
|
36
|
-
|
|
37
|
-
schema: ProfilesPolicyFileSchema,
|
|
38
|
-
dependencies: [
|
|
39
|
-
{ path: ['classifications', 'userPermissions'], errorName: 'UserPermClassificationRequiredForProfiles' },
|
|
40
|
-
],
|
|
41
|
-
},
|
|
42
|
-
permissionSets: {
|
|
43
|
-
schema: PermSetsPolicyFileSchema,
|
|
44
|
-
dependencies: [
|
|
45
|
-
{ path: ['classifications', 'userPermissions'], errorName: 'UserPermClassificationRequiredForPermSets' },
|
|
46
|
-
],
|
|
47
|
-
},
|
|
48
|
-
connectedApps: {
|
|
49
|
-
schema: PolicyFileSchema,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
classifications: {
|
|
53
|
-
userPermissions: {
|
|
54
|
-
schema: PermissionsConfigFileSchema,
|
|
55
|
-
},
|
|
56
|
-
customPermissions: {
|
|
57
|
-
schema: PermissionsConfigFileSchema,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
36
|
+
policies: policyDefs,
|
|
37
|
+
classifications: classificationDefs,
|
|
60
38
|
};
|
|
61
39
|
}
|
|
62
40
|
/**
|
|
@@ -68,7 +46,7 @@ export default class AuditConfigFileManager {
|
|
|
68
46
|
*/
|
|
69
47
|
parse(dirPath) {
|
|
70
48
|
const classifications = this.parseSubdir(dirPath, 'classifications');
|
|
71
|
-
const policies =
|
|
49
|
+
const policies = this.parseSubdir(dirPath, 'policies');
|
|
72
50
|
const conf = { classifications, policies };
|
|
73
51
|
assertIsMinimalConfig(conf, dirPath);
|
|
74
52
|
this.validateDependencies(conf);
|
|
@@ -83,41 +61,55 @@ export default class AuditConfigFileManager {
|
|
|
83
61
|
* @returns
|
|
84
62
|
*/
|
|
85
63
|
save(targetDirPath, conf) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.writeSubdir(configFiles, dirName, targetDirPath);
|
|
89
|
-
});
|
|
64
|
+
this.writeClassifications(conf.classifications, targetDirPath);
|
|
65
|
+
this.writePolicies(conf.policies, targetDirPath);
|
|
90
66
|
}
|
|
91
67
|
parseSubdir(dirPath, subdirName) {
|
|
92
68
|
const parseResults = {};
|
|
93
69
|
Object.entries(this.directoryStructure[subdirName]).forEach(([fileName, fileConfig]) => {
|
|
94
|
-
const filePath = path.join(dirPath, subdirName, `${fileName}.yml`);
|
|
70
|
+
const filePath = path.join(dirPath.toString(), subdirName, `${fileName}.yml`);
|
|
95
71
|
if (fs.existsSync(filePath)) {
|
|
96
72
|
const fileContent = yaml.load(fs.readFileSync(filePath, 'utf-8'));
|
|
97
|
-
const
|
|
98
|
-
|
|
73
|
+
const parseResult = fileConfig.schema.safeParse(fileContent);
|
|
74
|
+
if (parseResult.success) {
|
|
75
|
+
parseResults[fileName] = { filePath, content: parseResult.data };
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
throwAsSfError(`${fileName}.yml`, parseResult.error);
|
|
79
|
+
}
|
|
99
80
|
}
|
|
100
81
|
});
|
|
101
82
|
return parseResults;
|
|
102
83
|
}
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
84
|
+
writeClassifications(content, targetDirPath) {
|
|
85
|
+
const dirPath = path.join(targetDirPath.toString(), 'classifications');
|
|
86
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
87
|
+
const dirConf = this.directoryStructure.classifications;
|
|
88
|
+
Object.entries(content).forEach(([fileKey, confFile]) => {
|
|
89
|
+
const fileDef = dirConf[fileKey];
|
|
90
|
+
if (fileDef && !isEmpty(confFile.content)) {
|
|
91
|
+
// eslint-disable-next-line no-param-reassign
|
|
92
|
+
confFile.filePath = path.join(dirPath, `${fileKey}.yml`);
|
|
93
|
+
fs.writeFileSync(confFile.filePath, yaml.dump(confFile.content));
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
writePolicies(content, targetDirPath) {
|
|
98
|
+
const dirPath = path.join(targetDirPath.toString(), 'policies');
|
|
99
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
100
|
+
const dirConf = this.directoryStructure.policies;
|
|
101
|
+
Object.entries(content).forEach(([fileKey, confFile]) => {
|
|
102
|
+
const fileDef = dirConf[fileKey];
|
|
111
103
|
if (fileDef && !isEmpty(confFile.content)) {
|
|
112
104
|
// eslint-disable-next-line no-param-reassign
|
|
113
|
-
confFile.filePath = path.join(
|
|
105
|
+
confFile.filePath = path.join(dirPath, `${fileKey}.yml`);
|
|
114
106
|
fs.writeFileSync(confFile.filePath, yaml.dump(confFile.content));
|
|
115
107
|
}
|
|
116
108
|
});
|
|
117
109
|
}
|
|
118
110
|
validateDependencies(conf) {
|
|
119
111
|
Object.keys(conf.policies).forEach((policyName) => {
|
|
120
|
-
const policyDef = this.directoryStructure.policies[
|
|
112
|
+
const policyDef = this.directoryStructure.policies[policyName];
|
|
121
113
|
if (policyDef?.dependencies) {
|
|
122
114
|
policyDef.dependencies.forEach((dependency) => {
|
|
123
115
|
if (!dependencyExists(dependency.path, conf)) {
|
|
@@ -128,11 +120,6 @@ export default class AuditConfigFileManager {
|
|
|
128
120
|
});
|
|
129
121
|
}
|
|
130
122
|
}
|
|
131
|
-
function capitalizeKeys(object) {
|
|
132
|
-
const newObj = {};
|
|
133
|
-
Object.keys(object).forEach((key) => (newObj[capitalize(key)] = object[key]));
|
|
134
|
-
return newObj;
|
|
135
|
-
}
|
|
136
123
|
function dependencyExists(fullPath, rootNode) {
|
|
137
124
|
const dep = traverseDependencyPath(fullPath, rootNode);
|
|
138
125
|
return Boolean(dep);
|
|
@@ -150,7 +137,7 @@ function traverseDependencyPath(remainingPath, rootNode) {
|
|
|
150
137
|
}
|
|
151
138
|
function assertIsMinimalConfig(conf, dirPath) {
|
|
152
139
|
if (Object.keys(conf.policies).length === 0) {
|
|
153
|
-
const formattedDirPath = !dirPath || dirPath.length === 0 ? '<root-dir>' : dirPath;
|
|
140
|
+
const formattedDirPath = !dirPath || dirPath.toString().length === 0 ? '<root-dir>' : dirPath.toString();
|
|
154
141
|
throw messages.createError('NoAuditConfigFound', [formattedDirPath]);
|
|
155
142
|
}
|
|
156
143
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auditConfigFileManager.js","sourceRoot":"","sources":["../../../../src/libs/core/file-mgmt/auditConfigFileManager.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,
|
|
1
|
+
{"version":3,"file":"auditConfigFileManager.js","sourceRoot":"","sources":["../../../../src/libs/core/file-mgmt/auditConfigFileManager.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAgB,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAuB,UAAU,EAAe,MAAM,sBAAsB,CAAC;AACxG,OAAO,EAKL,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,oCAAoC,EAAE,eAAe,CAAC,CAAC;AAE9F;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAe,EAAkB,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAEtG;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAe,EAAE,IAAoB,EAAQ,EAAE;IAC7E,kBAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OA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AG,IAAI,sBAAsB,EAAE,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
import { PermissionRiskLevel } from '../classification-types.js';
|
|
3
3
|
import { ProfilesRiskPreset } from '../policy-types.js';
|
|
4
|
+
export declare function throwAsSfError(fileName: string, parseError: z.ZodError, rulePath?: PropertyKey[]): never;
|
|
4
5
|
declare const PermissionsClassificationSchema: z.ZodObject<{
|
|
5
6
|
label: z.ZodOptional<z.ZodString>;
|
|
6
7
|
reason: z.ZodOptional<z.ZodString>;
|
|
@@ -19,11 +20,11 @@ declare const NamedPermissionsClassificationSchema: z.ZodObject<{
|
|
|
19
20
|
}, z.z.core.$strip>;
|
|
20
21
|
declare const PolicyRuleConfigSchema: z.ZodObject<{
|
|
21
22
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
22
|
-
|
|
23
|
+
options: z.ZodOptional<z.ZodUnknown>;
|
|
23
24
|
}, z.z.core.$strip>;
|
|
24
25
|
declare const RuleMapSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
25
26
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
26
|
-
|
|
27
|
+
options: z.ZodOptional<z.ZodUnknown>;
|
|
27
28
|
}, z.z.core.$strip>>;
|
|
28
29
|
declare const PermSetConfig: z.ZodObject<{
|
|
29
30
|
preset: z.ZodEnum<typeof ProfilesRiskPreset>;
|
|
@@ -31,18 +32,25 @@ declare const PermSetConfig: z.ZodObject<{
|
|
|
31
32
|
declare const PermSetMap: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
32
33
|
preset: z.ZodEnum<typeof ProfilesRiskPreset>;
|
|
33
34
|
}, z.z.core.$strip>>;
|
|
35
|
+
export declare const UsersPolicyConfig: z.ZodObject<{
|
|
36
|
+
defaultRoleForMissingUsers: z.ZodDefault<z.ZodEnum<typeof ProfilesRiskPreset>>;
|
|
37
|
+
analyseLastNDaysOfLoginHistory: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
}, z.z.core.$strict>;
|
|
39
|
+
export declare const NoInactiveUsersOptionsSchema: z.ZodObject<{
|
|
40
|
+
daysAfterUserIsInactive: z.ZodDefault<z.ZodNumber>;
|
|
41
|
+
}, z.z.core.$strict>;
|
|
34
42
|
export declare const PolicyFileSchema: z.ZodObject<{
|
|
35
43
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
36
44
|
rules: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
37
45
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
38
|
-
|
|
46
|
+
options: z.ZodOptional<z.ZodUnknown>;
|
|
39
47
|
}, z.z.core.$strip>>>;
|
|
40
48
|
}, z.z.core.$strip>;
|
|
41
49
|
export declare const ProfilesPolicyFileSchema: z.ZodObject<{
|
|
42
50
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
43
51
|
rules: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
44
52
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
45
|
-
|
|
53
|
+
options: z.ZodOptional<z.ZodUnknown>;
|
|
46
54
|
}, z.z.core.$strip>>>;
|
|
47
55
|
profiles: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
48
56
|
preset: z.ZodEnum<typeof ProfilesRiskPreset>;
|
|
@@ -52,7 +60,7 @@ export declare const PermSetsPolicyFileSchema: z.ZodObject<{
|
|
|
52
60
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
53
61
|
rules: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
54
62
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
55
|
-
|
|
63
|
+
options: z.ZodOptional<z.ZodUnknown>;
|
|
56
64
|
}, z.z.core.$strip>>>;
|
|
57
65
|
permissionSets: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
58
66
|
preset: z.ZodEnum<typeof ProfilesRiskPreset>;
|
|
@@ -65,14 +73,30 @@ export declare const PermissionsConfigFileSchema: z.ZodObject<{
|
|
|
65
73
|
classification: z.ZodEnum<typeof PermissionRiskLevel>;
|
|
66
74
|
}, z.z.core.$strip>>;
|
|
67
75
|
}, z.z.core.$strip>;
|
|
76
|
+
export declare const UsersPolicyFileSchema: z.ZodObject<{
|
|
77
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
78
|
+
rules: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
79
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
80
|
+
options: z.ZodOptional<z.ZodUnknown>;
|
|
81
|
+
}, z.z.core.$strip>>>;
|
|
82
|
+
users: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
83
|
+
role: z.ZodEnum<typeof ProfilesRiskPreset>;
|
|
84
|
+
}, z.z.core.$strip>>;
|
|
85
|
+
options: z.ZodObject<{
|
|
86
|
+
defaultRoleForMissingUsers: z.ZodDefault<z.ZodEnum<typeof ProfilesRiskPreset>>;
|
|
87
|
+
analyseLastNDaysOfLoginHistory: z.ZodOptional<z.ZodNumber>;
|
|
88
|
+
}, z.z.core.$strict>;
|
|
89
|
+
}, z.z.core.$strip>;
|
|
68
90
|
export type PermissionsClassification = z.infer<typeof PermissionsClassificationSchema>;
|
|
69
91
|
export type NamedPermissionsClassification = z.infer<typeof NamedPermissionsClassificationSchema>;
|
|
70
92
|
export type PermsClassificationsMap = z.infer<typeof PermsClassificationsMapSchema>;
|
|
71
93
|
export type PermissionsConfig = z.infer<typeof PermissionsConfigFileSchema>;
|
|
94
|
+
export type NoInactiveUsersOptions = z.infer<typeof NoInactiveUsersOptionsSchema>;
|
|
72
95
|
export type PolicyRuleConfig = z.infer<typeof PolicyRuleConfigSchema>;
|
|
73
96
|
export type BasePolicyFileContent = z.infer<typeof PolicyFileSchema>;
|
|
74
97
|
export type ProfilesPolicyFileContent = z.infer<typeof ProfilesPolicyFileSchema>;
|
|
75
98
|
export type PermSetsPolicyFileContent = z.infer<typeof PermSetsPolicyFileSchema>;
|
|
99
|
+
export type UsersPolicyFileContent = z.infer<typeof UsersPolicyFileSchema>;
|
|
76
100
|
export type PermissionSetConfig = z.infer<typeof PermSetConfig>;
|
|
77
101
|
export type PermissionSetLikeMap = z.infer<typeof PermSetMap>;
|
|
78
102
|
export type RuleMap = z.infer<typeof RuleMapSchema>;
|
|
@@ -81,18 +105,16 @@ export type ConfigFile<T> = {
|
|
|
81
105
|
content: T;
|
|
82
106
|
};
|
|
83
107
|
export type AuditRunConfigClassifications = {
|
|
84
|
-
[classificationName: string]: unknown;
|
|
85
108
|
userPermissions?: ConfigFile<PermissionsConfig>;
|
|
86
109
|
customPermissions?: ConfigFile<PermissionsConfig>;
|
|
87
110
|
};
|
|
88
111
|
export type AuditRunConfigPolicies = {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
112
|
+
profiles?: ConfigFile<ProfilesPolicyFileContent>;
|
|
113
|
+
permissionSets?: ConfigFile<PermSetsPolicyFileContent>;
|
|
114
|
+
connectedApps?: ConfigFile<BasePolicyFileContent>;
|
|
115
|
+
users?: ConfigFile<UsersPolicyFileContent>;
|
|
93
116
|
};
|
|
94
117
|
export type AuditRunConfig = {
|
|
95
|
-
[configType: string]: unknown;
|
|
96
118
|
classifications: AuditRunConfigClassifications;
|
|
97
119
|
policies: AuditRunConfigPolicies;
|
|
98
120
|
};
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
|
+
import { Messages } from '@salesforce/core';
|
|
2
3
|
import { PermissionRiskLevel } from '../classification-types.js';
|
|
3
4
|
import { ProfilesRiskPreset } from '../policy-types.js';
|
|
5
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
6
|
+
const messages = Messages.loadMessages('@j-schreiber/sf-cli-security-audit', 'org.audit.run');
|
|
7
|
+
export function throwAsSfError(fileName, parseError, rulePath) {
|
|
8
|
+
const issues = parseError.issues.map((zodIssue) => {
|
|
9
|
+
const definitivePath = rulePath ? [...rulePath, ...zodIssue.path] : zodIssue.path;
|
|
10
|
+
return definitivePath.length > 0 ? `${zodIssue.message} in "${definitivePath.join('.')}"` : zodIssue.message;
|
|
11
|
+
});
|
|
12
|
+
throw messages.createError('error.InvalidConfigFileSchema', [fileName, issues.join(', ')]);
|
|
13
|
+
}
|
|
4
14
|
const PermissionsClassificationSchema = z.object({
|
|
5
15
|
/** UI Label */
|
|
6
16
|
label: z.string().optional(),
|
|
@@ -16,13 +26,22 @@ const NamedPermissionsClassificationSchema = PermissionsClassificationSchema.ext
|
|
|
16
26
|
});
|
|
17
27
|
const PolicyRuleConfigSchema = z.object({
|
|
18
28
|
enabled: z.boolean().default(true),
|
|
19
|
-
|
|
29
|
+
options: z.unknown().optional(),
|
|
20
30
|
});
|
|
21
31
|
const RuleMapSchema = z.record(z.string(), PolicyRuleConfigSchema);
|
|
22
32
|
const PermSetConfig = z.object({
|
|
23
33
|
preset: z.enum(ProfilesRiskPreset),
|
|
24
34
|
});
|
|
25
35
|
const PermSetMap = z.record(z.string(), PermSetConfig);
|
|
36
|
+
const UserConfig = z.object({ role: z.enum(ProfilesRiskPreset) });
|
|
37
|
+
const UsersMap = z.record(z.string(), UserConfig);
|
|
38
|
+
export const UsersPolicyConfig = z.strictObject({
|
|
39
|
+
defaultRoleForMissingUsers: z.enum(ProfilesRiskPreset).default(ProfilesRiskPreset.STANDARD_USER),
|
|
40
|
+
analyseLastNDaysOfLoginHistory: z.number().optional(),
|
|
41
|
+
});
|
|
42
|
+
export const NoInactiveUsersOptionsSchema = z.strictObject({
|
|
43
|
+
daysAfterUserIsInactive: z.number().default(90),
|
|
44
|
+
});
|
|
26
45
|
// FILE CONTENT SCHEMATA
|
|
27
46
|
export const PolicyFileSchema = z.object({
|
|
28
47
|
enabled: z.boolean().default(true),
|
|
@@ -37,6 +56,10 @@ export const PermSetsPolicyFileSchema = PolicyFileSchema.extend({
|
|
|
37
56
|
export const PermissionsConfigFileSchema = z.object({
|
|
38
57
|
permissions: z.record(z.string(), PermissionsClassificationSchema),
|
|
39
58
|
});
|
|
59
|
+
export const UsersPolicyFileSchema = PolicyFileSchema.extend({
|
|
60
|
+
users: UsersMap,
|
|
61
|
+
options: UsersPolicyConfig,
|
|
62
|
+
});
|
|
40
63
|
export function isPermissionsConfig(cls) {
|
|
41
64
|
return cls.content?.permissions !== undefined;
|
|
42
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/libs/core/file-mgmt/schema.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,+BAA+B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,eAAe;IACf,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,4DAA4D;IAC5D,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,yCAAyC;IACzC,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC;CAC5C,CAAC,CAAC;AAEH,MAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,+BAA+B,CAAC,CAAC;AAE5F,MAAM,oCAAoC,GAAG,+BAA+B,CAAC,MAAM,CAAC;IAClF,yDAAyD;IACzD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;CACjB,CAAC,CAAC;AAEH,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAClC,
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/libs/core/file-mgmt/schema.ts"],"names":[],"m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ePolicyFileContent } from '../file-mgmt/schema.js';
|
|
2
|
+
import { AuditContext } from '../registries/types.js';
|
|
3
|
+
import { ResolvedConnectedApp } from '../registries/connectedApps.js';
|
|
4
|
+
import Policy, { ResolveEntityResult } from './policy.js';
|
|
5
|
+
export default class ConnectedAppPolicy extends Policy<ResolvedConnectedApp> {
|
|
6
|
+
config: BasePolicyFileContent;
|
|
7
|
+
auditConfig: AuditRunConfig;
|
|
8
|
+
constructor(config: BasePolicyFileContent, auditConfig: AuditRunConfig, registry?: import("../registries/connectedApps.js").default);
|
|
9
|
+
protected resolveEntities(context: AuditContext): Promise<ResolveEntityResult<ResolvedConnectedApp>>;
|
|
10
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { CONNECTED_APPS_QUERY, OAUTH_TOKEN_QUERY } from '../
|
|
2
|
-
import {
|
|
3
|
-
import MDAPI from '../
|
|
1
|
+
import { CONNECTED_APPS_QUERY, OAUTH_TOKEN_QUERY } from '../constants.js';
|
|
2
|
+
import { ConnectedAppsRegistry } from '../registries/connectedApps.js';
|
|
3
|
+
import MDAPI from '../mdapi/mdapiRetriever.js';
|
|
4
4
|
import Policy, { getTotal } from './policy.js';
|
|
5
5
|
export default class ConnectedAppPolicy extends Policy {
|
|
6
6
|
config;
|
|
7
7
|
auditConfig;
|
|
8
|
-
constructor(config, auditConfig, registry =
|
|
8
|
+
constructor(config, auditConfig, registry = ConnectedAppsRegistry) {
|
|
9
9
|
super(config, auditConfig, registry);
|
|
10
10
|
this.config = config;
|
|
11
11
|
this.auditConfig = auditConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectedAppPolicy.js","sourceRoot":"","sources":["../../../../src/libs/core/policies/connectedAppPolicy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,OAAO,EAAE,qBAAqB,EAAwB,MAAM,gCAAgC,CAAC;AAC7F,OAAO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CAAC,2BAA2B,EAAE,CAAC;YACrF,2BAA2B,GAAG,IAAI,CAAC;QACrC,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACrD,6CAA6C;YAC7C,MAAM,CAAC,2BAA2B,GAAG,2BAA2B,CAAC;QACnE,CAAC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC;QAC3G,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACzB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC;YACvB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC;SAC3B,CAAC,CAAC;QACH,8DAA8D;QAC9D,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AuditRunConfig, PermSetsPolicyFileContent } from '../file-mgmt/schema.js';
|
|
2
|
+
import { AuditContext } from '../registries/types.js';
|
|
3
|
+
import { ResolvedPermissionSet } from '../registries/permissionSets.js';
|
|
4
|
+
import Policy, { ResolveEntityResult } from './policy.js';
|
|
5
|
+
export default class PermissionSetPolicy extends Policy<ResolvedPermissionSet> {
|
|
6
|
+
config: PermSetsPolicyFileContent;
|
|
7
|
+
auditContext: AuditRunConfig;
|
|
8
|
+
private totalEntities;
|
|
9
|
+
constructor(config: PermSetsPolicyFileContent, auditContext: AuditRunConfig, registry?: import("../registries/permissionSets.js").default);
|
|
10
|
+
protected resolveEntities(context: AuditContext): Promise<ResolveEntityResult<ResolvedPermissionSet>>;
|
|
11
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Messages } from '@salesforce/core';
|
|
2
|
-
import MDAPI from '../
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import MDAPI from '../mdapi/mdapiRetriever.js';
|
|
3
|
+
import { ProfilesRiskPreset } from '../policy-types.js';
|
|
4
|
+
import { PermissionSetsRegistry } from '../registries/permissionSets.js';
|
|
5
5
|
import Policy, { getTotal } from './policy.js';
|
|
6
6
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
7
7
|
const messages = Messages.loadMessages('@j-schreiber/sf-cli-security-audit', 'policies.general');
|
|
@@ -9,7 +9,7 @@ export default class PermissionSetPolicy extends Policy {
|
|
|
9
9
|
config;
|
|
10
10
|
auditContext;
|
|
11
11
|
totalEntities;
|
|
12
|
-
constructor(config, auditContext, registry =
|
|
12
|
+
constructor(config, auditContext, registry = PermissionSetsRegistry) {
|
|
13
13
|
super(config, auditContext, registry);
|
|
14
14
|
this.config = config;
|
|
15
15
|
this.auditContext = auditContext;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissionSetPolicy.js","sourceRoot":"","sources":["../../../../src/libs/core/policies/permissionSetPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,MAAM,4BAA4B,CAAC;AAG/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAAE,sBAAsB,EAAyB,MAAM,iCAAiC,CAAC;AAChG,OAAO,MAAM,EAAE,EAAE,QAAQ,EAAuB,MAAM,aAAa,CAAC;AAEpE,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,oCAAoC,EAAE,kBAAkB,CAAC,CAAC;AAEjG,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,MAA6B;IAGnE;IACA;IAHD,aAAa,CAAS;IAC9B,YACS,MAAiC,EACjC,YAA4B,EACnC,QAAQ,GAAG,sBAAsB;QAEjC,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,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KAAK,kBAAkB,CAAC,OAAO,EAAE,CAAC;oBAC9C,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC;gBACtG,CAAC;qBAAM,CAAC;oBACN,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC;gBACpF,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;QACtG,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACzB,KAAK,EAAE,IAAI,CAAC,aAAa;YACzB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC;SAC3B,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,SAAS,yBAAyB,CAAC,QAA8B;IAC/D,MAAM,aAAa,GAAa,EAAE,CAAC;IACnC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE;QAC9C,IAAI,GAAG,CAAC,MAAM,KAAK,kBAAkB,CAAC,OAAO,EAAE,CAAC;YAC9C,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import EventEmitter from 'node:events';
|
|
2
|
-
import { AuditPolicyResult, EntityResolveError } from '../
|
|
3
|
-
import { AuditRunConfig, BasePolicyFileContent } from '../
|
|
4
|
-
import RuleRegistry, { RegistryRuleResolveResult } from '../
|
|
5
|
-
import { AuditContext, IPolicy } from '../
|
|
6
|
-
export type ResolveEntityResult = {
|
|
7
|
-
resolvedEntities: Record<string,
|
|
2
|
+
import { AuditPolicyResult, EntityResolveError } from '../result-types.js';
|
|
3
|
+
import { AuditRunConfig, BasePolicyFileContent } from '../file-mgmt/schema.js';
|
|
4
|
+
import RuleRegistry, { RegistryRuleResolveResult } from '../registries/ruleRegistry.js';
|
|
5
|
+
import { AuditContext, IPolicy } from '../registries/types.js';
|
|
6
|
+
export type ResolveEntityResult<T> = {
|
|
7
|
+
resolvedEntities: Record<string, T>;
|
|
8
8
|
ignoredEntities: EntityResolveError[];
|
|
9
9
|
};
|
|
10
|
-
export default abstract class Policy extends EventEmitter implements IPolicy {
|
|
10
|
+
export default abstract class Policy<T> extends EventEmitter implements IPolicy {
|
|
11
11
|
config: BasePolicyFileContent;
|
|
12
12
|
auditConfig: AuditRunConfig;
|
|
13
13
|
protected registry: RuleRegistry;
|
|
14
14
|
protected resolvedRules: RegistryRuleResolveResult;
|
|
15
|
-
protected entities?: ResolveEntityResult
|
|
15
|
+
protected entities?: ResolveEntityResult<T>;
|
|
16
16
|
constructor(config: BasePolicyFileContent, auditConfig: AuditRunConfig, registry: RuleRegistry);
|
|
17
17
|
/**
|
|
18
18
|
* Resolves all entities of the policy.
|
|
19
19
|
*/
|
|
20
|
-
resolve(context: AuditContext): Promise<ResolveEntityResult
|
|
20
|
+
resolve(context: AuditContext): Promise<ResolveEntityResult<T>>;
|
|
21
21
|
/**
|
|
22
22
|
* Runs all rules of a policy. If the entities are not yet resolved, they are
|
|
23
23
|
* resolved on the fly before rules are executed.
|
|
@@ -26,6 +26,6 @@ export default abstract class Policy extends EventEmitter implements IPolicy {
|
|
|
26
26
|
* @returns
|
|
27
27
|
*/
|
|
28
28
|
run(context: AuditContext): Promise<AuditPolicyResult>;
|
|
29
|
-
protected abstract resolveEntities(context: AuditContext): Promise<ResolveEntityResult
|
|
29
|
+
protected abstract resolveEntities(context: AuditContext): Promise<ResolveEntityResult<T>>;
|
|
30
30
|
}
|
|
31
|
-
export declare function getTotal(resolveResult: ResolveEntityResult): number;
|
|
31
|
+
export declare function getTotal(resolveResult: ResolveEntityResult<unknown>): number;
|
|
@@ -16,6 +16,11 @@ export default class Policy extends EventEmitter {
|
|
|
16
16
|
* Resolves all entities of the policy.
|
|
17
17
|
*/
|
|
18
18
|
async resolve(context) {
|
|
19
|
+
// when a policy is disabled, we still want to appear it in audit results
|
|
20
|
+
// as disabled with 0 resolved entities and 0 executed rules
|
|
21
|
+
if (!this.config.enabled) {
|
|
22
|
+
return { resolvedEntities: {}, ignoredEntities: [] };
|
|
23
|
+
}
|
|
19
24
|
if (!this.entities) {
|
|
20
25
|
this.entities = await this.resolveEntities(context);
|
|
21
26
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../../../src/libs/core/policies/policy.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,aAAa,CAAC;AAUvC,MAAM,CAAC,OAAO,OAAgB,MAAU,SAAQ,YAAY;IAKjD;IACA;IACG;IANF,aAAa,CAA4B;IACzC,QAAQ,CAA0B;IAE5C,YACS,MAA6B,EAC7B,WAA2B,EACxB,QAAsB;QAEhC,KAAK,EAAE,CAAC;QAJD,WAAM,GAAN,MAAM,CAAuB;QAC7B,gBAAW,GAAX,WAAW,CAAgB;QACxB,aAAQ,GAAR,QAAQ,CAAc;QAGhC,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IACxE,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,OAAO,CAAC,OAAqB;QACxC,yEAAyE;QACzE,4DAA4D;QAC5D,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACzB,OAAO,EAAE,gBAAgB,EAAE,EAAE,EAAE,eAAe,EAA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C,gBAAgB,CAAC,EAAE,CAAC;YAC5C,iBAAiB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,aAA2C;IAClE,MAAM,aAAa,GAAG,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9G,MAAM,YAAY,GAAG,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9F,OAAO,aAAa,GAAG,YAAY,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AuditRunConfig, ProfilesPolicyFileContent } from '../file-mgmt/schema.js';
|
|
2
|
+
import { AuditContext } from '../registries/types.js';
|
|
3
|
+
import { ResolvedProfile } from '../registries/profiles.js';
|
|
4
|
+
import Policy, { ResolveEntityResult } from './policy.js';
|
|
5
|
+
export default class ProfilePolicy extends Policy<ResolvedProfile> {
|
|
6
|
+
config: ProfilesPolicyFileContent;
|
|
7
|
+
auditConfig: AuditRunConfig;
|
|
8
|
+
private totalEntities;
|
|
9
|
+
constructor(config: ProfilesPolicyFileContent, auditConfig: AuditRunConfig, registry?: import("../registries/profiles.js").default);
|
|
10
|
+
protected resolveEntities(context: AuditContext): Promise<ResolveEntityResult<ResolvedProfile>>;
|
|
11
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Messages } from '@salesforce/core';
|
|
2
|
-
import MDAPI from '../
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import MDAPI from '../mdapi/mdapiRetriever.js';
|
|
3
|
+
import { ProfilesRiskPreset } from '../policy-types.js';
|
|
4
|
+
import { ProfilesRegistry } from '../registries/profiles.js';
|
|
5
5
|
import Policy, { getTotal } from './policy.js';
|
|
6
6
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
7
7
|
const messages = Messages.loadMessages('@j-schreiber/sf-cli-security-audit', 'policies.general');
|
|
@@ -9,7 +9,7 @@ export default class ProfilePolicy extends Policy {
|
|
|
9
9
|
config;
|
|
10
10
|
auditConfig;
|
|
11
11
|
totalEntities;
|
|
12
|
-
constructor(config, auditConfig, registry =
|
|
12
|
+
constructor(config, auditConfig, registry = ProfilesRegistry) {
|
|
13
13
|
super(config, auditConfig, registry);
|
|
14
14
|
this.config = config;
|
|
15
15
|
this.auditConfig = auditConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profilePolicy.js","sourceRoot":"","sources":["../../../../src/libs/core/policies/profilePolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,KAAK,MAAM,4BAA4B,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAmB,MAAM,2BAA2B,CAAC;AAC9E,OAAO,MAAM,EAAE,EAAE,QAAQ,EAAuB,MAAM,aAAa,CAAC;AAEpE,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,oCAAoC,EAAE,kBAAkB,CAAC,CAAC;AAEjG,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,MAAuB;IAGvD;IACA;IAHD,aAAa,CAAS;IAC9B,YACS,MAAiC,EACjC,WAA2B,EAClC,QAAQ,GAAG,gBAAgB;QAE3B,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,Q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CAAC,CAAC;QAC5E,kBAAkB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;YACzC,MAAM,eAAe,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;YACtD,IAAI,CAAC,eAAe,EAAE,CAAC;gBACrB,eAAe,CAAC,WAAW,CAAC,GAAG;oBAC7B,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,kBAAkB,CAAC;iBACjD,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,oBAAoB,CAAC,WAAW,CAAC,GAAG;oBAClC,IAAI,EAAE,WAAW;oBACjB,MAAM,EAAE,kBAAkB,CAAC,WAAW,CAAC,CAAC,MAAM;oBAC9C,QAAQ,EAAE,eAAe;iBAC1B,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC;QAC3G,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACzB,KAAK,EAAE,IAAI,CAAC,aAAa;YACzB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC;SAC3B,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -18,6 +18,9 @@ export type OauthToken = Record & {
|
|
|
18
18
|
};
|
|
19
19
|
export type User = Record & {
|
|
20
20
|
Username: string;
|
|
21
|
+
LastLoginDate?: string;
|
|
22
|
+
CreatedDate: string;
|
|
23
|
+
Profile: ProfileBasic;
|
|
21
24
|
};
|
|
22
25
|
export type Profile = ProfileBasic & {
|
|
23
26
|
Metadata: JsForceProfile;
|
|
@@ -36,4 +39,15 @@ export type PermissionSet = Record & {
|
|
|
36
39
|
Profile: ProfileBasic;
|
|
37
40
|
NamespacePrefix?: string;
|
|
38
41
|
};
|
|
42
|
+
export type PermissionSetAssignment = Record & {
|
|
43
|
+
AssigneeId: string;
|
|
44
|
+
PermissionSet: Pick<PermissionSet, 'Name'>;
|
|
45
|
+
};
|
|
46
|
+
export type UserLoginsAggregate = Record & {
|
|
47
|
+
LoginType: string;
|
|
48
|
+
Application: string;
|
|
49
|
+
UserId: string;
|
|
50
|
+
LoginCount: number;
|
|
51
|
+
LastLogin: string;
|
|
52
|
+
};
|
|
39
53
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"salesforceStandardTypes.js","sourceRoot":"","sources":["../../../../src/libs/core/policies/salesforceStandardTypes.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AuditRunConfig, UsersPolicyFileContent } from '../file-mgmt/schema.js';
|
|
2
|
+
import { AuditContext } from '../registries/types.js';
|
|
3
|
+
import { ResolvedUser } from '../registries/users.js';
|
|
4
|
+
import Policy, { ResolveEntityResult } from './policy.js';
|
|
5
|
+
export default class UserPolicy extends Policy<ResolvedUser> {
|
|
6
|
+
config: UsersPolicyFileContent;
|
|
7
|
+
auditConfig: AuditRunConfig;
|
|
8
|
+
private totalEntities;
|
|
9
|
+
constructor(config: UsersPolicyFileContent, auditConfig: AuditRunConfig, registry?: import("../registries/users.js").default);
|
|
10
|
+
protected resolveEntities(context: AuditContext): Promise<ResolveEntityResult<ResolvedUser>>;
|
|
11
|
+
}
|