Skip to content

Commit 74f3356

Browse files
sawenzelclaude
andcommitted
Reject requested O2PDPSuite tags with unsafe characters
This fixes resolve_o2pdpsuite_tag accepting a requested tag containing path-traversal characters, and makes the harness executable like its siblings. - A "sim-tests-tag:" value taken from a fork PR's body could contain "../" and select a module outside O2PDPSuite, since only -e was checked before use. - Added a character-class check that rejects anything but [A-Za-z0-9._-] before the existence test. - Added a harness case asserting a requested value of "../O2/something" returns 1 and prints nothing on stdout. - chmod +x test/tests/resolve_tag.sh; it was 644 while its siblings are 755. test/ci/resolve_tag.sh stays 644, since it is sourced, not run. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 65ea52b commit 74f3356

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

test/ci/resolve_tag.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ resolve_o2pdpsuite_tag()
1414
fi
1515

1616
if [[ -n "${requested}" ]] ; then
17+
case ${requested} in
18+
*[!A-Za-z0-9._-]* )
19+
echo "resolve_o2pdpsuite_tag: invalid tag: ${requested}" >&2
20+
return 1 ;;
21+
esac
1722
if [[ ! -e "${moduledir}/${requested}" ]] ; then
1823
echo "resolve_o2pdpsuite_tag: requested tag not available: ${requested}" >&2
1924
return 1

test/tests/resolve_tag.sh

100644100755
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ mkdir -p "${TMP}/empty"
4848
out=$(resolve_o2pdpsuite_tag "${TMP}/empty" 2>/dev/null) ; rc=$?
4949
check "directory with no dailies fails" 1 "${rc}"
5050

51+
# A requested tag from a fork PR's body must not be able to escape the
52+
# O2PDPSuite module directory via "..".
53+
mkdir -p "${TMP}/O2"
54+
touch "${TMP}/O2/something"
55+
out=$(resolve_o2pdpsuite_tag "${D}" "../O2/something" 2>/dev/null) ; rc=$?
56+
check "path traversal tag fails" 1 "${rc}"
57+
check "path traversal tag prints nothing on stdout" "" "${out}"
58+
5159
echo
5260
if [[ "${FAILURES}" == "0" ]] ; then
5361
echo "All resolve_tag tests passed"

0 commit comments

Comments
 (0)