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

Defenders are listed in duplicate when using defenders list #83

Open
dukekautington3rd opened this issue Sep 30, 2022 · 5 comments
Open
Labels
bug Something isn't working

Comments

@dukekautington3rd
Copy link
Contributor

Describe the bug

pc defenders list produces duplicate output of each defender

Expected behavior

I would expect to see a single entry for each defender.

Current behavior

When using pc defenders list and any output format, each defender is listed double.

Possible solution

Discover why this duplicate output happens.
During debug I noticed that the data stored from the api call, is singular and doesn't seem to become duplicate until formatting or output occurs.

Steps to reproduce

pc defenders list

Screenshots

Output from command showing double:
Uploading Screen Shot 2022-09-29 at 5.07.08 PM.png…

Debug showing single data store:
Uploading Screen Shot 2022-09-29 at 5.03.33 PM.png…

Context

None needed

Your Environment

  • Version used: Python 3.10.6
  • Operating System and version (desktop or mobile): MacOS
@dukekautington3rd dukekautington3rd added the bug Something isn't working label Sep 30, 2022
@dukekautington3rd
Copy link
Contributor Author

Also pc discovery results are duplicated.

The duplication appears to be happening during the data_frame = flatten_nested_json_df(data_frame_normalized)
flatten_nested_json_df function

@dukekautington3rd
Copy link
Contributor Author

The following edit produces the appropriate output (singular). This essentially bypasses the whole flatten function, but I fear this would cause issues with other outputs.

diff --git a/prismacloud/cli/__init__.py b/prismacloud/cli/__init__.py
index 70942a6..d30280a 100644
--- a/prismacloud/cli/__init__.py
+++ b/prismacloud/cli/__init__.py
@@ -222,7 +222,8 @@ def process_data_frame(data):
     # If the size of our normalized data is 0, something went wrong but no exception was raised.
     if data_frame_normalized.size > 0:
         logging.debug("Using json_normalize() data")
-        data_frame = flatten_nested_json_df(data_frame_normalized)
+        # data_frame = flatten_nested_json_df(data_frame_normalized)
+        data_frame = data_frame_normalized
     else:
         try:
             data_frame = pd.DataFrame(data)

@steven-deboer
Copy link
Contributor

There is much room for improvement within the flatten function. Will keep it open for now and look for a permanent improvement for this.

@SimOnPanw
Copy link
Collaborator

@steven-deboer, I open a pull request on this. Can you review it ?
#91

@sgordon46
Copy link
Collaborator

@dukekautington3rd This PR has been merged and it fixed the issue for me. Take a look and we can close this issue if it is solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants