@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,255 +1,4 @@
1
1
  {
2
- "commands": {
3
- "org:scan:user-perms": {
4
- "aliases": [],
5
- "args": {},
6
- "description": "The quick scan does not need an audit config and does not create reports. The target org is scanned \"in memory\" and simply outputs information, where the searched user permissions",
7
- "examples": [
8
- "<%= config.bin %> <%= command.id %>"
9
- ],
10
- "flags": {
11
- "json": {
12
- "description": "Format output as json.",
13
- "helpGroup": "GLOBAL",
14
- "name": "json",
15
- "allowNo": false,
16
- "type": "boolean"
17
- },
18
- "flags-dir": {
19
- "helpGroup": "GLOBAL",
20
- "name": "flags-dir",
21
- "summary": "Import flag values from a directory.",
22
- "hasDynamicHelp": false,
23
- "multiple": false,
24
- "type": "option"
25
- },
26
- "name": {
27
- "char": "n",
28
- "description": "You can specify any valid user permission on your org, such as \"AuthorApex\", \"CustomizeApplication\" or \"ViewSetup\". If you are unsure what permissions are available on your org, initialise a new audit config and check the created userPermissions.yml.",
29
- "name": "name",
30
- "required": true,
31
- "summary": "One or more permissions to be scanned.",
32
- "hasDynamicHelp": false,
33
- "multiple": true,
34
- "type": "option"
35
- },
36
- "target-org": {
37
- "char": "o",
38
- "name": "target-org",
39
- "noCacheDefault": true,
40
- "required": true,
41
- "summary": "The target org to scan.",
42
- "hasDynamicHelp": true,
43
- "multiple": false,
44
- "type": "option"
45
- },
46
- "api-version": {
47
- "description": "Override the api version used for api requests made by this command",
48
- "name": "api-version",
49
- "hasDynamicHelp": false,
50
- "multiple": false,
51
- "type": "option"
52
- }
53
- },
54
- "hasDynamicHelp": true,
55
- "hiddenAliases": [],
56
- "id": "org:scan:user-perms",
57
- "pluginAlias": "@j-schreiber/sf-cli-security-audit",
58
- "pluginName": "@j-schreiber/sf-cli-security-audit",
59
- "pluginType": "core",
60
- "strict": true,
61
- "summary": "Performs a quick scan to check permission sets and profiles for user permissions.",
62
- "enableJsonFlag": true,
63
- "isESM": true,
64
- "relativePath": [
65
- "lib",
66
- "commands",
67
- "org",
68
- "scan",
69
- "user-perms.js"
70
- ],
71
- "aliasPermutations": [],
72
- "permutations": [
73
- "org:scan:user-perms",
74
- "scan:org:user-perms",
75
- "scan:user-perms:org",
76
- "org:user-perms:scan",
77
- "user-perms:org:scan",
78
- "user-perms:scan:org"
79
- ]
80
- },
81
- "org:audit:init": {
82
- "aliases": [],
83
- "args": {},
84
- "description": "Exports permissions (standard and custom), permission sets, profiles, users, etc from the target org. All classifications are initialised with sane defaults that you can customize later.",
85
- "examples": [
86
- "Initialise audit policies at the root directory\n<%= config.bin %> <%= command.id %> -o MyTargetOrg",
87
- "Initialise audit config at custom directory with preset\n<%= config.bin %> <%= command.id %> -o MyTargetOrg -d my_dir -p loose"
88
- ],
89
- "flags": {
90
- "json": {
91
- "description": "Format output as json.",
92
- "helpGroup": "GLOBAL",
93
- "name": "json",
94
- "allowNo": false,
95
- "type": "boolean"
96
- },
97
- "flags-dir": {
98
- "helpGroup": "GLOBAL",
99
- "name": "flags-dir",
100
- "summary": "Import flag values from a directory.",
101
- "hasDynamicHelp": false,
102
- "multiple": false,
103
- "type": "option"
104
- },
105
- "target-org": {
106
- "char": "o",
107
- "name": "target-org",
108
- "noCacheDefault": true,
109
- "required": true,
110
- "summary": "Target org to export permissions, profiles, users, etc.",
111
- "hasDynamicHelp": true,
112
- "multiple": false,
113
- "type": "option"
114
- },
115
- "output-dir": {
116
- "char": "d",
117
- "name": "output-dir",
118
- "required": false,
119
- "summary": "Directory where the audit config is initialised. If not set, the root directory will be used.",
120
- "default": "",
121
- "hasDynamicHelp": false,
122
- "multiple": false,
123
- "type": "option"
124
- },
125
- "preset": {
126
- "char": "p",
127
- "description": "The selected preset is applied before any other default mechanisms (such as template configs). This means, values from a selected template override the preset. Consult the documentation to learn more about the rationale behind the default risk levels. The risk levels interact with the configured preset on profiles and permission sets and essentially control, if a permission is allowed in a certain profile / permission set.",
128
- "name": "preset",
129
- "summary": "Select a preset to initialise permission classifications (risk levels).",
130
- "default": "strict",
131
- "hasDynamicHelp": false,
132
- "multiple": false,
133
- "options": [
134
- "strict",
135
- "loose",
136
- "none"
137
- ],
138
- "type": "option"
139
- },
140
- "api-version": {
141
- "description": "Override the api version used for api requests made by this command",
142
- "name": "api-version",
143
- "hasDynamicHelp": false,
144
- "multiple": false,
145
- "type": "option"
146
- }
147
- },
148
- "hasDynamicHelp": true,
149
- "hiddenAliases": [],
150
- "id": "org:audit:init",
151
- "pluginAlias": "@j-schreiber/sf-cli-security-audit",
152
- "pluginName": "@j-schreiber/sf-cli-security-audit",
153
- "pluginType": "core",
154
- "strict": true,
155
- "summary": "Initialises classifications and policies for a security audit.",
156
- "enableJsonFlag": true,
157
- "isESM": true,
158
- "relativePath": [
159
- "lib",
160
- "commands",
161
- "org",
162
- "audit",
163
- "init.js"
164
- ],
165
- "aliasPermutations": [],
166
- "permutations": [
167
- "org:audit:init",
168
- "audit:org:init",
169
- "audit:init:org",
170
- "org:init:audit",
171
- "init:org:audit",
172
- "init:audit:org"
173
- ]
174
- },
175
- "org:audit:run": {
176
- "aliases": [],
177
- "args": {},
178
- "description": "Loads a given audit config (a set of classifications and policies) and runs the policies against the target org. The audit run creates a comprehensive report that lists all executed policies and all resolved entities that were audited.",
179
- "examples": [
180
- "Audit the org MyTargetOrg with the config in configs/prod\n<%= config.bin %> <%= command.id %> -o MyTargetOrg -d configs/prod"
181
- ],
182
- "flags": {
183
- "json": {
184
- "description": "Format output as json.",
185
- "helpGroup": "GLOBAL",
186
- "name": "json",
187
- "allowNo": false,
188
- "type": "boolean"
189
- },
190
- "flags-dir": {
191
- "helpGroup": "GLOBAL",
192
- "name": "flags-dir",
193
- "summary": "Import flag values from a directory.",
194
- "hasDynamicHelp": false,
195
- "multiple": false,
196
- "type": "option"
197
- },
198
- "target-org": {
199
- "char": "o",
200
- "name": "target-org",
201
- "noCacheDefault": true,
202
- "required": true,
203
- "summary": "The org that is audited.",
204
- "hasDynamicHelp": true,
205
- "multiple": false,
206
- "type": "option"
207
- },
208
- "source-dir": {
209
- "char": "d",
210
- "name": "source-dir",
211
- "required": false,
212
- "summary": "Location of the audit config.",
213
- "default": "",
214
- "hasDynamicHelp": false,
215
- "multiple": false,
216
- "type": "option"
217
- },
218
- "api-version": {
219
- "description": "Override the api version used for api requests made by this command",
220
- "name": "api-version",
221
- "hasDynamicHelp": false,
222
- "multiple": false,
223
- "type": "option"
224
- }
225
- },
226
- "hasDynamicHelp": true,
227
- "hiddenAliases": [],
228
- "id": "org:audit:run",
229
- "pluginAlias": "@j-schreiber/sf-cli-security-audit",
230
- "pluginName": "@j-schreiber/sf-cli-security-audit",
231
- "pluginType": "core",
232
- "strict": true,
233
- "summary": "Audit your org.",
234
- "enableJsonFlag": true,
235
- "isESM": true,
236
- "relativePath": [
237
- "lib",
238
- "commands",
239
- "org",
240
- "audit",
241
- "run.js"
242
- ],
243
- "aliasPermutations": [],
244
- "permutations": [
245
- "org:audit:run",
246
- "audit:org:run",
247
- "audit:run:org",
248
- "org:run:audit",
249
- "run:org:audit",
250
- "run:audit:org"
251
- ]
252
- }
253
- },
254
- "version": "0.7.0"
2
+ "commands": {},
3
+ "version": "0.8.0"
255
4
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@j-schreiber/sf-cli-security-audit",
3
3
  "description": "Salesforce CLI plugin to automate highly configurable security audits",
4
- "version": "0.7.0",
4
+ "version": "0.8.0",
5
5
  "repository": {
6
6
  "type": "https",
7
7
  "url": "https://github.com/j-schreiber/js-sf-cli-security-audit"
@@ -1,19 +0,0 @@
1
- import { SfCommand } from '@salesforce/sf-plugins-core';
2
- import { AuditRunConfig } from '../../../libs/core/file-mgmt/schema.js';
3
- import { AuditInitPresets } from '../../../libs/conf-init/presets.js';
4
- export type OrgAuditInitResult = AuditRunConfig;
5
- export default class OrgAuditInit extends SfCommand<OrgAuditInitResult> {
6
- static readonly summary: string;
7
- static readonly description: string;
8
- static readonly examples: string[];
9
- static readonly flags: {
10
- 'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
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>;
13
- 'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
- };
15
- run(): Promise<OrgAuditInitResult>;
16
- private printResults;
17
- private printClassifications;
18
- private printPolicies;
19
- }
@@ -1,72 +0,0 @@
1
- import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
2
- import { Messages } from '@salesforce/core';
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';
6
- import { capitalize } from '../../../libs/core/utils.js';
7
- Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
8
- const messages = Messages.loadMessages('@j-schreiber/sf-cli-security-audit', 'org.audit.init');
9
- const presetFlag = Flags.custom({
10
- char: 'p',
11
- summary: messages.getMessage('flags.preset.summary'),
12
- description: messages.getMessage('flags.preset.description'),
13
- options: Object.values(AuditInitPresets),
14
- default: AuditInitPresets.strict,
15
- })();
16
- export default class OrgAuditInit extends SfCommand {
17
- static summary = messages.getMessage('summary');
18
- static description = messages.getMessage('description');
19
- static examples = messages.getMessages('examples');
20
- static flags = {
21
- 'target-org': Flags.requiredOrg({
22
- summary: messages.getMessage('flags.target-org.summary'),
23
- char: 'o',
24
- required: true,
25
- }),
26
- 'output-dir': Flags.directory({
27
- required: false,
28
- char: 'd',
29
- summary: messages.getMessage('flags.output-dir.summary'),
30
- default: '',
31
- }),
32
- preset: presetFlag,
33
- 'api-version': Flags.orgApiVersion(),
34
- };
35
- async run() {
36
- const { flags } = await this.parse(OrgAuditInit);
37
- const auditConfig = await AuditConfig.init(flags['target-org'].getConnection(flags['api-version']), {
38
- targetDir: flags['output-dir'],
39
- preset: flags.preset,
40
- });
41
- this.printResults(auditConfig);
42
- return auditConfig;
43
- }
44
- printResults(config) {
45
- this.printClassifications(config.classifications);
46
- this.printPolicies(config.policies);
47
- }
48
- printClassifications(classifications) {
49
- Object.values(classifications).forEach((def) => {
50
- if (isPermissionsConfig(def)) {
51
- const perms = def.content.permissions ? Object.entries(def.content.permissions) : [];
52
- if (perms.length > 0) {
53
- this.logSuccess(messages.getMessage('success.perm-classification-summary', [perms.length ?? 0, def.filePath]));
54
- }
55
- }
56
- });
57
- }
58
- printPolicies(policies) {
59
- Object.entries(policies).forEach(([name, def]) => {
60
- if (isPolicyConfig(def)) {
61
- if (def.filePath) {
62
- this.logSuccess(messages.getMessage('success.policy-summary', [
63
- capitalize(name),
64
- Object.keys(def.content.rules).length ?? 0,
65
- def.filePath,
66
- ]));
67
- }
68
- }
69
- });
70
- }
71
- }
72
- //# sourceMappingURL=init.js.map
@@ -1 +0,0 @@
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,wCAAwC,CAAC;AACjE,OAAO,EAIL,mBAAmB,EACnB,cAAc,GACf,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEzD,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,oCAAoC,EAAE,gBAAgB,CAAC,CAAC;AAI/F,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAmB;IAChD,IAAI,EAAE,GAAG;IACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,sBAAsB,CAAC;IACpD,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,0BAA0B,CAAC;IAC5D,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC;IACxC,OAAO,EAAE,gBAAgB,CAAC,MAAM;CACjC,CAAC,EAAE,CAAC;AAEL,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,SAA6B;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core';
3
- import { AuditResult } from '../../../libs/core/result-types.js';
4
- export type OrgAuditRunResult = AuditResult & {
5
- filePath: string;
6
- };
7
- export default class OrgAuditRun extends SfCommand<OrgAuditRunResult> {
8
- static readonly summary: string;
9
- static readonly description: string;
10
- static readonly examples: string[];
11
- static readonly flags: {
12
- 'target-org': Interfaces.OptionFlag<import("@salesforce/core").Org, Interfaces.CustomOptions>;
13
- 'source-dir': Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
14
- 'api-version': Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
15
- };
16
- run(): Promise<OrgAuditRunResult>;
17
- private printResults;
18
- private printPoliciesSummary;
19
- private printExecutedRulesSummary;
20
- private printRuleViolations;
21
- private writeReport;
22
- }
@@ -1,119 +0,0 @@
1
- import { writeFileSync } from 'node:fs';
2
- import path from 'node:path';
3
- import { SfCommand, Flags, StandardColors } from '@salesforce/sf-plugins-core';
4
- import { Messages } from '@salesforce/core';
5
- import { startAuditRun } from '../../../libs/core/auditRun.js';
6
- import AuditRunMultiStageOutput from '../../../ux/auditRunMultiStage.js';
7
- import { capitalize } from '../../../libs/core/utils.js';
8
- Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
9
- const messages = Messages.loadMessages('@j-schreiber/sf-cli-security-audit', 'org.audit.run');
10
- export default class OrgAuditRun extends SfCommand {
11
- static summary = messages.getMessage('summary');
12
- static description = messages.getMessage('description');
13
- static examples = messages.getMessages('examples');
14
- static flags = {
15
- 'target-org': Flags.requiredOrg({
16
- summary: messages.getMessage('flags.target-org.summary'),
17
- char: 'o',
18
- required: true,
19
- }),
20
- 'source-dir': Flags.directory({
21
- required: false,
22
- char: 'd',
23
- summary: messages.getMessage('flags.source-dir.summary'),
24
- default: '',
25
- }),
26
- 'api-version': Flags.orgApiVersion(),
27
- };
28
- async run() {
29
- const { flags } = await this.parse(OrgAuditRun);
30
- const stageOutput = AuditRunMultiStageOutput.create({
31
- directoryRootPath: flags['source-dir'],
32
- targetOrg: flags['target-org'].getUsername() ?? flags['target-org'].getOrgId(),
33
- jsonEnabled: flags.json,
34
- });
35
- stageOutput.start();
36
- const auditRun = startAuditRun(flags['source-dir']);
37
- stageOutput.startPolicyResolve(auditRun);
38
- await auditRun.resolve(flags['target-org'].getConnection(flags['api-version']));
39
- stageOutput.startRuleExecution();
40
- const partialResult = await auditRun.execute(flags['target-org'].getConnection(flags['api-version']));
41
- const result = { orgId: flags['target-org'].getOrgId(), ...partialResult };
42
- stageOutput.finish();
43
- this.printResults(result);
44
- const filePath = this.writeReport(result, flags);
45
- return { ...result, filePath };
46
- }
47
- printResults(result) {
48
- this.printPoliciesSummary(result);
49
- Object.entries(result.policies).forEach(([policyName, policyDetails]) => {
50
- this.printExecutedRulesSummary(policyName, policyDetails);
51
- this.printRuleViolations(policyDetails.executedRules);
52
- });
53
- }
54
- printPoliciesSummary(result) {
55
- const polSummaries = transposePoliciesToTable(result);
56
- if (result.isCompliant) {
57
- this.logSuccess(messages.getMessage('success.all-policies-compliant'));
58
- this.log('');
59
- }
60
- else {
61
- this.log(StandardColors.error(messages.getMessage('summary-non-compliant')));
62
- this.log('');
63
- }
64
- this.table({ data: polSummaries, title: '=== Summary ===', titleOptions: { bold: true } });
65
- }
66
- printExecutedRulesSummary(policyName, policyDetails) {
67
- if (!policyDetails.enabled) {
68
- return;
69
- }
70
- const rulesSummary = transposeExecutedPolicyRules(policyDetails);
71
- if (rulesSummary.length > 0) {
72
- this.table({
73
- data: rulesSummary,
74
- title: `--- Executed Rules for ${capitalize(policyName)} ---`,
75
- titleOptions: { underline: true },
76
- });
77
- }
78
- }
79
- printRuleViolations(executedRules) {
80
- Object.values(executedRules)
81
- .filter((ruleDetails) => !ruleDetails.isCompliant)
82
- .forEach((uncompliantRule) => {
83
- this.table({ data: uncompliantRule.violations, title: `Violations for ${uncompliantRule.ruleName}` });
84
- });
85
- }
86
- writeReport(result, flags) {
87
- const fileName = `report_${flags['target-org'].getOrgId()}_${Date.now()}.json`;
88
- const fullPath = path.join(flags['source-dir'], fileName);
89
- writeFileSync(fullPath, JSON.stringify(result, null, 2));
90
- this.info(messages.getMessage('info.report-file-location', [fullPath]));
91
- return fullPath;
92
- }
93
- }
94
- function transposePoliciesToTable(result) {
95
- return Object.entries(result.policies)
96
- .filter(([, policyDetails]) => policyDetails.enabled)
97
- .map(([policyName, policyDetails]) => {
98
- const rulesExecuted = policyDetails?.executedRules ? Object.keys(policyDetails.executedRules).length : 0;
99
- return {
100
- policy: capitalize(policyName),
101
- isCompliant: policyDetails.isCompliant,
102
- rulesExecuted,
103
- auditedEntities: policyDetails.auditedEntities?.length ?? 0,
104
- ignoredEntities: policyDetails.ignoredEntities?.length ?? 0,
105
- };
106
- });
107
- }
108
- function transposeExecutedPolicyRules(result) {
109
- return Object.entries(result.executedRules).map(([ruleName, ruleDetails]) => ({
110
- rule: ruleName,
111
- isCompliant: ruleDetails.isCompliant,
112
- compliantEntities: ruleDetails.compliantEntities?.length ?? 0,
113
- violatedEntities: ruleDetails.violatedEntities?.length ?? 0,
114
- violations: ruleDetails.violations.length,
115
- warnings: ruleDetails.warnings.length,
116
- errors: ruleDetails.errors.length,
117
- }));
118
- }
119
- //# sourceMappingURL=run.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../../../../src/commands/org/audit/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,wBAAwB,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEzD,QAAQ,CAAC,kCAAkC,CAAC,MAA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AACP,CAAC;AAED,SAAS,4BAA4B,CAAC,MAAyB;IAC7D,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;QAC5E,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,WAAW,CAAC,WAAW;QACpC,iBAAiB,EAAE,WAAW,CAAC,iBAAiB,EAAE,MAAM,IAAI,CAAC;QAC7D,gBAAgB,EAAE,WAAW,CAAC,gBAAgB,EAAE,MAAM,IAAI,CAAC;QAC3D,UAAU,EAAE,WAAW,CAAC,UAAU,CAAC,MAAM;QACzC,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAAC,MAAM;QACrC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,MAAM;KAClC,CAAC,CAAC,CAAC;AACN,CAAC"}
@@ -1,20 +0,0 @@
1
- import { SfCommand } from '@salesforce/sf-plugins-core';
2
- import { QuickScanResult } from '../../../libs/quick-scan/types.js';
3
- import { EntityScanStatus } from '../../../libs/quick-scan/userPermissionScanner.js';
4
- export type OrgUserPermScanResult = QuickScanResult;
5
- export default class OrgUserPermScan extends SfCommand<OrgUserPermScanResult> {
6
- static readonly summary: string;
7
- static readonly description: string;
8
- static readonly examples: string[];
9
- static readonly flags: {
10
- name: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
11
- 'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
12
- 'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
- };
14
- run(): Promise<OrgUserPermScanResult>;
15
- private reportProgress;
16
- private print;
17
- private printSummary;
18
- private printPermissionResults;
19
- }
20
- export declare function isEntityStatus(cls: unknown): cls is EntityScanStatus;
@@ -1,87 +0,0 @@
1
- import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
2
- import { Messages } from '@salesforce/core';
3
- import UserPermissionScanner from '../../../libs/quick-scan/userPermissionScanner.js';
4
- import { capitalize } from '../../../libs/core/utils.js';
5
- Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
6
- const messages = Messages.loadMessages('@j-schreiber/sf-cli-security-audit', 'org.scan.user-perms');
7
- export default class OrgUserPermScan extends SfCommand {
8
- static summary = messages.getMessage('summary');
9
- static description = messages.getMessage('description');
10
- static examples = messages.getMessages('examples');
11
- static flags = {
12
- name: Flags.string({
13
- summary: messages.getMessage('flags.name.summary'),
14
- description: messages.getMessage('flags.name.description'),
15
- char: 'n',
16
- multiple: true,
17
- required: true,
18
- }),
19
- 'target-org': Flags.requiredOrg({
20
- summary: messages.getMessage('flags.target-org.summary'),
21
- char: 'o',
22
- required: true,
23
- }),
24
- 'api-version': Flags.orgApiVersion(),
25
- };
26
- async run() {
27
- const { flags } = await this.parse(OrgUserPermScan);
28
- const scanner = new UserPermissionScanner();
29
- scanner.on('progress', this.reportProgress);
30
- const result = await scanner.quickScan({
31
- targetOrg: flags['target-org'].getConnection(flags['api-version']),
32
- permissions: flags.name,
33
- });
34
- this.print(result);
35
- return result;
36
- }
37
- reportProgress = (event) => {
38
- if (event.status === 'Pending') {
39
- this.spinner.start('Scanning');
40
- }
41
- const counters = [];
42
- Object.entries(event).forEach(([propName, entityStatus]) => {
43
- if (isEntityStatus(entityStatus)) {
44
- counters.push(`${capitalize(propName)} (${entityStatus.resolved}/${entityStatus.total})`);
45
- }
46
- });
47
- this.spinner.status = counters.join(' | ');
48
- if (event.status === 'Completed') {
49
- this.spinner.stop();
50
- this.logSuccess(messages.getMessage('success.scanned-entities-count', [event.profiles.total, event.permissionSets.total]));
51
- this.log();
52
- }
53
- };
54
- print(result) {
55
- this.printSummary(result);
56
- Object.entries(result.permissions).forEach(([permName, permResult]) => {
57
- this.printPermissionResults(permName, permResult);
58
- });
59
- }
60
- printSummary(result) {
61
- const data = [];
62
- Object.entries(result.permissions).forEach(([permissionName, permResult]) => {
63
- data.push({
64
- permissionName,
65
- profiles: permResult.profiles.length,
66
- permissionSets: permResult.permissionSets.length,
67
- });
68
- });
69
- this.table({ data, title: '=== Summary ===', titleOptions: { bold: true } });
70
- }
71
- printPermissionResults(permissionName, result) {
72
- const data = [];
73
- result.profiles.forEach((entityName) => {
74
- data.push({ entityName, type: 'Profile' });
75
- });
76
- result.permissionSets.forEach((entityName) => {
77
- data.push({ entityName, type: 'Permission Set' });
78
- });
79
- if (data.length > 0) {
80
- this.table({ data, title: permissionName, titleOptions: { underline: true } });
81
- }
82
- }
83
- }
84
- export function isEntityStatus(cls) {
85
- return cls.total !== undefined && cls.resolved !== undefined;
86
- }
87
- //# sourceMappingURL=user-perms.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user-perms.js","sourceRoot":"","sources":["../../../../src/commands/org/scan/user-perms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,qBAGN,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEzD,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,oCAAoC,EAAE,qBAAqB,CAAC,CAAC;AAIpG,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,SAAgC;IACpE,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,CAAU,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAE5D,MAAM,CAAU,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