@j-schreiber/sf-cli-security-audit 0.7.1 → 0.8.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.
Files changed (147) hide show
  1. package/README.md +26 -22
  2. package/messages/rules.enforceClassificationPresets.md +4 -0
  3. package/messages/rules.users.md +12 -0
  4. package/oclif.lock +365 -71
  5. package/oclif.manifest.json +2 -253
  6. package/package.json +1 -1
  7. package/lib/commands/org/audit/init.d.ts +0 -19
  8. package/lib/commands/org/audit/init.js +0 -72
  9. package/lib/commands/org/audit/init.js.map +0 -1
  10. package/lib/commands/org/audit/run.d.ts +0 -22
  11. package/lib/commands/org/audit/run.js +0 -119
  12. package/lib/commands/org/audit/run.js.map +0 -1
  13. package/lib/commands/org/scan/user-perms.d.ts +0 -20
  14. package/lib/commands/org/scan/user-perms.js +0 -87
  15. package/lib/commands/org/scan/user-perms.js.map +0 -1
  16. package/lib/libs/conf-init/auditConfig.d.ts +0 -35
  17. package/lib/libs/conf-init/auditConfig.js +0 -41
  18. package/lib/libs/conf-init/auditConfig.js.map +0 -1
  19. package/lib/libs/conf-init/permissionsClassification.d.ts +0 -17
  20. package/lib/libs/conf-init/permissionsClassification.js +0 -80
  21. package/lib/libs/conf-init/permissionsClassification.js.map +0 -1
  22. package/lib/libs/conf-init/policyConfigs.d.ts +0 -31
  23. package/lib/libs/conf-init/policyConfigs.js +0 -91
  24. package/lib/libs/conf-init/policyConfigs.js.map +0 -1
  25. package/lib/libs/conf-init/presets/loose.d.ts +0 -6
  26. package/lib/libs/conf-init/presets/loose.js +0 -51
  27. package/lib/libs/conf-init/presets/loose.js.map +0 -1
  28. package/lib/libs/conf-init/presets/none.d.ts +0 -30
  29. package/lib/libs/conf-init/presets/none.js +0 -54
  30. package/lib/libs/conf-init/presets/none.js.map +0 -1
  31. package/lib/libs/conf-init/presets/strict.d.ts +0 -4
  32. package/lib/libs/conf-init/presets/strict.js +0 -45
  33. package/lib/libs/conf-init/presets/strict.js.map +0 -1
  34. package/lib/libs/conf-init/presets.d.ts +0 -7
  35. package/lib/libs/conf-init/presets.js +0 -20
  36. package/lib/libs/conf-init/presets.js.map +0 -1
  37. package/lib/libs/core/auditRun.d.ts +0 -36
  38. package/lib/libs/core/auditRun.js +0 -86
  39. package/lib/libs/core/auditRun.js.map +0 -1
  40. package/lib/libs/core/classification-types.d.ts +0 -20
  41. package/lib/libs/core/classification-types.js +0 -23
  42. package/lib/libs/core/classification-types.js.map +0 -1
  43. package/lib/libs/core/constants.d.ts +0 -11
  44. package/lib/libs/core/constants.js +0 -20
  45. package/lib/libs/core/constants.js.map +0 -1
  46. package/lib/libs/core/file-mgmt/auditConfigFileManager.d.ts +0 -48
  47. package/lib/libs/core/file-mgmt/auditConfigFileManager.js +0 -145
  48. package/lib/libs/core/file-mgmt/auditConfigFileManager.js.map +0 -1
  49. package/lib/libs/core/file-mgmt/schema.d.ts +0 -123
  50. package/lib/libs/core/file-mgmt/schema.js +0 -69
  51. package/lib/libs/core/file-mgmt/schema.js.map +0 -1
  52. package/lib/libs/core/mdapi/mdapiRetriever.d.ts +0 -54
  53. package/lib/libs/core/mdapi/mdapiRetriever.js +0 -123
  54. package/lib/libs/core/mdapi/mdapiRetriever.js.map +0 -1
  55. package/lib/libs/core/mdapi/metadataRegistryEntry.d.ts +0 -40
  56. package/lib/libs/core/mdapi/metadataRegistryEntry.js +0 -46
  57. package/lib/libs/core/mdapi/metadataRegistryEntry.js.map +0 -1
  58. package/lib/libs/core/mdapi/namedMetadataToolingQueryable.d.ts +0 -33
  59. package/lib/libs/core/mdapi/namedMetadataToolingQueryable.js +0 -41
  60. package/lib/libs/core/mdapi/namedMetadataToolingQueryable.js.map +0 -1
  61. package/lib/libs/core/mdapi/namedMetadataType.d.ts +0 -20
  62. package/lib/libs/core/mdapi/namedMetadataType.js +0 -41
  63. package/lib/libs/core/mdapi/namedMetadataType.js.map +0 -1
  64. package/lib/libs/core/mdapi/singletonMetadataType.d.ts +0 -21
  65. package/lib/libs/core/mdapi/singletonMetadataType.js +0 -37
  66. package/lib/libs/core/mdapi/singletonMetadataType.js.map +0 -1
  67. package/lib/libs/core/policies/connectedAppPolicy.d.ts +0 -10
  68. package/lib/libs/core/policies/connectedAppPolicy.js +0 -78
  69. package/lib/libs/core/policies/connectedAppPolicy.js.map +0 -1
  70. package/lib/libs/core/policies/permissionSetPolicy.d.ts +0 -11
  71. package/lib/libs/core/policies/permissionSetPolicy.js +0 -62
  72. package/lib/libs/core/policies/permissionSetPolicy.js.map +0 -1
  73. package/lib/libs/core/policies/policy.d.ts +0 -31
  74. package/lib/libs/core/policies/policy.js +0 -100
  75. package/lib/libs/core/policies/policy.js.map +0 -1
  76. package/lib/libs/core/policies/profilePolicy.d.ts +0 -11
  77. package/lib/libs/core/policies/profilePolicy.js +0 -64
  78. package/lib/libs/core/policies/profilePolicy.js.map +0 -1
  79. package/lib/libs/core/policies/salesforceStandardTypes.d.ts +0 -53
  80. package/lib/libs/core/policies/salesforceStandardTypes.js +0 -2
  81. package/lib/libs/core/policies/salesforceStandardTypes.js.map +0 -1
  82. package/lib/libs/core/policies/userPolicy.d.ts +0 -11
  83. package/lib/libs/core/policies/userPolicy.js +0 -104
  84. package/lib/libs/core/policies/userPolicy.js.map +0 -1
  85. package/lib/libs/core/policy-types.d.ts +0 -18
  86. package/lib/libs/core/policy-types.js +0 -28
  87. package/lib/libs/core/policy-types.js.map +0 -1
  88. package/lib/libs/core/policyRegistry.d.ts +0 -23
  89. package/lib/libs/core/policyRegistry.js +0 -38
  90. package/lib/libs/core/policyRegistry.js.map +0 -1
  91. package/lib/libs/core/registries/connectedApps.d.ts +0 -13
  92. package/lib/libs/core/registries/connectedApps.js +0 -13
  93. package/lib/libs/core/registries/connectedApps.js.map +0 -1
  94. package/lib/libs/core/registries/permissionSets.d.ts +0 -11
  95. package/lib/libs/core/registries/permissionSets.js +0 -11
  96. package/lib/libs/core/registries/permissionSets.js.map +0 -1
  97. package/lib/libs/core/registries/profiles.d.ts +0 -11
  98. package/lib/libs/core/registries/profiles.js +0 -13
  99. package/lib/libs/core/registries/profiles.js.map +0 -1
  100. package/lib/libs/core/registries/ruleRegistry.d.ts +0 -37
  101. package/lib/libs/core/registries/ruleRegistry.js +0 -48
  102. package/lib/libs/core/registries/ruleRegistry.js.map +0 -1
  103. package/lib/libs/core/registries/rules/allUsedAppsUnderManagement.d.ts +0 -7
  104. package/lib/libs/core/registries/rules/allUsedAppsUnderManagement.js +0 -23
  105. package/lib/libs/core/registries/rules/allUsedAppsUnderManagement.js.map +0 -1
  106. package/lib/libs/core/registries/rules/enforceCustomPermsClassificationOnProfiles.d.ts +0 -7
  107. package/lib/libs/core/registries/rules/enforceCustomPermsClassificationOnProfiles.js +0 -52
  108. package/lib/libs/core/registries/rules/enforceCustomPermsClassificationOnProfiles.js.map +0 -1
  109. package/lib/libs/core/registries/rules/enforceUserPermsClassificationOnPermSets.d.ts +0 -7
  110. package/lib/libs/core/registries/rules/enforceUserPermsClassificationOnPermSets.js +0 -52
  111. package/lib/libs/core/registries/rules/enforceUserPermsClassificationOnPermSets.js.map +0 -1
  112. package/lib/libs/core/registries/rules/enforceUserPermsClassificationOnProfiles.d.ts +0 -7
  113. package/lib/libs/core/registries/rules/enforceUserPermsClassificationOnProfiles.js +0 -54
  114. package/lib/libs/core/registries/rules/enforceUserPermsClassificationOnProfiles.js.map +0 -1
  115. package/lib/libs/core/registries/rules/noInactiveUsers.d.ts +0 -9
  116. package/lib/libs/core/registries/rules/noInactiveUsers.js +0 -44
  117. package/lib/libs/core/registries/rules/noInactiveUsers.js.map +0 -1
  118. package/lib/libs/core/registries/rules/noOtherApexApiLogins.d.ts +0 -7
  119. package/lib/libs/core/registries/rules/noOtherApexApiLogins.js +0 -24
  120. package/lib/libs/core/registries/rules/noOtherApexApiLogins.js.map +0 -1
  121. package/lib/libs/core/registries/rules/noUserCanSelfAuthorize.d.ts +0 -7
  122. package/lib/libs/core/registries/rules/noUserCanSelfAuthorize.js +0 -31
  123. package/lib/libs/core/registries/rules/noUserCanSelfAuthorize.js.map +0 -1
  124. package/lib/libs/core/registries/rules/policyRule.d.ts +0 -21
  125. package/lib/libs/core/registries/rules/policyRule.js +0 -41
  126. package/lib/libs/core/registries/rules/policyRule.js.map +0 -1
  127. package/lib/libs/core/registries/types.d.ts +0 -37
  128. package/lib/libs/core/registries/types.js +0 -11
  129. package/lib/libs/core/registries/types.js.map +0 -1
  130. package/lib/libs/core/registries/users.d.ts +0 -26
  131. package/lib/libs/core/registries/users.js +0 -10
  132. package/lib/libs/core/registries/users.js.map +0 -1
  133. package/lib/libs/core/result-types.d.ts +0 -172
  134. package/lib/libs/core/result-types.js +0 -2
  135. package/lib/libs/core/result-types.js.map +0 -1
  136. package/lib/libs/core/utils.d.ts +0 -12
  137. package/lib/libs/core/utils.js +0 -31
  138. package/lib/libs/core/utils.js.map +0 -1
  139. package/lib/libs/quick-scan/types.d.ts +0 -17
  140. package/lib/libs/quick-scan/types.js +0 -2
  141. package/lib/libs/quick-scan/types.js.map +0 -1
  142. package/lib/libs/quick-scan/userPermissionScanner.d.ts +0 -22
  143. package/lib/libs/quick-scan/userPermissionScanner.js +0 -75
  144. package/lib/libs/quick-scan/userPermissionScanner.js.map +0 -1
  145. package/lib/ux/auditRunMultiStage.d.ts +0 -65
  146. package/lib/ux/auditRunMultiStage.js +0 -120
  147. package/lib/ux/auditRunMultiStage.js.map +0 -1
@@ -1,86 +0,0 @@
1
- // import fs from 'node:fs';
2
- import EventEmitter from 'node:events';
3
- import { loadAuditConfig } from './file-mgmt/auditConfigFileManager.js';
4
- import { policyDefs } from './policyRegistry.js';
5
- export function startAuditRun(directoryPath) {
6
- const conf = loadAuditConfig(directoryPath);
7
- return new AuditRun(conf);
8
- }
9
- /**
10
- * Instance of an audit run that manages high-level operations
11
- */
12
- export default class AuditRun extends EventEmitter {
13
- configs;
14
- executablePolicies;
15
- constructor(configs) {
16
- super();
17
- this.configs = configs;
18
- }
19
- /**
20
- * Loads all policies, resolves entities and caches the results.
21
- *
22
- * @param targetOrgConnection
23
- */
24
- async resolve(targetOrgConnection) {
25
- if (this.executablePolicies) {
26
- return this.executablePolicies;
27
- }
28
- this.executablePolicies = this.loadPolicies(this.configs);
29
- const resolveResultPromises = [];
30
- Object.values(this.executablePolicies).forEach((executable) => {
31
- resolveResultPromises.push(executable.resolve({ targetOrgConnection }));
32
- });
33
- await Promise.all(resolveResultPromises);
34
- return this.executablePolicies;
35
- }
36
- /**
37
- * Executes an initialised audit run. Resolves policies entities
38
- * and executes all rules.
39
- *
40
- * @param targetOrgConnection
41
- * @returns
42
- */
43
- async execute(targetCon) {
44
- this.executablePolicies = await this.resolve(targetCon);
45
- const results = await runPolicies(this.executablePolicies, targetCon);
46
- return {
47
- auditDate: new Date().toISOString(),
48
- isCompliant: isCompliant(results),
49
- policies: results,
50
- };
51
- }
52
- loadPolicies(config) {
53
- const pols = {};
54
- Object.entries(config.policies).forEach(([policyName, policyConfig]) => {
55
- const policy = new policyDefs[policyName].handler(policyConfig.content, config);
56
- policy.addListener('entityresolve', (resolveStats) => {
57
- this.emit(`entityresolve-${policyName}`, { policyName, ...resolveStats });
58
- });
59
- pols[policyName] = policy;
60
- });
61
- return pols;
62
- }
63
- }
64
- function isCompliant(results) {
65
- const list = Object.values(results);
66
- if (list.length === 0) {
67
- return true;
68
- }
69
- return list.reduce((prevVal, currentVal) => prevVal && currentVal.isCompliant, list[0].isCompliant);
70
- }
71
- async function runPolicies(policies, targetOrgConnection) {
72
- const resultsArray = [];
73
- const policiesList = [];
74
- Object.entries(policies).forEach(([policyKey, executable]) => {
75
- policiesList.push(policyKey);
76
- resultsArray.push(executable.run({ targetOrgConnection }));
77
- });
78
- const arrayResult = await Promise.all(resultsArray);
79
- const results = {};
80
- arrayResult.forEach((policyResult) => {
81
- const policyKey = policiesList[arrayResult.indexOf(policyResult)];
82
- results[policyKey] = policyResult;
83
- });
84
- return results;
85
- }
86
- //# sourceMappingURL=auditRun.js.map
@@ -1 +0,0 @@
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AC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;AACtG,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,QAAmB,EAAE,mBAA+B;IAC7E,MAAM,YAAY,GAAsC,EAAE,CAAC;IAC3D,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE;QAC3D,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC7B,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACpD,MAAM,OAAO,GAAe,EAAE,CAAC;IAC/B,WAAW,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;QACnC,MAAM,SAAS,GAAG,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;QAClE,OAAO,CAAC,SAAS,CAAC,GAAG,YAAY,CAAC;IACpC,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,20 +0,0 @@
1
- import { NamedPermissionsClassification } from './file-mgmt/schema.js';
2
- /**
3
- * Enum to classify user and custom permissions.
4
- */
5
- export declare enum PermissionRiskLevel {
6
- /** Blacklisted permissions that are considered too critical and not allowed */
7
- BLOCKED = "Blocked",
8
- /** Developer permissions, allow to modify the application */
9
- CRITICAL = "Critical",
10
- /** Admin permissions, allow to manage users and change permissions */
11
- HIGH = "High",
12
- /** Elevated business permissions for privileged users */
13
- MEDIUM = "Medium",
14
- /** Regular user permissions, typically needed for day-to-day work */
15
- LOW = "Low",
16
- /** Not categorized or unknown permission. Will be ignored but create a warning */
17
- UNKNOWN = "Unknown"
18
- }
19
- export declare function resolveRiskLevelOrdinalValue(value: string): number;
20
- export declare const classificationSorter: (a: NamedPermissionsClassification, b: NamedPermissionsClassification) => number;
@@ -1,23 +0,0 @@
1
- /**
2
- * Enum to classify user and custom permissions.
3
- */
4
- export var PermissionRiskLevel;
5
- (function (PermissionRiskLevel) {
6
- /** Blacklisted permissions that are considered too critical and not allowed */
7
- PermissionRiskLevel["BLOCKED"] = "Blocked";
8
- /** Developer permissions, allow to modify the application */
9
- PermissionRiskLevel["CRITICAL"] = "Critical";
10
- /** Admin permissions, allow to manage users and change permissions */
11
- PermissionRiskLevel["HIGH"] = "High";
12
- /** Elevated business permissions for privileged users */
13
- PermissionRiskLevel["MEDIUM"] = "Medium";
14
- /** Regular user permissions, typically needed for day-to-day work */
15
- PermissionRiskLevel["LOW"] = "Low";
16
- /** Not categorized or unknown permission. Will be ignored but create a warning */
17
- PermissionRiskLevel["UNKNOWN"] = "Unknown";
18
- })(PermissionRiskLevel || (PermissionRiskLevel = {}));
19
- export function resolveRiskLevelOrdinalValue(value) {
20
- return Object.keys(PermissionRiskLevel).indexOf(value.toUpperCase());
21
- }
22
- export const classificationSorter = (a, b) => resolveRiskLevelOrdinalValue(a.classification) - resolveRiskLevelOrdinalValue(b.classification);
23
- //# sourceMappingURL=classification-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"classification-types.js","sourceRoot":"","sources":["../../../src/libs/core/classification-types.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAN,IAAY,mBAaX;AAbD,WAAY,mBAAmB;IAC7B,+EAA+E;IAC/E,0CAAmB,CAAA;IACnB,6DAA6D;IAC7D,4CAAqB,CAAA;IACrB,sEAAsE;IACtE,oCAAa,CAAA;IACb,yDAAyD;IACzD,wCAAiB,CAAA;IACjB,qEAAqE;IACrE,kCAAW,CAAA;IACX,kFAAkF;IAClF,0CAAmB,CAAA;AACrB,CAAC,EAbW,mBAAmB,KAAnB,mBAAmB,QAa9B;AAED,MAAM,UAAU,4BAA4B,CAAC,KAAa;IACxD,OAAO,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;AACvE,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAiC,EAAE,CAAiC,EAAU,EAAE,CACnH,4BAA4B,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,4BAA4B,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC"}
@@ -1,11 +0,0 @@
1
- export declare const CUSTOM_PERMS_QUERY = "SELECT Id,MasterLabel,DeveloperName FROM CustomPermission";
2
- export declare const PROFILES_QUERY = "SELECT Profile.Name,Profile.UserType,IsCustom FROM PermissionSet WHERE IsOwnedByProfile = TRUE";
3
- export declare const PERMISSION_SETS_QUERY = "SELECT Name,Label,IsCustom,NamespacePrefix FROM PermissionSet WHERE IsOwnedByProfile = FALSE AND NamespacePrefix = NULL";
4
- export declare const CONNECTED_APPS_QUERY = "SELECT Name,OptionsAllowAdminApprovedUsersOnly FROM ConnectedApplication";
5
- export declare const OAUTH_TOKEN_QUERY = "SELECT User.Username,UseCount,AppName FROM OauthToken";
6
- export declare const ACTIVE_USERS_QUERY = "SELECT Id,Username,UserType FROM User WHERE IsActive = TRUE AND UserType IN ('Standard') LIMIT 2000";
7
- export declare const ACTIVE_USERS_DETAILS_QUERY = "SELECT Id,Username,Profile.Name,CreatedDate,LastLoginDate FROM User WHERE IsActive = TRUE AND UserType IN ('Standard') LIMIT 2000";
8
- export declare const USERS_PERMSET_ASSIGNMENTS_QUERY = "SELECT AssigneeId,PermissionSet.Name FROM PermissionSetAssignment WHERE PermissionSet.IsOwnedByProfile = FALSE AND PermissionSet.NamespacePrefix = NULL";
9
- export declare const buildPermsetAssignmentsQuery: (userIds: string[]) => string;
10
- export declare const buildLoginHistoryQuery: (daysToAnalayse?: number) => string;
11
- export declare const RETRIEVE_CACHE: string;
@@ -1,20 +0,0 @@
1
- import path from 'node:path';
2
- // QUERIES
3
- export const CUSTOM_PERMS_QUERY = 'SELECT Id,MasterLabel,DeveloperName FROM CustomPermission';
4
- export const PROFILES_QUERY = 'SELECT Profile.Name,Profile.UserType,IsCustom FROM PermissionSet WHERE IsOwnedByProfile = TRUE';
5
- export const PERMISSION_SETS_QUERY = 'SELECT Name,Label,IsCustom,NamespacePrefix FROM PermissionSet WHERE IsOwnedByProfile = FALSE AND NamespacePrefix = NULL';
6
- export const CONNECTED_APPS_QUERY = 'SELECT Name,OptionsAllowAdminApprovedUsersOnly FROM ConnectedApplication';
7
- export const OAUTH_TOKEN_QUERY = 'SELECT User.Username,UseCount,AppName FROM OauthToken';
8
- export const ACTIVE_USERS_QUERY = "SELECT Id,Username,UserType FROM User WHERE IsActive = TRUE AND UserType IN ('Standard') LIMIT 2000";
9
- export const ACTIVE_USERS_DETAILS_QUERY = "SELECT Id,Username,Profile.Name,CreatedDate,LastLoginDate FROM User WHERE IsActive = TRUE AND UserType IN ('Standard') LIMIT 2000";
10
- export const USERS_PERMSET_ASSIGNMENTS_QUERY = 'SELECT AssigneeId,PermissionSet.Name FROM PermissionSetAssignment WHERE PermissionSet.IsOwnedByProfile = FALSE AND PermissionSet.NamespacePrefix = NULL';
11
- // DYNAMIC QUERIES
12
- export const buildPermsetAssignmentsQuery = (userIds) => `${USERS_PERMSET_ASSIGNMENTS_QUERY} WHERE AssigneeId IN (${userIds.map((userId) => `'${userId}'`).join(',')})`;
13
- export const buildLoginHistoryQuery = (daysToAnalayse) => daysToAnalayse
14
- ? `${USERS_LOGIN_HISTORY_QUERY} WHERE LoginTime >= LAST_N_DAYS:${daysToAnalayse} GROUP BY LoginType,Application,UserId`
15
- : `${USERS_LOGIN_HISTORY_QUERY} GROUP BY LoginType,Application,UserId`;
16
- // PATHS
17
- export const RETRIEVE_CACHE = path.join('.jsc', 'retrieves');
18
- // BASE QUERIES
19
- const USERS_LOGIN_HISTORY_QUERY = 'SELECT LoginType,Application,UserId,COUNT(Id)LoginCount,MAX(LoginTime)LastLogin FROM LoginHistory';
20
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/libs/core/constants.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,UAAU;AACV,MAAM,CAAC,MAAM,kBAAkB,GAAG,2DAA2D,CAAC;AAC9F,MAAM,CAAC,MAAM,cAAc,GACzB,gGAAgG,CAAC;AACnG,MAAM,CAAC,MAAM,qBAAqB,GAChC,yHAAyH,CAAC;AAC5H,MAAM,CAAC,MAAM,oBAAoB,GAAG,0EAA0E,CAAC;AAC/G,MAAM,CAAC,MAAM,iBAAiB,GAAG,uDAAuD,CAAC;AACzF,MAAM,CAAC,MAAM,kBAAkB,GAC7B,qGAAqG,CAAC;AACxG,MAAM,CAAC,MAAM,0BAA0B,GACrC,mIAAmI,CAAC;AACtI,MAAM,CAAC,MAAM,+BAA+B,GAC1C,yJAAyJ,CAAC;AAE5J,kBAAkB;AAClB,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,OAAiB,EAAU,EAAE,CACxE,GAAG,+BAA+B,yBAAyB,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AAEjH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,cAAuB,EAAU,EAAE,CACxE,cAAc;IACZ,CAAC,CAAC,GAAG,yBAAyB,mCAAmC,cAAc,wCAAwC;IACvH,CAAC,CAAC,GAAG,yBAAyB,wCAAwC,CAAC;AAE3E,QAAQ;AACR,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAE7D,eAAe;AACf,MAAM,yBAAyB,GAC7B,mGAAmG,CAAC"}
@@ -1,48 +0,0 @@
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 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;
@@ -1,145 +0,0 @@
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
@@ -1 +0,0 @@
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,OAAO,sBAAsB;IACjC,kBAAkB,CAAC;IAE3B;QACE,IAAI,CAAC,kBAAkB,GAAG;YACxB,QAAQ,EAAE,UAAU;YACpB,eAAe,EAAE,kBAAkB;SACpC,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,OAAiB;QAC5B,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,EA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G,GAAG,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACvD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,sBAAsB,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"}
@@ -1,123 +0,0 @@
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 {};
@@ -1,69 +0,0 @@
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
@@ -1 +0,0 @@
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,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,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,MAAM,UAAU,cAAc,CAAC,QAAgB,EAAE,UAAsB,EAAE,QAAwB;IAC/F,MAAM,MAAM,GAAG,U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,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"}
@@ -1,54 +0,0 @@
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 connection;
8
- private static retrievers;
9
- private 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 {};