Skip to content

Commit f5f5e7f

Browse files
peffgitster
authored andcommitted
t0013: add a basic sha1 collision detection test
We don't actually have a Git-object collision, so the best we can do is to run one of the shattered PDFs through test-sha1. This should trigger the collision check and die. In a sense this isn't really checking anything that the upstream sha1collisiondetection project doesn't cover already. But it at least makes sure that our build correctly uses the library. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8325e43 commit f5f5e7f

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2236,6 +2236,7 @@ GIT-BUILD-OPTIONS: FORCE
22362236
@echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@+
22372237
@echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@+
22382238
@echo PAGER_ENV=\''$(subst ','\'',$(subst ','\'',$(PAGER_ENV)))'\' >>$@+
2239+
@echo DC_SHA1=\''$(subst ','\'',$(subst ','\'',$(DC_SHA1)))'\' >>$@+
22392240
ifdef TEST_OUTPUT_DIRECTORY
22402241
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
22412242
endif

t/t0013-sha1dc.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
test_description='test sha1 collision detection'
4+
. ./test-lib.sh
5+
TEST_DATA="$TEST_DIRECTORY/t0013"
6+
7+
if test -z "$DC_SHA1"
8+
then
9+
skip_all='skipping sha1 collision tests, DC_SHA1 not set'
10+
test_done
11+
fi
12+
13+
test_expect_success 'test-sha1 detects shattered pdf' '
14+
test_must_fail test-sha1 <"$TEST_DATA/shattered-1.pdf" 2>err &&
15+
test_i18ngrep collision err &&
16+
grep 38762cf7f55934b34d179ae6a4c80cadccbb7f0a err
17+
'
18+
19+
test_done

t/t0013/shattered-1.pdf

413 KB
Binary file not shown.

0 commit comments

Comments
 (0)