Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default Policy user count display is wrong #4

Open
ustayready opened this issue May 7, 2020 · 0 comments
Open

Default Policy user count display is wrong #4

ustayready opened this issue May 7, 2020 · 0 comments

Comments

@ustayready
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant