iac-secfix / tests /test_llm_parse.py
selcuksntrk's picture
Add IaC-SecFix agent package
0953e56 verified
Raw
History Blame Contribute Delete
761 Bytes
from iac_secfix_agents.llm import parse_fix_candidate
def test_parse_fix_candidate_from_json():
candidate, ok = parse_fix_candidate(
'{"patch":"diff","fixed_file":"resource \\"x\\" \\"y\\" {}","resolved_policy_ids":["CKV_X_1"],"explanation":"ok","verification_commands":[],"risk_notes":[],"requires_human_approval":true}'
)
assert ok
assert candidate is not None
assert candidate.resolved_policy_ids == ["CKV_X_1"]
def test_parse_fix_candidate_from_wrapped_text():
candidate, ok = parse_fix_candidate(
'Here is the JSON: {"patch":"","fixed_file":"kind: Pod\\n","resolved":["CKV_K8S_8"],"summary":"fixed"}'
)
assert ok
assert candidate is not None
assert candidate.resolved_policy_ids == ["CKV_K8S_8"]