@j-schreiber/sf-cli-security-audit 0.4.0 → 0.5.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 (148) hide show
  1. package/README.md +20 -5
  2. package/lib/commands/org/audit/init.d.ts +3 -1
  3. package/lib/commands/org/audit/init.js +12 -2
  4. package/lib/commands/org/audit/init.js.map +1 -1
  5. package/lib/commands/org/audit/run.d.ts +1 -1
  6. package/lib/libs/{policies/initialisation → conf-init}/auditConfig.d.ts +9 -1
  7. package/lib/libs/{policies/initialisation → conf-init}/auditConfig.js +4 -6
  8. package/lib/libs/conf-init/auditConfig.js.map +1 -0
  9. package/lib/libs/{policies/initialisation → conf-init}/permissionsClassification.d.ts +4 -4
  10. package/lib/libs/conf-init/permissionsClassification.js +80 -0
  11. package/lib/libs/conf-init/permissionsClassification.js.map +1 -0
  12. package/lib/libs/{policies/initialisation → conf-init}/policyConfigs.d.ts +1 -1
  13. package/lib/libs/{policies/initialisation → conf-init}/policyConfigs.js +8 -10
  14. package/lib/libs/conf-init/policyConfigs.js.map +1 -0
  15. package/lib/libs/conf-init/presets/loose.d.ts +6 -0
  16. package/lib/libs/conf-init/presets/loose.js +35 -0
  17. package/lib/libs/conf-init/presets/loose.js.map +1 -0
  18. package/lib/libs/conf-init/presets/none.d.ts +30 -0
  19. package/lib/libs/conf-init/presets/none.js +54 -0
  20. package/lib/libs/conf-init/presets/none.js.map +1 -0
  21. package/lib/libs/conf-init/presets/strict.d.ts +4 -0
  22. package/lib/libs/conf-init/presets/strict.js +28 -0
  23. package/lib/libs/conf-init/presets/strict.js.map +1 -0
  24. package/lib/libs/conf-init/presets.d.ts +7 -0
  25. package/lib/libs/conf-init/presets.js +20 -0
  26. package/lib/libs/conf-init/presets.js.map +1 -0
  27. package/lib/libs/core/classification-types.d.ts +20 -0
  28. package/lib/libs/core/classification-types.js +23 -0
  29. package/lib/libs/core/classification-types.js.map +1 -0
  30. package/lib/libs/{config/queries.js → core/constants.js} +1 -1
  31. package/lib/libs/core/constants.js.map +1 -0
  32. package/lib/libs/{config/audit-run → core/file-mgmt}/auditConfigFileManager.d.ts +19 -0
  33. package/lib/libs/{config/audit-run → core/file-mgmt}/auditConfigFileManager.js +22 -7
  34. package/lib/libs/core/file-mgmt/auditConfigFileManager.js.map +1 -0
  35. package/lib/libs/{config/audit-run → core/file-mgmt}/schema.d.ts +10 -9
  36. package/lib/libs/{config/audit-run → core/file-mgmt}/schema.js +4 -3
  37. package/lib/libs/core/file-mgmt/schema.js.map +1 -0
  38. package/lib/libs/core/mdapi/mdapiRetriever.d.ts +52 -0
  39. package/lib/libs/core/mdapi/mdapiRetriever.js +116 -0
  40. package/lib/libs/core/mdapi/mdapiRetriever.js.map +1 -0
  41. package/lib/libs/core/mdapi/metadataRegistryEntry.d.ts +39 -0
  42. package/lib/libs/core/mdapi/metadataRegistryEntry.js +31 -0
  43. package/lib/libs/core/mdapi/metadataRegistryEntry.js.map +1 -0
  44. package/lib/libs/core/mdapi/namedMetadataToolingQueryable.d.ts +33 -0
  45. package/lib/libs/core/mdapi/namedMetadataToolingQueryable.js +41 -0
  46. package/lib/libs/core/mdapi/namedMetadataToolingQueryable.js.map +1 -0
  47. package/lib/libs/core/mdapi/namedMetadataType.d.ts +20 -0
  48. package/lib/libs/core/mdapi/namedMetadataType.js +36 -0
  49. package/lib/libs/core/mdapi/namedMetadataType.js.map +1 -0
  50. package/lib/libs/core/mdapi/singletonMetadataType.d.ts +21 -0
  51. package/lib/libs/core/mdapi/singletonMetadataType.js +35 -0
  52. package/lib/libs/core/mdapi/singletonMetadataType.js.map +1 -0
  53. package/lib/libs/core/policy-types.d.ts +18 -0
  54. package/lib/libs/core/policy-types.js +28 -0
  55. package/lib/libs/core/policy-types.js.map +1 -0
  56. package/lib/libs/core/registries/connectedApps.d.ts +13 -0
  57. package/lib/libs/{config → core}/registries/connectedApps.js +2 -2
  58. package/lib/libs/core/registries/connectedApps.js.map +1 -0
  59. package/lib/libs/{config → core}/registries/permissionSets.d.ts +6 -0
  60. package/lib/libs/{config → core}/registries/permissionSets.js +1 -1
  61. package/lib/libs/core/registries/permissionSets.js.map +1 -0
  62. package/lib/libs/{config → core}/registries/profiles.d.ts +6 -0
  63. package/lib/libs/{config → core}/registries/profiles.js +2 -2
  64. package/lib/libs/core/registries/profiles.js.map +1 -0
  65. package/lib/libs/{config → core}/registries/ruleRegistry.d.ts +13 -3
  66. package/lib/libs/core/registries/ruleRegistry.js.map +1 -0
  67. package/lib/libs/{policies → core/registries}/rules/allUsedAppsUnderManagement.d.ts +2 -2
  68. package/lib/libs/core/registries/rules/allUsedAppsUnderManagement.js.map +1 -0
  69. package/lib/libs/{policies → core/registries}/rules/enforceCustomPermsClassificationOnProfiles.d.ts +2 -2
  70. package/lib/libs/{policies → core/registries}/rules/enforceCustomPermsClassificationOnProfiles.js +4 -3
  71. package/lib/libs/core/registries/rules/enforceCustomPermsClassificationOnProfiles.js.map +1 -0
  72. package/lib/libs/{policies → core/registries}/rules/enforceUserPermsClassificationOnPermSets.d.ts +2 -2
  73. package/lib/libs/{policies → core/registries}/rules/enforceUserPermsClassificationOnPermSets.js +4 -3
  74. package/lib/libs/core/registries/rules/enforceUserPermsClassificationOnPermSets.js.map +1 -0
  75. package/lib/libs/{policies → core/registries}/rules/enforceUserPermsClassificationOnProfiles.d.ts +2 -2
  76. package/lib/libs/{policies → core/registries}/rules/enforceUserPermsClassificationOnProfiles.js +4 -3
  77. package/lib/libs/core/registries/rules/enforceUserPermsClassificationOnProfiles.js.map +1 -0
  78. package/lib/libs/{policies → core/registries}/rules/noUserCanSelfAuthorize.d.ts +2 -2
  79. package/lib/libs/core/registries/rules/noUserCanSelfAuthorize.js.map +1 -0
  80. package/lib/libs/{policies → core/registries}/rules/policyRule.d.ts +2 -2
  81. package/lib/libs/core/registries/rules/policyRule.js.map +1 -0
  82. package/lib/libs/{policies/interfaces/policyRuleInterfaces.d.ts → core/registries/types.d.ts} +7 -2
  83. package/lib/libs/core/registries/types.js +9 -0
  84. package/lib/libs/core/registries/types.js.map +1 -0
  85. package/lib/libs/{audit/types.d.ts → core/result-types.d.ts} +17 -0
  86. package/lib/libs/core/result-types.js +2 -0
  87. package/lib/libs/core/result-types.js.map +1 -0
  88. package/lib/libs/core/utils.js.map +1 -0
  89. package/lib/libs/policies/auditRun.d.ts +2 -2
  90. package/lib/libs/policies/auditRun.js +2 -2
  91. package/lib/libs/policies/auditRun.js.map +1 -1
  92. package/lib/libs/policies/connectedAppPolicy.d.ts +3 -12
  93. package/lib/libs/policies/connectedAppPolicy.js +6 -6
  94. package/lib/libs/policies/connectedAppPolicy.js.map +1 -1
  95. package/lib/libs/policies/permissionSetPolicy.d.ts +3 -10
  96. package/lib/libs/policies/permissionSetPolicy.js +17 -16
  97. package/lib/libs/policies/permissionSetPolicy.js.map +1 -1
  98. package/lib/libs/policies/policy.d.ts +4 -5
  99. package/lib/libs/policies/policy.js.map +1 -1
  100. package/lib/libs/policies/profilePolicy.d.ts +3 -10
  101. package/lib/libs/policies/profilePolicy.js +24 -31
  102. package/lib/libs/policies/profilePolicy.js.map +1 -1
  103. package/messages/org.audit.init.md +12 -0
  104. package/messages/policyclassifications.md +38 -2
  105. package/oclif.manifest.json +18 -2
  106. package/package.json +1 -1
  107. package/lib/libs/audit/types.js +0 -2
  108. package/lib/libs/audit/types.js.map +0 -1
  109. package/lib/libs/config/audit-run/auditConfigFileManager.js.map +0 -1
  110. package/lib/libs/config/audit-run/schema.js.map +0 -1
  111. package/lib/libs/config/defaultPolicyClassification.d.ts +0 -2
  112. package/lib/libs/config/defaultPolicyClassification.js +0 -63
  113. package/lib/libs/config/defaultPolicyClassification.js.map +0 -1
  114. package/lib/libs/config/queries.js.map +0 -1
  115. package/lib/libs/config/registries/connectedApps.d.ts +0 -5
  116. package/lib/libs/config/registries/connectedApps.js.map +0 -1
  117. package/lib/libs/config/registries/permissionSets.js.map +0 -1
  118. package/lib/libs/config/registries/profiles.js.map +0 -1
  119. package/lib/libs/config/registries/ruleRegistry.js.map +0 -1
  120. package/lib/libs/config/registries/types.d.ts +0 -7
  121. package/lib/libs/config/registries/types.js +0 -2
  122. package/lib/libs/config/registries/types.js.map +0 -1
  123. package/lib/libs/mdapiRetriever.d.ts +0 -18
  124. package/lib/libs/mdapiRetriever.js +0 -60
  125. package/lib/libs/mdapiRetriever.js.map +0 -1
  126. package/lib/libs/policies/initialisation/auditConfig.js.map +0 -1
  127. package/lib/libs/policies/initialisation/permissionsClassification.js +0 -71
  128. package/lib/libs/policies/initialisation/permissionsClassification.js.map +0 -1
  129. package/lib/libs/policies/initialisation/policyConfigs.js.map +0 -1
  130. package/lib/libs/policies/interfaces/policyRuleInterfaces.js +0 -2
  131. package/lib/libs/policies/interfaces/policyRuleInterfaces.js.map +0 -1
  132. package/lib/libs/policies/rules/allUsedAppsUnderManagement.js.map +0 -1
  133. package/lib/libs/policies/rules/enforceCustomPermsClassificationOnProfiles.js.map +0 -1
  134. package/lib/libs/policies/rules/enforceUserPermsClassificationOnPermSets.js.map +0 -1
  135. package/lib/libs/policies/rules/enforceUserPermsClassificationOnProfiles.js.map +0 -1
  136. package/lib/libs/policies/rules/noUserCanSelfAuthorize.js.map +0 -1
  137. package/lib/libs/policies/rules/policyRule.js.map +0 -1
  138. package/lib/libs/policies/types.d.ts +0 -36
  139. package/lib/libs/policies/types.js +0 -45
  140. package/lib/libs/policies/types.js.map +0 -1
  141. package/lib/libs/utils.js.map +0 -1
  142. /package/lib/libs/{config/queries.d.ts → core/constants.d.ts} +0 -0
  143. /package/lib/libs/{config → core}/registries/ruleRegistry.js +0 -0
  144. /package/lib/libs/{policies → core/registries}/rules/allUsedAppsUnderManagement.js +0 -0
  145. /package/lib/libs/{policies → core/registries}/rules/noUserCanSelfAuthorize.js +0 -0
  146. /package/lib/libs/{policies → core/registries}/rules/policyRule.js +0 -0
  147. /package/lib/libs/{utils.d.ts → core/utils.d.ts} +0 -0
  148. /package/lib/libs/{utils.js → core/utils.js} +0 -0
package/README.md CHANGED
@@ -38,12 +38,15 @@ Initialises classifications and policies for a security audit.
38
38
 
39
39
  ```
40
40
  USAGE
41
- $ sf org audit init -o <value> [--json] [--flags-dir <value>] [-d <value>] [--api-version <value>]
41
+ $ sf org audit init -o <value> [--json] [--flags-dir <value>] [-d <value>] [-p strict|loose|none] [--api-version
42
+ <value>]
42
43
 
43
44
  FLAGS
44
45
  -d, --output-dir=<value> Directory where the audit config is initialised. If not set, the root directory will be
45
46
  used.
46
47
  -o, --target-org=<value> (required) Target org to export permissions, profiles, users, etc.
48
+ -p, --preset=<option> [default: strict] Select a preset to initialise permission classifications (risk levels).
49
+ <options: strict|loose|none>
47
50
  --api-version=<value> Override the api version used for api requests made by this command
48
51
 
49
52
  GLOBAL FLAGS
@@ -60,9 +63,21 @@ EXAMPLES
60
63
  Initialise audit policies at the root directory
61
64
 
62
65
  $ sf org audit init -o MyTargetOrg
66
+
67
+ Initialise audit config at custom directory with preset
68
+
69
+ $ sf org audit init -o MyTargetOrg -d my_dir -p loose
70
+
71
+ FLAG DESCRIPTIONS
72
+ -p, --preset=strict|loose|none Select a preset to initialise permission classifications (risk levels).
73
+
74
+ The selected preset is applied before any other default mechanisms (such as template configs). This means, values
75
+ from a selected template override the preset. Consult the documentation to learn more about the rationale behind the
76
+ default risk levels. The risk levels interact with the configured preset on profiles and permission sets and
77
+ essentially control, if a permission is allowed in a certain profile / permission set.
63
78
  ```
64
79
 
65
- _See code: [src/commands/org/audit/init.ts](https://github.com/j-schreiber/js-sf-cli-security-audit/blob/v0.1.0/src/commands/org/audit/init.ts)_
80
+ _See code: [src/commands/org/audit/init.ts](https://github.com/j-schreiber/js-sf-cli-security-audit/blob/v0.4.1/src/commands/org/audit/init.ts)_
66
81
 
67
82
  ## `sf org audit run`
68
83
 
@@ -70,10 +85,10 @@ Audit your org.
70
85
 
71
86
  ```
72
87
  USAGE
73
- $ sf org audit run -o <value> -d <value> [--json] [--flags-dir <value>] [--api-version <value>]
88
+ $ sf org audit run -o <value> [--json] [--flags-dir <value>] [-d <value>] [--api-version <value>]
74
89
 
75
90
  FLAGS
76
- -d, --source-dir=<value> (required) Location of the audit config.
91
+ -d, --source-dir=<value> Location of the audit config.
77
92
  -o, --target-org=<value> (required) The org that is audited.
78
93
  --api-version=<value> Override the api version used for api requests made by this command
79
94
 
@@ -93,7 +108,7 @@ EXAMPLES
93
108
  $ sf org audit run -o MyTargetOrg -d configs/prod
94
109
  ```
95
110
 
96
- _See code: [src/commands/org/audit/run.ts](https://github.com/j-schreiber/js-sf-cli-security-audit/blob/v0.1.0/src/commands/org/audit/run.ts)_
111
+ _See code: [src/commands/org/audit/run.ts](https://github.com/j-schreiber/js-sf-cli-security-audit/blob/v0.4.1/src/commands/org/audit/run.ts)_
97
112
 
98
113
  <!-- commandsstop -->
99
114
 
@@ -1,5 +1,6 @@
1
1
  import { SfCommand } from '@salesforce/sf-plugins-core';
2
- import { AuditRunConfig } from '../../../libs/config/audit-run/schema.js';
2
+ import { AuditRunConfig } from '../../../libs/core/file-mgmt/schema.js';
3
+ import { AuditInitPresets } from '../../../libs/conf-init/presets.js';
3
4
  export type OrgAuditInitResult = AuditRunConfig;
4
5
  export default class OrgAuditInit extends SfCommand<OrgAuditInitResult> {
5
6
  static readonly summary: string;
@@ -8,6 +9,7 @@ export default class OrgAuditInit extends SfCommand<OrgAuditInitResult> {
8
9
  static readonly flags: {
9
10
  'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
10
11
  'output-dir': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
+ preset: import("@oclif/core/interfaces").OptionFlag<AuditInitPresets, import("@oclif/core/interfaces").CustomOptions>;
11
13
  'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
14
  };
13
15
  run(): Promise<OrgAuditInitResult>;
@@ -1,9 +1,17 @@
1
1
  import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
2
2
  import { Messages } from '@salesforce/core';
3
- import AuditConfig from '../../../libs/policies/initialisation/auditConfig.js';
4
- import { isPermissionsConfig, isPolicyConfig, } from '../../../libs/config/audit-run/schema.js';
3
+ import AuditConfig from '../../../libs/conf-init/auditConfig.js';
4
+ import { isPermissionsConfig, isPolicyConfig, } from '../../../libs/core/file-mgmt/schema.js';
5
+ import { AuditInitPresets } from '../../../libs/conf-init/presets.js';
5
6
  Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
6
7
  const messages = Messages.loadMessages('@j-schreiber/sf-cli-security-audit', 'org.audit.init');
8
+ const presetFlag = Flags.custom({
9
+ char: 'p',
10
+ summary: messages.getMessage('flags.preset.summary'),
11
+ description: messages.getMessage('flags.preset.description'),
12
+ options: Object.values(AuditInitPresets),
13
+ default: AuditInitPresets.strict,
14
+ })();
7
15
  export default class OrgAuditInit extends SfCommand {
8
16
  static summary = messages.getMessage('summary');
9
17
  static description = messages.getMessage('description');
@@ -20,12 +28,14 @@ export default class OrgAuditInit extends SfCommand {
20
28
  summary: messages.getMessage('flags.output-dir.summary'),
21
29
  default: '',
22
30
  }),
31
+ preset: presetFlag,
23
32
  'api-version': Flags.orgApiVersion(),
24
33
  };
25
34
  async run() {
26
35
  const { flags } = await this.parse(OrgAuditInit);
27
36
  const auditConfig = await AuditConfig.init(flags['target-org'].getConnection(flags['api-version']), {
28
37
  targetDir: flags['output-dir'],
38
+ preset: flags.preset,
29
39
  });
30
40
  this.printResults(auditConfig);
31
41
  return auditConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../src/commands/org/audit/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,WAAW,MAAM,sDAAsD,CAAC;AAC/E,OAAO,EAIL,mBAAmB,EACnB,cA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C,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACrF,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACrB,IAAI,CAAC,UAAU,CACb,QAAQ,CAAC,UAAU,CAAC,qCAAqC,EAAE,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAC9F,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,aAAa,CAAC,QAAgC;QACpD,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE;YAC/C,IAAI,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;gBACxB,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;oBACjB,IAAI,CAAC,UAAU,CACb,QAAQ,CAAC,UAAU,CAAC,wBAAwB,EAAE;wBAC5C,IAAI;wBACJ,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,IAAI,CAAC;wBAC1C,GAAG,CAAC,QAAQ;qBACb,CAAC,CACH,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { Interfaces } from '@oclif/core';
2
2
  import { SfCommand } from '@salesforce/sf-plugins-core';
3
- import { AuditResult } from '../../../libs/audit/types.js';
3
+ import { AuditResult } from '../../../libs/core/result-types.js';
4
4
  export type OrgAuditRunResult = AuditResult & {
5
5
  filePath: string;
6
6
  };
@@ -1,10 +1,18 @@
1
1
  import { Connection } from '@salesforce/core';
2
- import { AuditRunConfig } from '../../config/audit-run/schema.js';
2
+ import { AuditRunConfig } from '../core/file-mgmt/schema.js';
3
+ import { AuditInitPresets } from './presets.js';
3
4
  /**
4
5
  * Additional options how the config should be initialised.
5
6
  */
6
7
  export type AuditInitOptions = {
8
+ /**
9
+ * When set, config files are created at the target location.
10
+ */
7
11
  targetDir?: string;
12
+ /**
13
+ * An optional preset to initialise classifications and policies.
14
+ */
15
+ preset?: AuditInitPresets;
8
16
  };
9
17
  /**
10
18
  * Exposes key functionality to load an audit config as static methods. This makes
@@ -1,4 +1,4 @@
1
- import AuditConfigFileManager from '../../config/audit-run/auditConfigFileManager.js';
1
+ import { DefaultFileManager } from '../core/file-mgmt/auditConfigFileManager.js';
2
2
  import { initCustomPermissions, initUserPermissions } from './permissionsClassification.js';
3
3
  import { initConnectedApps, initPermissionSets, initProfiles } from './policyConfigs.js';
4
4
  /**
@@ -13,9 +13,8 @@ export default class AuditConfig {
13
13
  * @param con
14
14
  */
15
15
  static async init(targetCon, opts) {
16
- const fileManager = new AuditConfigFileManager();
17
16
  const conf = { classifications: {}, policies: {} };
18
- conf.classifications.userPermissions = { content: await initUserPermissions(targetCon) };
17
+ conf.classifications.userPermissions = { content: await initUserPermissions(targetCon, opts?.preset) };
19
18
  const customPerms = await initCustomPermissions(targetCon);
20
19
  if (customPerms) {
21
20
  conf.classifications.customPermissions = { content: customPerms };
@@ -24,7 +23,7 @@ export default class AuditConfig {
24
23
  conf.policies.PermissionSets = { content: await initPermissionSets(targetCon) };
25
24
  conf.policies.ConnectedApps = { content: initConnectedApps() };
26
25
  if (opts?.targetDir) {
27
- fileManager.save(opts.targetDir, conf);
26
+ DefaultFileManager.save(opts.targetDir, conf);
28
27
  }
29
28
  return conf;
30
29
  }
@@ -34,8 +33,7 @@ export default class AuditConfig {
34
33
  * @param sourceDir
35
34
  */
36
35
  static load(sourceDir) {
37
- const fileManager = new AuditConfigFileManager();
38
- return fileManager.parse(sourceDir);
36
+ return DefaultFileManager.parse(sourceDir);
39
37
  }
40
38
  }
41
39
  //# sourceMappingURL=auditConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auditConfig.js","sourceRoot":"","sources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CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,IAAI,CAAC,SAAiB;QAClC,OAAO,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;CACF"}
@@ -1,12 +1,13 @@
1
1
  import { Connection } from '@salesforce/core';
2
- import { NamedPermissionsClassification, PermissionsConfig } from '../../config/audit-run/schema.js';
2
+ import { PermissionsConfig } from '../core/file-mgmt/schema.js';
3
+ import { AuditInitPresets } from './presets.js';
3
4
  /**
4
- * Initialises a fresh set of user permissions from target org connection
5
+ * Initialises a fresh set of user permissions from target org connection.
5
6
  *
6
7
  * @param con
7
8
  * @returns
8
9
  */
9
- export declare function initUserPermissions(con: Connection): Promise<PermissionsConfig>;
10
+ export declare function initUserPermissions(con: Connection, preset?: AuditInitPresets): Promise<PermissionsConfig>;
10
11
  /**
11
12
  * Initialises a fresh set of custom permissions from the target org
12
13
  *
@@ -14,4 +15,3 @@ export declare function initUserPermissions(con: Connection): Promise<Permission
14
15
  * @returns
15
16
  */
16
17
  export declare function initCustomPermissions(con: Connection): Promise<PermissionsConfig | undefined>;
17
- export declare const classificationSorter: (a: NamedPermissionsClassification, b: NamedPermissionsClassification) => number;
@@ -0,0 +1,80 @@
1
+ import { CUSTOM_PERMS_QUERY, PROFILES_QUERY } from '../core/constants.js';
2
+ import MDAPI from '../core/mdapi/mdapiRetriever.js';
3
+ import { classificationSorter, PermissionRiskLevel } from '../core/classification-types.js';
4
+ import { loadPreset } from './presets.js';
5
+ /**
6
+ * Initialises a fresh set of user permissions from target org connection.
7
+ *
8
+ * @param con
9
+ * @returns
10
+ */
11
+ export async function initUserPermissions(con, preset) {
12
+ const describePerms = await parsePermsFromDescribe(con);
13
+ const assignedPerms = await findAssignedPerms(con);
14
+ const allPerms = { ...describePerms, ...assignedPerms };
15
+ const presConfig = loadPreset(preset);
16
+ const perms = presConfig.classifyUserPermissions(Object.values(allPerms));
17
+ perms.sort(classificationSorter);
18
+ const result = { permissions: {} };
19
+ perms.forEach((perm) => (result.permissions[perm.name] = {
20
+ label: sanitiseLabel(perm.label),
21
+ classification: perm.classification,
22
+ reason: perm.reason,
23
+ }));
24
+ return result;
25
+ }
26
+ /**
27
+ * Initialises a fresh set of custom permissions from the target org
28
+ *
29
+ * @param con
30
+ * @returns
31
+ */
32
+ export async function initCustomPermissions(con) {
33
+ const result = { permissions: {} };
34
+ const customPerms = await con.query(CUSTOM_PERMS_QUERY);
35
+ if (customPerms.records.length === 0) {
36
+ return undefined;
37
+ }
38
+ const perms = customPerms.records.map((cp) => ({
39
+ name: cp.DeveloperName,
40
+ label: cp.MasterLabel,
41
+ classification: PermissionRiskLevel.UNKNOWN,
42
+ }));
43
+ perms.forEach((perm) => (result.permissions[perm.name] = {
44
+ label: perm.label,
45
+ classification: perm.classification,
46
+ }));
47
+ return result;
48
+ }
49
+ async function parsePermsFromDescribe(con) {
50
+ const permSet = await con.describe('PermissionSet');
51
+ const describeAvailablePerms = {};
52
+ permSet.fields
53
+ .filter((field) => field.name.startsWith('Permissions'))
54
+ .forEach((field) => {
55
+ const permName = field.name.replace('Permissions', '');
56
+ describeAvailablePerms[permName] = {
57
+ label: field.label,
58
+ name: permName,
59
+ };
60
+ });
61
+ return describeAvailablePerms;
62
+ }
63
+ async function findAssignedPerms(con) {
64
+ const assignedPerms = {};
65
+ const profiles = await con.query(PROFILES_QUERY);
66
+ if (profiles.records?.length > 0) {
67
+ const mdapi = new MDAPI(con);
68
+ const resolvedProfiles = await mdapi.resolve('Profile', profiles.records.map((p) => p.Profile.Name));
69
+ Object.values(resolvedProfiles).forEach((profile) => {
70
+ profile.userPermissions.forEach((userPerm) => {
71
+ assignedPerms[userPerm.name] = { name: userPerm.name };
72
+ });
73
+ });
74
+ }
75
+ return assignedPerms;
76
+ }
77
+ function sanitiseLabel(rawLabel) {
78
+ return rawLabel?.replace(/[ \t]+$|[\r\n]+/g, '');
79
+ }
80
+ //# sourceMappingURL=permissionsClassification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissionsClassification.js","sourceRoot":"","sources":["../../../src/libs/conf-init/permissionsClassification.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,MAAM,iCAAiC,CAAC;AAEpD,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,EAAoB,UAAU,EAAE,MAAM,cAAc,CAAC;AAG5D;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,GAAe,EAAE,MAAyB;IAClF,MAAM,aAAa,GAAG,MAAM,sBAAsB,CAAC,GAAG,CAAC,CAAC;IACxD,MAAM,aAAa,GAAG,MAAM,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACnD,MAAM,QAAQ,GAAG,EAAE,GAAG,aAAa,EAAE,GAAG,aAAa,EAAE,CAAC;IACxD,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,KAAK,GAAG,UAAU,CAAC,uBAAuB,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1E,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACjC,MAAM,MAAM,GAAsB,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IACtD,KAAK,CAAC,OAAO,CACX,CAAC,IAAI,EAAE,EAAE,CACP,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;QAC/B,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC;QAChC,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,MAAM,EAAE,IAAI,CAAC,MAAM;KACpB,CAAC,CACL,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,GAAe;IACzD,MAAM,M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J,CAAC,CAAC,CAAC;IACL,OAAO,sBAAsB,CAAC;AAChC,CAAC;AAED,KAAK,UAAU,iBAAiB,CAAC,GAAe;IAC9C,MAAM,aAAa,GAAqC,EAAE,CAAC;IAC3D,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,KAAK,CAAgB,cAAc,CAAC,CAAC;IAChE,IAAI,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7B,MAAM,gBAAgB,GAAG,MAAM,KAAK,CAAC,OAAO,CAC1C,SAAS,EACT,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAC5C,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAClD,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;gBAC3C,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;YACzD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,SAAS,aAAa,CAAC,QAAiB;IACtC,OAAO,QAAQ,EAAE,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { Connection } from '@salesforce/core';
2
- import { BasePolicyFileContent, PermSetsPolicyFileContent, ProfilesPolicyFileContent } from '../../config/audit-run/schema.js';
2
+ import { BasePolicyFileContent, PermSetsPolicyFileContent, ProfilesPolicyFileContent } from '../core/file-mgmt/schema.js';
3
3
  /**
4
4
  * Initialises a new profiles policy with the local org's
5
5
  * profiles and all default rules enabled.
@@ -1,8 +1,6 @@
1
- import { PERMISSION_SETS_QUERY, PROFILES_QUERY } from '../../config/queries.js';
2
- import { ProfilesRegistry } from '../../config/registries/profiles.js';
3
- import { PermissionRiskLevelPresets } from '../types.js';
4
- import { PermissionSetsRegistry } from '../../config/registries/permissionSets.js';
5
- import { ConnectedAppsRegistry } from '../../config/registries/connectedApps.js';
1
+ import { PERMISSION_SETS_QUERY, PROFILES_QUERY } from '../core/constants.js';
2
+ import { RuleRegistries } from '../core/registries/types.js';
3
+ import { ProfilesRiskPreset } from '../core/policy-types.js';
6
4
  /**
7
5
  * Initialises a new profiles policy with the local org's
8
6
  * profiles and all default rules enabled.
@@ -15,9 +13,9 @@ export async function initProfiles(targetOrgCon) {
15
13
  const profiles = await targetOrgCon.query(PROFILES_QUERY);
16
14
  const content = { enabled: true, profiles: {}, rules: {} };
17
15
  profiles.records.forEach((permsetRecord) => {
18
- content.profiles[permsetRecord.Profile.Name] = { preset: PermissionRiskLevelPresets.UNKNOWN };
16
+ content.profiles[permsetRecord.Profile.Name] = { preset: ProfilesRiskPreset.UNKNOWN };
19
17
  });
20
- ProfilesRegistry.registeredRules().forEach((ruleName) => {
18
+ RuleRegistries.Profiles.registeredRules().forEach((ruleName) => {
21
19
  content.rules[ruleName] = {
22
20
  enabled: true,
23
21
  };
@@ -41,9 +39,9 @@ export async function initPermissionSets(targetOrgCon) {
41
39
  permSets.records
42
40
  .filter((permsetRecord) => permsetRecord.IsCustom)
43
41
  .forEach((permsetRecord) => {
44
- content.permissionSets[permsetRecord.Name] = { preset: PermissionRiskLevelPresets.UNKNOWN };
42
+ content.permissionSets[permsetRecord.Name] = { preset: ProfilesRiskPreset.UNKNOWN };
45
43
  });
46
- PermissionSetsRegistry.registeredRules().forEach((ruleName) => {
44
+ RuleRegistries.PermissionSets.registeredRules().forEach((ruleName) => {
47
45
  content.rules[ruleName] = {
48
46
  enabled: true,
49
47
  };
@@ -57,7 +55,7 @@ export async function initPermissionSets(targetOrgCon) {
57
55
  */
58
56
  export function initConnectedApps() {
59
57
  const content = { enabled: true, rules: {} };
60
- ConnectedAppsRegistry.registeredRules().forEach((ruleName) => {
58
+ RuleRegistries.ConnectedApps.registeredRules().forEach((ruleName) => {
61
59
  content.rules[ruleName] = {
62
60
  enabled: true,
63
61
  };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policyConfigs.js","sourceRoot":"","sources":["../../../src/libs/conf-init/policyConfigs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAO7E,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,YAAwB;IACzD,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,KAAK,CAAgB,cAAc,CAAC,CAAC;IACzE,MAAM,OAAO,GAA8B,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACtF,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;QACzC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,kBAAkB,CAAC,OAAO,EAAE,CAAC;IACxF,CAAC,CAAC,CAAC;IACH,cAAc,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC7D,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG;YACxB,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,YAAwB;IAC/D,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,KAAK,CAAgB,qBAAqB,CAAC,CAAC;IAChF,MAAM,OAAO,GAA8B;QACzC,OAAO,EAAE,IAAI;QACb,cAAc,EAAE,EAAE;QAClB,KAAK,EAAE,EAAE;KACV,CAAC;IACF,QAAQ,CAAC,OAAO;SACb,MAAM,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC;SACjD,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;QACzB,OAAO,CAAC,cAAc,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,kBAAkB,CAAC,OAAO,EAAE,CAAC;IACtF,CAAC,CAAC,CAAC;IACL,cAAc,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;QACnE,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG;YACxB,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,OAAO,GAA0B,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACpE,cAAc,CAAC,aAAa,CAAC,eAAe,EAAE,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;QAClE,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG;YACxB,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { NamedPermissionsClassification } from '../../core/file-mgmt/schema.js';
2
+ import NonePreset from './none.js';
3
+ export default class LoosePreset extends NonePreset {
4
+ constructor();
5
+ initDefault(permName: string): NamedPermissionsClassification;
6
+ }
@@ -0,0 +1,35 @@
1
+ import { PermissionRiskLevel } from '../../core/classification-types.js';
2
+ import NonePreset from './none.js';
3
+ export default class LoosePreset extends NonePreset {
4
+ constructor() {
5
+ super({
6
+ UseAnyApiClient: PermissionRiskLevel.HIGH,
7
+ CustomizeApplication: PermissionRiskLevel.HIGH,
8
+ ModifyMetadata: PermissionRiskLevel.HIGH,
9
+ AuthorApex: PermissionRiskLevel.HIGH,
10
+ ManageAuthProviders: PermissionRiskLevel.HIGH,
11
+ Packaging2: PermissionRiskLevel.HIGH,
12
+ Packaging2Delete: PermissionRiskLevel.HIGH,
13
+ Packaging2PromoteVersion: PermissionRiskLevel.HIGH,
14
+ InstallPackaging: PermissionRiskLevel.HIGH,
15
+ ViewClientSecret: PermissionRiskLevel.HIGH,
16
+ ManageTwoFactor: PermissionRiskLevel.HIGH,
17
+ ManageRemoteAccess: PermissionRiskLevel.HIGH,
18
+ CanApproveUninstalledApps: PermissionRiskLevel.HIGH,
19
+ ViewSetup: PermissionRiskLevel.MEDIUM,
20
+ ViewAllData: PermissionRiskLevel.MEDIUM,
21
+ ModifyAllData: PermissionRiskLevel.MEDIUM,
22
+ ExportReport: PermissionRiskLevel.MEDIUM,
23
+ EmailMass: PermissionRiskLevel.MEDIUM,
24
+ ApiEnabled: PermissionRiskLevel.LOW,
25
+ });
26
+ }
27
+ initDefault(permName) {
28
+ const basePerm = super.initDefault(permName);
29
+ if (basePerm.classification === PermissionRiskLevel.UNKNOWN) {
30
+ basePerm.classification = PermissionRiskLevel.LOW;
31
+ }
32
+ return basePerm;
33
+ }
34
+ }
35
+ //# sourceMappingURL=loose.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loose.js","sourceRoot":"","sources":["../../../../src/libs/conf-init/presets/loose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,UAAU,MAAM,WAAW,CAAC;AAEnC,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,UAAU;IACjD;QACE,KAAK,CAAC;YACJ,eAAe,EAAE,mBAAmB,CAAC,IAAI;YACzC,oBAAoB,EAAE,mBAAmB,CAAC,IAAI;YAC9C,cAAc,EAAE,mBAAmB,CAAC,IAAI;YACxC,UAAU,EAAE,mBAAmB,CAAC,IAAI;YACpC,mBAAmB,EAAE,mBAAmB,CAAC,IAAI;YAC7C,UAAU,EAAE,mBAAmB,CAAC,IAAI;YACpC,gBAAgB,EAAE,mBAAmB,CAAC,IAAI;YAC1C,wBAAwB,EAAE,mBAAmB,CAAC,IAAI;YAClD,gBAAgB,EAAE,mBAAmB,CAAC,IAAI;YAC1C,gBAAgB,EAAE,mBAAmB,CAAC,IAAI;YAC1C,eAAe,EAAE,mBAAmB,CAAC,IAAI;YACzC,kBAAkB,EAAE,mBAAmB,CAAC,IAAI;YAC5C,yBAAyB,EAAE,mBAAmB,CAAC,IAAI;YACnD,SAAS,EAAE,mBAAmB,CAAC,MAAM;YACrC,WAAW,EAAE,mBAAmB,CAAC,MAAM;YACvC,aAAa,EAAE,mBAAmB,CAAC,MAAM;YACzC,YAAY,EAAE,mBAAmB,CAAC,MAAM;YACxC,SAAS,EAAE,mBAAmB,CAAC,MAAM;YACrC,UAAU,EAAE,mBAAmB,CAAC,GAAG;SACpC,CAAC,CAAC;IACL,CAAC;IAEe,WAAW,CAAC,QAAgB;QAC1C,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC7C,IAAI,QAAQ,CAAC,cAAc,KAAK,mBAAmB,CAAC,OAAO,EAAE,CAAC;YAC5D,QAAQ,CAAC,cAAc,GAAG,mBAAmB,CAAC,GAAG,CAAC;QACpD,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
@@ -0,0 +1,30 @@
1
+ import { NamedPermissionsClassification } from '../../core/file-mgmt/schema.js';
2
+ import { PermissionRiskLevel } from '../../core/classification-types.js';
3
+ import { Optional } from '../../core/utils.js';
4
+ export type UnclassifiedPerm = Optional<NamedPermissionsClassification, 'classification'>;
5
+ export type Preset = {
6
+ classifyUserPermissions(rawPerms: UnclassifiedPerm[]): NamedPermissionsClassification[];
7
+ };
8
+ /**
9
+ * A "blank" preset that is extended by all other presets
10
+ * and initialises classification descriptions
11
+ */
12
+ export default class NonePreset implements Preset {
13
+ protected userPermissions: Record<string, Partial<NamedPermissionsClassification>>;
14
+ constructor(userPerms?: Record<string, PermissionRiskLevel>);
15
+ /**
16
+ * Finalises permissions for all unclassified user perms that are set
17
+ * in this preset.
18
+ *
19
+ * @param perms
20
+ */
21
+ classifyUserPermissions(rawPerms: UnclassifiedPerm[]): NamedPermissionsClassification[];
22
+ /**
23
+ * Initialises a default classification for a given permission name.
24
+ * This merges pre-configured defaults with available descriptions.
25
+ *
26
+ * @param permName
27
+ * @returns
28
+ */
29
+ initDefault(permName: string): NamedPermissionsClassification;
30
+ }
@@ -0,0 +1,54 @@
1
+ import { Messages } from '@salesforce/core';
2
+ import { PermissionRiskLevel } from '../../core/classification-types.js';
3
+ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
4
+ const descriptions = Messages.loadMessages('@j-schreiber/sf-cli-security-audit', 'policyclassifications');
5
+ /**
6
+ * A "blank" preset that is extended by all other presets
7
+ * and initialises classification descriptions
8
+ */
9
+ export default class NonePreset {
10
+ userPermissions;
11
+ constructor(userPerms) {
12
+ this.userPermissions = {};
13
+ if (userPerms) {
14
+ Object.entries(userPerms).forEach(([name, classification]) => {
15
+ if (this.userPermissions[name]) {
16
+ this.userPermissions[name].classification = classification;
17
+ }
18
+ else {
19
+ this.userPermissions[name] = { classification };
20
+ }
21
+ });
22
+ }
23
+ }
24
+ /**
25
+ * Finalises permissions for all unclassified user perms that are set
26
+ * in this preset.
27
+ *
28
+ * @param perms
29
+ */
30
+ classifyUserPermissions(rawPerms) {
31
+ return rawPerms.map((perm) => ({
32
+ ...this.initDefault(perm.name),
33
+ ...perm,
34
+ }));
35
+ }
36
+ /**
37
+ * Initialises a default classification for a given permission name.
38
+ * This merges pre-configured defaults with available descriptions.
39
+ *
40
+ * @param permName
41
+ * @returns
42
+ */
43
+ initDefault(permName) {
44
+ const def = this.userPermissions[permName];
45
+ const hasDescription = descriptions.messages.has(permName);
46
+ return {
47
+ ...def,
48
+ name: permName,
49
+ classification: def?.classification ?? PermissionRiskLevel.UNKNOWN,
50
+ reason: hasDescription ? descriptions.getMessage(permName) : undefined,
51
+ };
52
+ }
53
+ }
54
+ //# sourceMappingURL=none.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"none.js","sourceRoot":"","sources":["../../../../src/libs/conf-init/presets/none.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAGzE,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC,oCAAoC,EAAE,uBAAuB,CAAC,CAAC;AAQ1G;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IACnB,eAAe,CAA0D;IAEnF,YAAmB,SAA+C;QAChE,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,EAAE;gBAC3D,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC/B,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,cAAc,GAAG,cAAc,CAAC;gBAC7D,CAAC;qBAAM,CAAC;oBACN,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,CAAC;gBAClD,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACI,uBAAuB,CAAC,QAA4B;QACzD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC7B,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;YAC9B,GAAG,IAAI;SACR,CAAC,CAAC,CAAC;IACN,CAAC;IAED;;;;;;OAMG;IACI,WAAW,CAAC,QAAgB;QACjC,MAAM,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QAC3C,MAAM,cAAc,GAAG,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC3D,OAAO;YACL,GAAG,GAAG;YACN,IAAI,EAAE,QAAQ;YACd,cAAc,EAAE,GAAG,EAAE,cAAc,IAAI,mBAAmB,CAAC,OAAO;YAClE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS;SACvE,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ import NonePreset from './none.js';
2
+ export default class StrictPreset extends NonePreset {
3
+ constructor();
4
+ }
@@ -0,0 +1,28 @@
1
+ import { PermissionRiskLevel } from '../../core/classification-types.js';
2
+ import NonePreset from './none.js';
3
+ export default class StrictPreset extends NonePreset {
4
+ constructor() {
5
+ super({
6
+ UseAnyApiClient: PermissionRiskLevel.BLOCKED,
7
+ CustomizeApplication: PermissionRiskLevel.CRITICAL,
8
+ ModifyMetadata: PermissionRiskLevel.CRITICAL,
9
+ AuthorApex: PermissionRiskLevel.CRITICAL,
10
+ ManageAuthProviders: PermissionRiskLevel.CRITICAL,
11
+ Packaging2: PermissionRiskLevel.CRITICAL,
12
+ Packaging2Delete: PermissionRiskLevel.CRITICAL,
13
+ Packaging2PromoteVersion: PermissionRiskLevel.CRITICAL,
14
+ InstallPackaging: PermissionRiskLevel.CRITICAL,
15
+ ViewClientSecret: PermissionRiskLevel.CRITICAL,
16
+ ExportReport: PermissionRiskLevel.HIGH,
17
+ ViewSetup: PermissionRiskLevel.HIGH,
18
+ ApiEnabled: PermissionRiskLevel.HIGH,
19
+ ViewAllData: PermissionRiskLevel.HIGH,
20
+ ModifyAllData: PermissionRiskLevel.HIGH,
21
+ ManageTwoFactor: PermissionRiskLevel.HIGH,
22
+ ManageRemoteAccess: PermissionRiskLevel.HIGH,
23
+ CanApproveUninstalledApps: PermissionRiskLevel.HIGH,
24
+ EmailMass: PermissionRiskLevel.MEDIUM,
25
+ });
26
+ }
27
+ }
28
+ //# sourceMappingURL=strict.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strict.js","sourceRoot":"","sources":["../../../../src/libs/conf-init/presets/strict.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,UAAU,MAAM,WAAW,CAAC;AAEnC,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,UAAU;IAClD;QACE,KAAK,CAAC;YACJ,eAAe,EAAE,mBAAmB,CAAC,OAAO;YAC5C,oBAAoB,EAAE,mBAAmB,CAAC,QAAQ;YAClD,cAAc,EAAE,mBAAmB,CAAC,QAAQ;YAC5C,UAAU,EAAE,mBAAmB,CAAC,QAAQ;YACxC,mBAAmB,EAAE,mBAAmB,CAAC,QAAQ;YACjD,UAAU,EAAE,mBAAmB,CAAC,QAAQ;YACxC,gBAAgB,EAAE,mBAAmB,CAAC,QAAQ;YAC9C,wBAAwB,EAAE,mBAAmB,CAAC,QAAQ;YACtD,gBAAgB,EAAE,mBAAmB,CAAC,QAAQ;YAC9C,gBAAgB,EAAE,mBAAmB,CAAC,QAAQ;YAC9C,YAAY,EAAE,mBAAmB,CAAC,IAAI;YACtC,SAAS,EAAE,mBAAmB,CAAC,IAAI;YACnC,UAAU,EAAE,mBAAmB,CAAC,IAAI;YACpC,WAAW,EAAE,mBAAmB,CAAC,IAAI;YACrC,aAAa,EAAE,mBAAmB,CAAC,IAAI;YACvC,eAAe,EAAE,mBAAmB,CAAC,IAAI;YACzC,kBAAkB,EAAE,mBAAmB,CAAC,IAAI;YAC5C,yBAAyB,EAAE,mBAAmB,CAAC,IAAI;YACnD,SAAS,EAAE,mBAAmB,CAAC,MAAM;SACtC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ import { Preset } from './presets/none.js';
2
+ export declare enum AuditInitPresets {
3
+ strict = "strict",
4
+ loose = "loose",
5
+ none = "none"
6
+ }
7
+ export declare function loadPreset(presetName?: AuditInitPresets): Preset;
@@ -0,0 +1,20 @@
1
+ import LoosePreset from './presets/loose.js';
2
+ import NonePreset from './presets/none.js';
3
+ import StrictPreset from './presets/strict.js';
4
+ export var AuditInitPresets;
5
+ (function (AuditInitPresets) {
6
+ AuditInitPresets["strict"] = "strict";
7
+ AuditInitPresets["loose"] = "loose";
8
+ AuditInitPresets["none"] = "none";
9
+ })(AuditInitPresets || (AuditInitPresets = {}));
10
+ export function loadPreset(presetName) {
11
+ switch (presetName) {
12
+ case AuditInitPresets.loose:
13
+ return new LoosePreset();
14
+ case AuditInitPresets.strict:
15
+ return new StrictPreset();
16
+ default:
17
+ return new NonePreset();
18
+ }
19
+ }
20
+ //# sourceMappingURL=presets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presets.js","sourceRoot":"","sources":["../../../src/libs/conf-init/presets.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,OAAO,UAAsB,MAAM,mBAAmB,CAAC;AACvD,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAE/C,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,qCAAiB,CAAA;IACjB,mCAAe,CAAA;IACf,iCAAa,CAAA;AACf,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B;AAED,MAAM,UAAU,UAAU,CAAC,UAA6B;IACtD,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,gBAAgB,CAAC,KAAK;YACzB,OAAO,IAAI,WAAW,EAAE,CAAC;QAC3B,KAAK,gBAAgB,CAAC,MAAM;YAC1B,OAAO,IAAI,YAAY,EAAE,CAAC;QAC5B;YACE,OAAO,IAAI,UAAU,EAAE,CAAC;IAC5B,CAAC;AACH,CAAC"}
@@ -0,0 +1,20 @@
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;
@@ -0,0 +1,23 @@
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