From 5a2bdb4ba7d9472dc60e2d394daeef7dfd370ba4 Mon Sep 17 00:00:00 2001 From: fabian Date: Tue, 28 Nov 2023 17:03:26 +0100 Subject: [PATCH] refactor(ecu): remove unnecessary level parameter from leave_session() --- src/gallia/commands/fuzz/uds/pdu.py | 2 +- src/gallia/commands/scan/uds/identifiers.py | 2 +- src/gallia/commands/scan/uds/reset.py | 2 +- src/gallia/commands/scan/uds/sa_dump_seeds.py | 2 +- src/gallia/commands/scan/uds/services.py | 2 +- src/gallia/services/uds/ecu.py | 8 ++------ 6 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/gallia/commands/fuzz/uds/pdu.py b/src/gallia/commands/fuzz/uds/pdu.py index 2585cdf36..67424d125 100644 --- a/src/gallia/commands/fuzz/uds/pdu.py +++ b/src/gallia/commands/fuzz/uds/pdu.py @@ -195,7 +195,7 @@ async def main(self, args: Namespace) -> None: logger.result(f"Flow control frames missing: {flow_control_miss}") logger.info(f"Leaving session 0x{session:02x} via hook") - await self.ecu.leave_session(session) + await self.ecu.leave_session() if args.observe_can_ids: recv_task.cancel() diff --git a/src/gallia/commands/scan/uds/identifiers.py b/src/gallia/commands/scan/uds/identifiers.py index 26565b6ff..7666b5b78 100644 --- a/src/gallia/commands/scan/uds/identifiers.py +++ b/src/gallia/commands/scan/uds/identifiers.py @@ -134,7 +134,7 @@ async def main(self, args: Namespace) -> None: logger.result(f"Scan in session {g_repr(session)} is complete!") logger.info(f"Leaving session {g_repr(session)} via hook") - await self.ecu.leave_session(session) + await self.ecu.leave_session() async def perform_scan(self, args: Namespace, session: None | int = None) -> None: positive_DIDs = 0 diff --git a/src/gallia/commands/scan/uds/reset.py b/src/gallia/commands/scan/uds/reset.py index 1c2f18947..ed8a82a1f 100644 --- a/src/gallia/commands/scan/uds/reset.py +++ b/src/gallia/commands/scan/uds/reset.py @@ -81,7 +81,7 @@ async def main(self, args: Namespace) -> None: logger.result(f"Scanning in session: {g_repr(session)}") await self.perform_scan(args, session) - await self.ecu.leave_session(session) + await self.ecu.leave_session() async def perform_scan(self, args: Namespace, session: None | int = None) -> None: l_ok: list[int] = [] diff --git a/src/gallia/commands/scan/uds/sa_dump_seeds.py b/src/gallia/commands/scan/uds/sa_dump_seeds.py index ae0b1e1ef..125992f05 100644 --- a/src/gallia/commands/scan/uds/sa_dump_seeds.py +++ b/src/gallia/commands/scan/uds/sa_dump_seeds.py @@ -218,4 +218,4 @@ async def main(self, args: Namespace) -> None: await file.close() self.log_size(seeds_file, time.time() - start_time) - await self.ecu.leave_session(session) + await self.ecu.leave_session() diff --git a/src/gallia/commands/scan/uds/services.py b/src/gallia/commands/scan/uds/services.py index 023efce65..892e43464 100644 --- a/src/gallia/commands/scan/uds/services.py +++ b/src/gallia/commands/scan/uds/services.py @@ -119,7 +119,7 @@ async def main(self, args: Namespace) -> None: found[session] = await self.perform_scan(args, session) - await self.ecu.leave_session(session) + await self.ecu.leave_session() for key, value in found.items(): logger.result(f"findings in session 0x{key:02X}:") diff --git a/src/gallia/services/uds/ecu.py b/src/gallia/services/uds/ecu.py index 51946fa00..c900c64f8 100644 --- a/src/gallia/services/uds/ecu.py +++ b/src/gallia/services/uds/ecu.py @@ -220,17 +220,13 @@ async def callback() -> None: self.state.reset() return True - async def leave_session( - self, level: int, config: UDSRequestConfig | None = None - ) -> bool: + async def leave_session(self, config: UDSRequestConfig | None = None) -> bool: """leave_session() is a hook which can be called explicitly by a scanner when a session is to be disabled. Use this hook if resetting the ECU is required, e.g. when disabling the programming session. Args: - uds: The UDSClient class where this hook is embedded. The caller typically - calls this function with `self` as the first argument. - session: The desired session identifier. + config: The configuration. Returns: True on success, False on error. """