Conversation
|
The failing CI against nightly build can be ignored, the AI says:
|
|
Codex found this issue too, I was about to open a PR when I saw this one. It wrote a non-regression test, in case you're interested to add it in this PR (I'd say it's a nice-to-have): Detailsdef test_loss_node_does_not_import_before_audit(monkeypatch):
from sklearn._loss._loss import CyAbsoluteError
dumped = dumps(CyAbsoluteError())
buffer = io.BytesIO()
with ZipFile(io.BytesIO(dumped), "r") as src, ZipFile(buffer, "w") as dst:
schema = json.loads(src.read("schema.json"))
schema["__module__"] = "malicious_mod"
schema["__class__"] = "Payload"
for info in src.infolist():
if info.filename == "schema.json":
dst.writestr("schema.json", json.dumps(schema))
else:
dst.writestr(info, src.read(info.filename))
dumped = buffer.getvalue()
def fail_gettype(*args, **kwargs):
raise AssertionError("gettype() should not be called before audit")
monkeypatch.setattr("skops.io._sklearn.gettype", fail_gettype)
with pytest.raises(UntrustedTypesFoundException, match="malicious_mod.Payload"):
loads(dumped) |
This fixes an issue in LossNode where we used to load module from a given file.
This is not too big of a deal since if the user has a malicious package, they're already compromised via
.pthfiles anyway. But this can still be avoided.