@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,14 +1,18 @@
|
|
|
1
|
+
import z from 'zod';
|
|
1
2
|
import { Messages } from '@salesforce/core';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import PolicyRule
|
|
3
|
+
import { differenceInDays } from '../../../../utils.js';
|
|
4
|
+
import { throwAsSfError } from '../schema.js';
|
|
5
|
+
import PolicyRule from './policyRule.js';
|
|
5
6
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
6
7
|
const messages = Messages.loadMessages('@j-schreiber/sf-cli-security-audit', 'rules.users');
|
|
8
|
+
const NoInactiveUsersOptionsSchema = z.strictObject({
|
|
9
|
+
daysAfterUserIsInactive: z.number().default(90),
|
|
10
|
+
});
|
|
7
11
|
export default class NoInactiveUsers extends PolicyRule {
|
|
8
12
|
ruleConfig;
|
|
9
13
|
constructor(localOpts) {
|
|
10
14
|
super(localOpts);
|
|
11
|
-
this.ruleConfig = parseRuleOptions(
|
|
15
|
+
this.ruleConfig = parseRuleOptions(localOpts.ruleConfig);
|
|
12
16
|
}
|
|
13
17
|
run(context) {
|
|
14
18
|
const result = this.initResult();
|
|
@@ -41,4 +45,13 @@ export default class NoInactiveUsers extends PolicyRule {
|
|
|
41
45
|
return Promise.resolve(result);
|
|
42
46
|
}
|
|
43
47
|
}
|
|
48
|
+
function parseRuleOptions(anyObject) {
|
|
49
|
+
const parseResult = NoInactiveUsersOptionsSchema.safeParse(anyObject ?? {});
|
|
50
|
+
if (parseResult.success) {
|
|
51
|
+
return parseResult.data;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
throwAsSfError('users.yml', parseResult.error, ['rules', 'NoInactiveUsers', 'options']);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
44
57
|
//# sourceMappingURL=noInactiveUsers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noInactiveUsers.js","sourceRoot":"","sources":["../../../../../src/libs/audit-engine/registry/rules/noInactiveUsers.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;A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
|
|
2
|
-
import { ResolvedUser } from '../users.js';
|
|
1
|
+
import { PartialPolicyRuleResult, RuleAuditContext } from '../context.types.js';
|
|
2
|
+
import { ResolvedUser } from '../policies/users.js';
|
|
3
3
|
import PolicyRule, { RuleOptions } from './policyRule.js';
|
|
4
4
|
export default class NoOtherApexApiLogins extends PolicyRule<ResolvedUser> {
|
|
5
5
|
constructor(opts: RuleOptions);
|
|
@@ -16,7 +16,10 @@ export default class NoOtherApexApiLogins extends PolicyRule {
|
|
|
16
16
|
if (loginSummary.loginType === 'Other Apex API') {
|
|
17
17
|
result.violations.push({
|
|
18
18
|
identifier: [user.username, new Date(loginSummary.lastLogin).toISOString()],
|
|
19
|
-
message: messages.getMessage('violations.no-other-apex-api-logins', [
|
|
19
|
+
message: messages.getMessage('violations.no-other-apex-api-logins', [
|
|
20
|
+
loginSummary.loginCount,
|
|
21
|
+
this.opts.auditConfig.policies.users?.options.analyseLastNDaysOfLoginHistory,
|
|
22
|
+
]),
|
|
20
23
|
});
|
|
21
24
|
}
|
|
22
25
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noOtherApexApiLogins.js","sourceRoot":"","sources":["../../../../../src/libs/audit-engine/registry/rules/noOtherApexApiLogins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,UAA2B,MAAM,iBAAiB,CAAC;AAE1D,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,oCAAoC,EAAE,aAAa,CAAC,CAAC;AAE5F,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,UAAwB;IACxE,YAAmB,IAAiB;QAClC,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,GAAG,CAAC,OAAuC;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QACjC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC3D,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACjB,SAAS;YACX,CAAC;YACD,KAAK,MAAM,YAAY,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBACvC,IAAI,YAAY,CAAC,SAAS,KAAK,gBAAgB,EAAE,CAAC;oBAChD,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC;wBACrB,UAAU,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;wBAC3E,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,qCAAqC,EAAE;4BAClE,YAAY,CAAC,UAAU;4BACvB,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,8BAA8B;yBAC7E,CAAC;qBACH,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PartialPolicyRuleResult, RuleAuditContext } from '../context.types.js';
|
|
2
|
+
import { ConnectedApp } from '../../../../salesforce/index.js';
|
|
3
|
+
import PolicyRule, { RuleOptions } from './policyRule.js';
|
|
4
|
+
export default class NoUserCanSelfAuthorize extends PolicyRule<ConnectedApp> {
|
|
5
|
+
constructor(opts: RuleOptions);
|
|
6
|
+
run(context: RuleAuditContext<ConnectedApp>): Promise<PartialPolicyRuleResult>;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noUserCanSelfAuthorize.js","sourceRoot":"","sources":["../../../../../src/libs/audit-engine/registry/rules/noUserCanSelfAuthorize.ts"],"names":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|
2
|
-
import {
|
|
3
|
-
import { AuditRunConfig } from '../../file-mgmt/schema.js';
|
|
1
|
+
import { PartialPolicyRuleResult, RowLevelPolicyRule, RuleAuditContext } from '../context.types.js';
|
|
2
|
+
import { AuditRunConfig } from '../shape/auditConfigShape.js';
|
|
4
3
|
export type RuleOptions = {
|
|
5
|
-
|
|
4
|
+
auditConfig: AuditRunConfig;
|
|
6
5
|
ruleDisplayName: string;
|
|
7
6
|
};
|
|
8
7
|
export type ConfigurableRuleOptions<T> = RuleOptions & {
|
|
@@ -10,10 +9,9 @@ export type ConfigurableRuleOptions<T> = RuleOptions & {
|
|
|
10
9
|
};
|
|
11
10
|
export default abstract class PolicyRule<EntityType> implements RowLevelPolicyRule<EntityType> {
|
|
12
11
|
protected opts: RuleOptions;
|
|
13
|
-
|
|
12
|
+
auditConfig: AuditRunConfig;
|
|
14
13
|
ruleDisplayName: string;
|
|
15
14
|
constructor(opts: RuleOptions);
|
|
16
15
|
protected initResult(): PartialPolicyRuleResult;
|
|
17
16
|
abstract run(context: RuleAuditContext<EntityType>): Promise<PartialPolicyRuleResult>;
|
|
18
17
|
}
|
|
19
|
-
export declare function parseRuleOptions(policyName: string, rulePath: string[], schema: z.ZodObject, anyObject?: unknown): z.infer<typeof schema>;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Messages } from '@salesforce/core';
|
|
2
|
-
import { throwAsSfError } from '../../file-mgmt/schema.js';
|
|
3
2
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
4
3
|
export default class PolicyRule {
|
|
5
4
|
opts;
|
|
6
|
-
|
|
5
|
+
auditConfig;
|
|
7
6
|
ruleDisplayName;
|
|
8
7
|
constructor(opts) {
|
|
9
8
|
this.opts = opts;
|
|
10
|
-
this.
|
|
9
|
+
this.auditConfig = opts.auditConfig;
|
|
11
10
|
this.ruleDisplayName = opts.ruleDisplayName;
|
|
12
11
|
}
|
|
13
12
|
initResult() {
|
|
@@ -20,13 +19,4 @@ export default class PolicyRule {
|
|
|
20
19
|
};
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
|
-
export function parseRuleOptions(policyName, rulePath, schema, anyObject) {
|
|
24
|
-
const parseResult = schema.safeParse(anyObject ?? {});
|
|
25
|
-
if (parseResult.success) {
|
|
26
|
-
return parseResult.data;
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
throwAsSfError(policyName, parseResult.error, [...rulePath, 'options']);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
22
|
//# sourceMappingURL=policyRule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policyRule.js","sourceRoot":"","sources":["../../../../../src/libs/audit-engine/registry/rules/policyRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAK5C,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAW7D,MAAM,CAAC,OAAO,OAAgB,UAAU;IAIT;IAHtB,WAAW,CAAiB;IAC5B,eAAe,CAAS;IAE/B,YAA6B,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;QAC5C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACpC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;IAC9C,CAAC;IAES,UAAU;QAClB,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,eAAe;YAC9B,UAAU,EAAE,IAAI,KAAK,EAAuB;YAC5C,eAAe,EAAE,IAAI,KAAK,EAA2B;YACrD,QAAQ,EAAE,IAAI,KAAK,EAAwB;YAC3C,MAAM,EAAE,IAAI,KAAK,EAAwB;SAC1C,CAAC;IACJ,CAAC;CAGF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Messages } from '@salesforce/core';
|
|
2
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
3
|
+
const messages = Messages.loadMessages('@j-schreiber/sf-cli-security-audit', 'org.audit.run');
|
|
4
|
+
export function throwAsSfError(fileName, parseError, rulePath) {
|
|
5
|
+
const issues = parseError.issues.map((zodIssue) => {
|
|
6
|
+
const definitivePath = rulePath ? [...rulePath, ...zodIssue.path] : zodIssue.path;
|
|
7
|
+
return definitivePath.length > 0 ? `${zodIssue.message} in "${definitivePath.join('.')}"` : zodIssue.message;
|
|
8
|
+
});
|
|
9
|
+
throw messages.createError('error.InvalidConfigFileSchema', [fileName, issues.join(', ')]);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/libs/audit-engine/registry/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,oCAAoC,EAAE,eAAe,CAAC,CAAC;AAE9F,MAAM,UAAU,cAAc,CAAC,QAAgB,EAAE,UAAsB,EAAE,QAAwB;IAC/F,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QAChD,MAAM,cAAc,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;QAClF,OAAO,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,OAAO,QAAQ,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;IAC/G,CAAC,CAAC,CAAC;IACH,MAAM,QAAQ,CAAC,WAAW,CAAC,+BAA+B,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC7F,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { ParsedAuditConfig } from '../../file-manager/fileManager.types.js';
|
|
2
|
+
export type AuditRunConfig = ParsedAuditConfig<typeof AuditConfigShape>;
|
|
3
|
+
export type Policies = keyof (typeof AuditConfigShape)['policies'];
|
|
4
|
+
export type PolicyShapes = AuditRunConfig['policies'];
|
|
5
|
+
export type Classifications = keyof (typeof AuditConfigShape)['classifications'];
|
|
6
|
+
export type ClassificationShapes = AuditRunConfig['classifications'];
|
|
7
|
+
/**
|
|
8
|
+
* The shape defines the directory structure and schema files to
|
|
9
|
+
* parse YAML files. It is the foundation to derive the runtime type of
|
|
10
|
+
* the audit config that is used by rules and policies.
|
|
11
|
+
*/
|
|
12
|
+
export declare const AuditConfigShape: {
|
|
13
|
+
classifications: {
|
|
14
|
+
userPermissions: {
|
|
15
|
+
schema: import("zod").ZodObject<{
|
|
16
|
+
permissions: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
17
|
+
label: import("zod").ZodOptional<import("zod").ZodString>;
|
|
18
|
+
reason: import("zod").ZodOptional<import("zod").ZodString>;
|
|
19
|
+
classification: import("zod").ZodEnum<typeof import("./schema.js").PermissionRiskLevel>;
|
|
20
|
+
}, import("zod/v4/core").$strip>>;
|
|
21
|
+
}, import("zod/v4/core").$strip>;
|
|
22
|
+
entities: string;
|
|
23
|
+
};
|
|
24
|
+
customPermissions: {
|
|
25
|
+
schema: import("zod").ZodObject<{
|
|
26
|
+
permissions: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
27
|
+
label: import("zod").ZodOptional<import("zod").ZodString>;
|
|
28
|
+
reason: import("zod").ZodOptional<import("zod").ZodString>;
|
|
29
|
+
classification: import("zod").ZodEnum<typeof import("./schema.js").PermissionRiskLevel>;
|
|
30
|
+
}, import("zod/v4/core").$strip>>;
|
|
31
|
+
}, import("zod/v4/core").$strip>;
|
|
32
|
+
entities: string;
|
|
33
|
+
};
|
|
34
|
+
profiles: {
|
|
35
|
+
schema: import("zod").ZodObject<{
|
|
36
|
+
profiles: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
37
|
+
role: import("zod").ZodEnum<typeof import("./schema.js").UserPrivilegeLevel>;
|
|
38
|
+
}, import("zod/v4/core").$strip>>;
|
|
39
|
+
}, import("zod/v4/core").$strip>;
|
|
40
|
+
entities: string;
|
|
41
|
+
};
|
|
42
|
+
permissionSets: {
|
|
43
|
+
schema: import("zod").ZodObject<{
|
|
44
|
+
permissionSets: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
45
|
+
role: import("zod").ZodEnum<typeof import("./schema.js").UserPrivilegeLevel>;
|
|
46
|
+
}, import("zod/v4/core").$strip>>;
|
|
47
|
+
}, import("zod/v4/core").$strip>;
|
|
48
|
+
entities: string;
|
|
49
|
+
};
|
|
50
|
+
users: {
|
|
51
|
+
schema: import("zod").ZodObject<{
|
|
52
|
+
users: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
53
|
+
role: import("zod").ZodEnum<typeof import("./schema.js").UserPrivilegeLevel>;
|
|
54
|
+
}, import("zod/v4/core").$strip>>;
|
|
55
|
+
}, import("zod/v4/core").$strip>;
|
|
56
|
+
entities: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
policies: {
|
|
60
|
+
profiles: {
|
|
61
|
+
schema: import("zod").ZodObject<{
|
|
62
|
+
enabled: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
63
|
+
rules: import("zod").ZodDefault<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
64
|
+
enabled: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
65
|
+
options: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
66
|
+
}, import("zod/v4/core").$strip>>>;
|
|
67
|
+
options: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
68
|
+
}, import("zod/v4/core").$strip>;
|
|
69
|
+
dependencies: {
|
|
70
|
+
path: string[];
|
|
71
|
+
errorName: string;
|
|
72
|
+
}[];
|
|
73
|
+
};
|
|
74
|
+
permissionSets: {
|
|
75
|
+
schema: import("zod").ZodObject<{
|
|
76
|
+
enabled: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
77
|
+
rules: import("zod").ZodDefault<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
78
|
+
enabled: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
79
|
+
options: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
80
|
+
}, import("zod/v4/core").$strip>>>;
|
|
81
|
+
options: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
82
|
+
}, import("zod/v4/core").$strip>;
|
|
83
|
+
dependencies: {
|
|
84
|
+
path: string[];
|
|
85
|
+
errorName: string;
|
|
86
|
+
}[];
|
|
87
|
+
};
|
|
88
|
+
connectedApps: {
|
|
89
|
+
schema: import("zod").ZodObject<{
|
|
90
|
+
enabled: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
91
|
+
rules: import("zod").ZodDefault<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
92
|
+
enabled: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
93
|
+
options: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
94
|
+
}, import("zod/v4/core").$strip>>>;
|
|
95
|
+
options: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
96
|
+
}, import("zod/v4/core").$strip>;
|
|
97
|
+
};
|
|
98
|
+
users: {
|
|
99
|
+
schema: import("zod").ZodObject<{
|
|
100
|
+
enabled: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
101
|
+
rules: import("zod").ZodDefault<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
102
|
+
enabled: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
103
|
+
options: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
104
|
+
}, import("zod/v4/core").$strip>>>;
|
|
105
|
+
options: import("zod").ZodObject<{
|
|
106
|
+
defaultRoleForMissingUsers: import("zod").ZodDefault<import("zod").ZodEnum<typeof import("./schema.js").UserPrivilegeLevel>>;
|
|
107
|
+
analyseLastNDaysOfLoginHistory: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
108
|
+
}, import("zod/v4/core").$strict>;
|
|
109
|
+
}, import("zod/v4/core").$strip>;
|
|
110
|
+
};
|
|
111
|
+
settings: {
|
|
112
|
+
schema: import("zod").ZodObject<{
|
|
113
|
+
enabled: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
114
|
+
rules: import("zod").ZodDefault<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
115
|
+
enabled: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
116
|
+
options: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
117
|
+
}, import("zod/v4/core").$strip>>>;
|
|
118
|
+
options: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
119
|
+
}, import("zod/v4/core").$strip>;
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { PermissionsClassificationFileSchema, PermissionSetsClassificationFileSchema, PolicyFileSchema, ProfilesClassificationFileSchema, UserClassificationFileSchema, UserPolicyFileSchema, } from './schema.js';
|
|
2
|
+
/**
|
|
3
|
+
* The shape defines the directory structure and schema files to
|
|
4
|
+
* parse YAML files. It is the foundation to derive the runtime type of
|
|
5
|
+
* the audit config that is used by rules and policies.
|
|
6
|
+
*/
|
|
7
|
+
export const AuditConfigShape = {
|
|
8
|
+
classifications: {
|
|
9
|
+
userPermissions: {
|
|
10
|
+
schema: PermissionsClassificationFileSchema,
|
|
11
|
+
entities: 'permissions',
|
|
12
|
+
},
|
|
13
|
+
customPermissions: {
|
|
14
|
+
schema: PermissionsClassificationFileSchema,
|
|
15
|
+
entities: 'permissions',
|
|
16
|
+
},
|
|
17
|
+
profiles: {
|
|
18
|
+
schema: ProfilesClassificationFileSchema,
|
|
19
|
+
entities: 'profiles',
|
|
20
|
+
},
|
|
21
|
+
permissionSets: {
|
|
22
|
+
schema: PermissionSetsClassificationFileSchema,
|
|
23
|
+
entities: 'permissionSets',
|
|
24
|
+
},
|
|
25
|
+
users: {
|
|
26
|
+
schema: UserClassificationFileSchema,
|
|
27
|
+
entities: 'users',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
policies: {
|
|
31
|
+
profiles: {
|
|
32
|
+
schema: PolicyFileSchema,
|
|
33
|
+
dependencies: [
|
|
34
|
+
{ path: ['classifications', 'userPermissions'], errorName: 'UserPermClassificationRequiredForProfiles' },
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
permissionSets: {
|
|
38
|
+
schema: PolicyFileSchema,
|
|
39
|
+
dependencies: [
|
|
40
|
+
{ path: ['classifications', 'userPermissions'], errorName: 'UserPermClassificationRequiredForPermSets' },
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
connectedApps: {
|
|
44
|
+
schema: PolicyFileSchema,
|
|
45
|
+
},
|
|
46
|
+
users: {
|
|
47
|
+
schema: UserPolicyFileSchema,
|
|
48
|
+
},
|
|
49
|
+
settings: {
|
|
50
|
+
schema: PolicyFileSchema,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=auditConfigShape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auditConfigShape.js","sourceRoot":"","sources":["../../../../../src/libs/audit-engine/registry/shape/auditConfigShape.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mCAAmC,EACnC,sCAAsC,EACtC,gBAAgB,EAChB,gCAAgC,EAChC,4BAA4B,EAC5B,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAQrB;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,eAAe,EAAE;QACf,eAAe,EAAE;YACf,MAAM,EAAE,mCAAmC;YAC3C,QAAQ,EAAE,aAAa;SACxB;QACD,iBAAiB,EAAE;YACjB,MAAM,EAAE,mCAAmC;YAC3C,QAAQ,EAAE,aAAa;SACxB;QACD,QAAQ,EAAE;YACR,MAAM,EAAE,gCAAgC;YACxC,QAAQ,EAAE,UAAU;SACrB;QACD,cAAc,EAAE;YACd,MAAM,EAAE,sCAAsC;YAC9C,QAAQ,EAAE,gBAAgB;SAC3B;QACD,KAAK,EAAE;YACL,MAAM,EAAE,4BAA4B;YACpC,QAAQ,EAAE,OAAO;SAClB;KACF;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE;YACR,MAAM,EAAE,gBAAgB;YACxB,YAAY,EAAE;gBACZ,EAAE,IAAI,EAAE,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,EAAE,SAAS,EAAE,2CAA2C,EAAE;aACzG;SACF;QACD,cAAc,EAAE;YACd,MAAM,EAAE,gBAAgB;YACxB,YAAY,EAAE;gBACZ,EAAE,IAAI,EAAE,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,EAAE,SAAS,EAAE,2CAA2C,EAAE;aACzG;SACF;QACD,aAAa,EAAE;YACb,MAAM,EAAE,gBAAgB;SACzB;QACD,KAAK,EAAE;YACL,MAAM,EAAE,oBAAoB;SAC7B;QACD,QAAQ,EAAE;YACR,MAAM,EAAE,gBAAgB;SACzB;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import z from 'zod';
|
|
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
|
+
/**
|
|
20
|
+
* Privilege levels are assigned to users, profiles and permission sets.
|
|
21
|
+
* Each level determins the allowed permissions, based on their risk levels.
|
|
22
|
+
*/
|
|
23
|
+
export declare enum UserPrivilegeLevel {
|
|
24
|
+
/** Allows up to "Critical" permissions */
|
|
25
|
+
DEVELOPER = "Developer",
|
|
26
|
+
/** Allows up to "High" permissions */
|
|
27
|
+
ADMIN = "Admin",
|
|
28
|
+
/** Allows up to "Medium" permissions */
|
|
29
|
+
POWER_USER = "Power User",
|
|
30
|
+
/** Allows only "Low" permissions */
|
|
31
|
+
STANDARD_USER = "Standard User",
|
|
32
|
+
/** Disables the profile for audit */
|
|
33
|
+
UNKNOWN = "Unknown"
|
|
34
|
+
}
|
|
35
|
+
declare const PermissionClassifications: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
36
|
+
label: z.ZodOptional<z.ZodString>;
|
|
37
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
38
|
+
classification: z.ZodEnum<typeof PermissionRiskLevel>;
|
|
39
|
+
}, z.z.core.$strip>>;
|
|
40
|
+
declare const PermSetMap: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
41
|
+
role: z.ZodEnum<typeof UserPrivilegeLevel>;
|
|
42
|
+
}, z.z.core.$strip>>;
|
|
43
|
+
declare const ProfilesMap: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
44
|
+
role: z.ZodEnum<typeof UserPrivilegeLevel>;
|
|
45
|
+
}, z.z.core.$strip>>;
|
|
46
|
+
declare const UsersMap: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
47
|
+
role: z.ZodEnum<typeof UserPrivilegeLevel>;
|
|
48
|
+
}, z.z.core.$strip>>;
|
|
49
|
+
export declare const PermissionsClassificationFileSchema: z.ZodObject<{
|
|
50
|
+
permissions: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
51
|
+
label: z.ZodOptional<z.ZodString>;
|
|
52
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
53
|
+
classification: z.ZodEnum<typeof PermissionRiskLevel>;
|
|
54
|
+
}, z.z.core.$strip>>;
|
|
55
|
+
}, z.z.core.$strip>;
|
|
56
|
+
export declare const ProfilesClassificationFileSchema: z.ZodObject<{
|
|
57
|
+
profiles: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
58
|
+
role: z.ZodEnum<typeof UserPrivilegeLevel>;
|
|
59
|
+
}, z.z.core.$strip>>;
|
|
60
|
+
}, z.z.core.$strip>;
|
|
61
|
+
export declare const PermissionSetsClassificationFileSchema: z.ZodObject<{
|
|
62
|
+
permissionSets: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
63
|
+
role: z.ZodEnum<typeof UserPrivilegeLevel>;
|
|
64
|
+
}, z.z.core.$strip>>;
|
|
65
|
+
}, z.z.core.$strip>;
|
|
66
|
+
export declare const UserClassificationFileSchema: z.ZodObject<{
|
|
67
|
+
users: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
68
|
+
role: z.ZodEnum<typeof UserPrivilegeLevel>;
|
|
69
|
+
}, z.z.core.$strip>>;
|
|
70
|
+
}, z.z.core.$strip>;
|
|
71
|
+
export declare const PolicyFileSchema: z.ZodObject<{
|
|
72
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
73
|
+
rules: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
74
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
75
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
76
|
+
}, z.z.core.$strip>>>;
|
|
77
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
78
|
+
}, z.z.core.$strip>;
|
|
79
|
+
export declare const UserPolicyFileSchema: z.ZodObject<{
|
|
80
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
81
|
+
rules: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
82
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
83
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
84
|
+
}, z.z.core.$strip>>>;
|
|
85
|
+
options: z.ZodObject<{
|
|
86
|
+
defaultRoleForMissingUsers: z.ZodDefault<z.ZodEnum<typeof UserPrivilegeLevel>>;
|
|
87
|
+
analyseLastNDaysOfLoginHistory: z.ZodOptional<z.ZodNumber>;
|
|
88
|
+
}, z.z.core.$strict>;
|
|
89
|
+
}, z.z.core.$strip>;
|
|
90
|
+
export type PermissionClassifications = z.infer<typeof PermissionClassifications>;
|
|
91
|
+
export type PermissionSetClassifications = z.infer<typeof PermSetMap>;
|
|
92
|
+
export type ProfileClassifications = z.infer<typeof ProfilesMap>;
|
|
93
|
+
export type UserClassifications = z.infer<typeof UsersMap>;
|
|
94
|
+
export type PolicyConfig = z.infer<typeof PolicyFileSchema>;
|
|
95
|
+
export type UserPolicyConfig = z.infer<typeof UserPolicyFileSchema>;
|
|
96
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Enum to classify user and custom permissions.
|
|
4
|
+
*/
|
|
5
|
+
export var PermissionRiskLevel;
|
|
6
|
+
(function (PermissionRiskLevel) {
|
|
7
|
+
/** Blacklisted permissions that are considered too critical and not allowed */
|
|
8
|
+
PermissionRiskLevel["BLOCKED"] = "Blocked";
|
|
9
|
+
/** Developer permissions, allow to modify the application */
|
|
10
|
+
PermissionRiskLevel["CRITICAL"] = "Critical";
|
|
11
|
+
/** Admin permissions, allow to manage users and change permissions */
|
|
12
|
+
PermissionRiskLevel["HIGH"] = "High";
|
|
13
|
+
/** Elevated business permissions for privileged users */
|
|
14
|
+
PermissionRiskLevel["MEDIUM"] = "Medium";
|
|
15
|
+
/** Regular user permissions, typically needed for day-to-day work */
|
|
16
|
+
PermissionRiskLevel["LOW"] = "Low";
|
|
17
|
+
/** Not categorized or unknown permission. Will be ignored but create a warning */
|
|
18
|
+
PermissionRiskLevel["UNKNOWN"] = "Unknown";
|
|
19
|
+
})(PermissionRiskLevel || (PermissionRiskLevel = {}));
|
|
20
|
+
/**
|
|
21
|
+
* Privilege levels are assigned to users, profiles and permission sets.
|
|
22
|
+
* Each level determins the allowed permissions, based on their risk levels.
|
|
23
|
+
*/
|
|
24
|
+
export var UserPrivilegeLevel;
|
|
25
|
+
(function (UserPrivilegeLevel) {
|
|
26
|
+
/** Allows up to "Critical" permissions */
|
|
27
|
+
UserPrivilegeLevel["DEVELOPER"] = "Developer";
|
|
28
|
+
/** Allows up to "High" permissions */
|
|
29
|
+
UserPrivilegeLevel["ADMIN"] = "Admin";
|
|
30
|
+
/** Allows up to "Medium" permissions */
|
|
31
|
+
UserPrivilegeLevel["POWER_USER"] = "Power User";
|
|
32
|
+
/** Allows only "Low" permissions */
|
|
33
|
+
UserPrivilegeLevel["STANDARD_USER"] = "Standard User";
|
|
34
|
+
/** Disables the profile for audit */
|
|
35
|
+
UserPrivilegeLevel["UNKNOWN"] = "Unknown";
|
|
36
|
+
})(UserPrivilegeLevel || (UserPrivilegeLevel = {}));
|
|
37
|
+
const PermClassification = z.object({
|
|
38
|
+
/** UI Label */
|
|
39
|
+
label: z.string().optional(),
|
|
40
|
+
/** An optional description to explain the classification */
|
|
41
|
+
reason: z.string().optional(),
|
|
42
|
+
/** Risk assessment of the permissions */
|
|
43
|
+
classification: z.enum(PermissionRiskLevel),
|
|
44
|
+
});
|
|
45
|
+
const PermissionClassifications = z.record(z.string(), PermClassification);
|
|
46
|
+
const PolicyRuleConfigSchema = z.object({
|
|
47
|
+
enabled: z.boolean().default(false),
|
|
48
|
+
options: z.record(z.string(), z.unknown()).optional(),
|
|
49
|
+
});
|
|
50
|
+
const RuleMapSchema = z.record(z.string(), PolicyRuleConfigSchema);
|
|
51
|
+
const PermSetConfig = z.object({
|
|
52
|
+
role: z.enum(UserPrivilegeLevel),
|
|
53
|
+
});
|
|
54
|
+
const PermSetMap = z.record(z.string(), PermSetConfig);
|
|
55
|
+
const ProfilesMap = z.record(z.string(), PermSetConfig);
|
|
56
|
+
const UserConfig = z.object({ role: z.enum(UserPrivilegeLevel) });
|
|
57
|
+
const UsersMap = z.record(z.string(), UserConfig);
|
|
58
|
+
const UsersPolicyOptions = z.strictObject({
|
|
59
|
+
defaultRoleForMissingUsers: z.enum(UserPrivilegeLevel).default(UserPrivilegeLevel.STANDARD_USER),
|
|
60
|
+
analyseLastNDaysOfLoginHistory: z.number().optional(),
|
|
61
|
+
});
|
|
62
|
+
// Classification File Schemata
|
|
63
|
+
export const PermissionsClassificationFileSchema = z.object({
|
|
64
|
+
permissions: PermissionClassifications,
|
|
65
|
+
});
|
|
66
|
+
export const ProfilesClassificationFileSchema = z.object({
|
|
67
|
+
profiles: ProfilesMap,
|
|
68
|
+
});
|
|
69
|
+
export const PermissionSetsClassificationFileSchema = z.object({
|
|
70
|
+
permissionSets: PermSetMap,
|
|
71
|
+
});
|
|
72
|
+
export const UserClassificationFileSchema = z.object({
|
|
73
|
+
users: UsersMap,
|
|
74
|
+
});
|
|
75
|
+
// Policy File Schemata
|
|
76
|
+
export const PolicyFileSchema = z.object({
|
|
77
|
+
enabled: z.boolean().default(true),
|
|
78
|
+
rules: RuleMapSchema.default({}),
|
|
79
|
+
options: z.record(z.string(), z.unknown()).optional(),
|
|
80
|
+
});
|
|
81
|
+
export const UserPolicyFileSchema = PolicyFileSchema.extend({
|
|
82
|
+
options: UsersPolicyOptions,
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../src/libs/audit-engine/registry/shape/schema.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB;;GAEG;AACH,MAAM,CAAN,IAAY,mBAaX;AAbD,WAAY,mBAAmB;IAC7B,+EAA+E;IAC/E,0CAAmB,CAAA;IACnB,6DAA6D;IAC7D,4CAAqB,CAAA;IACrB,sEAAsE;IACtE,oCAAa,CAAA;IACb,yDAAyD;IACzD,wCAAiB,CAAA;IACjB,qEAAqE;IACrE,kCAAW,CAAA;IACX,kFAAkF;IAClF,0CAAmB,CAAA;AACrB,CAAC,EAbW,mBAAmB,KAAnB,mBAAmB,QAa9B;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,kBAWX;AAXD,WAAY,kBAAkB;IAC5B,0CAA0C;IAC1C,6CAAuB,CAAA;IACvB,sCAAsC;IACtC,qCAAe,CAAA;IACf,wCAAwC;IACxC,+CAAyB,CAAA;IACzB,oCAAoC;IACpC,qDAA+B,CAAA;IAC/B,qCAAqC;IACrC,yCAAmB,CAAA;AACrB,CAAC,EAXW,kBAAkB,KAAlB,kBAAkB,QAW7B;AAED,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,eAAe;IACf,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,4DAA4D;IAC5D,MAAM,EAAE,CAAC,CAA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AAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,aAAa,CAAC;IAChG,8BAA8B,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACtD,CAAC,CAAC;AAEH,+BAA+B;AAE/B,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1D,WAAW,EAAE,yBAAyB;CACvC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC;IACvD,QAAQ,EAAE,WAAW;CACtB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sCAAsC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7D,cAAc,EAAE,UAAU;CAC3B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IACnD,KAAK,EAAE,QAAQ;CAChB,CAAC,CAAC;AAEH,uBAAuB;AAEvB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAClC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;IAChC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;CACtD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC,MAAM,CAAC;IAC1D,OAAO,EAAE,kBAAkB;CAC5B,CAAC,CAAC"}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { Connection } from '@salesforce/core';
|
|
2
|
-
import { AuditRunConfig } from '../
|
|
3
|
-
import { AuditInitPresets } from './
|
|
2
|
+
import { AuditRunConfig, Policies, PolicyDefinitions } from '../audit-engine/index.js';
|
|
3
|
+
import { AuditInitPresets } from './init.types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Additional options how the config should be initialised.
|
|
6
6
|
*/
|
|
7
7
|
export type AuditInitOptions = {
|
|
8
|
-
/**
|
|
9
|
-
* When set, config files are created at the target location.
|
|
10
|
-
*/
|
|
11
|
-
targetDir?: string;
|
|
12
8
|
/**
|
|
13
9
|
* An optional preset to initialise classifications and policies.
|
|
14
10
|
*/
|
|
@@ -26,10 +22,5 @@ export default class AuditConfig {
|
|
|
26
22
|
* @param con
|
|
27
23
|
*/
|
|
28
24
|
static init(targetCon: Connection, opts?: AuditInitOptions): Promise<AuditRunConfig>;
|
|
29
|
-
/**
|
|
30
|
-
* Loads an existing audit config from a source directory
|
|
31
|
-
*
|
|
32
|
-
* @param sourceDir
|
|
33
|
-
*/
|
|
34
|
-
static load(sourceDir: string): AuditRunConfig;
|
|
35
25
|
}
|
|
26
|
+
export declare function initPolicyConfig<P extends Policies>(policyName: P): (typeof PolicyDefinitions)[P]['configType'];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { RuleRegistry, PolicyDefinitions, } from '../audit-engine/index.js';
|
|
2
|
+
import { ClassificationInitDefinitions } from './defaultClassifications.js';
|
|
3
|
+
import { DefaultPolicyDefinitions } from './defaultPolicies.js';
|
|
4
4
|
/**
|
|
5
5
|
* Exposes key functionality to load an audit config as static methods. This makes
|
|
6
6
|
* it easy to mock the results during tests.
|
|
@@ -14,32 +14,32 @@ export default class AuditConfig {
|
|
|
14
14
|
*/
|
|
15
15
|
static async init(targetCon, opts) {
|
|
16
16
|
const conf = { classifications: {}, policies: {} };
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
conf.classifications.customPermissions = { content: customPerms };
|
|
17
|
+
for (const [className, classInitDef] of Object.entries(ClassificationInitDefinitions)) {
|
|
18
|
+
// eslint-disable-next-line no-await-in-loop
|
|
19
|
+
const defaultClassification = await classInitDef.initialiser(targetCon, opts?.preset);
|
|
20
|
+
if (defaultClassification) {
|
|
21
|
+
conf.classifications[className] = defaultClassification;
|
|
22
|
+
}
|
|
24
23
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
conf.policies.connectedApps = { content: initDefaultPolicy('connectedApps') };
|
|
29
|
-
conf.policies.settings = { content: initSettings() };
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
31
|
-
if (opts?.targetDir || opts?.targetDir === '') {
|
|
32
|
-
DefaultFileManager.save(opts.targetDir, conf);
|
|
24
|
+
for (const policyName of Object.keys(PolicyDefinitions)) {
|
|
25
|
+
const policy = initPolicyConfig(policyName);
|
|
26
|
+
conf.policies[policyName] = policy;
|
|
33
27
|
}
|
|
34
28
|
return conf;
|
|
35
29
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
}
|
|
31
|
+
export function initPolicyConfig(policyName) {
|
|
32
|
+
const def = PolicyDefinitions[policyName];
|
|
33
|
+
const registry = new RuleRegistry(def.rules);
|
|
34
|
+
const content = { enabled: true, rules: {} };
|
|
35
|
+
for (const validRule of registry.registeredRules()) {
|
|
36
|
+
content.rules[validRule] = {
|
|
37
|
+
enabled: true,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (DefaultPolicyDefinitions[policyName]) {
|
|
41
|
+
return { ...content, ...DefaultPolicyDefinitions[policyName]() };
|
|
43
42
|
}
|
|
43
|
+
return content;
|
|
44
44
|
}
|
|
45
45
|
//# sourceMappingURL=auditConfig.js.map
|