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

ZeroTrust performance fixes #645

Merged
merged 20 commits into from
May 20, 2020
Merged

ZeroTrust performance fixes #645

merged 20 commits into from
May 20, 2020

Conversation

VakarisZ
Copy link
Contributor

@VakarisZ VakarisZ commented May 11, 2020

What is this?

  • Fixes zero trust report generation performance test
  • Implements map and report generation tests that doesn't run monkeys, but instead sends telemetries
  • Added @profile() decorator that outputs profiling info of method decorated.

Checklist

  • Have you added an explanation of what your changes do and why you'd like to include them?
  • Have you successfully tested your changes locally?
  • Is the TravisCI build passing?

Proof that it works

If applicable, add screenshots or log transcripts of the feature working

Copy link
Contributor

@ShayNehmad ShayNehmad left a comment

Choose a reason for hiding this comment

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

Some questions and minor comments.
I'd also like to see the test status and/or the profile info posted in the PR discussion for future reference

assert (len(existing_findings) < 2), "More than one finding exists for {}:{}".format(test, status)

if len(existing_findings) == 0:
Finding.save_finding(test, status, events)
else:
# Now we know for sure this is the only one
orig_finding = existing_findings[0]
orig_finding.add_events(events)
orig_finding.update(push_all__events=events)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment explaining what this is doing, why this is better, and link to the documentation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why do we need to reimplement mongoengine methods? It's error prone and adds lines of code that are not necessary. https://github.com/guardicore/pyinstaller/blob/develop/bootloader/src/old_machine_common_functions.c

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what the link should be telling me, but I agree - just adding a link to the method's documentation will help

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohh, you were talking about commenting the method in the code? Ok, I'll improve

Comment on lines 322 to 324
self.assertListEqual([], ZeroTrustService._ZeroTrustService__get_events_without_overlap(5, [1, 2, 3]))
self.assertListEqual([3], ZeroTrustService._ZeroTrustService__get_events_without_overlap(6, [1, 2, 3]))
self.assertListEqual([1, 2, 3, 4, 5], ZeroTrustService._ZeroTrustService__get_events_without_overlap(10, [1, 2, 3, 4, 5]))
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're using something it's better to not name-mangle it... this test will break when we rename the class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So you suggest to rename __get_events_without_overlap?

Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest making it not protected with __ but rather just mark it as "private" with a single _.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So we are talking about the same thing :) I wanted to be consistent at least on the module scope. Why are methods mangled there anyway?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree we should be consistent - you can rename all of them to not be mangled, I think that would be better

PROFILER_LOG_DIR = "./profiler_logs/"


def profile(sort_args=['cumulative'], print_args=[100]):
Copy link
Contributor

Choose a reason for hiding this comment

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

Some usage documentation and examples would be useful

@ShayNehmad
Copy link
Contributor

Also, not all unit tests are passing - please fix them :)

@ShayNehmad ShayNehmad added the Enhancement Issue that describes an enhancement to a current feature. label May 11, 2020
.gitignore Outdated
Comment on lines 88 to 90
# Profiling logs
/monkey/profiler_logs/

Copy link
Contributor

Choose a reason for hiding this comment

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

Won't that depend on the working directory from which you execute stuff which might change, let's say when you're running UTs?

Probs safer to ignore all directories called profiler_logs

Suggested change
# Profiling logs
/monkey/profiler_logs/
# Profiling logs
profiler_logs/

@VakarisZ
Copy link
Contributor Author

UT's fail because of similar issue mongomock/mongomock#625

@ShayNehmad ShayNehmad closed this May 20, 2020
@ShayNehmad ShayNehmad reopened this May 20, 2020
@VakarisZ VakarisZ force-pushed the feature/zt_performance_fixes branch from 5301402 to 44cb87a Compare May 20, 2020 12:03
@VakarisZ VakarisZ closed this May 20, 2020
@VakarisZ VakarisZ reopened this May 20, 2020
@VakarisZ VakarisZ mentioned this pull request May 20, 2020
@VakarisZ VakarisZ merged commit 1f79c16 into develop May 20, 2020
@VakarisZ VakarisZ deleted the feature/zt_performance_fixes branch May 20, 2020 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Issue that describes an enhancement to a current feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants