mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-10-16 03:49:26 +00:00
fix(model-grounded-detection): type the config literals list
mypy could not see that row["literals"] is a list on an object-valued dict. Narrowed at the use site rather than widened at the boundary. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01T7XD7x5KonMdmGRkp63EQG
This commit is contained in:
co-authored by
Claude Opus 5
parent
d9ceeb6a09
commit
4f8f590b93
@@ -28,7 +28,10 @@ def verdict(cpg: CpgResult, spec: ConfigSpec, *, function: str = "") -> Verdict
|
|||||||
|
|
||||||
permissive = {value.strip().strip("'\"").lower() for value in spec.permissive}
|
permissive = {value.strip().strip("'\"").lower() for value in spec.permissive}
|
||||||
for row in settings:
|
for row in settings:
|
||||||
for literal in row["literals"]:
|
literals = row["literals"]
|
||||||
|
if not isinstance(literals, list):
|
||||||
|
continue
|
||||||
|
for literal in literals:
|
||||||
if str(literal).strip().strip("'\"").lower() in permissive:
|
if str(literal).strip().strip("'\"").lower() in permissive:
|
||||||
return Verdict(
|
return Verdict(
|
||||||
rung=Rung.ENTAILED,
|
rung=Rung.ENTAILED,
|
||||||
@@ -37,7 +40,7 @@ def verdict(cpg: CpgResult, spec: ConfigSpec, *, function: str = "") -> Verdict
|
|||||||
)
|
)
|
||||||
|
|
||||||
# A setting whose value the model could not read. Not safe, not decided.
|
# A setting whose value the model could not read. Not safe, not decided.
|
||||||
computed = [row for row in settings if not row["literals"]]
|
computed = [row for row in settings if not row["literals"]] # type: ignore[truthy-iterable]
|
||||||
if computed:
|
if computed:
|
||||||
row = computed[0]
|
row = computed[0]
|
||||||
return Verdict(
|
return Verdict(
|
||||||
|
|||||||
Reference in New Issue
Block a user