Skip to content

Default Policy user count display is wrong #4

@ustayready

Description

@ustayready

Default policy user count is reduced twice for the same set of users.

On line 53 the unsafe users are removed from the users being sprayed. Then on line 59 the the fine grained policy users are subtracted from the user count. This results in the default policy user count being reduced twice for the same users.

var removedUnsafe = Users.RemoveAll(x => x.UserState != UserState.SAFE_TO_SPRAY);

var fineGrainedPoliciesUserCount = Policies
    .Where(x => x.IsFineGrained)
    .Sum(y => y.AppliesToUsers.Count());

var defaultPolicyUserCount = Users.Count() - fineGrainedPoliciesUserCount;

var removedExcluded = Users.RemoveAll(x => excluded.Contains(x.Username, StringComparer.OrdinalIgnoreCase));

_logger.Log($"Default Policy: {defaultPolicyUserCount} total user(s)");
_logger.Log($"Fine Grained Policies: {fineGrainedPoliciesUserCount} total user(s)");
 _logger.Log($"Removed {removedUnsafe} unsafe user(s)");
 _logger.Log($"Removed {removedExcluded} excluded user(s)");
_logger.Log($"Preparing to spray {Users.Count} user(s)");

A simple fix is to move the removedUnsafe line below where the defaultPolicyUserCount is being set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions