Commit Graph

14507 Commits

Author SHA1 Message Date
Edward Thomson
ec501334a3 Merge pull request #6478 from libgit2/ethomson/v1.4.6
v1.4.6
v1.4.6
2023-02-14 22:53:13 +00:00
Edward Thomson
d2d4b681e2 meta: add changelog for v1.4.6 2023-02-14 16:26:45 +00:00
Edward Thomson
39ed5e35e8 meta: update version numbers to 1.4.6 2023-02-14 16:26:45 +00:00
Edward Thomson
5b1667a908 Merge pull request #6476 from libgit2/ethomson/v1.4.6
ssh: backport windows known_hosts fixes to v1.4
2023-02-14 16:20:06 +00:00
Edward Thomson
08ed0881ea test: isolate home directory separately from global config 2023-02-14 11:07:24 +00:00
Eric Huss
b7352a7058 Set all SSH hostkey preferences that are available 2023-02-14 11:06:44 +00:00
Edward Thomson
870f69c34c ci: convert PATH correctly to Cygwin format on Windows
We provide `BUILD_PATH` to our build script; provide it and mutate
`PATH` when running our tests as well.

We were previously using `cygpath` to try to convert a _list_ of Windows
paths into cygwin / Unix style `PATH` format. This does not work -- it
treats the path list as a single path (with semicolons -- understandably
as those are allowed characters in a Windows path).

For example, `C:\One;C:\Two;C:\Three` is converted to
`/c/one;c:/two;c:/three`.

Add a new function to convert path lists, so that paths are split by
semicolon and fed to `cygpath` independently, then re-joined with a
colon. This means that our example `C:\One;C:\Two;C:\Three` is correctly
converted to `/c/one:/c/two:/c/three`.
2023-02-14 11:06:38 +00:00
Edward Thomson
62b03ef3a6 ci: limit test runner to build path
We provide `BUILD_PATH` to our build script; provide it and mutate
`PATH` when running our tests as well.
2023-02-14 11:06:33 +00:00
Edward Thomson
8044fa8460 ci: run clone tests in online 2023-02-14 11:06:24 +00:00
Edward Thomson
867ee90fb0 tests: known_hosts manipulating ssh clone tests
Teach the clone tests how to clone from github.com, when given a keypair
with a passphrase and known_hosts data. This allows us to better
exercise our known_hosts checking and ensure that the lifecycle of the
certificate callback matches our expectations.
2023-02-14 11:05:49 +00:00
Edward Thomson
7a7123d197 ci: compile against libssh2 on windows 2023-02-14 11:05:44 +00:00
Edward Thomson
042c0857c5 ssh: give a realistic error message
I spent an hour banging my head against this, when it was because the
remote didn't trust my key.
2023-02-14 11:05:38 +00:00
Edward Thomson
c8b389d1f2 ssh: support windows known_hosts files
Use `git_sysdir_find_homedir_file` to identify the path to the home
directory's `.ssh/known_hosts`; this takes Windows paths into account by
preferring `HOME`, then falling back to `HOMEPATH` and `USERPROFILE`
directories.
2023-02-14 11:05:33 +00:00
Edward Thomson
99678ab650 sysdir: provide actual home directory
Provide a mechanism to look up the user's home directory, using the same
mechanism that we use for locating the global configuration path (a
fancy name for saying "the home directory").

SSH known hosts lookups now use this, instead of simply looking at the
HOME environment variable, to support Windows-style home directory
lookups in `HOME`, `HOMEPATH`, or `USERPROFILE`.
2023-02-14 11:05:16 +00:00
Edward Thomson
cd6f679af4 Merge pull request #6449 from libgit2/1.4_ssh
ssh: perform host key checking by default
v1.4.5
2023-01-20 22:11:46 +00:00
Edward Thomson
ddf3d295f4 meta: add changelog for v1.4.5 2023-01-18 22:32:47 +00:00
Edward Thomson
c998cb0426 meta: update version numbers to 1.4.5 2023-01-18 21:42:44 +00:00
Carlos Martín Nieto
63b083e5d8 ssh: look for a key in known_hosts to set the key type for the handshake
The server and client negotiate a single hostkey, but the "best" cipher may not
be the one for which we have an entry in `known_hosts`. This can lead to us not
finding the key in known_hosts even though we should be connecting.

Instead here we look up the hostname with a nonsense key to perform a lookup in
the known hosts and set that. This is roughly what the OpenSSH client does as
well.
2023-01-18 21:36:29 +00:00
Carlos Martín Nieto
bbcadbbcd8 tests: move online::clone::ssh_auth_methods into the ssh test suite
We're currently running it as part of the online suite but that doesn't have any
setup for ssh so we won't find the GitHub keys we set up during the test.

It doesn't need the private key setup as we just want to make sure we see some
auth request from the server, but with the addition of hostkey checking we're
now seeing it fail when we skip these tests.
2023-01-18 21:36:10 +00:00
Carlos Martín Nieto
724ae0b201 tests: append the github.com ssh keys so we have access during tests
Currently just the one test needs it.

The ssh-rsa makes sure we're asking for the cipher we find in `known_hosts` as
that won't be the one selected by default. This will be relevant in later changes.
2023-01-18 21:34:13 +00:00
Carlos Martín Nieto
67126da8f5 ssh: verify the remote's host key against known_hosts if it exists
It turns out this has been available in libssh2 for a long time and we should
have been verifying this the whole time.
2023-01-18 21:34:07 +00:00
Edward Thomson
3b7d756ccf meta: add changelog for v1.4.4 v1.4.4 2022-07-12 13:12:57 -04:00
Edward Thomson
bb8fc663b2 meta: update version numbers to 1.4.4 2022-07-12 13:12:29 -04:00
Mark Adler
efcded852c zlib: Silence some warnings from Visual Studio C. 2022-07-07 00:23:30 -04:00
Andrzej Hunt
8a6cb7ad0f zlib: slide_hash: add MSAN annotation to suppress known read from uninitialised memory
slide_hash knowingly reads (possibly) uninitialised memory, see comment
lower down about prev[n] potentially being garbage. In this case, the
result is never used - so we don't care about MSAN complaining about
this read.

By adding the no_sanitize("memory") attribute, clients of zlib won't
see this (unnecessary) error when building and running with
MemorySanitizer. An alternative approach is for clients to build zlib
with -fsanitize-ignorelist=... where the ignorelist contains something
like 'fun:slide_hash'. But that's more work and needs to be redone
for any and all CI systems running a given project with MSAN. Adding
this annotation to zlib's sources is overall more convenient - but
also won't affect non-MSAN builds.

This specific issue was found while running git's test suite, but has
also been reported by other clients, see e.g. #518.
2022-07-07 00:23:30 -04:00
Edward Thomson
b74880b9b3 zlib: declare prototypes for new functions
The `crc32_combine_gen64` missed a prototype in our define path.
Add one.
2022-07-07 00:23:30 -04:00
Edward Thomson
f0cf45d33e zlib: updated bundled zlib to v1.2.12 2022-07-06 14:34:06 -04:00
Edward Thomson
a0c5275c79 repo: allow users running with sudo to access their repositories
In the ownership checks implemented for CVE-2022-24765, we disallowed
users to access their own repositories when running with `sudo`.

Examine the `SUDO_UID` environment variable and allow users running
with `sudo`. This matches git's behavior.
2022-07-06 14:34:06 -04:00
Edward Thomson
af50c16f12 repo: validate gitdir and gitlink ownership
To match git's behavior with CVE 2022-29187, validate not only the
working directory, but also the gitdir and gitlink (if it exists). This
a follow up to CVE-2022-24765 that was fixed earlier.
2022-07-06 14:34:06 -04:00
Edward Thomson
b2264f45b1 repo: allow admin owned configs by admin users
Allow users in the administrator group to use git configs that are owned
by administrators.
2022-07-06 14:34:06 -04:00
Edward Thomson
258e38b02f fs: allow ownership match if user is in admin group
Allow the user ownership to match if the file is owned by the admin
group and the user is in the admin group, even if the current process is
not running as administrator directly.
2022-07-06 14:34:06 -04:00
Edward Thomson
3dd9b24ef9 fs: refactor file ownership checks
Refactor the file ownership checks so that callers can provide discrete
information about the ownership expectations to a single function.
2022-07-06 14:34:06 -04:00
Edward Thomson
a98b7feba4 fs: remove mock naming from change ownership constants
The file ownership concepts can reflect the actual file ownership, they
are not necessarily limited to mocking the interface. Rename them so
that they can be more broadly applicable.
2022-07-06 14:34:06 -04:00
Edward Thomson
3d48195869 repo: add tests for bare repo permissions
Ensure that we test opening a bare repository with odd permissions.
2022-07-06 14:34:06 -04:00
Edward Thomson
c590801556 ci: update dockerfiles for mbedTLS new url
Update the new URL for mbedTLS.
2022-07-06 14:34:06 -04:00
Edward Thomson
d580639da8 actions: pass UID and GID to PR builds of dockerfiles 2022-07-06 14:34:06 -04:00
Edward Thomson
64a5110669 ci: updates for CI 2022-07-06 14:34:06 -04:00
Carl Dong
c39e028c19 revparse: Remove error-prone, redundant test
Originally introduced in: 776a6a8e5f

This test case has recently been fixed in bdab22384c, but that fix will only last for a year. Next year the same problem will crop up and the test will need to be re-edited.

This is not ideal as
- This test case becomes an unnecessary burden for developers
- Downstream distros or even just users who want to build older versions of libgit2 are guaranteed to have this test fail

Furthermore, this test case is entirely unnecessary, as the functionality that was originally (see 776a6a8e5f) intended to be tested is well-covered by subsequent tests which specify a date instead of a "x ago" specification.
2022-07-06 14:34:06 -04:00
Edward Thomson
7678e4e574 Merge pull request #6273 from apnadkarni/describe-crash-fix
Bug #6272 - fix crash in git_describe_commit.
2022-04-18 17:10:54 -04:00
apnadkarni
350cea37ec Makes sense.
Co-authored-by: Edward Thomson <ethomson@github.com>
2022-04-14 07:40:43 +05:30
Ashok P. Nadkarni
f016709540 Bug #6272 - fix crash in git_describe_commit.
When the passed object fails to be peeled into a commit pointer,
the cleanup code still tries to free the (uninitialized) pointer.
2022-04-13 16:09:58 +05:30
Edward Thomson
465bbf88ea Merge pull request #6270 from libgit2/ethomson/v1.4.3
v1.4.3 release
v1.4.3
2022-04-12 16:17:07 -04:00
Edward Thomson
0e5eff4d7b meta: changelog for v1.4.3 2022-04-12 15:42:08 -04:00
Edward Thomson
a63532aafd meta: update version numbers for v1.4.3 2022-04-12 15:29:28 -04:00
Edward Thomson
ff85adf0d7 Merge pull request #6269 from libgit2/ethomson/14_backports
Backports to v1.4
2022-04-12 15:29:11 -04:00
Edward Thomson
8d9842993c Update src/libgit2/diff_print.c 2022-04-12 14:18:03 -04:00
Iliyas Jorio
9d6b6c5d0a diff_delta_format_path: handle null filename
This fixes a crash in test cases
test_diff_parse__new_file_with_space_and_regenerate_patch
and
test_diff_parse__delete_file_with_space_and_regenerate_patch
2022-04-12 14:17:56 -04:00
Iliyas Jorio
8e29fa38c0 test: add test that regenerates patches with spaces in filename
This currently crashes, proposed fix in subsequent commit.
2022-04-12 14:17:48 -04:00
lhchavez
c93609120a [midx] Fix an undefined behavior (left-shift signed overflow)
There was a missing check to ensure that the `off64_t` (which is a
signed value) didn't overflow when parsing it from the midx file. This
shouldn't have huge repercusions since the parsed value is immediately
validated afterwards, but then again, there is no such thing as "benign"
undefined behavior.

This change makes all the bitwise arithmetic happen with unsigned types
and is only casted to `off64_t` until the very end.

Thanks to Taotao Gu for finding and reporting this!
2022-04-12 14:17:24 -04:00
Edward Thomson
99336fe3dd fetch: support OID refspec without dst
Support the ability to create a refspec that is a single object ID
without a destination.
2022-04-12 14:17:00 -04:00