Commit c0017ce4 authored by Ximin Luo's avatar Ximin Luo

Add a safety device to guard against typos

parent 46866143
......@@ -7,6 +7,7 @@ import configparser
import logging
import os
import pathlib
import re
import subprocess
import sys
import tempfile
......@@ -294,6 +295,8 @@ def build(script, source_root, dist_root, artifact_pattern, testbed, artifact_st
print(artifact_pattern)
# remove any existing artifact, in case the build script doesn't overwrite
# it e.g. like how make(1) sometimes works.
if re.search(r"""(^| )['"]*/""", artifact_pattern):
raise ValueError("artifact_pattern is possibly dangerous; refusing to continue")
testbed.check_exec(
['sh', '-ec', 'cd "%s" && rm -rf %s' %
(source_root, artifact_pattern)])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment