@j-schreiber/sf-cli-security-audit 0.7.0 → 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 (150) hide show
  1. package/README.md +26 -22
  2. package/messages/org.audit.init.md +3 -3
  3. package/messages/org.audit.run.md +11 -3
  4. package/messages/org.scan.user-perms.md +7 -5
  5. package/messages/rules.enforceClassificationPresets.md +4 -0
  6. package/messages/rules.users.md +12 -0
  7. package/oclif.lock +365 -71
  8. package/oclif.manifest.json +2 -253
  9. package/package.json +1 -1
  10. package/lib/commands/org/audit/init.d.ts +0 -19
  11. package/lib/commands/org/audit/init.js +0 -72
  12. package/lib/commands/org/audit/init.js.map +0 -1
  13. package/lib/commands/org/audit/run.d.ts +0 -22
  14. package/lib/commands/org/audit/run.js +0 -119
  15. package/lib/commands/org/audit/run.js.map +0 -1
  16. package/lib/commands/org/scan/user-perms.d.ts +0 -20
  17. package/lib/commands/org/scan/user-perms.js +0 -87
  18. package/lib/commands/org/scan/user-perms.js.map +0 -1
  19. package/lib/libs/conf-init/auditConfig.d.ts +0 -35
  20. package/lib/libs/conf-init/auditConfig.js +0 -41
  21. package/lib/libs/conf-init/auditConfig.js.map +0 -1
  22. package/lib/libs/conf-init/permissionsClassification.d.ts +0 -17
  23. package/lib/libs/conf-init/permissionsClassification.js +0 -80
  24. package/lib/libs/conf-init/permissionsClassification.js.map +0 -1
  25. package/lib/libs/conf-init/policyConfigs.d.ts +0 -31
  26. package/lib/libs/conf-init/policyConfigs.js +0 -91
  27. package/lib/libs/conf-init/policyConfigs.js.map +0 -1
  28. package/lib/libs/conf-init/presets/loose.d.ts +0 -6
  29. package/lib/libs/conf-init/presets/loose.js +0 -51
  30. package/lib/libs/conf-init/presets/loose.js.map +0 -1
  31. package/lib/libs/conf-init/presets/none.d.ts +0 -30
  32. package/lib/libs/conf-init/presets/none.js +0 -54
  33. package/lib/libs/conf-init/presets/none.js.map +0 -1
  34. package/lib/libs/conf-init/presets/strict.d.ts +0 -4
  35. package/lib/libs/conf-init/presets/strict.js +0 -45
  36. package/lib/libs/conf-init/presets/strict.js.map +0 -1
  37. package/lib/libs/conf-init/presets.d.ts +0 -7
  38. package/lib/libs/conf-init/presets.js +0 -20
  39. package/lib/libs/conf-init/presets.js.map +0 -1
  40. package/lib/libs/core/auditRun.d.ts +0 -36
  41. package/lib/libs/core/auditRun.js +0 -86
  42. package/lib/libs/core/auditRun.js.map +0 -1
  43. package/lib/libs/core/classification-types.d.ts +0 -20
  44. package/lib/libs/core/classification-types.js +0 -23
  45. package/lib/libs/core/classification-types.js.map +0 -1
  46. package/lib/libs/core/constants.d.ts +0 -11
  47. package/lib/libs/core/constants.js +0 -20
  48. package/lib/libs/core/constants.js.map +0 -1
  49. package/lib/libs/core/file-mgmt/auditConfigFileManager.d.ts +0 -48
  50. package/lib/libs/core/file-mgmt/auditConfigFileManager.js +0 -139
  51. package/lib/libs/core/file-mgmt/auditConfigFileManager.js.map +0 -1
  52. package/lib/libs/core/file-mgmt/schema.d.ts +0 -122
  53. package/lib/libs/core/file-mgmt/schema.js +0 -59
  54. package/lib/libs/core/file-mgmt/schema.js.map +0 -1
  55. package/lib/libs/core/mdapi/mdapiRetriever.d.ts +0 -54
  56. package/lib/libs/core/mdapi/mdapiRetriever.js +0 -123
  57. package/lib/libs/core/mdapi/mdapiRetriever.js.map +0 -1
  58. package/lib/libs/core/mdapi/metadataRegistryEntry.d.ts +0 -40
  59. package/lib/libs/core/mdapi/metadataRegistryEntry.js +0 -46
  60. package/lib/libs/core/mdapi/metadataRegistryEntry.js.map +0 -1
  61. package/lib/libs/core/mdapi/namedMetadataToolingQueryable.d.ts +0 -33
  62. package/lib/libs/core/mdapi/namedMetadataToolingQueryable.js +0 -41
  63. package/lib/libs/core/mdapi/namedMetadataToolingQueryable.js.map +0 -1
  64. package/lib/libs/core/mdapi/namedMetadataType.d.ts +0 -20
  65. package/lib/libs/core/mdapi/namedMetadataType.js +0 -41
  66. package/lib/libs/core/mdapi/namedMetadataType.js.map +0 -1
  67. package/lib/libs/core/mdapi/singletonMetadataType.d.ts +0 -21
  68. package/lib/libs/core/mdapi/singletonMetadataType.js +0 -37
  69. package/lib/libs/core/mdapi/singletonMetadataType.js.map +0 -1
  70. package/lib/libs/core/policies/connectedAppPolicy.d.ts +0 -10
  71. package/lib/libs/core/policies/connectedAppPolicy.js +0 -78
  72. package/lib/libs/core/policies/connectedAppPolicy.js.map +0 -1
  73. package/lib/libs/core/policies/permissionSetPolicy.d.ts +0 -11
  74. package/lib/libs/core/policies/permissionSetPolicy.js +0 -62
  75. package/lib/libs/core/policies/permissionSetPolicy.js.map +0 -1
  76. package/lib/libs/core/policies/policy.d.ts +0 -31
  77. package/lib/libs/core/policies/policy.js +0 -100
  78. package/lib/libs/core/policies/policy.js.map +0 -1
  79. package/lib/libs/core/policies/profilePolicy.d.ts +0 -11
  80. package/lib/libs/core/policies/profilePolicy.js +0 -64
  81. package/lib/libs/core/policies/profilePolicy.js.map +0 -1
  82. package/lib/libs/core/policies/salesforceStandardTypes.d.ts +0 -53
  83. package/lib/libs/core/policies/salesforceStandardTypes.js +0 -2
  84. package/lib/libs/core/policies/salesforceStandardTypes.js.map +0 -1
  85. package/lib/libs/core/policies/userPolicy.d.ts +0 -11
  86. package/lib/libs/core/policies/userPolicy.js +0 -104
  87. package/lib/libs/core/policies/userPolicy.js.map +0 -1
  88. package/lib/libs/core/policy-types.d.ts +0 -18
  89. package/lib/libs/core/policy-types.js +0 -28
  90. package/lib/libs/core/policy-types.js.map +0 -1
  91. package/lib/libs/core/policyRegistry.d.ts +0 -23
  92. package/lib/libs/core/policyRegistry.js +0 -38
  93. package/lib/libs/core/policyRegistry.js.map +0 -1
  94. package/lib/libs/core/registries/connectedApps.d.ts +0 -13
  95. package/lib/libs/core/registries/connectedApps.js +0 -13
  96. package/lib/libs/core/registries/connectedApps.js.map +0 -1
  97. package/lib/libs/core/registries/permissionSets.d.ts +0 -11
  98. package/lib/libs/core/registries/permissionSets.js +0 -11
  99. package/lib/libs/core/registries/permissionSets.js.map +0 -1
  100. package/lib/libs/core/registries/profiles.d.ts +0 -11
  101. package/lib/libs/core/registries/profiles.js +0 -13
  102. package/lib/libs/core/registries/profiles.js.map +0 -1
  103. package/lib/libs/core/registries/ruleRegistry.d.ts +0 -37
  104. package/lib/libs/core/registries/ruleRegistry.js +0 -48
  105. package/lib/libs/core/registries/ruleRegistry.js.map +0 -1
  106. package/lib/libs/core/registries/rules/allUsedAppsUnderManagement.d.ts +0 -7
  107. package/lib/libs/core/registries/rules/allUsedAppsUnderManagement.js +0 -23
  108. package/lib/libs/core/registries/rules/allUsedAppsUnderManagement.js.map +0 -1
  109. package/lib/libs/core/registries/rules/enforceCustomPermsClassificationOnProfiles.d.ts +0 -7
  110. package/lib/libs/core/registries/rules/enforceCustomPermsClassificationOnProfiles.js +0 -52
  111. package/lib/libs/core/registries/rules/enforceCustomPermsClassificationOnProfiles.js.map +0 -1
  112. package/lib/libs/core/registries/rules/enforceUserPermsClassificationOnPermSets.d.ts +0 -7
  113. package/lib/libs/core/registries/rules/enforceUserPermsClassificationOnPermSets.js +0 -52
  114. package/lib/libs/core/registries/rules/enforceUserPermsClassificationOnPermSets.js.map +0 -1
  115. package/lib/libs/core/registries/rules/enforceUserPermsClassificationOnProfiles.d.ts +0 -7
  116. package/lib/libs/core/registries/rules/enforceUserPermsClassificationOnProfiles.js +0 -54
  117. package/lib/libs/core/registries/rules/enforceUserPermsClassificationOnProfiles.js.map +0 -1
  118. package/lib/libs/core/registries/rules/noInactiveUsers.d.ts +0 -9
  119. package/lib/libs/core/registries/rules/noInactiveUsers.js +0 -44
  120. package/lib/libs/core/registries/rules/noInactiveUsers.js.map +0 -1
  121. package/lib/libs/core/registries/rules/noOtherApexApiLogins.d.ts +0 -7
  122. package/lib/libs/core/registries/rules/noOtherApexApiLogins.js +0 -24
  123. package/lib/libs/core/registries/rules/noOtherApexApiLogins.js.map +0 -1
  124. package/lib/libs/core/registries/rules/noUserCanSelfAuthorize.d.ts +0 -7
  125. package/lib/libs/core/registries/rules/noUserCanSelfAuthorize.js +0 -31
  126. package/lib/libs/core/registries/rules/noUserCanSelfAuthorize.js.map +0 -1
  127. package/lib/libs/core/registries/rules/policyRule.d.ts +0 -19
  128. package/lib/libs/core/registries/rules/policyRule.js +0 -31
  129. package/lib/libs/core/registries/rules/policyRule.js.map +0 -1
  130. package/lib/libs/core/registries/types.d.ts +0 -37
  131. package/lib/libs/core/registries/types.js +0 -11
  132. package/lib/libs/core/registries/types.js.map +0 -1
  133. package/lib/libs/core/registries/users.d.ts +0 -26
  134. package/lib/libs/core/registries/users.js +0 -10
  135. package/lib/libs/core/registries/users.js.map +0 -1
  136. package/lib/libs/core/result-types.d.ts +0 -172
  137. package/lib/libs/core/result-types.js +0 -2
  138. package/lib/libs/core/result-types.js.map +0 -1
  139. package/lib/libs/core/utils.d.ts +0 -12
  140. package/lib/libs/core/utils.js +0 -31
  141. package/lib/libs/core/utils.js.map +0 -1
  142. package/lib/libs/quick-scan/types.d.ts +0 -17
  143. package/lib/libs/quick-scan/types.js +0 -2
  144. package/lib/libs/quick-scan/types.js.map +0 -1
  145. package/lib/libs/quick-scan/userPermissionScanner.d.ts +0 -22
  146. package/lib/libs/quick-scan/userPermissionScanner.js +0 -75
  147. package/lib/libs/quick-scan/userPermissionScanner.js.map +0 -1
  148. package/lib/ux/auditRunMultiStage.d.ts +0 -65
  149. package/lib/ux/auditRunMultiStage.js +0 -120
  150. package/lib/ux/auditRunMultiStage.js.map +0 -1
@@ -1,37 +0,0 @@
1
- import { EntityResolveError, PolicyRuleSkipResult } from '../result-types.js';
2
- import { AuditRunConfig, RuleMap } from '../../core/file-mgmt/schema.js';
3
- import { Constructor, RowLevelPolicyRule } from './types.js';
4
- /**
5
- * Result contains the actually available and enabled rules
6
- * from the raw config file. Rules that are not present in the
7
- * policie's registry are errors, disabled rules are skipped.
8
- */
9
- export type RegistryRuleResolveResult = {
10
- enabledRules: Array<RowLevelPolicyRule<unknown>>;
11
- skippedRules: PolicyRuleSkipResult[];
12
- resolveErrors: EntityResolveError[];
13
- };
14
- /**
15
- * The rule registry holds all available rules for a given policy at run time.
16
- * It is designed to be extendible so we can easily register new rules and it will
17
- * allow users to BYOR ("bring your own rules").
18
- */
19
- export default class RuleRegistry {
20
- rules: Record<string, Constructor<RowLevelPolicyRule<unknown>>>;
21
- constructor(rules: Record<string, Constructor<RowLevelPolicyRule<unknown>>>);
22
- /**
23
- * Returns the display/config names of all registered rules
24
- *
25
- * @returns
26
- */
27
- registeredRules(): string[];
28
- /**
29
- * Resolves a given set of rule configs to actually registered rules. Unknown
30
- * rules are ignored and disabled rules are skipped.
31
- *
32
- * @param ruleObjs
33
- * @param auditContext
34
- * @returns
35
- */
36
- resolveRules(ruleObjs: RuleMap, auditContext: AuditRunConfig): RegistryRuleResolveResult;
37
- }
@@ -1,48 +0,0 @@
1
- import { Messages } from '@salesforce/core';
2
- Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
3
- const messages = Messages.loadMessages('@j-schreiber/sf-cli-security-audit', 'policies.general');
4
- /**
5
- * The rule registry holds all available rules for a given policy at run time.
6
- * It is designed to be extendible so we can easily register new rules and it will
7
- * allow users to BYOR ("bring your own rules").
8
- */
9
- export default class RuleRegistry {
10
- rules;
11
- constructor(rules) {
12
- this.rules = rules;
13
- }
14
- /**
15
- * Returns the display/config names of all registered rules
16
- *
17
- * @returns
18
- */
19
- registeredRules() {
20
- return Object.keys(this.rules);
21
- }
22
- /**
23
- * Resolves a given set of rule configs to actually registered rules. Unknown
24
- * rules are ignored and disabled rules are skipped.
25
- *
26
- * @param ruleObjs
27
- * @param auditContext
28
- * @returns
29
- */
30
- resolveRules(ruleObjs, auditContext) {
31
- const enabledRules = new Array();
32
- const skippedRules = new Array();
33
- const resolveErrors = new Array();
34
- Object.entries(ruleObjs).forEach(([ruleName, ruleConfig]) => {
35
- if (this.rules[ruleName] && ruleConfig.enabled) {
36
- enabledRules.push(new this.rules[ruleName]({ auditContext, ruleDisplayName: ruleName, ruleConfig: ruleConfig.options }));
37
- }
38
- else if (!ruleConfig.enabled) {
39
- skippedRules.push({ name: ruleName, skipReason: messages.getMessage('skip-reason.rule-not-enabled') });
40
- }
41
- else {
42
- resolveErrors.push({ name: ruleName, message: messages.getMessage('resolve-error.rule-not-registered') });
43
- }
44
- });
45
- return { enabledRules, skippedRules, resolveErrors };
46
- }
47
- }
48
- //# sourceMappingURL=ruleRegistry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ruleRegistry.js","sourceRoot":"","sources":["../../../../src/libs/core/registries/ruleRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAK5C,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,oCAAoC,EAAE,kBAAkB,CAAC,CAAC;AAajG;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY;IACL;IAA1B,YAA0B,KAA+D;QAA/D,UAAK,GAAL,KAAK,CAA0D;IAAG,CAAC;IAE7F;;;;OAIG;IACI,eAAe;QACpB,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;;OAOG;IACI,YAAY,CAAC,QAAiB,EAAE,YAA4B;QACjE,MAAM,YAAY,GAAG,IAAI,KAAK,EAA+B,CAAC;QAC9D,MAAM,YAAY,GAAG,IAAI,KAAK,EAAwB,CAAC;QACvD,MAAM,aAAa,GAAG,IAAI,KAAK,EAAsB,CAAC;QACtD,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,EAAE;YAC1D,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;gBAC/C,YAAY,CAAC,IAAI,CACf,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,CACtG,CAAC;YACJ,CAAC;iBAAM,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;gBAC/B,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,8BAA8B,CAAC,EAAE,CAAC,CAAC;YACzG,CAAC;iBAAM,CAAC;gBACN,aAAa,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,mCAAmC,CAAC,EAAE,CAAC,CAAC;YAC5G,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC;IACvD,CAAC;CACF"}
@@ -1,7 +0,0 @@
1
- import { PartialPolicyRuleResult, RuleAuditContext } from '../types.js';
2
- import { ResolvedConnectedApp } from '../connectedApps.js';
3
- import PolicyRule, { RuleOptions } from './policyRule.js';
4
- export default class AllUsedAppsUnderManagement extends PolicyRule<ResolvedConnectedApp> {
5
- constructor(opts: RuleOptions);
6
- run(context: RuleAuditContext<ResolvedConnectedApp>): Promise<PartialPolicyRuleResult>;
7
- }
@@ -1,23 +0,0 @@
1
- import { Messages } from '@salesforce/core';
2
- import PolicyRule from './policyRule.js';
3
- Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
4
- const messages = Messages.loadMessages('@j-schreiber/sf-cli-security-audit', 'rules.connectedApps');
5
- export default class AllUsedAppsUnderManagement extends PolicyRule {
6
- constructor(opts) {
7
- super(opts);
8
- }
9
- run(context) {
10
- const result = this.initResult();
11
- const resolvedConnectedApps = context.resolvedEntities;
12
- Object.values(resolvedConnectedApps).forEach((app) => {
13
- if (app.origin === 'OauthToken') {
14
- result.violations.push({
15
- identifier: [app.name],
16
- message: messages.getMessage('violations.app-used-but-not-registered', [app.users.length, app.useCount]),
17
- });
18
- }
19
- });
20
- return Promise.resolve(result);
21
- }
22
- }
23
- //# sourceMappingURL=allUsedAppsUnderManagement.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"allUsedAppsUnderManagement.js","sourceRoot":"","sources":["../../../../../src/libs/core/registries/rules/allUsedAppsUnderManagement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,UAA2B,MAAM,iBAAiB,CAAC;AAE1D,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,oCAAoC,EAAE,qBAAqB,CAAC,CAAC;AAEpG,MAAM,CAAC,OAAO,OAAO,0BAA2B,SAAQ,UAAgC;IACtF,YAAmB,IAAiB;QAClC,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,GAAG,CAAC,OAA+C;QACxD,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QACjC,MAAM,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC;QACvD,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACnD,IAAI,GAAG,CAAC,MAAM,KAAK,YAAY,EAAE,CAAC;gBAChC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC;oBACrB,UAAU,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC;oBACtB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,wCAAwC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;iBACzG,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;CACF"}
@@ -1,7 +0,0 @@
1
- import { PartialPolicyRuleResult, RuleAuditContext } from '../types.js';
2
- import { ResolvedProfile } from '../profiles.js';
3
- import PolicyRule, { RuleOptions } from './policyRule.js';
4
- export default class EnforceCustomPermsClassificationOnProfiles extends PolicyRule<ResolvedProfile> {
5
- constructor(opts: RuleOptions);
6
- run(context: RuleAuditContext<ResolvedProfile>): Promise<PartialPolicyRuleResult>;
7
- }
@@ -1,52 +0,0 @@
1
- import { Messages } from '@salesforce/core';
2
- import { PermissionRiskLevel } from '../../classification-types.js';
3
- import { permissionAllowedInPreset } from '../../policy-types.js';
4
- import PolicyRule from './policyRule.js';
5
- const messages = Messages.loadMessages('@j-schreiber/sf-cli-security-audit', 'rules.enforceClassificationPresets');
6
- export default class EnforceCustomPermsClassificationOnProfiles extends PolicyRule {
7
- constructor(opts) {
8
- super(opts);
9
- }
10
- run(context) {
11
- const result = this.initResult();
12
- const resolvedProfiles = context.resolvedEntities;
13
- Object.values(resolvedProfiles).forEach((profile) => {
14
- const customPerms = profile.metadata.customPermissions ?? [];
15
- customPerms.forEach((perm) => {
16
- const identifier = [profile.name, perm.name];
17
- const classifiedPerm = this.resolveCustomPermission(perm.name);
18
- if (classifiedPerm) {
19
- if (classifiedPerm.classification === PermissionRiskLevel.BLOCKED) {
20
- result.violations.push({
21
- identifier,
22
- message: messages.getMessage('violations.permission-is-blocked'),
23
- });
24
- }
25
- else if (!permissionAllowedInPreset(classifiedPerm.classification, profile.preset)) {
26
- result.violations.push({
27
- identifier,
28
- message: messages.getMessage('violations.classification-preset-mismatch', [
29
- classifiedPerm.classification,
30
- profile.preset,
31
- ]),
32
- });
33
- }
34
- else if (classifiedPerm.classification === PermissionRiskLevel.UNKNOWN) {
35
- result.warnings.push({
36
- identifier,
37
- message: messages.getMessage('warnings.permission-unknown'),
38
- });
39
- }
40
- }
41
- else {
42
- result.warnings.push({
43
- identifier,
44
- message: messages.getMessage('warnings.permission-not-classified-in-profile'),
45
- });
46
- }
47
- });
48
- });
49
- return Promise.resolve(result);
50
- }
51
- }
52
- //# sourceMappingURL=enforceCustomPermsClassificationOnProfiles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enforceCustomPermsClassificationOnProfiles.js","sourceRoot":"","sources":["../../../../../src/libs/core/registries/rules/enforceCustomPermsClassificationOnProfiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,UAA2B,MAAM,iBAAiB,CAAC;AAC1D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,oCAAoC,EAAE,oCAAoC,CAAC,CAAC;AAEnH,MAAM,CAAC,OAAO,OAAO,0CAA2C,SAAQ,UAA2B;IACjG,YAAmB,IAAiB;QAClC,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,GAAG,CAAC,OAA0C;QACnD,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QACjC,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;QAClD,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAClD,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,iBAAiB,IAAI,EAAE,CAAC;YAC7D,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBAC3B,MAAM,UAAU,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC7C,MAAM,cAAc,GAAG,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC/D,IAAI,cAAc,EAAE,CAAC;oBACnB,IAAI,cAAc,CAAC,cAAc,KAAK,mBAAmB,CAAC,OAAO,EAAE,CAAC;wBAClE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC;4BACrB,UAAU;4BACV,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,kCAAkC,CAAC;yBACjE,CAAC,CAAC;oBACL,CAAC;yBAAM,IAAI,CAAC,yBAAyB,CAAC,cAAc,CAAC,cAAc,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;wBACrF,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC;4BACrB,UAAU;4BACV,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,2CAA2C,EAAE;gCACxE,cAAc,CAAC,cAAc;gCAC7B,OAAO,CAAC,MAAM;6BACf,CAAC;yBACH,CAAC,CAAC;oBACL,CAAC;yBAAM,IAAI,cAAc,CAAC,cAAc,KAAK,mBAAmB,CAAC,OAAO,EAAE,CAAC;wBACzE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;4BACnB,UAAU;4BACV,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,6BAA6B,CAAC;yBAC5D,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;wBACnB,UAAU;wBACV,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,+CAA+C,CAAC;qBAC9E,CAAC,CAAC;gBACL,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;CACF"}
@@ -1,7 +0,0 @@
1
- import { PartialPolicyRuleResult, RuleAuditContext } from '../types.js';
2
- import { ResolvedPermissionSet } from '../permissionSets.js';
3
- import PolicyRule, { RuleOptions } from './policyRule.js';
4
- export default class EnforceUserPermsClassificationOnPermSets extends PolicyRule<ResolvedPermissionSet> {
5
- constructor(opts: RuleOptions);
6
- run(context: RuleAuditContext<ResolvedPermissionSet>): Promise<PartialPolicyRuleResult>;
7
- }
@@ -1,52 +0,0 @@
1
- import { Messages } from '@salesforce/core';
2
- import { PermissionRiskLevel } from '../../classification-types.js';
3
- import { permissionAllowedInPreset } from '../../policy-types.js';
4
- import PolicyRule from './policyRule.js';
5
- const messages = Messages.loadMessages('@j-schreiber/sf-cli-security-audit', 'rules.enforceClassificationPresets');
6
- export default class EnforceUserPermsClassificationOnPermSets extends PolicyRule {
7
- constructor(opts) {
8
- super(opts);
9
- }
10
- run(context) {
11
- const result = this.initResult();
12
- const resolvedPermsets = context.resolvedEntities;
13
- Object.values(resolvedPermsets).forEach((permset) => {
14
- const userPerms = permset.metadata.userPermissions ?? [];
15
- userPerms.forEach((userPerm) => {
16
- const identifier = [permset.name, userPerm.name];
17
- const classifiedUserPerm = this.resolveUserPermission(userPerm.name);
18
- if (classifiedUserPerm) {
19
- if (classifiedUserPerm.classification === PermissionRiskLevel.BLOCKED) {
20
- result.violations.push({
21
- identifier,
22
- message: messages.getMessage('violations.permission-is-blocked'),
23
- });
24
- }
25
- else if (!permissionAllowedInPreset(classifiedUserPerm.classification, permset.preset)) {
26
- result.violations.push({
27
- identifier,
28
- message: messages.getMessage('violations.classification-preset-mismatch', [
29
- classifiedUserPerm.classification,
30
- permset.preset,
31
- ]),
32
- });
33
- }
34
- else if (classifiedUserPerm.classification === PermissionRiskLevel.UNKNOWN) {
35
- result.warnings.push({
36
- identifier,
37
- message: messages.getMessage('warnings.permission-unknown'),
38
- });
39
- }
40
- }
41
- else {
42
- result.warnings.push({
43
- identifier,
44
- message: messages.getMessage('warnings.permission-not-classified-in-permission-set'),
45
- });
46
- }
47
- });
48
- });
49
- return Promise.resolve(result);
50
- }
51
- }
52
- //# sourceMappingURL=enforceUserPermsClassificationOnPermSets.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enforceUserPermsClassification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AAC;yBACjE,CAAC,CAAC;oBACL,CAAC;yBAAM,IAAI,CAAC,yBAAyB,CAAC,kBAAkB,CAAC,cAAc,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;wBACzF,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC;4BACrB,UAAU;4BACV,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,2CAA2C,EAAE;gCACxE,kBAAkB,CAAC,cAAc;gCACjC,OAAO,CAAC,MAAM;6BACf,CAAC;yBACH,CAAC,CAAC;oBACL,CAAC;yBAAM,IAAI,kBAAkB,CAAC,cAAc,KAAK,mBAAmB,CAAC,OAAO,EAAE,CAAC;wBAC7E,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;4BACnB,UAAU;4BACV,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,6BAA6B,CAAC;yBAC5D,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;wBACnB,UAAU;wBACV,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,sDAAsD,CAAC;qBACrF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;CACF"}
@@ -1,7 +0,0 @@
1
- import { PartialPolicyRuleResult, RuleAuditContext } from '../types.js';
2
- import { ResolvedProfile } from '../profiles.js';
3
- import PolicyRule, { RuleOptions } from './policyRule.js';
4
- export default class EnforceUserPermsClassificationOnProfiles extends PolicyRule<ResolvedProfile> {
5
- constructor(opts: RuleOptions);
6
- run(context: RuleAuditContext<ResolvedProfile>): Promise<PartialPolicyRuleResult>;
7
- }
@@ -1,54 +0,0 @@
1
- import { Messages } from '@salesforce/core';
2
- import { isNullish } from '../../utils.js';
3
- import { PermissionRiskLevel } from '../../classification-types.js';
4
- import { permissionAllowedInPreset } from '../../policy-types.js';
5
- import PolicyRule from './policyRule.js';
6
- const messages = Messages.loadMessages('@j-schreiber/sf-cli-security-audit', 'rules.enforceClassificationPresets');
7
- export default class EnforceUserPermsClassificationOnProfiles extends PolicyRule {
8
- constructor(opts) {
9
- super(opts);
10
- }
11
- run(context) {
12
- const result = this.initResult();
13
- const resolvedProfiles = context.resolvedEntities;
14
- Object.values(resolvedProfiles).forEach((profile) => {
15
- if (!isNullish(profile.metadata.userPermissions)) {
16
- profile.metadata.userPermissions.forEach((userPerm) => {
17
- const identifier = [profile.name, userPerm.name];
18
- const classifiedUserPerm = this.resolveUserPermission(userPerm.name);
19
- if (classifiedUserPerm) {
20
- if (classifiedUserPerm.classification === PermissionRiskLevel.BLOCKED) {
21
- result.violations.push({
22
- identifier,
23
- message: messages.getMessage('violations.permission-is-blocked'),
24
- });
25
- }
26
- else if (!permissionAllowedInPreset(classifiedUserPerm.classification, profile.preset)) {
27
- result.violations.push({
28
- identifier,
29
- message: messages.getMessage('violations.classification-preset-mismatch', [
30
- classifiedUserPerm.classification,
31
- profile.preset,
32
- ]),
33
- });
34
- }
35
- else if (classifiedUserPerm.classification === PermissionRiskLevel.UNKNOWN) {
36
- result.warnings.push({
37
- identifier,
38
- message: messages.getMessage('warnings.permission-unknown'),
39
- });
40
- }
41
- }
42
- else {
43
- result.warnings.push({
44
- identifier,
45
- message: messages.getMessage('warnings.permission-not-classified-in-profile'),
46
- });
47
- }
48
- });
49
- }
50
- });
51
- return Promise.resolve(result);
52
- }
53
- }
54
- //# sourceMappingURL=enforceUserPermsClassificationOnProfiles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enforceUserPermsClassificationOnProfiles.js","sourceRoot":"","sources":["../../../../../src/libs/core/registries/rules/enforceUserPermsClassificationOnProfiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3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,CAAC,EAAE,CAAC;4BACzF,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC;gCACrB,UAAU;gCACV,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,2CAA2C,EAAE;oCACxE,kBAAkB,CAAC,cAAc;oCACjC,OAAO,CAAC,MAAM;iCACf,CAAC;6BACH,CAAC,CAAC;wBACL,CAAC;6BAAM,IAAI,kBAAkB,CAAC,cAAc,KAAK,mBAAmB,CAAC,OAAO,EAAE,CAAC;4BAC7E,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;gCACnB,UAAU;gCACV,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,6BAA6B,CAAC;6BAC5D,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC;yBAAM,CAAC;wBACN,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;4BACnB,UAAU;4BACV,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,+CAA+C,CAAC;yBAC9E,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;CACF"}
@@ -1,9 +0,0 @@
1
- import { NoInactiveUsersOptions } from '../../file-mgmt/schema.js';
2
- import { PartialPolicyRuleResult, RuleAuditContext } from '../types.js';
3
- import { ResolvedUser } from '../users.js';
4
- import PolicyRule, { ConfigurableRuleOptions } from './policyRule.js';
5
- export default class NoInactiveUsers extends PolicyRule<ResolvedUser> {
6
- private ruleConfig;
7
- constructor(localOpts: ConfigurableRuleOptions<NoInactiveUsersOptions>);
8
- run(context: RuleAuditContext<ResolvedUser>): Promise<PartialPolicyRuleResult>;
9
- }
@@ -1,44 +0,0 @@
1
- import { Messages } from '@salesforce/core';
2
- import { NoInactiveUsersOptionsSchema } from '../../file-mgmt/schema.js';
3
- import { differenceInDays } from '../../utils.js';
4
- import PolicyRule from './policyRule.js';
5
- Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
6
- const messages = Messages.loadMessages('@j-schreiber/sf-cli-security-audit', 'rules.users');
7
- export default class NoInactiveUsers extends PolicyRule {
8
- ruleConfig;
9
- constructor(localOpts) {
10
- super(localOpts);
11
- this.ruleConfig = NoInactiveUsersOptionsSchema.parse(localOpts.ruleConfig ?? {});
12
- }
13
- run(context) {
14
- const result = this.initResult();
15
- Object.values(context.resolvedEntities).forEach((user) => {
16
- if (user.lastLogin) {
17
- const diffInDays = differenceInDays(Date.now(), user.lastLogin);
18
- if (diffInDays > this.ruleConfig.daysAfterUserIsInactive) {
19
- result.violations.push({
20
- identifier: [user.username],
21
- message: messages.getMessage('violations.inactive-since-n-days', [
22
- diffInDays,
23
- new Date(user.lastLogin).toISOString(),
24
- ]),
25
- });
26
- }
27
- }
28
- });
29
- Object.values(context.resolvedEntities).forEach((user) => {
30
- if (!user.lastLogin) {
31
- const createdNDaysAgo = differenceInDays(Date.now(), user.createdDate);
32
- result.violations.push({
33
- identifier: [user.username],
34
- message: messages.getMessage('violations.has-never-logged-in', [
35
- new Date(user.createdDate).toISOString(),
36
- createdNDaysAgo,
37
- ]),
38
- });
39
- }
40
- });
41
- return Promise.resolve(result);
42
- }
43
- }
44
- //# sourceMappingURL=noInactiveUsers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"noInactiveUsers.js","sourceRoot":"","sources":["../../../../../src/libs/core/registries/rules/noInactiveUsers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAA0B,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAEjG,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,UAAuC,MAAM,iBAAiB,CAAC;AAEtE,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC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AC;gBACvE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC;oBACrB,UAAU,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC;oBAC3B,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,gCAAgC,EAAE;wBAC7D,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,WAAW,EAAE;wBACxC,eAAe;qBAChB,CAAC;iBACH,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;CACF"}
@@ -1,7 +0,0 @@
1
- import { PartialPolicyRuleResult, RuleAuditContext } from '../types.js';
2
- import { ResolvedUser } from '../users.js';
3
- import PolicyRule, { RuleOptions } from './policyRule.js';
4
- export default class NoOtherApexApiLogins extends PolicyRule<ResolvedUser> {
5
- constructor(opts: RuleOptions);
6
- run(context: RuleAuditContext<ResolvedUser>): Promise<PartialPolicyRuleResult>;
7
- }
@@ -1,24 +0,0 @@
1
- import { Messages } from '@salesforce/core';
2
- import PolicyRule from './policyRule.js';
3
- Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
4
- const messages = Messages.loadMessages('@j-schreiber/sf-cli-security-audit', 'rules.users');
5
- export default class NoOtherApexApiLogins extends PolicyRule {
6
- constructor(opts) {
7
- super(opts);
8
- }
9
- run(context) {
10
- const result = this.initResult();
11
- Object.values(context.resolvedEntities).forEach((user) => {
12
- user.logins.forEach((loginSummary) => {
13
- if (loginSummary.loginType === 'Other Apex API') {
14
- result.violations.push({
15
- identifier: [user.username],
16
- message: messages.getMessage('violations.no-other-apex-api-logins', [loginSummary.loginCount]),
17
- });
18
- }
19
- });
20
- });
21
- return Promise.resolve(result);
22
- }
23
- }
24
- //# sourceMappingURL=noOtherApexApiLogins.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"noOtherApexApiLogins.js","sourceRoot":"","sources":["../../../../../src/libs/core/registries/rules/noOtherApexApiLogins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,UAA2B,MAAM,iBAAiB,CAAC;AAE1D,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,oCAAoC,EAAE,aAAa,CAAC,CAAC;AAE5F,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,UAAwB;IACxE,YAAmB,IAAiB;QAClC,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,GAAG,CAAC,OAAuC;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QACjC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACvD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;gBACnC,IAAI,YAAY,CAAC,SAAS,KAAK,gBAAgB,EAAE,CAAC;oBAChD,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC;wBACrB,UAAU,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC;wBAC3B,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,qCAAqC,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;qBAC/F,CAAC,CAAC;gBACL,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;CACF"}
@@ -1,7 +0,0 @@
1
- import { PartialPolicyRuleResult, RuleAuditContext } from '../types.js';
2
- import { ResolvedConnectedApp } from '../connectedApps.js';
3
- import PolicyRule, { RuleOptions } from './policyRule.js';
4
- export default class NoUserCanSelfAuthorize extends PolicyRule<ResolvedConnectedApp> {
5
- constructor(opts: RuleOptions);
6
- run(context: RuleAuditContext<ResolvedConnectedApp>): Promise<PartialPolicyRuleResult>;
7
- }
@@ -1,31 +0,0 @@
1
- import { Messages } from '@salesforce/core';
2
- import PolicyRule from './policyRule.js';
3
- Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
4
- const messages = Messages.loadMessages('@j-schreiber/sf-cli-security-audit', 'rules.connectedApps');
5
- export default class NoUserCanSelfAuthorize extends PolicyRule {
6
- constructor(opts) {
7
- super(opts);
8
- }
9
- run(context) {
10
- const result = this.initResult();
11
- const resolvedConnectedApps = context.resolvedEntities;
12
- Object.values(resolvedConnectedApps).forEach((app) => {
13
- if (!app.onlyAdminApprovedUsersAllowed) {
14
- if (app.overrideByApiSecurityAccess) {
15
- result.warnings.push({
16
- identifier: [app.name],
17
- message: messages.getMessage('warnings.users-can-self-authorize-but-setting-overrides'),
18
- });
19
- }
20
- else {
21
- result.violations.push({
22
- identifier: [app.name],
23
- message: messages.getMessage('violations.users-can-self-authorize'),
24
- });
25
- }
26
- }
27
- });
28
- return Promise.resolve(result);
29
- }
30
- }
31
- //# sourceMappingURL=noUserCanSelfAuthorize.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"noUserCanSelfAuthorize.js","sourceRoot":"","sources":["../../../../../src/libs/core/registries/rules/noUserCanSelfAuthorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,UAA2B,MAAM,iBAAiB,CAAC;AAE1D,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,oCAAoC,EAAE,qBAAqB,CAAC,CAAC;AAEpG,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,UAAgC;IAClF,YAAmB,IAAiB;QAClC,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,GAAG,CAAC,OAA+C;QACxD,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QACjC,MAAM,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC;QACvD,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACnD,IAAI,CAAC,GAAG,CAAC,6BAA6B,EAAE,CAAC;gBACvC,IAAI,GAAG,CAAC,2BAA2B,EAAE,CAAC;oBACpC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;wBACnB,UAAU,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC;wBACtB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,yDAAyD,CAAC;qBACxF,CAAC,CAAC;gBACL,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC;wBACrB,UAAU,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC;wBACtB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,qCAAqC,CAAC;qBACpE,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;CACF"}
@@ -1,19 +0,0 @@
1
- import { PartialPolicyRuleResult, RowLevelPolicyRule, RuleAuditContext } from '../types.js';
2
- import { AuditRunConfig, NamedPermissionsClassification } from '../../file-mgmt/schema.js';
3
- export type RuleOptions = {
4
- auditContext: AuditRunConfig;
5
- ruleDisplayName: string;
6
- };
7
- export type ConfigurableRuleOptions<T> = RuleOptions & {
8
- ruleConfig: T;
9
- };
10
- export default abstract class PolicyRule<EntityType> implements RowLevelPolicyRule<EntityType> {
11
- protected opts: RuleOptions;
12
- auditContext: AuditRunConfig;
13
- ruleDisplayName: string;
14
- constructor(opts: RuleOptions);
15
- protected initResult(): PartialPolicyRuleResult;
16
- protected resolveUserPermission(permName: string): NamedPermissionsClassification | undefined;
17
- protected resolveCustomPermission(permName: string): NamedPermissionsClassification | undefined;
18
- abstract run(context: RuleAuditContext<EntityType>): Promise<PartialPolicyRuleResult>;
19
- }
@@ -1,31 +0,0 @@
1
- import { Messages } from '@salesforce/core';
2
- Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
3
- export default class PolicyRule {
4
- opts;
5
- auditContext;
6
- ruleDisplayName;
7
- constructor(opts) {
8
- this.opts = opts;
9
- this.auditContext = opts.auditContext;
10
- this.ruleDisplayName = opts.ruleDisplayName;
11
- }
12
- initResult() {
13
- return {
14
- ruleName: this.ruleDisplayName,
15
- violations: new Array(),
16
- mutedViolations: new Array(),
17
- warnings: new Array(),
18
- errors: new Array(),
19
- };
20
- }
21
- resolveUserPermission(permName) {
22
- return nameClassification(permName, this.auditContext.classifications.userPermissions?.content.permissions[permName]);
23
- }
24
- resolveCustomPermission(permName) {
25
- return nameClassification(permName, this.auditContext.classifications.customPermissions?.content.permissions[permName]);
26
- }
27
- }
28
- function nameClassification(permName, perm) {
29
- return perm ? { name: permName, ...perm } : undefined;
30
- }
31
- //# sourceMappingURL=policyRule.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"policyRule.js","sourceRoot":"","sources":["../../../../../src/libs/core/registries/rules/policyRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAK5C,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAW7D,MAAM,CAAC,OAAO,OAAgB,UAAU;IAIT;IAHtB,YAAY,CAAiB;IAC7B,eAAe,CAAS;IAE/B,YAA6B,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;QAC5C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QACtC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;IAC9C,CAAC;IAES,UAAU;QAClB,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,eAAe;YAC9B,UAAU,EAAE,IAAI,KAAK,EAAuB;YAC5C,eAAe,EAAE,IAAI,KAAK,EAA2B;YACrD,QAAQ,EAAE,IAAI,KAAK,EAAwB;YAC3C,MAAM,EAAE,IAAI,KAAK,EAAwB;SAC1C,CAAC;IACJ,CAAC;IAES,qBAAqB,CAAC,QAAgB;QAC9C,OAAO,kBAAkB,CACvB,QAAQ,EACR,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,eAAe,EAAE,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CACjF,CAAC;IACJ,CAAC;IAES,uBAAuB,CAAC,QAAgB;QAChD,OAAO,kBAAkB,CACvB,QAAQ,EACR,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,iBAAiB,EAAE,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CACnF,CAAC;IACJ,CAAC;CAGF;AAED,SAAS,kBAAkB,CACzB,QAAgB,EAChB,IAAgC;IAEhC,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACxD,CAAC"}
@@ -1,37 +0,0 @@
1
- import { Connection } from '@salesforce/core';
2
- import { AuditPolicyResult, PolicyRuleExecutionResult } from '../result-types.js';
3
- import { Optional } from '../utils.js';
4
- export declare const RuleRegistries: {
5
- ConnectedApps: import("./connectedApps.js").default;
6
- Profiles: import("./profiles.js").default;
7
- PermissionSets: import("./permissionSets.js").default;
8
- Users: import("./users.js").default;
9
- };
10
- export type Constructor<T, Args extends any[] = any[]> = new (...args: Args) => T;
11
- /**
12
- * A rule must only implement a subset of the rule result. All optional
13
- * properties are completed by the policy.
14
- */
15
- export type PartialPolicyRuleResult = Optional<PolicyRuleExecutionResult, 'isCompliant' | 'compliantEntities' | 'violatedEntities'>;
16
- /**
17
- *
18
- */
19
- export type RowLevelPolicyRule<ResolvedEntityType> = {
20
- run(context: RuleAuditContext<ResolvedEntityType>): Promise<PartialPolicyRuleResult>;
21
- };
22
- export type IPolicy = {
23
- run(context: AuditContext): Promise<AuditPolicyResult>;
24
- };
25
- export type AuditContext = {
26
- /**
27
- * Connection to the target org
28
- */
29
- targetOrgConnection: Connection;
30
- };
31
- export type RuleAuditContext<T> = AuditContext & {
32
- /**
33
- * Resolved entities from the policy. Can be permission sets,
34
- * profiles, users, connected apps, etc.
35
- */
36
- resolvedEntities: Record<string, T>;
37
- };
@@ -1,11 +0,0 @@
1
- import { ConnectedAppsRegistry } from './connectedApps.js';
2
- import { PermissionSetsRegistry } from './permissionSets.js';
3
- import { ProfilesRegistry } from './profiles.js';
4
- import { UsersRegistry } from './users.js';
5
- export const RuleRegistries = {
6
- ConnectedApps: ConnectedAppsRegistry,
7
- Profiles: ProfilesRegistry,
8
- PermissionSets: PermissionSetsRegistry,
9
- Users: UsersRegistry,
10
- };
11
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/libs/core/registries/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,aAAa,EAAE,qBAAqB;IACpC,QAAQ,EAAE,gBAAgB;IAC1B,cAAc,EAAE,sBAAsB;IACtC,KAAK,EAAE,aAAa;CACrB,CAAC"}
@@ -1,26 +0,0 @@
1
- import { ProfilesRiskPreset } from '../policy-types.js';
2
- import RuleRegistry from './ruleRegistry.js';
3
- export type ResolvedUser = {
4
- userId: string;
5
- username: string;
6
- role: ProfilesRiskPreset;
7
- assignedPermissionSets: UserPermissionSetAssignment[];
8
- logins: UserLogins[];
9
- assignedProfile: string;
10
- createdDate: number;
11
- lastLogin?: number;
12
- };
13
- type UserLogins = {
14
- loginType: string;
15
- application: string;
16
- loginCount: number;
17
- lastLogin: number;
18
- };
19
- type UserPermissionSetAssignment = {
20
- permissionSetIdentifier: string;
21
- };
22
- export default class UsersRuleRegistry extends RuleRegistry {
23
- constructor();
24
- }
25
- export declare const UsersRegistry: UsersRuleRegistry;
26
- export {};
@@ -1,10 +0,0 @@
1
- import RuleRegistry from './ruleRegistry.js';
2
- import NoInactiveUsers from './rules/noInactiveUsers.js';
3
- import NoOtherApexApiLogins from './rules/noOtherApexApiLogins.js';
4
- export default class UsersRuleRegistry extends RuleRegistry {
5
- constructor() {
6
- super({ NoOtherApexApiLogins, NoInactiveUsers });
7
- }
8
- }
9
- export const UsersRegistry = new UsersRuleRegistry();
10
- //# sourceMappingURL=users.js.map