4 ms·
> def tail(job_id, info): > logs = os.path.join(cfg("builds.sr.ht::worker", "buildlogs"), str(job_id)) Depending on where your job_id comes from, you may w
by muxator 7y ago
> def tail(job_id, info):
> logs = os.path.join(cfg("builds.sr.ht::worker", "buildlogs"), str(job_id))
Depending on where your job_id comes from, you may want to ensure "logs" variable still ends up pointing a subdirectory of buildlogs. You could use a combination of os.path.abspath() and various methods for checking the common prefix.
Maybe this is only a simplified snippet, but concatenating values with external parameters without checking ng the end result can lead to unpleasant surprises in production code.
- emersion 7y agoI believe job_id is an int in this case. Buy yeah, it doesn't hurt to double-check, just in case it somehow gets called with a user-supplied variable at some point.