From b37756e8b062f9b9ef0a5e9992ae1896d8070a87 Mon Sep 17 00:00:00 2001 From: Tyson Smith Date: Tue, 30 Apr 2024 12:30:41 -0700 Subject: [PATCH] Add final decorator for type checker --- grizzly/adapter/adapter.py | 5 ++++- grizzly/target/target.py | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/grizzly/adapter/adapter.py b/grizzly/adapter/adapter.py index 67cc54a6..d0669f04 100644 --- a/grizzly/adapter/adapter.py +++ b/grizzly/adapter/adapter.py @@ -3,7 +3,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. from abc import ABCMeta, abstractmethod from pathlib import Path -from typing import Any, Dict, Generator, Optional, Tuple +from typing import Any, Dict, Generator, Optional, Tuple, final from grizzly.common.storage import TestCase from grizzly.common.utils import DEFAULT_TIME_LIMIT, HARNESS_FILE @@ -65,6 +65,7 @@ def __enter__(self) -> "Adapter": def __exit__(self, *exc: Any) -> None: self.cleanup() + @final def cleanup(self) -> None: """Automatically called once at shutdown. Used internally by Grizzly. *** DO NOT OVERRIDE! *** @@ -77,6 +78,7 @@ def cleanup(self) -> None: """ self.shutdown() + @final def enable_harness(self, path: Path = HARNESS_FILE) -> None: """Enable use of a harness during fuzzing. By default no harness is used. *** DO NOT OVERRIDE! *** @@ -90,6 +92,7 @@ def enable_harness(self, path: Path = HARNESS_FILE) -> None: self._harness = path.read_bytes() assert self._harness, f"empty harness file '{path.resolve()}'" + @final def get_harness(self) -> Optional[bytes]: """Get the harness. Used internally by Grizzly. *** DO NOT OVERRIDE! *** diff --git a/grizzly/target/target.py b/grizzly/target/target.py index 2847c018..582743fb 100644 --- a/grizzly/target/target.py +++ b/grizzly/target/target.py @@ -7,7 +7,7 @@ from os import environ from pathlib import Path from threading import Lock -from typing import Any, Dict, Optional, Set, Tuple +from typing import Any, Dict, Optional, Set, Tuple, final from ..common.report import Report from ..common.utils import CertificateBundle, grz_tmp @@ -141,6 +141,7 @@ def check_result(self, ignored: Set[str]) -> Result: Result code. """ + @final def cleanup(self) -> None: """Perform necessary cleanup. DO NOT OVERRIDE.