Disallow refs starting with a non-letter or digit
authorColin Walters <walters@verbum.org>
Wed, 18 Oct 2017 00:53:27 +0000 (20:53 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Wed, 18 Oct 2017 20:55:43 +0000 (20:55 +0000)
commite466e482b156ad89c1dea8bcb0a5ee639f18e884
tree94ae4ed16eea9f6a022204eb24118cc6140f9d9f
parent3f3d3d64acf0391df3c91b4e3a7c6c7bc5741685
Disallow refs starting with a non-letter or digit

Change the regexp for validating refs to require at least one letter or digit
before allowing the other special chars in the set `[.-_]`. Names that start
with `.` are traditionally Unix hidden files; let's ignore them under the
assumption they're metadata for some other tool, and we don't want to
potentially conflict with the special `.` and `..` Unix directory entries.
Further, names starting with `-` are problematic for Unix cmdline option
processing; there's no good reason to support that. Finally, disallow `_` just
on general principle - it's simpler to say that ref identifiers must start with
a letter or digit.

We also ignore any existing files (that might be previously created refs) that
start with `.` in the `refs/` directory - there's a Red Hat tool for content
management that injects `.rsync` files, which is why this patch was first
written.

V1: Update to ban all refs starting with a non-letter/digit, and
    also add another call to `ostree_validate_rev` in the pull
    code.

Closes: https://github.com/ostreedev/ostree/issues/1285
Closes: #1286
Approved by: jlebon
src/libostree/ostree-core-private.h
src/libostree/ostree-core.c
src/libostree/ostree-repo-pull.c
src/libostree/ostree-repo-refs.c
tests/test-refs.sh