Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4059af827 | ||
|
|
8c08b3d467 |
@@ -347,12 +347,6 @@ are outside `make check`. Neither opens the popup from the toolbar button: both
|
||||
load its page in an ordinary tab, so what the toolbar popup itself adds, its
|
||||
size and its closing when it loses focus, is covered by neither.
|
||||
|
||||
Each run builds its image under a tag of its own, `autistmask-e2e-chrome:` or
|
||||
`autistmask-e2e-firefox:` followed by twelve random hex digits, and removes that
|
||||
image when it exits, an interrupt included. Two clones can therefore run the
|
||||
same suite at once without one build taking the other's image away, and no run
|
||||
leaves an image behind.
|
||||
|
||||
### Chrome (`make test-e2e`)
|
||||
|
||||
`make test-e2e` builds `dist/chrome/` and drives the **real popup in a real
|
||||
@@ -2669,7 +2663,8 @@ plaintext list of anyone's domain names.
|
||||
When a dApp on a blocklisted domain requests a wallet connection, transaction
|
||||
approval, or signature, the approval popup displays a prominent red warning
|
||||
banner alerting the user. The domain checker matches exact hostnames and all
|
||||
parent domains (subdomain matching).
|
||||
parent domains (subdomain matching), and checks a hostname written with a
|
||||
trailing dot (`name.`) as `name`.
|
||||
|
||||
#### Transaction Decoding
|
||||
|
||||
|
||||
+15
-13
@@ -22,18 +22,13 @@ set -eu
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
|
||||
ROOT="$(cd "$SCRIPT_DIR/.." && pwd -P)"
|
||||
|
||||
# Each run builds, runs and then removes an image under a tag of its own.
|
||||
# Under one tag shared by every run, a second clone's build moves the tag
|
||||
# off this run's image, and the image store can then delete that untagged
|
||||
# image before or while this run uses it. The tag is random rather than
|
||||
# $$ because CI jobs share one docker daemon, but each job's container
|
||||
# numbers its processes from scratch.
|
||||
IMAGE="$("$SCRIPT_DIR/projectname")-e2e-chrome:$(od -An -N6 -tx1 /dev/urandom | tr -d ' \n')"
|
||||
IMAGE="$("$SCRIPT_DIR/projectname")-e2e-chrome"
|
||||
|
||||
IIDFILE=""
|
||||
|
||||
cleanup() {
|
||||
# No image to remove when the build failed or was interrupted.
|
||||
if docker image inspect "$IMAGE" >/dev/null 2>&1; then
|
||||
docker image rm "$IMAGE" >/dev/null
|
||||
if [ -n "$IIDFILE" ]; then
|
||||
rm -f "$IIDFILE"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -45,15 +40,22 @@ main() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IIDFILE="$(mktemp)"
|
||||
trap cleanup EXIT
|
||||
trap 'cleanup; exit 130' INT TERM
|
||||
|
||||
echo "Building the Chrome e2e image (extension included)..."
|
||||
# --no-cache: the image build runs make build and its checks, and a
|
||||
# cached layer is a check that did not run.
|
||||
docker build --no-cache -t "$IMAGE" -f tests/e2e/Dockerfile .
|
||||
docker build --no-cache --iidfile "$IIDFILE" -t "$IMAGE" \
|
||||
-f tests/e2e/Dockerfile .
|
||||
|
||||
echo "Running e2e suite in the pinned Playwright container..."
|
||||
# The image is run by ID, not by tag: where two clones of this repo run
|
||||
# the suite at once, the other build can move the tag between this
|
||||
# build and this run, and the suite would then silently test the other
|
||||
# checkout.
|
||||
#
|
||||
# --ipc=host: Chromium's shared-memory needs more than the default
|
||||
# 64MB /dev/shm or renderers crash.
|
||||
# HOME=/tmp: the image's root home is not a reliable place for the
|
||||
@@ -77,7 +79,7 @@ main() {
|
||||
-e HOME=/tmp \
|
||||
-e PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1 \
|
||||
-e "E2E_TRACE_NETWORK=${E2E_TRACE_NETWORK:-0}" \
|
||||
"$IMAGE" \
|
||||
"$(cat "$IIDFILE")" \
|
||||
node tests/e2e/run.js
|
||||
|
||||
# Where chrome.storage.local lives, and what moves it: two unpacked loads
|
||||
@@ -93,7 +95,7 @@ main() {
|
||||
docker run --rm \
|
||||
--ipc=host \
|
||||
-e HOME=/tmp \
|
||||
"$IMAGE" \
|
||||
"$(cat "$IIDFILE")" \
|
||||
node tests/e2e/storagePartition.js
|
||||
}
|
||||
|
||||
|
||||
+15
-8
@@ -21,13 +21,13 @@ set -eu
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
|
||||
ROOT="$(cd "$SCRIPT_DIR/.." && pwd -P)"
|
||||
|
||||
# A tag of this run's own, as in script/test-e2e, which says why.
|
||||
IMAGE="$("$SCRIPT_DIR/projectname")-e2e-firefox:$(od -An -N6 -tx1 /dev/urandom | tr -d ' \n')"
|
||||
IMAGE="$("$SCRIPT_DIR/projectname")-e2e-firefox"
|
||||
|
||||
IIDFILE=""
|
||||
|
||||
cleanup() {
|
||||
# No image to remove when the build failed or was interrupted.
|
||||
if docker image inspect "$IMAGE" >/dev/null 2>&1; then
|
||||
docker image rm "$IMAGE" >/dev/null
|
||||
if [ -n "$IIDFILE" ]; then
|
||||
rm -f "$IIDFILE"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -39,15 +39,22 @@ main() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IIDFILE="$(mktemp)"
|
||||
trap cleanup EXIT
|
||||
trap 'cleanup; exit 130' INT TERM
|
||||
|
||||
echo "Building the pinned Firefox e2e image (extension included)..."
|
||||
# --no-cache: the image build runs make build and its checks, and a
|
||||
# cached layer is a check that did not run.
|
||||
docker build --no-cache -t "$IMAGE" -f tests/e2e/firefox/Dockerfile .
|
||||
docker build --no-cache --iidfile "$IIDFILE" -t "$IMAGE" \
|
||||
-f tests/e2e/firefox/Dockerfile .
|
||||
|
||||
echo "Running the Firefox e2e suite..."
|
||||
# The image is run by ID, not by tag: where two clones of this repo run
|
||||
# the suite at once, the other build can move the tag between this
|
||||
# build and this run, and the suite would then silently test the other
|
||||
# checkout.
|
||||
#
|
||||
# --shm-size=1g: Firefox needs more than the default 64MB /dev/shm.
|
||||
# --network none: the suite stubs nothing, so this is what keeps the
|
||||
# run offline and deterministic. The extension swallows its own
|
||||
@@ -65,7 +72,7 @@ main() {
|
||||
--shm-size=1g \
|
||||
--network none \
|
||||
-e HOME=/tmp \
|
||||
"$IMAGE" \
|
||||
"$(cat "$IIDFILE")" \
|
||||
node tests/e2e/firefox/run.js dist/firefox
|
||||
|
||||
# The install/uninstall/re-install property, against the packaged XPI
|
||||
@@ -78,7 +85,7 @@ main() {
|
||||
--shm-size=1g \
|
||||
--network none \
|
||||
-e HOME=/tmp \
|
||||
"$IMAGE" \
|
||||
"$(cat "$IIDFILE")" \
|
||||
node tests/e2e/firefox/reinstall.js
|
||||
}
|
||||
|
||||
|
||||
@@ -633,8 +633,9 @@ function isExtensionSender(sender) {
|
||||
// had refused.
|
||||
//
|
||||
// TX and sign approvals do not decide here. They stay pending across a
|
||||
// disconnect — the user can reopen the toolbar popup — and are rejected by the
|
||||
// windows.onRemoved listener below.
|
||||
// disconnect. When their window closes, the windows.onRemoved listener below
|
||||
// rejects them, unless an approved attempt is still running, in which case
|
||||
// that attempt answers the page.
|
||||
runtime.onConnect.addListener((port) => {
|
||||
if (port.name.startsWith("approval:")) {
|
||||
const id = port.name.split(":")[1];
|
||||
@@ -662,7 +663,9 @@ runtime.onConnect.addListener((port) => {
|
||||
const approval = pendingApprovals[id];
|
||||
if (approval) {
|
||||
if (approval.type === "tx" || approval.type === "sign") {
|
||||
// Keep pending — user can reopen the toolbar popup
|
||||
// When its window closes, windows.onRemoved rejects it,
|
||||
// unless an approved attempt is still running, in which
|
||||
// case that attempt answers the page.
|
||||
return;
|
||||
}
|
||||
settleApproval(id, { approved: false, remember: false });
|
||||
|
||||
@@ -110,11 +110,14 @@ function hashListed(hash) {
|
||||
* Generate hostname variants for subdomain matching.
|
||||
* "sub.evil.com" yields ["sub.evil.com", "evil.com"].
|
||||
*
|
||||
* A trailing dot is dropped: "evil.com." is the fully qualified spelling of
|
||||
* "evil.com", and the browser loads the same site from either.
|
||||
*
|
||||
* @param {string} hostname
|
||||
* @returns {string[]}
|
||||
*/
|
||||
function hostnameVariants(hostname) {
|
||||
const h = hostname.toLowerCase();
|
||||
const h = hostname.toLowerCase().replace(/\.$/, "");
|
||||
const variants = [h];
|
||||
const parts = h.split(".");
|
||||
// Parent domains: a.b.c.d -> b.c.d, c.d
|
||||
|
||||
@@ -89,6 +89,12 @@ describe("vendored blocklist", () => {
|
||||
expect(isPhishingDomain(LISTED[0].toUpperCase())).toBe(true);
|
||||
});
|
||||
|
||||
test("a hostname ending in a dot is the same host", () => {
|
||||
expect(isPhishingDomain(LISTED[1] + ".")).toBe(true);
|
||||
expect(isPhishingDomain("wallet." + LISTED[1] + ".")).toBe(true);
|
||||
expect(isPhishingDomain(CLEAN[0] + ".")).toBe(false);
|
||||
});
|
||||
|
||||
test("returns false for an empty or missing hostname", () => {
|
||||
expect(isPhishingDomain("")).toBe(false);
|
||||
expect(isPhishingDomain(null)).toBe(false);
|
||||
@@ -133,6 +139,13 @@ describe("hostnameVariants", () => {
|
||||
test("lowercases hostnames", () => {
|
||||
expect(hostnameVariants("Evil.COM")).toEqual(["evil.com"]);
|
||||
});
|
||||
|
||||
test("drops the trailing dot of a fully qualified hostname", () => {
|
||||
expect(hostnameVariants("sub.evil.com.")).toEqual([
|
||||
"sub.evil.com",
|
||||
"evil.com",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("domain hashing", () => {
|
||||
|
||||
Reference in New Issue
Block a user