Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: chrome/test/data/extensions/unpacker/bad_zip/bad_zip.sh

Issue 10868050: Remove "theme" in extension/app unpacker error messages, make those messages localizable, and add u… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Applied suggestions in patch set 2 comments and added paths in errors. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/bin/bash -e
2 #
3 # Purpose: Create a corrupt (invalid ZIP) version of a Chromium crx.
4 if test $# -ne 2; then
5 echo "Usage: bad_zip.sh <extension dir> <pem path>"
6 exit 1
7 fi
8 dir=$1
9 key=$2
10 name=$(basename "$dir")
11 crx="$name.crx"
12 pub="$name.pub"
13 sig="$name.sig"
14 zip="$name.zip"
15 trap 'rm -f "$pub" "$sig" "$zip"' EXIT
16 # zip up the crx dir
17 cwd=$(pwd -P)
18 (cd "$dir" && zip -qr -9 -X "$cwd/$zip" .)
19 # truncate the zip to 8K so it's invalid
20 dd if=$zip of=$zip+ bs=1024 count=8 2>/dev/null && mv $zip+ $zip
21 # signature
22 openssl sha1 -sha1 -binary -sign "$key" < "$zip" > "$sig"
23 # public key
24 openssl rsa -pubout -outform DER < "$key" > "$pub" 2>/dev/null
25 byte_swap () {
26 # Take "abcdefgh" and return it as "ghefcdab"
27 echo "${1:6:2}${1:4:2}${1:2:2}${1:0:2}"
28 }
29 crmagic_hex="4372 3234" # Cr24
30 version_hex="0200 0000" # 2
31 pub_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$pub" | awk '{print $5}')))
32 sig_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$sig" | awk '{print $5}')))
33 (
34 echo "$crmagic_hex $version_hex $pub_len_hex $sig_len_hex" | xxd -r -p
35 cat "$pub" "$sig" "$zip"
36 ) > "$crx"
37 echo "Wrote $crx with invalid ZIP"
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698