Skip to content

Commit 5e18991

Browse files
committed
fix: thread-worker prc calculation
1 parent fb89db3 commit 5e18991

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

extensions/business/cybersec/red_mesh/pentester_api_01.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -757,20 +757,20 @@ def list_features(self):
757757
return result
758758

759759

760-
@BasePlugin.endpoint
760+
@BasePlugin.endpoint(method="post")
761761
def launch_test(
762762
self,
763763
target: str = "",
764764
start_port: int = 1, end_port: int = 65535,
765765
exceptions: str = "64297",
766766
distribution_strategy: str = "",
767767
port_order: str = "",
768-
excluded_features=None,
768+
excluded_features: list[str] = None,
769769
):
770770
"""
771771
Start a pentest on the specified target.
772772
773-
Announces the job to the network via CStore; actual execution is handled
773+
Announces the job to the network via CStore; actual executtarget:ion is handled
774774
asynchronously by worker threads.
775775
776776
Parameters
@@ -830,6 +830,9 @@ def launch_test(
830830
excluded_features = [f for f in excluded_features if f in all_features]
831831
enabled_features = [f for f in all_features if f not in excluded_features]
832832

833+
self.P(f"Excluded features: {self.json_dumps(excluded_features)}")
834+
self.P(f"Enabled features: {self.json_dumps(enabled_features)}")
835+
833836
distribution_strategy = str(distribution_strategy).upper()
834837

835838
if not distribution_strategy or distribution_strategy not in ["MIRROR", "SLICE"]:

extensions/business/cybersec/red_mesh/redmesh_utils.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,14 @@ def get_status(self, for_aggregations=False):
204204
Worker status including progress and findings.
205205
"""
206206
completed_tests = self.state.get("completed_tests", [])
207-
max_features = len(self.__enabled_features) + 3 # +1 port scan, +1 service_info_completed, +1 web_tests_completed
208-
progress = f"{(len(completed_tests) / max_features) * 100 if self.__enabled_features else 0:.1f}%"
207+
open_ports = self.state.get("open_ports", [])
208+
if open_ports:
209+
# Full work: port scan + all enabled features + 2 completion markers
210+
max_features = len(self.__enabled_features) + 3
211+
else:
212+
# No open ports: just port scan + 2 completion markers
213+
max_features = 3
214+
progress = f"{(len(completed_tests) / max_features) * 100:.1f}%"
209215

210216
dct_status = {
211217
# same data for all workers below

0 commit comments

Comments
 (0)