python-discord / snekbox

Easy, safe evaluation of arbitrary Python code
https://pythondiscord.com
MIT License
214 stars 39 forks source link

raise error if attachment pathname contains invalid bytes #209

Closed Esther-Goldberg closed 8 months ago

Esther-Goldberg commented 8 months ago

safe_path is used for input, to parse a file path from the dict. This error is occurring when doing the reverse. This change throws an EvalError if any file created by the Python code isn't able to be encoded in UTF-8.

coveralls commented 8 months ago

Coverage Status

coverage: 90.826% (+0.1%) from 90.704% when pulling c11b4e8f235cd21246ae5030288a0d01de2cc42d on invalid_bytes_in_filename into f45ae67942240270bb0ee285848b1c6f499a8748 on main.

Esther-Goldberg commented 8 months ago

This would close #205

MarkKoz commented 8 months ago

Thanks for the PR! Can you add a test for this as well?

Esther-Goldberg commented 8 months ago

Sure! I'll add that once I get it done

Esther-Goldberg commented 8 months ago

Is a test for the error returned by nsjail enough, or should the function that creates files from paths also have a test?

MarkKoz commented 8 months ago

That test is sufficient - it's what I also had in mind. However, the test is failing in CI.