@j-schreiber/sf-cli-security-audit 0.8.2 → 0.8.4
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 +3 -3
- package/lib/commands/org/audit/init.d.ts +19 -0
- package/lib/commands/org/audit/init.js +72 -0
- package/lib/commands/org/audit/init.js.map +1 -0
- package/lib/commands/org/audit/run.d.ts +23 -0
- package/lib/commands/org/audit/run.js +124 -0
- package/lib/commands/org/audit/run.js.map +1 -0
- package/lib/commands/org/scan/user-perms.d.ts +20 -0
- package/lib/commands/org/scan/user-perms.js +87 -0
- package/lib/commands/org/scan/user-perms.js.map +1 -0
- package/lib/libs/conf-init/auditConfig.d.ts +35 -0
- package/lib/libs/conf-init/auditConfig.js +41 -0
- package/lib/libs/conf-init/auditConfig.js.map +1 -0
- package/lib/libs/conf-init/permissionsClassification.d.ts +17 -0
- package/lib/libs/conf-init/permissionsClassification.js +80 -0
- package/lib/libs/conf-init/permissionsClassification.js.map +1 -0
- package/lib/libs/conf-init/policyConfigs.d.ts +31 -0
- package/lib/libs/conf-init/policyConfigs.js +91 -0
- package/lib/libs/conf-init/policyConfigs.js.map +1 -0
- package/lib/libs/conf-init/presets/loose.d.ts +6 -0
- package/lib/libs/conf-init/presets/loose.js +85 -0
- package/lib/libs/conf-init/presets/loose.js.map +1 -0
- package/lib/libs/conf-init/presets/none.d.ts +30 -0
- package/lib/libs/conf-init/presets/none.js +54 -0
- package/lib/libs/conf-init/presets/none.js.map +1 -0
- package/lib/libs/conf-init/presets/strict.d.ts +4 -0
- package/lib/libs/conf-init/presets/strict.js +79 -0
- package/lib/libs/conf-init/presets/strict.js.map +1 -0
- package/lib/libs/conf-init/presets.d.ts +7 -0
- package/lib/libs/conf-init/presets.js +20 -0
- package/lib/libs/conf-init/presets.js.map +1 -0
- package/lib/libs/core/auditRun.d.ts +36 -0
- package/lib/libs/core/auditRun.js +86 -0
- package/lib/libs/core/auditRun.js.map +1 -0
- package/lib/libs/core/classification-types.d.ts +20 -0
- package/lib/libs/core/classification-types.js +23 -0
- package/lib/libs/core/classification-types.js.map +1 -0
- package/lib/libs/core/constants.d.ts +10 -0
- package/lib/libs/core/constants.js +20 -0
- package/lib/libs/core/constants.js.map +1 -0
- package/lib/libs/core/file-mgmt/auditConfigFileManager.d.ts +48 -0
- package/lib/libs/core/file-mgmt/auditConfigFileManager.js +145 -0
- package/lib/libs/core/file-mgmt/auditConfigFileManager.js.map +1 -0
- package/lib/libs/core/file-mgmt/schema.d.ts +123 -0
- package/lib/libs/core/file-mgmt/schema.js +69 -0
- package/lib/libs/core/file-mgmt/schema.js.map +1 -0
- package/lib/libs/core/mdapi/mdapiRetriever.d.ts +54 -0
- package/lib/libs/core/mdapi/mdapiRetriever.js +123 -0
- package/lib/libs/core/mdapi/mdapiRetriever.js.map +1 -0
- package/lib/libs/core/mdapi/metadataRegistryEntry.d.ts +40 -0
- package/lib/libs/core/mdapi/metadataRegistryEntry.js +46 -0
- package/lib/libs/core/mdapi/metadataRegistryEntry.js.map +1 -0
- package/lib/libs/core/mdapi/namedMetadataToolingQueryable.d.ts +33 -0
- package/lib/libs/core/mdapi/namedMetadataToolingQueryable.js +41 -0
- package/lib/libs/core/mdapi/namedMetadataToolingQueryable.js.map +1 -0
- package/lib/libs/core/mdapi/namedMetadataType.d.ts +20 -0
- package/lib/libs/core/mdapi/namedMetadataType.js +41 -0
- package/lib/libs/core/mdapi/namedMetadataType.js.map +1 -0
- package/lib/libs/core/mdapi/singletonMetadataType.d.ts +21 -0
- package/lib/libs/core/mdapi/singletonMetadataType.js +37 -0
- package/lib/libs/core/mdapi/singletonMetadataType.js.map +1 -0
- package/lib/libs/core/mdapi/usersRepository.d.ts +85 -0
- package/lib/libs/core/mdapi/usersRepository.js +126 -0
- package/lib/libs/core/mdapi/usersRepository.js.map +1 -0
- package/lib/libs/core/policies/connectedAppPolicy.d.ts +10 -0
- package/lib/libs/core/policies/connectedAppPolicy.js +78 -0
- package/lib/libs/core/policies/connectedAppPolicy.js.map +1 -0
- package/lib/libs/core/policies/permissionSetPolicy.d.ts +11 -0
- package/lib/libs/core/policies/permissionSetPolicy.js +62 -0
- package/lib/libs/core/policies/permissionSetPolicy.js.map +1 -0
- package/lib/libs/core/policies/policy.d.ts +31 -0
- package/lib/libs/core/policies/policy.js +100 -0
- package/lib/libs/core/policies/policy.js.map +1 -0
- package/lib/libs/core/policies/profilePolicy.d.ts +11 -0
- package/lib/libs/core/policies/profilePolicy.js +64 -0
- package/lib/libs/core/policies/profilePolicy.js.map +1 -0
- package/lib/libs/core/policies/salesforceStandardTypes.d.ts +58 -0
- package/lib/libs/core/policies/salesforceStandardTypes.js +2 -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 +60 -0
- package/lib/libs/core/policies/userPolicy.js.map +1 -0
- package/lib/libs/core/policy-types.d.ts +18 -0
- package/lib/libs/core/policy-types.js +28 -0
- package/lib/libs/core/policy-types.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/connectedApps.d.ts +13 -0
- package/lib/libs/core/registries/connectedApps.js +13 -0
- package/lib/libs/core/registries/connectedApps.js.map +1 -0
- package/lib/libs/core/registries/helpers/permissionsScanning.d.ts +29 -0
- package/lib/libs/core/registries/helpers/permissionsScanning.js +69 -0
- package/lib/libs/core/registries/helpers/permissionsScanning.js.map +1 -0
- package/lib/libs/core/registries/permissionSets.d.ts +11 -0
- package/lib/libs/core/registries/permissionSets.js +11 -0
- package/lib/libs/core/registries/permissionSets.js.map +1 -0
- package/lib/libs/core/registries/profiles.d.ts +11 -0
- package/lib/libs/core/registries/profiles.js +11 -0
- package/lib/libs/core/registries/profiles.js.map +1 -0
- package/lib/libs/core/registries/ruleRegistry.d.ts +37 -0
- package/lib/libs/core/registries/ruleRegistry.js +48 -0
- package/lib/libs/core/registries/ruleRegistry.js.map +1 -0
- package/lib/libs/core/registries/rules/allUsedAppsUnderManagement.d.ts +7 -0
- package/lib/libs/core/registries/rules/allUsedAppsUnderManagement.js +23 -0
- package/lib/libs/core/registries/rules/allUsedAppsUnderManagement.js.map +1 -0
- package/lib/libs/core/registries/rules/enforcePermissionPresets.d.ts +7 -0
- package/lib/libs/core/registries/rules/enforcePermissionPresets.js +58 -0
- package/lib/libs/core/registries/rules/enforcePermissionPresets.js.map +1 -0
- package/lib/libs/core/registries/rules/enforcePermissionsOnProfileLike.d.ts +7 -0
- package/lib/libs/core/registries/rules/enforcePermissionsOnProfileLike.js +26 -0
- package/lib/libs/core/registries/rules/enforcePermissionsOnProfileLike.js.map +1 -0
- package/lib/libs/core/registries/rules/enforcePermissionsOnUser.d.ts +8 -0
- package/lib/libs/core/registries/rules/enforcePermissionsOnUser.js +42 -0
- package/lib/libs/core/registries/rules/enforcePermissionsOnUser.js.map +1 -0
- 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 +27 -0
- package/lib/libs/core/registries/rules/noOtherApexApiLogins.js.map +1 -0
- package/lib/libs/core/registries/rules/noUserCanSelfAuthorize.d.ts +7 -0
- package/lib/libs/core/registries/rules/noUserCanSelfAuthorize.js +31 -0
- package/lib/libs/core/registries/rules/noUserCanSelfAuthorize.js.map +1 -0
- package/lib/libs/core/registries/rules/policyRule.d.ts +19 -0
- package/lib/libs/core/registries/rules/policyRule.js +32 -0
- package/lib/libs/core/registries/rules/policyRule.js.map +1 -0
- package/lib/libs/core/registries/types.d.ts +37 -0
- package/lib/libs/core/registries/types.js +11 -0
- package/lib/libs/core/registries/types.js.map +1 -0
- package/lib/libs/core/registries/users.d.ts +10 -0
- package/lib/libs/core/registries/users.js +17 -0
- package/lib/libs/core/registries/users.js.map +1 -0
- package/lib/libs/core/result-types.d.ts +172 -0
- package/lib/libs/core/result-types.js +2 -0
- package/lib/libs/core/result-types.js.map +1 -0
- package/lib/libs/core/utils.d.ts +12 -0
- package/lib/libs/core/utils.js +31 -0
- package/lib/libs/core/utils.js.map +1 -0
- package/lib/libs/quick-scan/types.d.ts +17 -0
- package/lib/libs/quick-scan/types.js +2 -0
- package/lib/libs/quick-scan/types.js.map +1 -0
- package/lib/libs/quick-scan/userPermissionScanner.d.ts +22 -0
- package/lib/libs/quick-scan/userPermissionScanner.js +75 -0
- package/lib/libs/quick-scan/userPermissionScanner.js.map +1 -0
- package/lib/ux/auditRunMultiStage.d.ts +65 -0
- package/lib/ux/auditRunMultiStage.js +120 -0
- package/lib/ux/auditRunMultiStage.js.map +1 -0
- package/oclif.lock +13606 -10113
- package/oclif.manifest.json +253 -2
- package/package.json +13 -41
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { PathLike } from 'node:fs';
|
|
2
|
+
import { AuditRunConfig } from './schema.js';
|
|
3
|
+
/**
|
|
4
|
+
* Loads an audit run config with the default file manager
|
|
5
|
+
*
|
|
6
|
+
* @param dirPath
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare const loadAuditConfig: (dirPath: string) => AuditRunConfig;
|
|
10
|
+
/**
|
|
11
|
+
* Saves a new or modified audit run config with the default file manager
|
|
12
|
+
*
|
|
13
|
+
* @param dirPath
|
|
14
|
+
* @param conf
|
|
15
|
+
*/
|
|
16
|
+
export declare const saveAuditConfig: (dirPath: string, conf: AuditRunConfig) => void;
|
|
17
|
+
/**
|
|
18
|
+
* The file manager streamlines initialisation of an audit config from
|
|
19
|
+
* a source directory and writing updated content back to disk. The directory
|
|
20
|
+
* structure is configurable, but most of the time using the default file manager
|
|
21
|
+
* will be enough.
|
|
22
|
+
*/
|
|
23
|
+
export default class AuditConfigFileManager {
|
|
24
|
+
private readonly directoryStructure;
|
|
25
|
+
constructor();
|
|
26
|
+
/**
|
|
27
|
+
* Parses a directory path for policy and classification files
|
|
28
|
+
* and initialises an audit config from file contents.
|
|
29
|
+
*
|
|
30
|
+
* @param dirPath
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
parse(dirPath: PathLike): AuditRunConfig;
|
|
34
|
+
/**
|
|
35
|
+
* Writes a full audit config to disk. If the config was not
|
|
36
|
+
* saved yet, initialises filePath on each element.
|
|
37
|
+
*
|
|
38
|
+
* @param dirPath
|
|
39
|
+
* @param subdirName
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
save(targetDirPath: string, conf: AuditRunConfig): void;
|
|
43
|
+
private parseSubdir;
|
|
44
|
+
private writeClassifications;
|
|
45
|
+
private writePolicies;
|
|
46
|
+
private validateDependencies;
|
|
47
|
+
}
|
|
48
|
+
export declare const DefaultFileManager: AuditConfigFileManager;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import yaml from 'js-yaml';
|
|
4
|
+
import { Messages } from '@salesforce/core';
|
|
5
|
+
import { isEmpty } from '../utils.js';
|
|
6
|
+
import { classificationDefs, policyDefs } from '../policyRegistry.js';
|
|
7
|
+
import { throwAsSfError, } from './schema.js';
|
|
8
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
9
|
+
const messages = Messages.loadMessages('@j-schreiber/sf-cli-security-audit', 'org.audit.run');
|
|
10
|
+
/**
|
|
11
|
+
* Loads an audit run config with the default file manager
|
|
12
|
+
*
|
|
13
|
+
* @param dirPath
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export const loadAuditConfig = (dirPath) => DefaultFileManager.parse(dirPath);
|
|
17
|
+
/**
|
|
18
|
+
* Saves a new or modified audit run config with the default file manager
|
|
19
|
+
*
|
|
20
|
+
* @param dirPath
|
|
21
|
+
* @param conf
|
|
22
|
+
*/
|
|
23
|
+
export const saveAuditConfig = (dirPath, conf) => {
|
|
24
|
+
DefaultFileManager.save(dirPath, conf);
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The file manager streamlines initialisation of an audit config from
|
|
28
|
+
* a source directory and writing updated content back to disk. The directory
|
|
29
|
+
* structure is configurable, but most of the time using the default file manager
|
|
30
|
+
* will be enough.
|
|
31
|
+
*/
|
|
32
|
+
export default class AuditConfigFileManager {
|
|
33
|
+
directoryStructure;
|
|
34
|
+
constructor() {
|
|
35
|
+
this.directoryStructure = {
|
|
36
|
+
policies: policyDefs,
|
|
37
|
+
classifications: classificationDefs,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Parses a directory path for policy and classification files
|
|
42
|
+
* and initialises an audit config from file contents.
|
|
43
|
+
*
|
|
44
|
+
* @param dirPath
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
parse(dirPath) {
|
|
48
|
+
const classifications = this.parseSubdir(dirPath, 'classifications');
|
|
49
|
+
const policies = this.parseSubdir(dirPath, 'policies');
|
|
50
|
+
const conf = { classifications, policies };
|
|
51
|
+
assertIsMinimalConfig(conf, dirPath);
|
|
52
|
+
this.validateDependencies(conf);
|
|
53
|
+
return conf;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Writes a full audit config to disk. If the config was not
|
|
57
|
+
* saved yet, initialises filePath on each element.
|
|
58
|
+
*
|
|
59
|
+
* @param dirPath
|
|
60
|
+
* @param subdirName
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
save(targetDirPath, conf) {
|
|
64
|
+
this.writeClassifications(conf.classifications, targetDirPath);
|
|
65
|
+
this.writePolicies(conf.policies, targetDirPath);
|
|
66
|
+
}
|
|
67
|
+
parseSubdir(dirPath, subdirName) {
|
|
68
|
+
const parseResults = {};
|
|
69
|
+
Object.entries(this.directoryStructure[subdirName]).forEach(([fileName, fileConfig]) => {
|
|
70
|
+
const filePath = path.join(dirPath.toString(), subdirName, `${fileName}.yml`);
|
|
71
|
+
if (fs.existsSync(filePath)) {
|
|
72
|
+
const fileContent = yaml.load(fs.readFileSync(filePath, 'utf-8'));
|
|
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
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return parseResults;
|
|
83
|
+
}
|
|
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];
|
|
103
|
+
if (fileDef && !isEmpty(confFile.content)) {
|
|
104
|
+
// eslint-disable-next-line no-param-reassign
|
|
105
|
+
confFile.filePath = path.join(dirPath, `${fileKey}.yml`);
|
|
106
|
+
fs.writeFileSync(confFile.filePath, yaml.dump(confFile.content));
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
validateDependencies(conf) {
|
|
111
|
+
Object.keys(conf.policies).forEach((policyName) => {
|
|
112
|
+
const policyDef = this.directoryStructure.policies[policyName];
|
|
113
|
+
if (policyDef?.dependencies) {
|
|
114
|
+
policyDef.dependencies.forEach((dependency) => {
|
|
115
|
+
if (!dependencyExists(dependency.path, conf)) {
|
|
116
|
+
throw messages.createError(dependency.errorName);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function dependencyExists(fullPath, rootNode) {
|
|
124
|
+
const dep = traverseDependencyPath(fullPath, rootNode);
|
|
125
|
+
return Boolean(dep);
|
|
126
|
+
}
|
|
127
|
+
function traverseDependencyPath(remainingPath, rootNode) {
|
|
128
|
+
if (remainingPath.length >= 2) {
|
|
129
|
+
return traverseDependencyPath(remainingPath.slice(1), rootNode[remainingPath[0]]);
|
|
130
|
+
}
|
|
131
|
+
else if (remainingPath.length === 0) {
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
return rootNode[remainingPath[0]];
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function assertIsMinimalConfig(conf, dirPath) {
|
|
139
|
+
if (Object.keys(conf.policies).length === 0) {
|
|
140
|
+
const formattedDirPath = !dirPath || dirPath.toString().length === 0 ? '<root-dir>' : dirPath.toString();
|
|
141
|
+
throw messages.createError('NoAuditConfigFound', [formattedDirPath]);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export const DefaultFileManager = new AuditConfigFileManager();
|
|
145
|
+
//# sourceMappingURL=auditConfigFileManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auditConfigFileManager.js","sourceRoot":"","sources":["../../../../src/libs/core/file-mgmt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sB,CAAC,aAAuB,EAAE,QAAiC;IACxF,IAAI,aAAa,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QAC9B,OAAO,sBAAsB,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAA4B,CAAC,CAAC;IAC/G,CAAC;SAAM,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtC,OAAO,SAAS,CAAC;IACnB,CAAC;SAAM,CAAC;QACN,OAAO,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,IAAoB,EAAE,OAAiB;IACpE,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5C,MAAM,gBAAgB,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACzG,MAAM,QAAQ,CAAC,WAAW,CAAC,oBAAoB,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACvE,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { PermissionRiskLevel } from '../classification-types.js';
|
|
3
|
+
import { ProfilesRiskPreset } from '../policy-types.js';
|
|
4
|
+
export declare function throwAsSfError(fileName: string, parseError: z.ZodError, rulePath?: PropertyKey[]): never;
|
|
5
|
+
declare const PermissionsClassificationSchema: z.ZodObject<{
|
|
6
|
+
label: z.ZodOptional<z.ZodString>;
|
|
7
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
8
|
+
classification: z.ZodEnum<typeof PermissionRiskLevel>;
|
|
9
|
+
}, z.z.core.$strip>;
|
|
10
|
+
declare const PermsClassificationsMapSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
11
|
+
label: z.ZodOptional<z.ZodString>;
|
|
12
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
13
|
+
classification: z.ZodEnum<typeof PermissionRiskLevel>;
|
|
14
|
+
}, z.z.core.$strip>>;
|
|
15
|
+
declare const NamedPermissionsClassificationSchema: z.ZodObject<{
|
|
16
|
+
label: z.ZodOptional<z.ZodString>;
|
|
17
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
18
|
+
classification: z.ZodEnum<typeof PermissionRiskLevel>;
|
|
19
|
+
name: z.ZodString;
|
|
20
|
+
}, z.z.core.$strip>;
|
|
21
|
+
declare const PolicyRuleConfigSchema: z.ZodObject<{
|
|
22
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
23
|
+
options: z.ZodOptional<z.ZodUnknown>;
|
|
24
|
+
}, z.z.core.$strip>;
|
|
25
|
+
declare const RuleMapSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
26
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
27
|
+
options: z.ZodOptional<z.ZodUnknown>;
|
|
28
|
+
}, z.z.core.$strip>>;
|
|
29
|
+
declare const PermSetConfig: z.ZodObject<{
|
|
30
|
+
preset: z.ZodEnum<typeof ProfilesRiskPreset>;
|
|
31
|
+
}, z.z.core.$strip>;
|
|
32
|
+
declare const PermSetMap: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
33
|
+
preset: z.ZodEnum<typeof ProfilesRiskPreset>;
|
|
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>;
|
|
42
|
+
export declare const PolicyFileSchema: z.ZodObject<{
|
|
43
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
44
|
+
rules: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
45
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
46
|
+
options: z.ZodOptional<z.ZodUnknown>;
|
|
47
|
+
}, z.z.core.$strip>>>;
|
|
48
|
+
}, z.z.core.$strip>;
|
|
49
|
+
export declare const ProfilesPolicyFileSchema: z.ZodObject<{
|
|
50
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
51
|
+
rules: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
52
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
53
|
+
options: z.ZodOptional<z.ZodUnknown>;
|
|
54
|
+
}, z.z.core.$strip>>>;
|
|
55
|
+
profiles: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
56
|
+
preset: z.ZodEnum<typeof ProfilesRiskPreset>;
|
|
57
|
+
}, z.z.core.$strip>>;
|
|
58
|
+
}, z.z.core.$strip>;
|
|
59
|
+
export declare const PermSetsPolicyFileSchema: z.ZodObject<{
|
|
60
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
61
|
+
rules: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
62
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
63
|
+
options: z.ZodOptional<z.ZodUnknown>;
|
|
64
|
+
}, z.z.core.$strip>>>;
|
|
65
|
+
permissionSets: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
66
|
+
preset: z.ZodEnum<typeof ProfilesRiskPreset>;
|
|
67
|
+
}, z.z.core.$strip>>;
|
|
68
|
+
}, z.z.core.$strip>;
|
|
69
|
+
export declare const PermissionsConfigFileSchema: z.ZodObject<{
|
|
70
|
+
permissions: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
71
|
+
label: z.ZodOptional<z.ZodString>;
|
|
72
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
73
|
+
classification: z.ZodEnum<typeof PermissionRiskLevel>;
|
|
74
|
+
}, z.z.core.$strip>>;
|
|
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>;
|
|
90
|
+
export type PermissionsClassification = z.infer<typeof PermissionsClassificationSchema>;
|
|
91
|
+
export type NamedPermissionsClassification = z.infer<typeof NamedPermissionsClassificationSchema>;
|
|
92
|
+
export type PermsClassificationsMap = z.infer<typeof PermsClassificationsMapSchema>;
|
|
93
|
+
export type PermissionsConfig = z.infer<typeof PermissionsConfigFileSchema>;
|
|
94
|
+
export type NoInactiveUsersOptions = z.infer<typeof NoInactiveUsersOptionsSchema>;
|
|
95
|
+
export type PolicyRuleConfig = z.infer<typeof PolicyRuleConfigSchema>;
|
|
96
|
+
export type BasePolicyFileContent = z.infer<typeof PolicyFileSchema>;
|
|
97
|
+
export type ProfilesPolicyFileContent = z.infer<typeof ProfilesPolicyFileSchema>;
|
|
98
|
+
export type PermSetsPolicyFileContent = z.infer<typeof PermSetsPolicyFileSchema>;
|
|
99
|
+
export type UsersPolicyFileContent = z.infer<typeof UsersPolicyFileSchema>;
|
|
100
|
+
export type PermissionSetConfig = z.infer<typeof PermSetConfig>;
|
|
101
|
+
export type PermissionSetLikeMap = z.infer<typeof PermSetMap>;
|
|
102
|
+
export type RuleMap = z.infer<typeof RuleMapSchema>;
|
|
103
|
+
export type ConfigFile<T> = {
|
|
104
|
+
filePath?: string;
|
|
105
|
+
content: T;
|
|
106
|
+
};
|
|
107
|
+
export type AuditRunConfigClassifications = {
|
|
108
|
+
userPermissions?: ConfigFile<PermissionsConfig>;
|
|
109
|
+
customPermissions?: ConfigFile<PermissionsConfig>;
|
|
110
|
+
};
|
|
111
|
+
export type AuditRunConfigPolicies = {
|
|
112
|
+
profiles?: ConfigFile<ProfilesPolicyFileContent>;
|
|
113
|
+
permissionSets?: ConfigFile<PermSetsPolicyFileContent>;
|
|
114
|
+
connectedApps?: ConfigFile<BasePolicyFileContent>;
|
|
115
|
+
users?: ConfigFile<UsersPolicyFileContent>;
|
|
116
|
+
};
|
|
117
|
+
export type AuditRunConfig = {
|
|
118
|
+
classifications: AuditRunConfigClassifications;
|
|
119
|
+
policies: AuditRunConfigPolicies;
|
|
120
|
+
};
|
|
121
|
+
export declare function isPermissionsConfig(cls: unknown): cls is ConfigFile<PermissionsConfig>;
|
|
122
|
+
export declare function isPolicyConfig(cls: unknown): cls is ConfigFile<BasePolicyFileContent>;
|
|
123
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { Messages } from '@salesforce/core';
|
|
3
|
+
import { PermissionRiskLevel } from '../classification-types.js';
|
|
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
|
+
}
|
|
14
|
+
const PermissionsClassificationSchema = z.object({
|
|
15
|
+
/** UI Label */
|
|
16
|
+
label: z.string().optional(),
|
|
17
|
+
/** An optional description to explain the classification */
|
|
18
|
+
reason: z.string().optional(),
|
|
19
|
+
/** Risk assessment of the permissions */
|
|
20
|
+
classification: z.enum(PermissionRiskLevel),
|
|
21
|
+
});
|
|
22
|
+
const PermsClassificationsMapSchema = z.record(z.string(), PermissionsClassificationSchema);
|
|
23
|
+
const NamedPermissionsClassificationSchema = PermissionsClassificationSchema.extend({
|
|
24
|
+
/** Developer name of the permission, used in metadata */
|
|
25
|
+
name: z.string(),
|
|
26
|
+
});
|
|
27
|
+
const PolicyRuleConfigSchema = z.object({
|
|
28
|
+
enabled: z.boolean().default(true),
|
|
29
|
+
options: z.unknown().optional(),
|
|
30
|
+
});
|
|
31
|
+
const RuleMapSchema = z.record(z.string(), PolicyRuleConfigSchema);
|
|
32
|
+
const PermSetConfig = z.object({
|
|
33
|
+
preset: z.enum(ProfilesRiskPreset),
|
|
34
|
+
});
|
|
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
|
+
});
|
|
45
|
+
// FILE CONTENT SCHEMATA
|
|
46
|
+
export const PolicyFileSchema = z.object({
|
|
47
|
+
enabled: z.boolean().default(true),
|
|
48
|
+
rules: RuleMapSchema.default({}),
|
|
49
|
+
});
|
|
50
|
+
export const ProfilesPolicyFileSchema = PolicyFileSchema.extend({
|
|
51
|
+
profiles: PermSetMap,
|
|
52
|
+
});
|
|
53
|
+
export const PermSetsPolicyFileSchema = PolicyFileSchema.extend({
|
|
54
|
+
permissionSets: PermSetMap,
|
|
55
|
+
});
|
|
56
|
+
export const PermissionsConfigFileSchema = z.object({
|
|
57
|
+
permissions: z.record(z.string(), PermissionsClassificationSchema),
|
|
58
|
+
});
|
|
59
|
+
export const UsersPolicyFileSchema = PolicyFileSchema.extend({
|
|
60
|
+
users: UsersMap,
|
|
61
|
+
options: UsersPolicyConfig,
|
|
62
|
+
});
|
|
63
|
+
export function isPermissionsConfig(cls) {
|
|
64
|
+
return cls.content?.permissions !== undefined;
|
|
65
|
+
}
|
|
66
|
+
export function isPolicyConfig(cls) {
|
|
67
|
+
return cls.content?.rules !== undefined;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +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,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EA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AC,OAAO,CAAC,EAAE,CAAC;CAChD,CAAC,CAAC;AAEH,wBAAwB;AAExB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAClC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;CACjC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,gBAAgB,CAAC,MAAM,CAAC;IAC9D,QAAQ,EAAE,UAAU;CACrB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,gBAAgB,CAAC,MAAM,CAAC;IAC9D,cAAc,EAAE,UAAU;CAC3B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,+BAA+B,CAAC;CACnE,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,gBAAgB,CAAC,MAAM,CAAC;IAC3D,KAAK,EAAE,QAAQ;IACf,OAAO,EAAE,iBAAiB;CAC3B,CAAC,CAAC;AA+CH,MAAM,UAAU,mBAAmB,CAAC,GAAY;IAC9C,OAAQ,GAAqC,CAAC,OAAO,EAAE,WAAW,KAAK,SAAS,CAAC;AACnF,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAY;IACzC,OAAQ,GAAyC,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Connection } from '@salesforce/core';
|
|
2
|
+
import { ConnectedAppSettings, PermissionSet, Profile as ProfileMetadata } from '@jsforce/jsforce-node/lib/api/metadata.js';
|
|
3
|
+
import NamedMetadata from './namedMetadataType.js';
|
|
4
|
+
import SingletonMetadata from './singletonMetadataType.js';
|
|
5
|
+
import NamedMetadataQueryable from './namedMetadataToolingQueryable.js';
|
|
6
|
+
export default class MDAPI {
|
|
7
|
+
private readonly connection;
|
|
8
|
+
private static readonly retrievers;
|
|
9
|
+
private readonly cache;
|
|
10
|
+
constructor(connection: Connection);
|
|
11
|
+
static create(connection: Connection): MDAPI;
|
|
12
|
+
/**
|
|
13
|
+
* Resolves one of the pre-configured metadata types and returns
|
|
14
|
+
* a map of resolved names and entire XML content of source file body.
|
|
15
|
+
*
|
|
16
|
+
* @param typeName
|
|
17
|
+
* @param componentNames
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
resolve<K extends keyof typeof NamedTypesRegistry>(typeName: K, componentNames: string[]): Promise<NamedReturnTypes[K]>;
|
|
21
|
+
/**
|
|
22
|
+
* Resolves one of the pre-configured metadata types and returns
|
|
23
|
+
* the entire XML content of source file body.
|
|
24
|
+
*
|
|
25
|
+
* @param typeName
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
resolveSingleton<K extends keyof typeof SingletonRegistry>(typeName: K): Promise<SingletonReturnTypes[K]>;
|
|
29
|
+
private cacheResults;
|
|
30
|
+
private fetchCached;
|
|
31
|
+
}
|
|
32
|
+
export declare const NamedTypesRegistry: {
|
|
33
|
+
PermissionSet: NamedMetadata<PermissionSetXml, "PermissionSet">;
|
|
34
|
+
Profile: NamedMetadataQueryable<ProfileXml, "Profile">;
|
|
35
|
+
};
|
|
36
|
+
export declare const SingletonRegistry: {
|
|
37
|
+
ConnectedAppSettings: SingletonMetadata<ConnectedAppSettingsXml, "ConnectedAppSettings">;
|
|
38
|
+
};
|
|
39
|
+
type NamedReturnTypes = {
|
|
40
|
+
[K in keyof typeof NamedTypesRegistry]: Awaited<ReturnType<(typeof NamedTypesRegistry)[K]['resolve']>>;
|
|
41
|
+
};
|
|
42
|
+
type SingletonReturnTypes = {
|
|
43
|
+
[K in keyof typeof SingletonRegistry]: Awaited<ReturnType<(typeof SingletonRegistry)[K]['resolve']>>;
|
|
44
|
+
};
|
|
45
|
+
type ProfileXml = {
|
|
46
|
+
Profile: ProfileMetadata;
|
|
47
|
+
};
|
|
48
|
+
type PermissionSetXml = {
|
|
49
|
+
PermissionSet: PermissionSet;
|
|
50
|
+
};
|
|
51
|
+
type ConnectedAppSettingsXml = {
|
|
52
|
+
ConnectedAppSettings: ConnectedAppSettings;
|
|
53
|
+
};
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { XMLParser } from 'fast-xml-parser';
|
|
2
|
+
import NamedMetadata from './namedMetadataType.js';
|
|
3
|
+
import SingletonMetadata from './singletonMetadataType.js';
|
|
4
|
+
import NamedMetadataQueryable from './namedMetadataToolingQueryable.js';
|
|
5
|
+
export default class MDAPI {
|
|
6
|
+
connection;
|
|
7
|
+
static retrievers = new Map();
|
|
8
|
+
cache;
|
|
9
|
+
constructor(connection) {
|
|
10
|
+
this.connection = connection;
|
|
11
|
+
this.cache = new MetadataCache();
|
|
12
|
+
}
|
|
13
|
+
static create(connection) {
|
|
14
|
+
if (!this.retrievers.has(connection.instanceUrl)) {
|
|
15
|
+
this.retrievers.set(connection.instanceUrl, new MDAPI(connection));
|
|
16
|
+
}
|
|
17
|
+
return this.retrievers.get(connection.instanceUrl);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Resolves one of the pre-configured metadata types and returns
|
|
21
|
+
* a map of resolved names and entire XML content of source file body.
|
|
22
|
+
*
|
|
23
|
+
* @param typeName
|
|
24
|
+
* @param componentNames
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
async resolve(typeName, componentNames) {
|
|
28
|
+
const retriever = NamedTypesRegistry[typeName];
|
|
29
|
+
const { toRetrieve, cached } = this.fetchCached(componentNames);
|
|
30
|
+
if (toRetrieve.length > 0) {
|
|
31
|
+
const retrieveResults = await retriever.resolve(this.connection, toRetrieve);
|
|
32
|
+
this.cacheResults(retrieveResults);
|
|
33
|
+
return {
|
|
34
|
+
...cached,
|
|
35
|
+
...retrieveResults,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return cached;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Resolves one of the pre-configured metadata types and returns
|
|
42
|
+
* the entire XML content of source file body.
|
|
43
|
+
*
|
|
44
|
+
* @param typeName
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
async resolveSingleton(typeName) {
|
|
48
|
+
const retriever = SingletonRegistry[typeName];
|
|
49
|
+
const { toRetrieve, cached } = this.fetchCached([typeName]);
|
|
50
|
+
if (toRetrieve.length > 0) {
|
|
51
|
+
const retrieveResults = await retriever.resolve(this.connection);
|
|
52
|
+
this.cache.set(typeName, retrieveResults);
|
|
53
|
+
return retrieveResults;
|
|
54
|
+
}
|
|
55
|
+
return cached[typeName];
|
|
56
|
+
}
|
|
57
|
+
cacheResults(results) {
|
|
58
|
+
for (const [cname, mdata] of Object.entries(results)) {
|
|
59
|
+
this.cache.set(cname, mdata);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
fetchCached(componentNames) {
|
|
63
|
+
const toRetrieve = [];
|
|
64
|
+
const cached = {};
|
|
65
|
+
for (const cname of componentNames) {
|
|
66
|
+
if (this.cache.isCached(cname)) {
|
|
67
|
+
cached[cname] = this.cache.fetch(cname);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
toRetrieve.push(cname);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return { toRetrieve, cached };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
class MetadataCache {
|
|
77
|
+
components = {};
|
|
78
|
+
isCached(cmpName) {
|
|
79
|
+
return this.components[cmpName] !== undefined && this.components[cmpName] !== null;
|
|
80
|
+
}
|
|
81
|
+
fetch(cmpName) {
|
|
82
|
+
if (!this.isCached(cmpName)) {
|
|
83
|
+
throw new Error('Component not cached. Check first before fetching: ' + cmpName);
|
|
84
|
+
}
|
|
85
|
+
return this.components[cmpName];
|
|
86
|
+
}
|
|
87
|
+
set(cmpName, content) {
|
|
88
|
+
this.components[cmpName] = content;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export const NamedTypesRegistry = {
|
|
92
|
+
PermissionSet: new NamedMetadata({
|
|
93
|
+
retrieveType: 'PermissionSet',
|
|
94
|
+
rootNodeName: 'PermissionSet',
|
|
95
|
+
parser: new XMLParser({
|
|
96
|
+
isArray: (jpath) => ['userPermissions', 'fieldPermissions', 'customPermissions', 'classAccesses'].includes(jpath),
|
|
97
|
+
}),
|
|
98
|
+
parsePostProcessor: (parseResult) => ({
|
|
99
|
+
...parseResult,
|
|
100
|
+
userPermissions: parseResult.userPermissions ?? [],
|
|
101
|
+
customPermissions: parseResult.customPermissions ?? [],
|
|
102
|
+
classAccesses: parseResult.classAccesses ?? [],
|
|
103
|
+
}),
|
|
104
|
+
}),
|
|
105
|
+
Profile: new NamedMetadataQueryable({
|
|
106
|
+
objectName: 'Profile',
|
|
107
|
+
nameField: 'Name',
|
|
108
|
+
parsePostProcessor: (parseResult) => ({
|
|
109
|
+
...parseResult,
|
|
110
|
+
userPermissions: parseResult.userPermissions ?? [],
|
|
111
|
+
customPermissions: parseResult.customPermissions ?? [],
|
|
112
|
+
classAccesses: parseResult.classAccesses ?? [],
|
|
113
|
+
}),
|
|
114
|
+
}),
|
|
115
|
+
};
|
|
116
|
+
export const SingletonRegistry = {
|
|
117
|
+
ConnectedAppSettings: new SingletonMetadata({
|
|
118
|
+
rootNodeName: 'ConnectedAppSettings',
|
|
119
|
+
retrieveName: 'ConnectedApp',
|
|
120
|
+
retrieveType: 'Settings',
|
|
121
|
+
}),
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=mdapiRetriever.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdapiRetriever.js","sourceRoot":"","sources":["../../../../src/libs/core/mdapi/mdapiRetriever.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,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EAAE,CAAC,WAAW,EAAmB,EAAE,CAAC,CAAC;YACrD,GAAG,WAAW;YACd,eAAe,EAAE,WAAW,CAAC,eAAe,IAAI,EAAE;YAClD,iBAAiB,EAAE,WAAW,CAAC,iBAAiB,IAAI,EAAE;YACtD,aAAa,EAAE,WAAW,CAAC,aAAa,IAAI,EAAE;SAC/C,CAAC;KACH,CAAC;CACH,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,oBAAoB,EAAE,IAAI,iBAAiB,CAAkD;QAC3F,YAAY,EAAE,sBAAsB;QACpC,YAAY,EAAE,cAAc;QAC5B,YAAY,EAAE,UAAU;KACzB,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PathLike } from 'node:fs';
|
|
2
|
+
import { XMLParser } from 'fast-xml-parser';
|
|
3
|
+
import { ComponentSet, FileResponse, RetrieveResult } from '@salesforce/source-deploy-retrieve';
|
|
4
|
+
import { Connection } from '@salesforce/core';
|
|
5
|
+
export type MetadataRegistryEntryOpts<Type, Key extends keyof Type> = {
|
|
6
|
+
/**
|
|
7
|
+
* Metadata API name of the type.
|
|
8
|
+
*/
|
|
9
|
+
retrieveType: string;
|
|
10
|
+
/**
|
|
11
|
+
* Metadata API name entity.
|
|
12
|
+
*/
|
|
13
|
+
retrieveName?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optional XML parser instance. Typically used to fix errors for
|
|
16
|
+
* properties that must be parsed as list.
|
|
17
|
+
*/
|
|
18
|
+
parser?: XMLParser;
|
|
19
|
+
/**
|
|
20
|
+
* Name of the root node in XML file content
|
|
21
|
+
*/
|
|
22
|
+
rootNodeName: Key;
|
|
23
|
+
/**
|
|
24
|
+
* Post processor function that sanitises the XML parse result
|
|
25
|
+
*/
|
|
26
|
+
parsePostProcessor?: (parseResult: Type[Key]) => Type[Key];
|
|
27
|
+
};
|
|
28
|
+
export type NamedMetadataResolver<Type> = {
|
|
29
|
+
resolve(con: Connection, componentNames: string[]): Promise<Record<string, Type>>;
|
|
30
|
+
};
|
|
31
|
+
export default abstract class MetadataRegistryEntry<Type, Key extends keyof Type> {
|
|
32
|
+
private opts;
|
|
33
|
+
parser: XMLParser;
|
|
34
|
+
retrieveType: string;
|
|
35
|
+
rootNodeName: Key;
|
|
36
|
+
constructor(opts: MetadataRegistryEntryOpts<Type, Key>);
|
|
37
|
+
parse(fullFilePath: PathLike): Type[Key];
|
|
38
|
+
}
|
|
39
|
+
export declare function retrieve(compSet: ComponentSet, con: Connection): Promise<RetrieveResult>;
|
|
40
|
+
export declare function cleanRetrieveDir(files: FileResponse[]): void;
|