Deploy guard: require raytracer path segment; join FTP root with slash
@@ -57,7 +57,23 @@ ftp_upload:
57
57
- apt-get update -qy
58
58
- apt-get install -y --no-install-recommends lftp python3 ca-certificates
59
59
# BlueGit expandeert $timftproot in secrets niet altijd; doe het zelf.
60
- export projectftp="$(python3 -c 'import os;r=os.environ.get("timftproot","");print(os.environ["projectftp"].replace("${timftproot}",r).replace("$timftproot",r))')"
60
- |
61
export projectftp="$(python3 - <<'PY'
62
import os
63
root = os.environ.get("timftproot", "") or ""
64
raw = os.environ["projectftp"]
65
# Expand placeholder; ensure a slash between root and suffix when glued.
66
if "${timftproot}" in raw or "$timftproot" in raw:
67
suf = raw.replace("${timftproot}", "").replace("$timftproot", "")
68
if root and suf and not root.endswith("/") and not suf.startswith("/"):
69
out = root + "/" + suf
70
else:
71
out = root + suf
72
else:
73
out = raw
74
print(out)
75
PY
76
)"
61
77
- test -n "$projectftp"
62
78
- |
63
79
python3 - <<'PY'
@@ -68,11 +84,13 @@ ftp_upload:
68
84
print("REFUSING: projectftp is FTP-root or empty:", repr(p))
69
85
sys.exit(3)
70
86
# Pad moet op dit project eindigen (voorkomt verkeerde secret).
71
leaf = p.rsplit("/", 1)[-1]
72
if leaf != "raytracer" and not p.endswith("/raytracer"):
73
print("REFUSING: projectftp does not end with raytracer:", p)
87
# Require "raytracer" as a path segment (secret leaf may include host dirs).
88
segs = [s for s in p.split("/") if s]
89
leaf = segs[-1] if segs else ""
90
if "raytracer" not in [s.lower() for s in segs]:
91
print("REFUSING: projectftp has no raytracer segment; leaf=%r nsegs=%d" % (leaf, len(segs)))
74
92
sys.exit(3)
75
print("deploy target ok (path redacted length=%d leaf=%s)" % (len(p), leaf))
93
print("deploy target ok (length=%d leaf=%s nsegs=%d)" % (len(p), leaf, len(segs)))
76
94
PY
77
95
- test -f build/index.html
78
96
- test -f build/editor.html
@@ -57,7 +57,23 @@ ftp_upload:57
- apt-get update -qy57
- apt-get update -qy58
- apt-get install -y --no-install-recommends lftp python3 ca-certificates58
- apt-get install -y --no-install-recommends lftp python3 ca-certificates59
# BlueGit expandeert $timftproot in secrets niet altijd; doe het zelf.59
# BlueGit expandeert $timftproot in secrets niet altijd; doe het zelf.60
- export projectftp="$(python3 -c 'import os;r=os.environ.get("timftproot","");print(os.environ["projectftp"].replace("${timftproot}",r).replace("$timftproot",r))')"60
- |61
export projectftp="$(python3 - <<'PY'62
import os63
root = os.environ.get("timftproot", "") or ""64
raw = os.environ["projectftp"]65
# Expand placeholder; ensure a slash between root and suffix when glued.66
if "${timftproot}" in raw or "$timftproot" in raw:67
suf = raw.replace("${timftproot}", "").replace("$timftproot", "")68
if root and suf and not root.endswith("/") and not suf.startswith("/"):69
out = root + "/" + suf70
else:71
out = root + suf72
else:73
out = raw74
print(out)75
PY76
)"61
- test -n "$projectftp"77
- test -n "$projectftp"62
- |78
- |63
python3 - <<'PY'79
python3 - <<'PY'@@ -68,11 +84,13 @@ ftp_upload:68
print("REFUSING: projectftp is FTP-root or empty:", repr(p))84
print("REFUSING: projectftp is FTP-root or empty:", repr(p))69
sys.exit(3)85
sys.exit(3)70
# Pad moet op dit project eindigen (voorkomt verkeerde secret).86
# Pad moet op dit project eindigen (voorkomt verkeerde secret).71
leaf = p.rsplit("/", 1)[-1]87
# Require "raytracer" as a path segment (secret leaf may include host dirs).72
if leaf != "raytracer" and not p.endswith("/raytracer"):88
segs = [s for s in p.split("/") if s]73
print("REFUSING: projectftp does not end with raytracer:", p)89
leaf = segs[-1] if segs else ""90
if "raytracer" not in [s.lower() for s in segs]:91
print("REFUSING: projectftp has no raytracer segment; leaf=%r nsegs=%d" % (leaf, len(segs)))74
sys.exit(3)92
sys.exit(3)75
print("deploy target ok (path redacted length=%d leaf=%s)" % (len(p), leaf))93
print("deploy target ok (length=%d leaf=%s nsegs=%d)" % (len(p), leaf, len(segs)))76
PY94
PY77
- test -f build/index.html95
- test -f build/index.html78
- test -f build/editor.html96
- test -f build/editor.html