Spaces:
Sleeping
Sleeping
Delete client.py
Browse files
client.py
DELETED
|
@@ -1,51 +0,0 @@
|
|
| 1 |
-
from __future__ import annotations
|
| 2 |
-
|
| 3 |
-
from typing import Dict
|
| 4 |
-
|
| 5 |
-
try:
|
| 6 |
-
from core.client_types import StepResult
|
| 7 |
-
from core.env_client import EnvClient
|
| 8 |
-
except ImportError:
|
| 9 |
-
from openenv.core.client_types import StepResult
|
| 10 |
-
from openenv.core.env_client import EnvClient
|
| 11 |
-
|
| 12 |
-
try:
|
| 13 |
-
from .models import CodeSecurityAction, CodeSecurityObservation, CodeSecurityState
|
| 14 |
-
except ImportError:
|
| 15 |
-
from models import CodeSecurityAction, CodeSecurityObservation, CodeSecurityState
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
class CodeSecurityAuditorEnv(
|
| 19 |
-
EnvClient[CodeSecurityAction, CodeSecurityObservation, CodeSecurityState]
|
| 20 |
-
):
|
| 21 |
-
"""Client wrapper for the Code Security Auditor environment server."""
|
| 22 |
-
|
| 23 |
-
def _step_payload(self, action: CodeSecurityAction) -> dict:
|
| 24 |
-
payload = {
|
| 25 |
-
"action_type": action.action_type,
|
| 26 |
-
"confidence": action.confidence,
|
| 27 |
-
"evidence": action.evidence,
|
| 28 |
-
"summary": action.summary,
|
| 29 |
-
}
|
| 30 |
-
if action.filename is not None:
|
| 31 |
-
payload["filename"] = action.filename
|
| 32 |
-
if action.line_start is not None:
|
| 33 |
-
payload["line_start"] = action.line_start
|
| 34 |
-
if action.line_end is not None:
|
| 35 |
-
payload["line_end"] = action.line_end
|
| 36 |
-
if action.vuln_type is not None:
|
| 37 |
-
payload["vuln_type"] = action.vuln_type
|
| 38 |
-
if action.severity is not None:
|
| 39 |
-
payload["severity"] = action.severity
|
| 40 |
-
return payload
|
| 41 |
-
|
| 42 |
-
def _parse_result(self, payload: Dict) -> StepResult[CodeSecurityObservation]:
|
| 43 |
-
observation = CodeSecurityObservation(**payload.get("observation", {}))
|
| 44 |
-
return StepResult(
|
| 45 |
-
observation=observation,
|
| 46 |
-
reward=payload.get("reward"),
|
| 47 |
-
done=bool(payload.get("done", False)),
|
| 48 |
-
)
|
| 49 |
-
|
| 50 |
-
def _parse_state(self, payload: Dict) -> CodeSecurityState:
|
| 51 |
-
return CodeSecurityState(**payload)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|