-
Notifications
You must be signed in to change notification settings - Fork 786
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #645 from guardicore/feature/zt_performance_fixes
ZeroTrust performance fixes
- Loading branch information
Showing
23 changed files
with
305 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
envs/monkey_zoo/blackbox/tests/performance/map_generation_from_telemetries.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from datetime import timedelta | ||
|
||
from envs.monkey_zoo.blackbox.tests.performance.performance_test import PerformanceTest | ||
from envs.monkey_zoo.blackbox.tests.performance.performance_test_config import PerformanceTestConfig | ||
from envs.monkey_zoo.blackbox.tests.performance.telemetry_performance_test_workflow import \ | ||
TelemetryPerformanceTestWorkflow | ||
|
||
MAX_ALLOWED_SINGLE_PAGE_TIME = timedelta(seconds=2) | ||
MAX_ALLOWED_TOTAL_TIME = timedelta(seconds=5) | ||
|
||
MAP_RESOURCES = [ | ||
"api/netmap", | ||
] | ||
|
||
|
||
class MapGenerationFromTelemetryTest(PerformanceTest): | ||
|
||
TEST_NAME = "Map generation from fake telemetries test" | ||
|
||
def __init__(self, island_client, break_on_timeout=False): | ||
self.island_client = island_client | ||
performance_config = PerformanceTestConfig(max_allowed_single_page_time=MAX_ALLOWED_SINGLE_PAGE_TIME, | ||
max_allowed_total_time=MAX_ALLOWED_TOTAL_TIME, | ||
endpoints_to_test=MAP_RESOURCES, | ||
break_on_timeout=break_on_timeout) | ||
self.performance_test_workflow = TelemetryPerformanceTestWorkflow(MapGenerationFromTelemetryTest.TEST_NAME, | ||
self.island_client, | ||
performance_config) | ||
|
||
def run(self): | ||
self.performance_test_workflow.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
envs/monkey_zoo/blackbox/tests/performance/report_generation_from_telemetries.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from datetime import timedelta | ||
|
||
from envs.monkey_zoo.blackbox.tests.performance.performance_test import PerformanceTest | ||
from envs.monkey_zoo.blackbox.tests.performance.performance_test_config import PerformanceTestConfig | ||
from envs.monkey_zoo.blackbox.tests.performance.telemetry_performance_test_workflow import \ | ||
TelemetryPerformanceTestWorkflow | ||
|
||
MAX_ALLOWED_SINGLE_PAGE_TIME = timedelta(seconds=2) | ||
MAX_ALLOWED_TOTAL_TIME = timedelta(seconds=5) | ||
|
||
REPORT_RESOURCES = [ | ||
"api/report/security", | ||
"api/attack/report", | ||
"api/report/zero_trust/findings", | ||
"api/report/zero_trust/principles", | ||
"api/report/zero_trust/pillars" | ||
] | ||
|
||
|
||
class ReportGenerationFromTelemetryTest(PerformanceTest): | ||
|
||
TEST_NAME = "Map generation from fake telemetries test" | ||
|
||
def __init__(self, island_client, break_on_timeout=False): | ||
self.island_client = island_client | ||
performance_config = PerformanceTestConfig(max_allowed_single_page_time=MAX_ALLOWED_SINGLE_PAGE_TIME, | ||
max_allowed_total_time=MAX_ALLOWED_TOTAL_TIME, | ||
endpoints_to_test=REPORT_RESOURCES, | ||
break_on_timeout=break_on_timeout) | ||
self.performance_test_workflow = TelemetryPerformanceTestWorkflow(ReportGenerationFromTelemetryTest.TEST_NAME, | ||
self.island_client, | ||
performance_config) | ||
|
||
def run(self): | ||
self.performance_test_workflow.run() |
20 changes: 20 additions & 0 deletions
20
envs/monkey_zoo/blackbox/tests/performance/telemetry_performance_test_workflow.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from envs.monkey_zoo.blackbox.tests.basic_test import BasicTest | ||
from envs.monkey_zoo.blackbox.tests.performance.endpoint_performance_test import EndpointPerformanceTest | ||
from envs.monkey_zoo.blackbox.tests.performance.performance_test_config import PerformanceTestConfig | ||
from envs.monkey_zoo.blackbox.tests.performance.telemetry_performance_test import TelemetryPerformanceTest | ||
|
||
|
||
class TelemetryPerformanceTestWorkflow(BasicTest): | ||
|
||
def __init__(self, name, island_client, performance_config: PerformanceTestConfig): | ||
self.name = name | ||
self.island_client = island_client | ||
self.performance_config = performance_config | ||
|
||
def run(self): | ||
try: | ||
TelemetryPerformanceTest(island_client=self.island_client).test_telemetry_performance() | ||
performance_test = EndpointPerformanceTest(self.name, self.performance_config, self.island_client) | ||
assert performance_test.run() | ||
finally: | ||
self.island_client.reset_env() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
monkey/monkey_island/cc/resources/zero_trust/finding_event.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import flask_restful | ||
import json | ||
|
||
from monkey_island.cc.auth import jwt_required | ||
from monkey_island.cc.services.reporting.zero_trust_service import ZeroTrustService | ||
|
||
|
||
class ZeroTrustFindingEvent(flask_restful.Resource): | ||
|
||
@jwt_required() | ||
def get(self, finding_id: str): | ||
return {'events_json': json.dumps(ZeroTrustService.get_events_by_finding(finding_id), default=str)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Profiling island | ||
|
||
To profile specific methods on island a `@profile(sort_args=['cumulative'], print_args=[100])` | ||
decorator can be used. | ||
Use it as any other decorator. After decorated method is used, a file will appear in a | ||
directory provided in `profiler_decorator.py`. Filename describes the path of | ||
the method that was profiled. For example if method `monkey_island/cc/resources/netmap.get` | ||
was profiled, then the results of this profiling will appear in | ||
`monkey_island_cc_resources_netmap_get`. |
Oops, something went wrong.