Skip to content

Users command: option to report on legal hold membership #290

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

Merged
merged 13 commits into from
Aug 27, 2021

Conversation

maddie-vargo
Copy link
Contributor

This PR addresses the final component of Issue #176 by adding functionality to the users command to report on legal hold membership. This option will report on the legal hold matter name and ID for any user on legal hold. This work largely mimics the legal hold reporting option in the devices command

Testing Procedure

code42 users list --include-legal-hold-membership

PR Checklist
Did you remember to do the below?

  • Add unit tests to verify this change
  • Add an entry to CHANGELOG.md describing this change
  • Add docstrings for any new public parameters / methods / classes

@github-actions
Copy link

github-actions bot commented May 27, 2021

CLA Assistant Lite bot All contributors have signed the CLA ✍️

CHANGELOG.md Outdated
@@ -16,6 +16,8 @@ how a consumer would use the library (e.g. adding unit tests, updating documenta

- New command `code42 users remove-role` to remove a user role from a single user.

- New command 'code42 users list --include-legal-hold-membership' to print the legal hold matter name and ID for any user on legal hold
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this has probably already been said, but what is the use-case for this functionality? I had heard most customers have a single matter for legal hold.

Is this flag general enough or this just for a specific use-case? I am also wondering if this is the right place to include this flag... What if I wanted to filter users by matter ID instead? Or what if I want to know which detection list or alert rules each user belong to as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The primary use case that this addresses is "show me all the users on legal hold."

There are customers that have a lot of legal hold matters. Therefore, the legal-hold show <matter ID> command would not meet their needs if they need to see users on all legal holds.

Also, legal-hold show <matter ID> produces the users in column format. This makes sense for a show command, which is meant to be a high-level overview (This was discussed in the PR that added the devices list --include-legal-hold-membership). However, for an admin to work with the data and put it in different formats, the list command provided some more flexibility (at least for device info)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good with this being in the CLI proper. As it could be useful to any customer using legal hold.

I think I'd also be ok with future flags for including if a user is on a detection list as well. Having the CLI users command be a kind of one-stop reporting tool to get all users info makes sense. Especially for larger customers who might have multiple teams (or automations) managing who gets put on what list/hold.

@maddie-vargo
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

.agg(",".join)
.rename(
{
"legalHold.legalHoldUid": "legalHoldUid",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to be able to pass in user friendly keys for Table format headers for when using DataFrameOutputFormatter, as that was the norm before.

Table format should use label-esque keys while all the other ones should use raw API values.

assert "Legal Hold #1,Legal Hold #2" in result.output
assert "123456789,987654321" in result.output


Copy link
Contributor

@antazoey antazoey Jul 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get tests for the following two cases:

1.) A user is not on any legal hold but the --include-legal-hold-membership flag was passed in (keys should be there but their values should be None)
2.) A user is on a legal hold but the flag --include-legal-hold-membership was not passed in (keys and values should not be present in the output)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added these tests. The code didn't handle cases where 0 custodians were returned. Thanks for suggesting this test case.

I also added a test for cases where the flag--include-legal-hold-membership and no matters were returned.

@antazoey
Copy link
Contributor

antazoey commented Jul 8, 2021

The build failures will go away if you catch your branch up with upstream main
Also, can you target main as the target branch? master is no longer the main branch.

@antazoey
Copy link
Contributor

antazoey commented Jul 8, 2021

when using Table format, the spacing between the end of the Users data in the beginning of the Legal Hold data is really really big... Even when the user is part of many matters, it is still almost twice as big as it needs to be.
Screen Shot 2021-07-08 at 12 54 41

@antazoey
Copy link
Contributor

antazoey commented Jul 8, 2021

I am little curious what the legal hold data is a comma-separated string rather than a list type.

For example, when I create a CSV, the license entry is ['admin.securityTools'] while the legalHoldUid entry is "1002360211054033697,996367185330237359,995898853137248175,995896307393194971,995894227423915951"

Same with JSON.

Would using lists be easier for programmatically handling the output for CSV and JSON outputs?

@maddie-vargo maddie-vargo changed the base branch from master to main August 5, 2021 17:48
@maddie-vargo maddie-vargo requested a review from a team as a code owner August 5, 2021 17:48
@maddie-vargo
Copy link
Contributor Author

Re: Build Failures
Resolved the build failures by syncing the fork, and set main as the target branch. Thanks!

Re: Column spacing for a long list of legal holds:
I find that this column will be as long as the longest list. In the output referenced by your screenshot, is there someone listed that has many more legal holds listed?
I'm not able to reproduce this. I've added a user to 5 legal holds and ran a users list --include-legal-hold-membership command. The most legal holds a user has is 5, and the spacing is appropriate.

Re: Legal Hold Info as a comma-separated string
The user license info is coming directly from the api, where the value is a list type. The Legal Hold info is being formatted by the code. Currently, I'm only aggregating it into a comma-separated string, but I can certainly change it to a standard list.

"955060991270602172,946193444244471969" >> [955060991270602172, 946193444244471969]

However, I'm not sure how to programmatically have that display as a list for some formats, and as a string for the table. If I had to choose, I err on the side of making it a list for all formats, as opposed to the comma-separated string.



def custodian_list_generator():
yield TEST_CUSTODIANS_RESPONSE
Copy link
Contributor

@antazoey antazoey Aug 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should use the create_mock_response() method:

yield create_mock_response(mocker, data=TEST_CUSTODIANS_RESPONSE)

Anything that is a response from a py42 method should use this method, so all these ones here,

it is being used in some of the other fixtures below as an example!

Please and thank you! This is looking really good.

Copy link
Contributor

@antazoey antazoey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maddie-vargo Work with one of the other members of Literally Skynet on a good time to merge this, thanks for your contribution!

@timabrmsn timabrmsn merged commit 4ca646d into code42:main Aug 27, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Aug 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants