@j-schreiber/sf-cli-security-audit 0.11.0 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/lib/commands/org/audit/init.d.ts +5 -3
- package/lib/commands/org/audit/init.js +14 -20
- package/lib/commands/org/audit/init.js.map +1 -1
- package/lib/commands/org/audit/run.d.ts +1 -1
- package/lib/commands/org/audit/run.js +5 -3
- package/lib/commands/org/audit/run.js.map +1 -1
- package/lib/commands/org/scan/user-perms.js +1 -1
- package/lib/commands/org/scan/user-perms.js.map +1 -1
- package/lib/libs/{core → audit-engine}/auditRun.d.ts +6 -7
- package/lib/libs/{core → audit-engine}/auditRun.js +20 -16
- package/lib/libs/audit-engine/auditRun.js.map +1 -0
- package/lib/libs/audit-engine/file-manager/fileManager.d.ts +31 -0
- package/lib/libs/audit-engine/file-manager/fileManager.js +139 -0
- package/lib/libs/audit-engine/file-manager/fileManager.js.map +1 -0
- package/lib/libs/audit-engine/file-manager/fileManager.types.d.ts +30 -0
- package/lib/libs/audit-engine/file-manager/fileManager.types.js +2 -0
- package/lib/libs/audit-engine/file-manager/fileManager.types.js.map +1 -0
- package/lib/libs/audit-engine/index.d.ts +121 -0
- package/lib/libs/audit-engine/index.js +9 -0
- package/lib/libs/audit-engine/index.js.map +1 -0
- package/lib/libs/{core/registries/types.d.ts → audit-engine/registry/context.types.d.ts} +6 -10
- package/lib/libs/audit-engine/registry/context.types.js +2 -0
- package/lib/libs/audit-engine/registry/context.types.js.map +1 -0
- package/lib/libs/audit-engine/registry/definitions.d.ts +23 -0
- package/lib/libs/audit-engine/registry/definitions.js +53 -0
- package/lib/libs/audit-engine/registry/definitions.js.map +1 -0
- package/lib/libs/{core/registries → audit-engine/registry}/helpers/permissionsScanning.d.ts +12 -2
- package/lib/libs/{core/registries → audit-engine/registry}/helpers/permissionsScanning.js +15 -3
- package/lib/libs/audit-engine/registry/helpers/permissionsScanning.js.map +1 -0
- package/lib/libs/audit-engine/registry/policies/connectedApps.d.ts +12 -0
- package/lib/libs/audit-engine/registry/policies/connectedApps.js +22 -0
- package/lib/libs/audit-engine/registry/policies/connectedApps.js.map +1 -0
- package/lib/libs/audit-engine/registry/policies/permissionSets.d.ts +18 -0
- package/lib/libs/audit-engine/registry/policies/permissionSets.js +80 -0
- package/lib/libs/audit-engine/registry/policies/permissionSets.js.map +1 -0
- package/lib/libs/audit-engine/registry/policies/profiles.d.ts +18 -0
- package/lib/libs/audit-engine/registry/policies/profiles.js +76 -0
- package/lib/libs/audit-engine/registry/policies/profiles.js.map +1 -0
- package/lib/libs/audit-engine/registry/policies/settings.d.ts +18 -0
- package/lib/libs/{core/policies/settingsPolicy.js → audit-engine/registry/policies/settings.js} +48 -18
- package/lib/libs/audit-engine/registry/policies/settings.js.map +1 -0
- package/lib/libs/audit-engine/registry/policies/users.d.ts +19 -0
- package/lib/libs/audit-engine/registry/policies/users.js +76 -0
- package/lib/libs/audit-engine/registry/policies/users.js.map +1 -0
- package/lib/libs/{core/policies → audit-engine/registry}/policy.d.ts +7 -6
- package/lib/libs/{core/policies → audit-engine/registry}/policy.js +2 -0
- package/lib/libs/audit-engine/registry/policy.js.map +1 -0
- package/lib/libs/{core/result-types.d.ts → audit-engine/registry/result.types.d.ts} +2 -2
- package/lib/libs/audit-engine/registry/result.types.js +2 -0
- package/lib/libs/audit-engine/registry/result.types.js.map +1 -0
- package/lib/libs/{core/registries → audit-engine/registry}/ruleRegistry.d.ts +10 -7
- package/lib/libs/{core/registries → audit-engine/registry}/ruleRegistry.js +7 -7
- package/lib/libs/audit-engine/registry/ruleRegistry.js.map +1 -0
- package/lib/libs/audit-engine/registry/rules/allUsedAppsUnderManagement.d.ts +7 -0
- package/lib/libs/audit-engine/registry/rules/allUsedAppsUnderManagement.js.map +1 -0
- package/lib/libs/{core/registries → audit-engine/registry}/rules/enforcePermissionPresets.d.ts +4 -2
- package/lib/libs/{core/registries → audit-engine/registry}/rules/enforcePermissionPresets.js +17 -15
- package/lib/libs/audit-engine/registry/rules/enforcePermissionPresets.js.map +1 -0
- package/lib/libs/{core/registries → audit-engine/registry}/rules/enforcePermissionsOnProfileLike.d.ts +1 -1
- package/lib/libs/{core/registries → audit-engine/registry}/rules/enforcePermissionsOnProfileLike.js +3 -3
- package/lib/libs/audit-engine/registry/rules/enforcePermissionsOnProfileLike.js.map +1 -0
- package/lib/libs/{core/registries → audit-engine/registry}/rules/enforcePermissionsOnUser.d.ts +2 -2
- package/lib/libs/audit-engine/registry/rules/enforcePermissionsOnUser.js +38 -0
- package/lib/libs/audit-engine/registry/rules/enforcePermissionsOnUser.js.map +1 -0
- package/lib/libs/{core/registries → audit-engine/registry}/rules/enforceSettings.d.ts +2 -2
- package/lib/libs/audit-engine/registry/rules/enforceSettings.js.map +1 -0
- package/lib/libs/audit-engine/registry/rules/noInactiveUsers.d.ts +14 -0
- package/lib/libs/{core/registries → audit-engine/registry}/rules/noInactiveUsers.js +17 -4
- package/lib/libs/audit-engine/registry/rules/noInactiveUsers.js.map +1 -0
- package/lib/libs/{core/registries → audit-engine/registry}/rules/noOtherApexApiLogins.d.ts +2 -2
- package/lib/libs/{core/registries → audit-engine/registry}/rules/noOtherApexApiLogins.js +4 -1
- package/lib/libs/audit-engine/registry/rules/noOtherApexApiLogins.js.map +1 -0
- package/lib/libs/audit-engine/registry/rules/noUserCanSelfAuthorize.d.ts +7 -0
- package/lib/libs/audit-engine/registry/rules/noUserCanSelfAuthorize.js.map +1 -0
- package/lib/libs/{core/registries → audit-engine/registry}/rules/policyRule.d.ts +4 -6
- package/lib/libs/{core/registries → audit-engine/registry}/rules/policyRule.js +2 -12
- package/lib/libs/audit-engine/registry/rules/policyRule.js.map +1 -0
- package/lib/libs/audit-engine/registry/schema.d.ts +2 -0
- package/lib/libs/audit-engine/registry/schema.js +11 -0
- package/lib/libs/audit-engine/registry/schema.js.map +1 -0
- package/lib/libs/audit-engine/registry/shape/auditConfigShape.d.ts +122 -0
- package/lib/libs/audit-engine/registry/shape/auditConfigShape.js +54 -0
- package/lib/libs/audit-engine/registry/shape/auditConfigShape.js.map +1 -0
- package/lib/libs/audit-engine/registry/shape/schema.d.ts +96 -0
- package/lib/libs/audit-engine/registry/shape/schema.js +84 -0
- package/lib/libs/audit-engine/registry/shape/schema.js.map +1 -0
- package/lib/libs/conf-init/auditConfig.d.ts +3 -12
- package/lib/libs/conf-init/auditConfig.js +25 -25
- package/lib/libs/conf-init/auditConfig.js.map +1 -1
- package/lib/libs/conf-init/defaultClassifications.d.ts +8 -0
- package/lib/libs/conf-init/defaultClassifications.js +116 -0
- package/lib/libs/conf-init/defaultClassifications.js.map +1 -0
- package/lib/libs/conf-init/defaultPolicies.d.ts +2 -0
- package/lib/libs/conf-init/defaultPolicies.js +20 -0
- package/lib/libs/conf-init/defaultPolicies.js.map +1 -0
- package/lib/libs/conf-init/init.types.d.ts +27 -0
- package/lib/libs/conf-init/init.types.js +8 -0
- package/lib/libs/conf-init/init.types.js.map +1 -0
- package/lib/libs/conf-init/presets/loose.d.ts +1 -1
- package/lib/libs/conf-init/presets/loose.js +4 -2
- package/lib/libs/conf-init/presets/loose.js.map +1 -1
- package/lib/libs/conf-init/presets/none.d.ts +2 -7
- package/lib/libs/conf-init/presets/none.js +1 -1
- package/lib/libs/conf-init/presets/none.js.map +1 -1
- package/lib/libs/conf-init/presets/strict.js +3 -1
- package/lib/libs/conf-init/presets/strict.js.map +1 -1
- package/lib/libs/conf-init/presets.d.ts +1 -6
- package/lib/libs/conf-init/presets.js +1 -6
- package/lib/libs/conf-init/presets.js.map +1 -1
- package/lib/libs/quick-scan/userPermissionScanner.js +17 -13
- package/lib/libs/quick-scan/userPermissionScanner.js.map +1 -1
- package/lib/salesforce/index.d.ts +10 -0
- package/lib/salesforce/index.js +8 -0
- package/lib/salesforce/index.js.map +1 -0
- package/lib/salesforce/mdapi/constants.d.ts +1 -0
- package/lib/salesforce/mdapi/constants.js +3 -0
- package/lib/salesforce/mdapi/constants.js.map +1 -0
- package/lib/{libs/core/mdapi/anySettingsMetadata.d.ts → salesforce/mdapi/genericSettingsMetadata.d.ts} +3 -4
- package/lib/{libs/core/mdapi/anySettingsMetadata.js → salesforce/mdapi/genericSettingsMetadata.js} +8 -10
- package/lib/salesforce/mdapi/genericSettingsMetadata.js.map +1 -0
- package/lib/salesforce/mdapi/mdapi.d.ts +46 -0
- package/lib/{libs/core/mdapi/mdapiRetriever.js → salesforce/mdapi/mdapi.js} +19 -40
- package/lib/salesforce/mdapi/mdapi.js.map +1 -0
- package/lib/salesforce/mdapi/metadataRegistry.d.ts +26 -0
- package/lib/salesforce/mdapi/metadataRegistry.js +43 -0
- package/lib/salesforce/mdapi/metadataRegistry.js.map +1 -0
- package/lib/{libs/core → salesforce}/mdapi/metadataRegistryEntry.js +1 -1
- package/lib/salesforce/mdapi/metadataRegistryEntry.js.map +1 -0
- package/lib/{libs/core → salesforce}/mdapi/namedMetadataToolingQueryable.js +1 -1
- package/lib/{libs/core → salesforce}/mdapi/namedMetadataToolingQueryable.js.map +1 -1
- package/lib/salesforce/mdapi/namedMetadataType.js.map +1 -0
- package/lib/salesforce/mdapi/singletonMetadataType.js.map +1 -0
- package/lib/salesforce/repositories/connected-apps/connected-app.types.d.ts +28 -0
- package/lib/salesforce/repositories/connected-apps/connected-app.types.js +6 -0
- package/lib/salesforce/repositories/connected-apps/connected-app.types.js.map +1 -0
- package/lib/salesforce/repositories/connected-apps/connected-apps.d.ts +16 -0
- package/lib/salesforce/repositories/connected-apps/connected-apps.js +83 -0
- package/lib/salesforce/repositories/connected-apps/connected-apps.js.map +1 -0
- package/lib/salesforce/repositories/connected-apps/queries.d.ts +2 -0
- package/lib/salesforce/repositories/connected-apps/queries.js +3 -0
- package/lib/salesforce/repositories/connected-apps/queries.js.map +1 -0
- package/lib/salesforce/repositories/perm-sets/perm-sets.types.d.ts +29 -0
- package/lib/salesforce/repositories/perm-sets/perm-sets.types.js +10 -0
- package/lib/salesforce/repositories/perm-sets/perm-sets.types.js.map +1 -0
- package/lib/salesforce/repositories/perm-sets/permission-sets.d.ts +11 -0
- package/lib/salesforce/repositories/perm-sets/permission-sets.js +43 -0
- package/lib/salesforce/repositories/perm-sets/permission-sets.js.map +1 -0
- package/lib/salesforce/repositories/perm-sets/queries.d.ts +1 -0
- package/lib/salesforce/repositories/perm-sets/queries.js +2 -0
- package/lib/salesforce/repositories/perm-sets/queries.js.map +1 -0
- package/lib/salesforce/repositories/profiles/profile.types.d.ts +29 -0
- package/lib/salesforce/repositories/profiles/profile.types.js +8 -0
- package/lib/salesforce/repositories/profiles/profile.types.js.map +1 -0
- package/lib/salesforce/repositories/profiles/profiles.d.ts +14 -0
- package/lib/salesforce/repositories/profiles/profiles.js +38 -0
- package/lib/salesforce/repositories/profiles/profiles.js.map +1 -0
- package/lib/salesforce/repositories/profiles/queries.d.ts +2 -0
- package/lib/salesforce/repositories/profiles/queries.js +7 -0
- package/lib/salesforce/repositories/profiles/queries.js.map +1 -0
- package/lib/salesforce/repositories/users/queries.d.ts +3 -0
- package/lib/{libs/core/constants.js → salesforce/repositories/users/queries.js} +1 -11
- package/lib/salesforce/repositories/users/queries.js.map +1 -0
- package/lib/salesforce/repositories/users/user.types.d.ts +54 -0
- package/lib/salesforce/repositories/users/user.types.js +12 -0
- package/lib/salesforce/repositories/users/user.types.js.map +1 -0
- package/lib/salesforce/repositories/users/users.d.ts +22 -0
- package/lib/salesforce/repositories/users/users.js +134 -0
- package/lib/salesforce/repositories/users/users.js.map +1 -0
- package/lib/{libs/core/utils.d.ts → utils.d.ts} +2 -0
- package/lib/{libs/core/utils.js → utils.js} +26 -0
- package/lib/utils.js.map +1 -0
- package/lib/ux/auditRunMultiStage.d.ts +1 -1
- package/lib/ux/auditRunMultiStage.js +5 -5
- package/lib/ux/auditRunMultiStage.js.map +1 -1
- package/messages/policies.general.md +9 -1
- package/messages/policyclassifications.md +8 -0
- package/messages/rules.enforceClassificationPresets.md +2 -2
- package/messages/rules.users.md +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/lib/libs/conf-init/permissionsClassification.d.ts +0 -37
- package/lib/libs/conf-init/permissionsClassification.js +0 -126
- package/lib/libs/conf-init/permissionsClassification.js.map +0 -1
- package/lib/libs/conf-init/policyConfigs.d.ts +0 -21
- package/lib/libs/conf-init/policyConfigs.js +0 -47
- package/lib/libs/conf-init/policyConfigs.js.map +0 -1
- package/lib/libs/core/auditRun.js.map +0 -1
- package/lib/libs/core/classification-types.d.ts +0 -20
- package/lib/libs/core/classification-types.js +0 -23
- package/lib/libs/core/classification-types.js.map +0 -1
- package/lib/libs/core/constants.d.ts +0 -10
- package/lib/libs/core/constants.js.map +0 -1
- package/lib/libs/core/file-mgmt/auditConfigFileManager.d.ts +0 -48
- package/lib/libs/core/file-mgmt/auditConfigFileManager.js +0 -145
- package/lib/libs/core/file-mgmt/auditConfigFileManager.js.map +0 -1
- package/lib/libs/core/file-mgmt/schema.d.ts +0 -156
- package/lib/libs/core/file-mgmt/schema.js +0 -81
- package/lib/libs/core/file-mgmt/schema.js.map +0 -1
- package/lib/libs/core/mdapi/anySettingsMetadata.js.map +0 -1
- package/lib/libs/core/mdapi/mdapiRetriever.d.ts +0 -54
- package/lib/libs/core/mdapi/mdapiRetriever.js.map +0 -1
- package/lib/libs/core/mdapi/metadataRegistryEntry.js.map +0 -1
- package/lib/libs/core/mdapi/namedMetadataType.js.map +0 -1
- package/lib/libs/core/mdapi/singletonMetadataType.js.map +0 -1
- package/lib/libs/core/mdapi/usersRepository.d.ts +0 -85
- package/lib/libs/core/mdapi/usersRepository.js +0 -126
- package/lib/libs/core/mdapi/usersRepository.js.map +0 -1
- package/lib/libs/core/policies/connectedAppPolicy.d.ts +0 -10
- package/lib/libs/core/policies/connectedAppPolicy.js +0 -78
- package/lib/libs/core/policies/connectedAppPolicy.js.map +0 -1
- package/lib/libs/core/policies/permissionSetPolicy.d.ts +0 -12
- package/lib/libs/core/policies/permissionSetPolicy.js +0 -64
- package/lib/libs/core/policies/permissionSetPolicy.js.map +0 -1
- package/lib/libs/core/policies/policy.js.map +0 -1
- package/lib/libs/core/policies/profilePolicy.d.ts +0 -12
- package/lib/libs/core/policies/profilePolicy.js +0 -65
- package/lib/libs/core/policies/profilePolicy.js.map +0 -1
- package/lib/libs/core/policies/salesforceStandardTypes.d.ts +0 -58
- package/lib/libs/core/policies/salesforceStandardTypes.js +0 -2
- package/lib/libs/core/policies/salesforceStandardTypes.js.map +0 -1
- package/lib/libs/core/policies/settingsPolicy.d.ts +0 -11
- package/lib/libs/core/policies/settingsPolicy.js.map +0 -1
- package/lib/libs/core/policies/userPolicy.d.ts +0 -12
- package/lib/libs/core/policies/userPolicy.js +0 -62
- package/lib/libs/core/policies/userPolicy.js.map +0 -1
- package/lib/libs/core/policy-types.d.ts +0 -18
- package/lib/libs/core/policy-types.js +0 -28
- package/lib/libs/core/policy-types.js.map +0 -1
- package/lib/libs/core/policyRegistry.d.ts +0 -23
- package/lib/libs/core/policyRegistry.js +0 -52
- package/lib/libs/core/policyRegistry.js.map +0 -1
- package/lib/libs/core/registries/connectedApps.d.ts +0 -13
- package/lib/libs/core/registries/connectedApps.js +0 -13
- package/lib/libs/core/registries/connectedApps.js.map +0 -1
- package/lib/libs/core/registries/helpers/permissionsScanning.js.map +0 -1
- package/lib/libs/core/registries/permissionSets.d.ts +0 -11
- package/lib/libs/core/registries/permissionSets.js +0 -11
- package/lib/libs/core/registries/permissionSets.js.map +0 -1
- package/lib/libs/core/registries/profiles.d.ts +0 -11
- package/lib/libs/core/registries/profiles.js +0 -11
- package/lib/libs/core/registries/profiles.js.map +0 -1
- package/lib/libs/core/registries/ruleRegistry.js.map +0 -1
- package/lib/libs/core/registries/rules/allUsedAppsUnderManagement.d.ts +0 -7
- package/lib/libs/core/registries/rules/allUsedAppsUnderManagement.js.map +0 -1
- package/lib/libs/core/registries/rules/enforcePermissionPresets.js.map +0 -1
- package/lib/libs/core/registries/rules/enforcePermissionsOnProfileLike.js.map +0 -1
- package/lib/libs/core/registries/rules/enforcePermissionsOnUser.js +0 -42
- package/lib/libs/core/registries/rules/enforcePermissionsOnUser.js.map +0 -1
- package/lib/libs/core/registries/rules/enforceSettings.js.map +0 -1
- package/lib/libs/core/registries/rules/noInactiveUsers.d.ts +0 -9
- package/lib/libs/core/registries/rules/noInactiveUsers.js.map +0 -1
- package/lib/libs/core/registries/rules/noOtherApexApiLogins.js.map +0 -1
- package/lib/libs/core/registries/rules/noUserCanSelfAuthorize.d.ts +0 -7
- package/lib/libs/core/registries/rules/noUserCanSelfAuthorize.js.map +0 -1
- package/lib/libs/core/registries/rules/policyRule.js.map +0 -1
- package/lib/libs/core/registries/settings.d.ts +0 -8
- package/lib/libs/core/registries/settings.js +0 -51
- package/lib/libs/core/registries/settings.js.map +0 -1
- package/lib/libs/core/registries/types.js +0 -13
- package/lib/libs/core/registries/types.js.map +0 -1
- package/lib/libs/core/registries/users.d.ts +0 -10
- package/lib/libs/core/registries/users.js +0 -17
- package/lib/libs/core/registries/users.js.map +0 -1
- package/lib/libs/core/result-types.js +0 -2
- package/lib/libs/core/result-types.js.map +0 -1
- package/lib/libs/core/utils.js.map +0 -1
- /package/lib/libs/{core/registries → audit-engine/registry}/rules/allUsedAppsUnderManagement.js +0 -0
- /package/lib/libs/{core/registries → audit-engine/registry}/rules/enforceSettings.js +0 -0
- /package/lib/libs/{core/registries → audit-engine/registry}/rules/noUserCanSelfAuthorize.js +0 -0
- /package/lib/{libs/core → salesforce}/mdapi/metadataRegistryEntry.d.ts +0 -0
- /package/lib/{libs/core → salesforce}/mdapi/namedMetadataToolingQueryable.d.ts +0 -0
- /package/lib/{libs/core → salesforce}/mdapi/namedMetadataType.d.ts +0 -0
- /package/lib/{libs/core → salesforce}/mdapi/namedMetadataType.js +0 -0
- /package/lib/{libs/core → salesforce}/mdapi/singletonMetadataType.d.ts +0 -0
- /package/lib/{libs/core → salesforce}/mdapi/singletonMetadataType.js +0 -0
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
// QUERIES
|
|
3
|
-
export const CUSTOM_PERMS_QUERY = 'SELECT Id,MasterLabel,DeveloperName FROM CustomPermission';
|
|
4
|
-
export const PROFILES_QUERY = 'SELECT Profile.Name,Profile.UserType,IsCustom FROM PermissionSet WHERE IsOwnedByProfile = TRUE';
|
|
5
|
-
export const PERMISSION_SETS_QUERY = 'SELECT Name,Label,IsCustom,NamespacePrefix FROM PermissionSet WHERE IsOwnedByProfile = FALSE AND NamespacePrefix = NULL';
|
|
6
|
-
export const CONNECTED_APPS_QUERY = 'SELECT Name,OptionsAllowAdminApprovedUsersOnly FROM ConnectedApplication';
|
|
7
|
-
export const OAUTH_TOKEN_QUERY = 'SELECT User.Username,UseCount,AppName FROM OauthToken';
|
|
8
|
-
export const ACTIVE_USERS_QUERY = "SELECT Id,Username,UserType FROM User WHERE IsActive = TRUE AND UserType IN ('Standard') LIMIT 2000";
|
|
9
1
|
export const ACTIVE_USERS_DETAILS_QUERY = "SELECT Id,Username,Profile.Name,CreatedDate,LastLoginDate FROM User WHERE IsActive = TRUE AND UserType IN ('Standard') LIMIT 2000";
|
|
10
2
|
// DYNAMIC QUERIES
|
|
11
3
|
export const buildPermsetAssignmentsQuery = (userIds) => `${USERS_PERMSET_ASSIGNMENTS_QUERY} AND AssigneeId IN (${userIds.map((userId) => `'${userId}'`).join(',')})`;
|
|
12
4
|
export const buildLoginHistoryQuery = (daysToAnalayse) => daysToAnalayse
|
|
13
5
|
? `${USERS_LOGIN_HISTORY_QUERY} WHERE LoginTime >= LAST_N_DAYS:${daysToAnalayse} GROUP BY LoginType,Application,UserId`
|
|
14
6
|
: `${USERS_LOGIN_HISTORY_QUERY} GROUP BY LoginType,Application,UserId`;
|
|
15
|
-
// PATHS
|
|
16
|
-
export const RETRIEVE_CACHE = path.join('.jsc', 'retrieves');
|
|
17
7
|
// BASE QUERIES
|
|
18
8
|
const USERS_LOGIN_HISTORY_QUERY = 'SELECT LoginType,Application,UserId,COUNT(Id)LoginCount,MAX(LoginTime)LastLogin FROM LoginHistory';
|
|
19
9
|
const USERS_PERMSET_ASSIGNMENTS_QUERY = 'SELECT AssigneeId,PermissionSet.Name FROM PermissionSetAssignment WHERE PermissionSet.IsOwnedByProfile = FALSE AND PermissionSet.NamespacePrefix = NULL';
|
|
20
|
-
//# sourceMappingURL=
|
|
10
|
+
//# sourceMappingURL=queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../../src/salesforce/repositories/users/queries.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0BAA0B,GACrC,mIAAmI,CAAC;AAEtI,kBAAkB;AAClB,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,OAAiB,EAAU,EAAE,CACxE,GAAG,+BAA+B,uBAAuB,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AAE/G,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,cAAuB,EAAU,EAAE,CACxE,cAAc;IACZ,CAAC,CAAC,GAAG,yBAAyB,mCAAmC,cAAc,wCAAwC;IACvH,CAAC,CAAC,GAAG,yBAAyB,wCAAwC,CAAC;AAE3E,eAAe;AACf,MAAM,yBAAyB,GAC7B,mGAAmG,CAAC;AACtG,MAAM,+BAA+B,GACnC,yJAAyJ,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { PermissionSet, Profile } from '@jsforce/jsforce-node/lib/api/metadata.js';
|
|
3
|
+
export type User = {
|
|
4
|
+
userId: string;
|
|
5
|
+
username: string;
|
|
6
|
+
profileName: string;
|
|
7
|
+
createdDate: number;
|
|
8
|
+
lastLogin?: number;
|
|
9
|
+
logins?: UserLogins[];
|
|
10
|
+
assignments?: PermissionSetAssignment[];
|
|
11
|
+
profileMetadata?: Profile;
|
|
12
|
+
};
|
|
13
|
+
export type UserPermissions = {
|
|
14
|
+
profileMetadata?: Profile;
|
|
15
|
+
assignedPermissionsets: PermissionSetAssignment[];
|
|
16
|
+
};
|
|
17
|
+
export type UserLogins = {
|
|
18
|
+
loginType: string;
|
|
19
|
+
application: string;
|
|
20
|
+
loginCount: number;
|
|
21
|
+
lastLogin: number;
|
|
22
|
+
};
|
|
23
|
+
export type PermissionSetAssignment = {
|
|
24
|
+
/**
|
|
25
|
+
* Developer name of the permission set
|
|
26
|
+
*/
|
|
27
|
+
permissionSetIdentifier: string;
|
|
28
|
+
/**
|
|
29
|
+
* How user got this permission set assigned
|
|
30
|
+
*/
|
|
31
|
+
permissionSetSource: 'direct' | 'group';
|
|
32
|
+
/**
|
|
33
|
+
* Metadata of the permission set
|
|
34
|
+
*/
|
|
35
|
+
metadata?: PermissionSet;
|
|
36
|
+
/**
|
|
37
|
+
* If permission set is assigned through a group,
|
|
38
|
+
* this is the name of the group.
|
|
39
|
+
*/
|
|
40
|
+
groupName?: string;
|
|
41
|
+
};
|
|
42
|
+
export declare const ResolveUsersOptionsSchema: z.ZodObject<{
|
|
43
|
+
withLoginHistory: z.ZodDefault<z.ZodBoolean>;
|
|
44
|
+
loginHistoryDaysToAnalyse: z.ZodOptional<z.ZodNumber>;
|
|
45
|
+
withPermissions: z.ZodDefault<z.ZodBoolean>;
|
|
46
|
+
withPermissionsMetadata: z.ZodDefault<z.ZodBoolean>;
|
|
47
|
+
}, z.z.core.$strip>;
|
|
48
|
+
export type ResolveUsersOptions = z.infer<typeof ResolveUsersOptionsSchema>;
|
|
49
|
+
export type ResolvePermissionsOptions = {
|
|
50
|
+
/**
|
|
51
|
+
* Resolve permission set and profile metadata
|
|
52
|
+
*/
|
|
53
|
+
withMetadata: boolean;
|
|
54
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
export const ResolveUsersOptionsSchema = z.object({
|
|
3
|
+
/** Resolve users with login history */
|
|
4
|
+
withLoginHistory: z.boolean().default(false),
|
|
5
|
+
/** Length of login history. Has no effect, if login history is false */
|
|
6
|
+
loginHistoryDaysToAnalyse: z.number().optional(),
|
|
7
|
+
/** Include profile and assigned permission sets */
|
|
8
|
+
withPermissions: z.boolean().default(false),
|
|
9
|
+
/** Adds metadata to permissions. Has no effect, if withPermissions is false */
|
|
10
|
+
withPermissionsMetadata: z.boolean().default(false),
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=user.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.types.js","sourceRoot":"","sources":["../../../../src/salesforce/repositories/users/user.types.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AA8CpB,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,uCAAuC;IACvC,gBAAgB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IAC5C,wEAAwE;IACxE,yBAAyB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChD,mDAAmD;IACnD,eAAe,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IAC3C,+EAA+E;IAC/E,uBAAuB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;CACpD,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Connection } from '@salesforce/core';
|
|
2
|
+
import { ResolveUsersOptions, User } from './user.types.js';
|
|
3
|
+
export default class Users {
|
|
4
|
+
private readonly connection;
|
|
5
|
+
private readonly mdapiRepo;
|
|
6
|
+
constructor(connection: Connection);
|
|
7
|
+
/**
|
|
8
|
+
* Resolve all users from the target connection. Options controls
|
|
9
|
+
* additional properties that are resolved.
|
|
10
|
+
*
|
|
11
|
+
* @param opts
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
resolve(opts?: Partial<ResolveUsersOptions>): Promise<Map<string, User>>;
|
|
15
|
+
private resolveLogins;
|
|
16
|
+
private resolvePermissions;
|
|
17
|
+
private fetchLoginData;
|
|
18
|
+
private resolvePermSetAssignments;
|
|
19
|
+
private resolveProfiles;
|
|
20
|
+
private resolvePermissionSets;
|
|
21
|
+
private fetchAssignments;
|
|
22
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { isNullish } from '../../../utils.js';
|
|
2
|
+
import MDAPI from '../../mdapi/mdapi.js';
|
|
3
|
+
import { ResolveUsersOptionsSchema, } from './user.types.js';
|
|
4
|
+
import { ACTIVE_USERS_DETAILS_QUERY, buildLoginHistoryQuery, buildPermsetAssignmentsQuery } from './queries.js';
|
|
5
|
+
export default class Users {
|
|
6
|
+
connection;
|
|
7
|
+
mdapiRepo;
|
|
8
|
+
constructor(connection) {
|
|
9
|
+
this.connection = connection;
|
|
10
|
+
this.mdapiRepo = MDAPI.create(this.connection);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Resolve all users from the target connection. Options controls
|
|
14
|
+
* additional properties that are resolved.
|
|
15
|
+
*
|
|
16
|
+
* @param opts
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
async resolve(opts) {
|
|
20
|
+
const definitiveOpts = ResolveUsersOptionsSchema.parse(opts ?? {});
|
|
21
|
+
const result = new Map();
|
|
22
|
+
const allUsersOnOrg = await this.connection.query(ACTIVE_USERS_DETAILS_QUERY);
|
|
23
|
+
for (const user of allUsersOnOrg.records) {
|
|
24
|
+
const usr = {
|
|
25
|
+
userId: user.Id,
|
|
26
|
+
username: user.Username,
|
|
27
|
+
lastLogin: user.LastLoginDate ? Date.parse(user.LastLoginDate) : undefined,
|
|
28
|
+
createdDate: Date.parse(user.CreatedDate),
|
|
29
|
+
profileName: user.Profile.Name,
|
|
30
|
+
};
|
|
31
|
+
result.set(user.Username, usr);
|
|
32
|
+
}
|
|
33
|
+
if (definitiveOpts.withLoginHistory) {
|
|
34
|
+
await this.resolveLogins(result, definitiveOpts.loginHistoryDaysToAnalyse);
|
|
35
|
+
}
|
|
36
|
+
if (definitiveOpts.withPermissions) {
|
|
37
|
+
await this.resolvePermissions(result, definitiveOpts.withPermissionsMetadata);
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
// PRIVATE ZONE
|
|
42
|
+
async resolveLogins(users, daysToAnalyse) {
|
|
43
|
+
const userLogins = await this.fetchLoginData(daysToAnalyse);
|
|
44
|
+
for (const user of users.values()) {
|
|
45
|
+
if (userLogins.has(user.userId)) {
|
|
46
|
+
user.logins = userLogins.get(user.userId);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
user.logins = [];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async resolvePermissions(users, withMetadata) {
|
|
54
|
+
await this.resolvePermSetAssignments(users);
|
|
55
|
+
if (withMetadata) {
|
|
56
|
+
await this.resolveProfiles(users);
|
|
57
|
+
await this.resolvePermissionSets(users);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async fetchLoginData(daysToAnalyse) {
|
|
61
|
+
const loginHistory = await this.connection.query(buildLoginHistoryQuery(daysToAnalyse));
|
|
62
|
+
const partialUsers = new Map();
|
|
63
|
+
for (const loginHistoryRow of loginHistory.records) {
|
|
64
|
+
if (!partialUsers.has(loginHistoryRow.UserId)) {
|
|
65
|
+
partialUsers.set(loginHistoryRow.UserId, []);
|
|
66
|
+
}
|
|
67
|
+
partialUsers.get(loginHistoryRow.UserId).push({
|
|
68
|
+
loginType: loginHistoryRow.LoginType,
|
|
69
|
+
loginCount: loginHistoryRow.LoginCount,
|
|
70
|
+
application: loginHistoryRow.Application,
|
|
71
|
+
lastLogin: Date.parse(loginHistoryRow.LastLogin),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return partialUsers;
|
|
75
|
+
}
|
|
76
|
+
async resolvePermSetAssignments(users) {
|
|
77
|
+
const userIds = Array.from(users.values()).map((usr) => usr.userId);
|
|
78
|
+
const assignments = await this.fetchAssignments(userIds);
|
|
79
|
+
for (const user of users.values()) {
|
|
80
|
+
user.assignments = assignments.get(user.userId) ?? [];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
async resolveProfiles(users) {
|
|
84
|
+
const profiles = await this.mdapiRepo.resolve('Profile', uniqueProfileNames(users.values()));
|
|
85
|
+
for (const user of users.values()) {
|
|
86
|
+
user.profileMetadata = profiles[user.profileName];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async resolvePermissionSets(users) {
|
|
90
|
+
const permSetNames = uniquePermissionSetNames(users.values());
|
|
91
|
+
const permsets = await this.mdapiRepo.resolve('PermissionSet', permSetNames);
|
|
92
|
+
for (const user of users.values()) {
|
|
93
|
+
for (const ass of user.assignments) {
|
|
94
|
+
ass.metadata = permsets[ass.permissionSetIdentifier];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async fetchAssignments(userIds) {
|
|
99
|
+
const assignments = new Map();
|
|
100
|
+
const rawAssignment = await this.connection.query(buildPermsetAssignmentsQuery(userIds));
|
|
101
|
+
for (const assignment of rawAssignment.records) {
|
|
102
|
+
if (isNullish(assignments.get(assignment.AssigneeId))) {
|
|
103
|
+
assignments.set(assignment.AssigneeId, []);
|
|
104
|
+
}
|
|
105
|
+
assignments.get(assignment.AssigneeId).push({
|
|
106
|
+
permissionSetIdentifier: assignment.PermissionSet.Name,
|
|
107
|
+
permissionSetSource: assignment.PermissionSetGroupId ? 'group' : 'direct',
|
|
108
|
+
...(assignment.PermissionSetGroup?.DeveloperName && {
|
|
109
|
+
groupName: assignment.PermissionSetGroup?.DeveloperName,
|
|
110
|
+
}),
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return assignments;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function uniquePermissionSetNames(users) {
|
|
117
|
+
const permSetNames = new Set();
|
|
118
|
+
for (const usr of users) {
|
|
119
|
+
if (usr.assignments) {
|
|
120
|
+
for (const ass of usr.assignments) {
|
|
121
|
+
permSetNames.add(ass.permissionSetIdentifier);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return Array.from(permSetNames);
|
|
126
|
+
}
|
|
127
|
+
function uniqueProfileNames(users) {
|
|
128
|
+
const uniqueProfiles = new Set();
|
|
129
|
+
for (const usr of users) {
|
|
130
|
+
uniqueProfiles.add(usr.profileName);
|
|
131
|
+
}
|
|
132
|
+
return Array.from(uniqueProfiles);
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=users.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.js","sourceRoot":"","sources":["../../../../src/salesforce/repositories/users/users.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,MAAM,sBAAsB,CAAC;AACzC,OAAO,EAGL,yBAAyB,GAG1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAEhH,MAAM,CAAC,OAAO,OAAO,KAAK;IAGY;IAFnB,SAAS,CAAQ;IAElC,YAAoC,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;QACxD,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,OAAO,CAAC,IAAmC;QACtD,MAAM,cAAc,GAAG,yBAAyB,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QACnE,MAAM,MAAM,GAAsB,IAAI,GAAG,EAAgB,CAAC;QAC1D,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,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C;QACxB,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -2,6 +2,8 @@ export declare function isEmpty(anything?: unknown): boolean;
|
|
|
2
2
|
export declare function isNullish(anything: unknown): boolean;
|
|
3
3
|
export declare function capitalize(anyString: string): string;
|
|
4
4
|
export declare function uncapitalize(anyString: string): string;
|
|
5
|
+
export declare function isParseableDate(value: unknown): boolean;
|
|
6
|
+
export declare function formatToLocale(value: unknown): string;
|
|
5
7
|
/**
|
|
6
8
|
* Both dates have to be UNIX timestamps
|
|
7
9
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isDate } from 'node:util/types';
|
|
1
2
|
export function isEmpty(anything) {
|
|
2
3
|
if (isNullish(anything)) {
|
|
3
4
|
return true;
|
|
@@ -16,6 +17,31 @@ export function capitalize(anyString) {
|
|
|
16
17
|
export function uncapitalize(anyString) {
|
|
17
18
|
return `${anyString[0].toLowerCase()}${anyString.slice(1)}`;
|
|
18
19
|
}
|
|
20
|
+
export function isParseableDate(value) {
|
|
21
|
+
if (typeof value === 'string') {
|
|
22
|
+
const d = new Date(value);
|
|
23
|
+
return !Number.isNaN(d.getTime());
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
export function formatToLocale(value) {
|
|
28
|
+
if (isParseableDate(value)) {
|
|
29
|
+
return new Date(value).toLocaleString();
|
|
30
|
+
}
|
|
31
|
+
if (isDate(value)) {
|
|
32
|
+
return value.toLocaleString();
|
|
33
|
+
}
|
|
34
|
+
switch (typeof value) {
|
|
35
|
+
case 'string':
|
|
36
|
+
return value;
|
|
37
|
+
case 'number':
|
|
38
|
+
return value.toLocaleString();
|
|
39
|
+
case 'object':
|
|
40
|
+
return JSON.stringify(value);
|
|
41
|
+
default:
|
|
42
|
+
return '';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
19
45
|
/**
|
|
20
46
|
* Both dates have to be UNIX timestamps
|
|
21
47
|
*
|
package/lib/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,MAAM,UAAU,OAAO,CAAC,QAAkB;IACxC,IAAI,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,MAAM,CAAC,OAAO,CAAC,QAAS,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,QAAiB;IACzC,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,KAAK,IAAI,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,SAAiB;IAC1C,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,SAAiB;IAC5C,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IACpC,C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+
import { AuditRun } from '../libs/audit-engine/index.js';
|
|
3
3
|
export declare const LOAD_AUDIT_CONFIG = "Loading audit config";
|
|
4
4
|
export declare const RESOLVE_POLICIES = "Resolving policies";
|
|
5
5
|
export declare const EXECUTE_RULES = "Executing rules";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MultiStageOutput } from '@oclif/multi-stage-output';
|
|
2
|
-
import { capitalize } from '../
|
|
2
|
+
import { capitalize } from '../utils.js';
|
|
3
3
|
export const LOAD_AUDIT_CONFIG = 'Loading audit config';
|
|
4
4
|
export const RESOLVE_POLICIES = 'Resolving policies';
|
|
5
5
|
export const EXECUTE_RULES = 'Executing rules';
|
|
@@ -61,8 +61,8 @@ export default class AuditRunMultiStageOutput {
|
|
|
61
61
|
}
|
|
62
62
|
startPolicyResolve(runInstance) {
|
|
63
63
|
this.mso.goto(RESOLVE_POLICIES, { currentStatus: 'Resolving' });
|
|
64
|
-
Object.entries(runInstance.
|
|
65
|
-
if (policy.
|
|
64
|
+
Object.entries(runInstance.config.policies).forEach(([policyName, policy]) => {
|
|
65
|
+
if (policy.enabled) {
|
|
66
66
|
this.addPolicyStatsListener(policyName, runInstance);
|
|
67
67
|
this.stageSpecificBlocks.push({
|
|
68
68
|
stage: RESOLVE_POLICIES,
|
|
@@ -83,8 +83,8 @@ export default class AuditRunMultiStageOutput {
|
|
|
83
83
|
}
|
|
84
84
|
startRuleExecution(runInstance) {
|
|
85
85
|
this.mso.goto(EXECUTE_RULES, { currentStatus: 'Executing' });
|
|
86
|
-
Object.entries(runInstance.
|
|
87
|
-
if (policy.
|
|
86
|
+
Object.entries(runInstance.config.policies).forEach(([policyName, policy]) => {
|
|
87
|
+
if (policy.enabled) {
|
|
88
88
|
const enabledRules = runInstance.getExecutableRulesCount(policyName);
|
|
89
89
|
this.stageSpecificBlocks.push({
|
|
90
90
|
stage: EXECUTE_RULES,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auditRunMultiStage.js","sourceRoot":"","sources":["../../src/ux/auditRunMultiStage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA2B,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"auditRunMultiStage.js","sourceRoot":"","sources":["../../src/ux/auditRunMultiStage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA2B,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,CAAC,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;AACxD,MAAM,CAAC,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;AACrD,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAC/C,MAAM,CAAC,MAAM,QAAQ,GAAG,oBAAoB,CAAC;AAmB7C,MAAM,CAAC,OAAO,OAAO,wBAAwB;IACpC,GAAG,CAAiC;IACpC,mBAAmB,CAAsC;IACxD,QAAQ,CAAmB;IAEnC,YAAmB,IAA2C;QAC5D,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,kBAAyD,CAAC;QAC1F,IAAI,CAAC,GAAG,GAAG,wBAAwB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACrB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,IAA2C;QAC9D,OAAO,IAAI,gBAAgB,CAAe,IAAI,CAAC,CAAC;IAClD,CAAC;IAED;;;;;;;;;;;;OAYG;IACI,MAAM,CAAC,MAAM,CAAC,IAA0B;QAC7C,OAAO,IAAI,wBAAwB,CAAC;YAClC,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,KAAK;YACtC,MAAM,EAAE,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,EAAE,QAAQ,CAAC;YACtE,KAAK,EAAE,cAAc;YACrB,cAAc,EAAE;gBACd;oBACE,IAAI,EAAE,SAA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,EAAE,CAAC,IAAwB,EAAE,EAAE;YAClF,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC9B,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;oBAClB,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;gBACrD,CAAC;gBACD,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;oBACf,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;gBAC/C,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC;YACvF,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;CACH"}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
# entity-not-found
|
|
2
2
|
|
|
3
|
-
Entity was not found on the target org.
|
|
3
|
+
Entity was classified, but not found on the target org.
|
|
4
|
+
|
|
5
|
+
# entity-not-classified
|
|
6
|
+
|
|
7
|
+
Entity was found on the target org, but not classified.
|
|
4
8
|
|
|
5
9
|
# profile-invalid-no-metadata
|
|
6
10
|
|
|
7
11
|
Org did not return valid metadata for the profile. Entity cannot be processed.
|
|
8
12
|
|
|
13
|
+
# permission-set-invalid-no-metadata
|
|
14
|
+
|
|
15
|
+
Org did not return valid metadata for the permission set. Entity cannot be processed.
|
|
16
|
+
|
|
9
17
|
# preset-unknown
|
|
10
18
|
|
|
11
19
|
%ss with preset UNKNOWN are ignored.
|
|
@@ -69,3 +69,11 @@ Reports allow to export classified or sensitive data.
|
|
|
69
69
|
# ManageRemoteAccess
|
|
70
70
|
|
|
71
71
|
Manage, create, edit, and delete connected applications.
|
|
72
|
+
|
|
73
|
+
# DeleteFieldHistoryArchive
|
|
74
|
+
|
|
75
|
+
Enabled in "User Interface" and allows to delete audit records. It should be limited to technical users.
|
|
76
|
+
|
|
77
|
+
# DeleteFieldHistory
|
|
78
|
+
|
|
79
|
+
Enabled in "User Interface" and allows to delete audit records. It should be limited to technical users.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# violations.classification-preset-mismatch
|
|
2
2
|
|
|
3
|
-
Permission is classified as "%s" and not allowed in
|
|
3
|
+
Permission is classified as "%s" and not allowed in role "%s".
|
|
4
4
|
|
|
5
5
|
# violations.permission-is-blocked
|
|
6
6
|
|
|
7
|
-
Permission is BLOCKED and not allowed
|
|
7
|
+
Permission is BLOCKED and not allowed for any role.
|
|
8
8
|
|
|
9
9
|
# warnings.permission-unknown
|
|
10
10
|
|
package/messages/rules.users.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# violations.no-other-apex-api-logins
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
%s logins with "Other Apex API" in the last %s days, which is a deprecated and insecure login type.
|
|
4
4
|
|
|
5
5
|
# violations.inactive-since-n-days
|
|
6
6
|
|
package/oclif.manifest.json
CHANGED
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.11.
|
|
4
|
+
"version": "0.11.2",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/j-schreiber/js-sf-cli-security-audit"
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Connection } from '@salesforce/core';
|
|
2
|
-
import { PermissionsClassificationContent, PermissionSetsClassificationContent, ProfilesClassificationContent, UsersClassificationContent } from '../core/file-mgmt/schema.js';
|
|
3
|
-
import { AuditInitPresets } from './presets.js';
|
|
4
|
-
/**
|
|
5
|
-
* Initialises a fresh set of user permissions from target org connection.
|
|
6
|
-
*
|
|
7
|
-
* @param con
|
|
8
|
-
* @returns
|
|
9
|
-
*/
|
|
10
|
-
export declare function initUserPermissions(con: Connection, preset?: AuditInitPresets): Promise<PermissionsClassificationContent>;
|
|
11
|
-
/**
|
|
12
|
-
* Initialises a fresh set of custom permissions from the target org
|
|
13
|
-
*
|
|
14
|
-
* @param con
|
|
15
|
-
* @returns
|
|
16
|
-
*/
|
|
17
|
-
export declare function initCustomPermissions(con: Connection): Promise<PermissionsClassificationContent | undefined>;
|
|
18
|
-
/**
|
|
19
|
-
* Initialises a profiles classification with all profiles from the org.
|
|
20
|
-
*
|
|
21
|
-
* @param targetOrgCon
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
export declare function initProfiles(targetOrgCon: Connection): Promise<ProfilesClassificationContent>;
|
|
25
|
-
/**
|
|
26
|
-
* Initialises permission set classification with all perm sets
|
|
27
|
-
*
|
|
28
|
-
* @param targetOrgCon
|
|
29
|
-
* @returns
|
|
30
|
-
*/
|
|
31
|
-
export declare function initPermissionSets(targetOrgCon: Connection): Promise<PermissionSetsClassificationContent>;
|
|
32
|
-
/**
|
|
33
|
-
* Initialises users classification with all users classified as standard users.
|
|
34
|
-
*
|
|
35
|
-
* @param targetOrgCon
|
|
36
|
-
*/
|
|
37
|
-
export declare function initUsers(targetOrgCon: Connection): Promise<UsersClassificationContent>;
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { ACTIVE_USERS_QUERY, CUSTOM_PERMS_QUERY, PERMISSION_SETS_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 { UserPrivilegeLevel } from '../core/policy-types.js';
|
|
5
|
-
import { loadPreset } from './presets.js';
|
|
6
|
-
/**
|
|
7
|
-
* Initialises a fresh set of user permissions from target org connection.
|
|
8
|
-
*
|
|
9
|
-
* @param con
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
export async function initUserPermissions(con, preset) {
|
|
13
|
-
const describePerms = await parsePermsFromDescribe(con);
|
|
14
|
-
const assignedPerms = await findAssignedPerms(con);
|
|
15
|
-
const allPerms = { ...describePerms, ...assignedPerms };
|
|
16
|
-
const presConfig = loadPreset(preset);
|
|
17
|
-
const perms = presConfig.classifyUserPermissions(Object.values(allPerms));
|
|
18
|
-
perms.sort(classificationSorter);
|
|
19
|
-
const result = { permissions: {} };
|
|
20
|
-
perms.forEach((perm) => (result.permissions[perm.name] = {
|
|
21
|
-
label: sanitiseLabel(perm.label),
|
|
22
|
-
classification: perm.classification,
|
|
23
|
-
reason: perm.reason,
|
|
24
|
-
}));
|
|
25
|
-
return result;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Initialises a fresh set of custom permissions from the target org
|
|
29
|
-
*
|
|
30
|
-
* @param con
|
|
31
|
-
* @returns
|
|
32
|
-
*/
|
|
33
|
-
export async function initCustomPermissions(con) {
|
|
34
|
-
const result = { permissions: {} };
|
|
35
|
-
const customPerms = await con.query(CUSTOM_PERMS_QUERY);
|
|
36
|
-
if (customPerms.records.length === 0) {
|
|
37
|
-
return undefined;
|
|
38
|
-
}
|
|
39
|
-
const perms = customPerms.records.map((cp) => ({
|
|
40
|
-
name: cp.DeveloperName,
|
|
41
|
-
label: cp.MasterLabel,
|
|
42
|
-
classification: PermissionRiskLevel.UNKNOWN,
|
|
43
|
-
}));
|
|
44
|
-
perms.forEach((perm) => (result.permissions[perm.name] = {
|
|
45
|
-
label: perm.label,
|
|
46
|
-
classification: perm.classification,
|
|
47
|
-
}));
|
|
48
|
-
return result;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Initialises a profiles classification with all profiles from the org.
|
|
52
|
-
*
|
|
53
|
-
* @param targetOrgCon
|
|
54
|
-
* @returns
|
|
55
|
-
*/
|
|
56
|
-
export async function initProfiles(targetOrgCon) {
|
|
57
|
-
const profiles = await targetOrgCon.query(PROFILES_QUERY);
|
|
58
|
-
const content = { profiles: {} };
|
|
59
|
-
profiles.records.forEach((permsetRecord) => {
|
|
60
|
-
content.profiles[permsetRecord.Profile.Name] = { role: UserPrivilegeLevel.UNKNOWN };
|
|
61
|
-
});
|
|
62
|
-
return content;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Initialises permission set classification with all perm sets
|
|
66
|
-
*
|
|
67
|
-
* @param targetOrgCon
|
|
68
|
-
* @returns
|
|
69
|
-
*/
|
|
70
|
-
export async function initPermissionSets(targetOrgCon) {
|
|
71
|
-
const permSets = await targetOrgCon.query(PERMISSION_SETS_QUERY);
|
|
72
|
-
const content = { permissionSets: {} };
|
|
73
|
-
permSets.records
|
|
74
|
-
.filter((permsetRecord) => permsetRecord.IsCustom)
|
|
75
|
-
.forEach((permsetRecord) => {
|
|
76
|
-
content.permissionSets[permsetRecord.Name] = { role: UserPrivilegeLevel.UNKNOWN };
|
|
77
|
-
});
|
|
78
|
-
return content;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Initialises users classification with all users classified as standard users.
|
|
82
|
-
*
|
|
83
|
-
* @param targetOrgCon
|
|
84
|
-
*/
|
|
85
|
-
export async function initUsers(targetOrgCon) {
|
|
86
|
-
const users = await targetOrgCon.query(ACTIVE_USERS_QUERY);
|
|
87
|
-
const content = {
|
|
88
|
-
users: {},
|
|
89
|
-
};
|
|
90
|
-
users.records.forEach((userRecord) => {
|
|
91
|
-
content.users[userRecord.Username] = { role: UserPrivilegeLevel.STANDARD_USER };
|
|
92
|
-
});
|
|
93
|
-
return content;
|
|
94
|
-
}
|
|
95
|
-
async function parsePermsFromDescribe(con) {
|
|
96
|
-
const permSet = await con.describe('PermissionSet');
|
|
97
|
-
const describeAvailablePerms = {};
|
|
98
|
-
permSet.fields
|
|
99
|
-
.filter((field) => field.name.startsWith('Permissions'))
|
|
100
|
-
.forEach((field) => {
|
|
101
|
-
const permName = field.name.replace('Permissions', '');
|
|
102
|
-
describeAvailablePerms[permName] = {
|
|
103
|
-
label: field.label,
|
|
104
|
-
name: permName,
|
|
105
|
-
};
|
|
106
|
-
});
|
|
107
|
-
return describeAvailablePerms;
|
|
108
|
-
}
|
|
109
|
-
async function findAssignedPerms(con) {
|
|
110
|
-
const assignedPerms = {};
|
|
111
|
-
const profiles = await con.query(PROFILES_QUERY);
|
|
112
|
-
if (profiles.records?.length > 0) {
|
|
113
|
-
const mdapi = new MDAPI(con);
|
|
114
|
-
const resolvedProfiles = await mdapi.resolve('Profile', profiles.records.map((p) => p.Profile.Name));
|
|
115
|
-
Object.values(resolvedProfiles).forEach((profile) => {
|
|
116
|
-
profile.userPermissions.forEach((userPerm) => {
|
|
117
|
-
assignedPerms[userPerm.name] = { name: userPerm.name };
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
return assignedPerms;
|
|
122
|
-
}
|
|
123
|
-
function sanitiseLabel(rawLabel) {
|
|
124
|
-
return rawLabel?.replaceAll(/[ \t]+$|[\r\n]+/g, '');
|
|
125
|
-
}
|
|
126
|
-
//# sourceMappingURL=permissionsClassification.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"permissionsClassification.js","sourceRoot":"","sources":["../../../src/libs/conf-init/permissionsClassification.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACrH,OAAO,KAAK,MAAM,iCAAiC,CAAC;AAEpD,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,MAAM,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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,UAAU,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { BasePolicyFileContent, UsersPolicyFileContent } from '../core/file-mgmt/schema.js';
|
|
2
|
-
import { PolicyNames } from '../core/policyRegistry.js';
|
|
3
|
-
/**
|
|
4
|
-
* Initialises a new settings policy with default rules enabled.
|
|
5
|
-
*
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
export declare function initSettings(): BasePolicyFileContent;
|
|
9
|
-
/**
|
|
10
|
-
* Initialises a users policy with all users flagged as standard user
|
|
11
|
-
*
|
|
12
|
-
* @param targetOrgCon
|
|
13
|
-
*/
|
|
14
|
-
export declare function initUserPolicy(): UsersPolicyFileContent;
|
|
15
|
-
/**
|
|
16
|
-
* Initialises a default policy with all registered rules.
|
|
17
|
-
*
|
|
18
|
-
* @param policyName
|
|
19
|
-
* @returns
|
|
20
|
-
*/
|
|
21
|
-
export declare function initDefaultPolicy(policyName: PolicyNames): BasePolicyFileContent;
|