core: Sanitize error text validating refs (e.g. against HTML)
See: https://github.com/projectatomic/rpm-ostree/issues/885 If we get a successful Apache directory listing HTML when fetching what we intend to be a ref, we'd dump the HTML into the error. I did some scanning of the pull code, and this was the only case I saw offhand where we were dumping text out into an error. Which makes sense, since most of our formats are binary, the exeptions I think are just `repo/config` and `repo/refs/`. Closes: #1015 Approved by: mbarnes
This commit is contained in:
1 parent
bed931c91f
commit
c740b7f6d2
4 files changed
+59
-5
No files matched your search
+12
-1
@@ -35,7 +35,7 @@ function verify_initial_contents() {
|
||||
assert_file_has_content baz/cow '^moo$'
|
||||
}
|
||||
|
||||
echo "1..26"
|
||||
echo "1..27"
|
||||
|
||||
# Try both syntaxes
|
||||
repo_init --no-gpg-verify
|
||||
@@ -413,3 +413,14 @@ rm $localsig
|
||||
${CMD_PREFIX} ostree --repo=repo pull origin main
|
||||
test -f $localsig
|
||||
echo "ok re-pull signature for stored commit"
|
||||
|
||||
cd ${test_tmpdir}
|
||||
repo_init --no-gpg-verify
|
||||
mv ostree-srv/gnomerepo/refs/heads/main{,.orig}
|
||||
rm ostree-srv/gnomerepo/summary
|
||||
(for x in $(seq 20); do echo "lots of html here "; done) > ostree-srv/gnomerepo/refs/heads/main
|
||||
if ${CMD_PREFIX} ostree --repo=repo pull origin main 2>err.txt; then
|
||||
fatal "pull of invalid ref succeeded"
|
||||
fi
|
||||
assert_file_has_content_literal err.txt 'error: Fetching refs/heads/main: Invalid rev lots of html here lots of html here lots of html here lots of'
|
||||
echo "ok pull got HTML for a ref"
|
||||
+1
-1
@@ -258,6 +258,6 @@ ${CMD_PREFIX} ostree --repo=repo summary -u
|
||||
if ${CMD_PREFIX} ostree --repo=repo static-delta show GARBAGE 2> err.txt; then
|
||||
assert_not_reached "static-delta show GARBAGE unexpectedly succeeded"
|
||||
fi
|
||||
assert_file_has_content err.txt "Invalid rev 'GARBAGE'"
|
||||
assert_file_has_content err.txt "Invalid rev GARBAGE"
|
||||
|
||||
echo 'ok handle bad delta name'
|
||||
Reference in new issue
Block a user