diff options
author | David Kalnischkies <david@kalnischkies.de> | 2017-07-26 18:35:42 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2017-07-26 19:07:56 +0200 |
commit | f2f8e89f08cdf01c83a0b8ab053c65329d85ca90 (patch) | |
tree | 7ca9caf3e9dfa5caaad5dda836c0d95278a57204 /test/integration/test-apt-update-not-modified | |
parent | d7518dba50e2285c41c7002a1d86f876401fd9ea (diff) |
fail early in http if server answer is too small as well
Failing on too much data is good, but we can do better by checking for
exact filesizes as we know with hashsums how large a file should be, so
if we get a file which has a size we do not expect we can drop it
directly, regardless of if the file is larger or smaller than what we
expect which should catch most cases which would end up as hashsum
errors later now a lot sooner.
Diffstat (limited to 'test/integration/test-apt-update-not-modified')
-rwxr-xr-x | test/integration/test-apt-update-not-modified | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/test/integration/test-apt-update-not-modified b/test/integration/test-apt-update-not-modified index cb42e8954..c6dbb8d55 100755 --- a/test/integration/test-apt-update-not-modified +++ b/test/integration/test-apt-update-not-modified @@ -37,20 +37,14 @@ Reading package lists..." aptget update configarchitecture 'amd64' 'i386' # … but oh noes, hashsum mismatch! SIZE=$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') - mv aptarchive/dists/unstable/main/binary-amd64/Packages.gz aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig - cat > aptarchive/dists/unstable/main/binary-amd64/Packages <<EOF -Package: thisisbad -Architecture: amd64 -Version: 1 -EOF - compressfile aptarchive/dists/unstable/main/binary-amd64/Packages + breakfiles aptarchive/dists/unstable/main/binary-amd64/Packages.gz testfailureequal "Hit:1 $1 unstable InRelease Get:2 $1 unstable/main amd64 Packages [$SIZE B] Err:2 $1 unstable/main amd64 Packages Hash Sum mismatch Hashes of expected file: - - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig') [weak] - - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig' | cut -d' ' -f 1) + - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.bak') [weak] + - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.bak' | cut -d' ' -f 1) Hashes of received file: - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz' | cut -d' ' -f 1) - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') [weak] @@ -59,8 +53,8 @@ Err:2 $1 unstable/main amd64 Packages Reading package lists... E: Failed to fetch $1/dists/unstable/main/binary-amd64/Packages.gz Hash Sum mismatch Hashes of expected file: - - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig') [weak] - - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig' | cut -d' ' -f 1) + - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.bak') [weak] + - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.bak' | cut -d' ' -f 1) Hashes of received file: - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz' | cut -d' ' -f 1) - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') [weak] @@ -111,13 +105,7 @@ Reading package lists..." aptget update configarchitecture 'amd64' 'i386' # … but oh noes, hashsum mismatch! SIZE=$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') - mv aptarchive/dists/unstable/main/binary-amd64/Packages.gz aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig - cat > aptarchive/dists/unstable/main/binary-amd64/Packages <<EOF -Package: thisisbad -Architecture: amd64 -Version: 1 -EOF - compressfile aptarchive/dists/unstable/main/binary-amd64/Packages + breakfiles 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz' testfailureequal "Ign:1 $1 unstable InRelease 404 Not Found Hit:2 $1 unstable Release @@ -125,8 +113,8 @@ Get:4 $1 unstable/main amd64 Packages [$SIZE B] Err:4 $1 unstable/main amd64 Packages Hash Sum mismatch Hashes of expected file: - - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig') [weak] - - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig' | cut -d' ' -f 1) + - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.bak') [weak] + - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.bak' | cut -d' ' -f 1) Hashes of received file: - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz' | cut -d' ' -f 1) - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') [weak] @@ -135,8 +123,8 @@ Err:4 $1 unstable/main amd64 Packages Reading package lists... E: Failed to fetch $1/dists/unstable/main/binary-amd64/Packages.gz Hash Sum mismatch Hashes of expected file: - - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig') [weak] - - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig' | cut -d' ' -f 1) + - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.bak') [weak] + - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.bak' | cut -d' ' -f 1) Hashes of received file: - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz' | cut -d' ' -f 1) - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') [weak] |