Skip to content

Commit 2244733

Browse files
committed
Require encoded exfil Rust extension
Signed-off-by: lucarlig <luca.carlig@ibm.com>
1 parent 34327a1 commit 2244733

2 files changed

Lines changed: 6 additions & 30 deletions

File tree

plugins/rust/python-package/encoded_exfil_detection/cpex_encoded_exfil_detection/encoded_exfil_detection.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,10 @@
3434
ToolPostInvokePayload,
3535
ToolPostInvokeResult,
3636
)
37-
38-
try:
39-
from cpex_encoded_exfil_detection.encoded_exfil_detection_rust import (
40-
ExfilDetectorEngine,
41-
py_scan_container as _py_scan_container,
42-
)
43-
_RUST_IMPORT_ERROR: ImportError | None = None
44-
except ImportError as _err:
45-
ExfilDetectorEngine = None # type: ignore[assignment,misc]
46-
_py_scan_container = None # type: ignore[assignment]
47-
_RUST_IMPORT_ERROR = _err
37+
from cpex_encoded_exfil_detection.encoded_exfil_detection_rust import (
38+
ExfilDetectorEngine,
39+
py_scan_container as _py_scan_container,
40+
)
4841

4942
logger = logging.getLogger(__name__)
5043

@@ -136,10 +129,6 @@ def _scan_container(
136129
path: str = "",
137130
) -> tuple[int, Any, list[dict[str, Any]]]:
138131
"""Scan a container for encoded exfiltration patterns via the Rust engine."""
139-
if _RUST_IMPORT_ERROR is not None:
140-
raise ImportError(
141-
"Rust extension not built — run 'make install' before using this plugin"
142-
) from _RUST_IMPORT_ERROR
143132
count, redacted, findings = _py_scan_container(container, cfg)
144133
normalized = _prefix_finding_paths(
145134
[f for f in findings if isinstance(f, dict)],
@@ -168,10 +157,6 @@ def __init__(self, config: PluginConfig) -> None:
168157
config: Plugin configuration.
169158
"""
170159
super().__init__(config)
171-
if _RUST_IMPORT_ERROR is not None:
172-
raise ImportError(
173-
"Rust extension not built — run 'make install' before using this plugin"
174-
) from _RUST_IMPORT_ERROR
175160
self._cfg = EncodedExfilDetectorConfig(**(config.config or {}))
176161
try:
177162
self._rust_engine = ExfilDetectorEngine(self._cfg)

plugins/tests/encoded_exfil_detection/test_integration.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# Standard
55
import base64
66
import logging
7-
import os
87
from pathlib import Path
98

109
# Third-Party
@@ -32,13 +31,7 @@
3231
EncodedExfilDetectorConfig,
3332
EncodedExfilDetectorPlugin,
3433
)
35-
36-
37-
try:
38-
import cpex_encoded_exfil_detection.encoded_exfil_detection_rust # noqa: F401
39-
RUST_AVAILABLE = True
40-
except ImportError:
41-
RUST_AVAILABLE = False
34+
import cpex_encoded_exfil_detection.encoded_exfil_detection_rust # noqa: F401
4235

4336

4437
def test_imports_with_real_cpex_package() -> None:
@@ -55,9 +48,7 @@ def test_imports_with_real_cpex_package() -> None:
5548
"from cpex_encoded_exfil_detection.encoded_exfil_detection import EncodedExfilDetectorConfig, EncodedExfilDetectorPlugin",
5649
],
5750
)
58-
# Fail in CI if Rust plugins are required
59-
if not RUST_AVAILABLE and os.environ.get("REQUIRE_RUST") == "1":
60-
raise ImportError("Rust plugin 'encoded_exfil_detection' is required in CI but not available")
51+
6152

6253
class TestEncodedDetectionScan:
6354
"""Validate scanner behavior."""

0 commit comments

Comments
 (0)