Skip to content

Commit e05714e

Browse files
EricSesterhennX41JarLobsteadmon
authored andcommitted
fuzz: port fuzz-credential-from-url-gently from OSS-Fuzz
Git's fuzz tests are run continuously as part of OSS-Fuzz [1]. Several additional fuzz tests have been contributed directly to OSS-Fuzz; however, these tests are vulnerable to bitrot because they are not built during Git's CI runs, and thus breaking changes are much less likely to be noticed by Git contributors. Port one of these tests back to the Git project: fuzz-credential-from-url-gently This test was originally written by Eric Sesterhenn as part of a security audit of Git [2]. It was then contributed to the OSS-Fuzz repo in commit c58ac4492 (Git fuzzing: uncomment the existing and add new targets. (#11486), 2024-02-21) by Jaroslav Lobačevski. I (Josh Steadmon) have verified with both Eric and Jaroslav that they're OK with moving this test to the Git project. [1] https://github.com/google/oss-fuzz [2] https://ostif.org/wp-content/uploads/2023/01/X41-OSTIF-Gitlab-Git-Security-Audit-20230117-public.pdf Co-authored-by: Jaroslav Lobačevski <[email protected]> Co-authored-by: Josh Steadmon <[email protected]> Signed-off-by: Josh Steadmon <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4f71522 commit e05714e

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2373,6 +2373,7 @@ endif
23732373
FUZZ_OBJS += oss-fuzz/dummy-cmd-main.o
23742374
FUZZ_OBJS += oss-fuzz/fuzz-commit-graph.o
23752375
FUZZ_OBJS += oss-fuzz/fuzz-config.o
2376+
FUZZ_OBJS += oss-fuzz/fuzz-credential-from-url-gently.o
23762377
FUZZ_OBJS += oss-fuzz/fuzz-date.o
23772378
FUZZ_OBJS += oss-fuzz/fuzz-pack-headers.o
23782379
FUZZ_OBJS += oss-fuzz/fuzz-pack-idx.o

ci/run-build-and-minimal-fuzzers.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@ group "Build fuzzers" make \
1313
LIB_FUZZING_ENGINE="-fsanitize=fuzzer,address" \
1414
fuzz-all
1515

16-
for fuzzer in commit-graph config date pack-headers pack-idx ; do
16+
fuzzers="
17+
commit-graph \
18+
config \
19+
credential-from-url-gently \
20+
date \
21+
pack-headers \
22+
pack-idx \
23+
"
24+
25+
for fuzzer in $fuzzers ; do
1726
begin_group "fuzz-$fuzzer"
18-
./oss-fuzz/fuzz-$fuzzer -verbosity=0 -runs=1 || exit 1
27+
echo ./oss-fuzz/fuzz-$fuzzer -verbosity=0 -runs=1 || exit 1
1928
end_group "fuzz-$fuzzer"
2029
done

oss-fuzz/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
fuzz-commit-graph
22
fuzz-config
3+
fuzz-credential-from-url-gently
34
fuzz-date
45
fuzz-pack-headers
56
fuzz-pack-idx
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include "git-compat-util.h"
2+
#include <stddef.h>
3+
#include <stdlib.h>
4+
#include <stdint.h>
5+
#include <string.h>
6+
#include <stdio.h>
7+
#include "credential.h"
8+
9+
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
10+
11+
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
12+
{
13+
struct credential c;
14+
char *buf;
15+
16+
buf = malloc(size + 1);
17+
if (!buf)
18+
return 0;
19+
20+
memcpy(buf, data, size);
21+
buf[size] = 0;
22+
23+
// start fuzzing
24+
credential_init(&c);
25+
credential_from_url_gently(&c, buf, 1);
26+
27+
// cleanup
28+
credential_clear(&c);
29+
free(buf);
30+
31+
return 0;
32+
}

0 commit comments

Comments
 (0)