From 46a47b96e91dd08b56533cd4798bf04b22331c43 Mon Sep 17 00:00:00 2001 From: Martin Kainzbauer Date: Thu, 2 Nov 2023 22:17:31 +0100 Subject: [PATCH] chore:improved iframe scan --- config/chains.json | 39 +++++++++++++++++++++----------------- config/explorers.json | 39 +++++++++++++++++++++----------------- scripts/getExplorerInfo.js | 36 ++++++++++++++++++++--------------- 3 files changed, 65 insertions(+), 49 deletions(-) diff --git a/config/chains.json b/config/chains.json index 2530742aa..3369860d6 100644 --- a/config/chains.json +++ b/config/chains.json @@ -1274,8 +1274,7 @@ { "name": "alphscan", "url": "https://explorer.alph.network", - "standard": "EIP3091", - "iframe": true + "standard": "EIP3091" } ], "shortName": "alph" @@ -1543,7 +1542,8 @@ { "name": "a8scan-testnet", "url": "https://testnet.a8scan.io", - "standard": "EIP3091" + "standard": "EIP3091", + "iframe": true } ], "shortName": "a8" @@ -2547,8 +2547,7 @@ { "name": "Bitrock Testnet Explorer", "url": "https://testnetscan.bit-rock.io", - "standard": "EIP3091", - "iframe": true + "standard": "EIP3091" } ], "shortName": "tbitrock" @@ -3519,8 +3518,7 @@ { "name": "scoville-explorer", "url": "https://scoville-explorer.chiliz.com", - "standard": "none", - "iframe": true + "standard": "none" } ], "shortName": "chz" @@ -5067,8 +5065,7 @@ "name": "blockscout", "url": "https://blockexplorer.electroneum.com", "icon": "electroneum", - "standard": "EIP3091", - "iframe": true + "standard": "EIP3091" } ], "shortName": "etn-mainnet" @@ -9805,7 +9802,8 @@ { "name": "modescout", "url": "https://sepolia.explorer.mode.network", - "standard": "none" + "standard": "none", + "iframe": true } ], "shortName": "modesep" @@ -11266,7 +11264,8 @@ "name": "orderlyscout", "url": "https://explorer.orderly.network", "icon": "blockscout", - "standard": "EIP3091" + "standard": "EIP3091", + "iframe": true } ], "shortName": "orderly" @@ -11288,7 +11287,8 @@ "name": "basescout", "url": "https://explorerl2new-orderly-l2-4460-sepolia-8tc3sd7dvy.t.conduit.xyz", "icon": "blockscout", - "standard": "EIP3091" + "standard": "EIP3091", + "iframe": true } ], "shortName": "orderlyl2" @@ -11697,7 +11697,8 @@ "name": "blockscout", "url": "https://explorer.publicgoods.network", "icon": "blockscout", - "standard": "EIP3091" + "standard": "EIP3091", + "iframe": true } ], "shortName": "PGN" @@ -13931,7 +13932,8 @@ "name": "blockscout", "url": "https://explorer.sepolia.publicgoods.network", "icon": "blockscout", - "standard": "EIP3091" + "standard": "EIP3091", + "iframe": true } ], "shortName": "sepPGN" @@ -14789,7 +14791,8 @@ { "name": "Synapse Chain Sepolia", "url": "https://sepolia.synapsescan.com", - "standard": "EIP3091" + "standard": "EIP3091", + "iframe": true } ], "shortName": "synapse-sepolia" @@ -16963,7 +16966,8 @@ { "name": "Zora Network Explorer", "url": "https://explorer.zora.energy", - "standard": "EIP3091" + "standard": "EIP3091", + "iframe": true } ], "shortName": "zora" @@ -16984,7 +16988,8 @@ { "name": "Zora Sepolia Testnet Network Explorer", "url": "https://sepolia.explorer.zora.energy", - "standard": "EIP3091" + "standard": "EIP3091", + "iframe": true } ], "shortName": "zsep" diff --git a/config/explorers.json b/config/explorers.json index b2aedeb41..96e11a980 100644 --- a/config/explorers.json +++ b/config/explorers.json @@ -1080,7 +1080,8 @@ "name": "orderlyscout", "url": "https://explorer.orderly.network", "icon": "blockscout", - "standard": "EIP3091" + "standard": "EIP3091", + "iframe": true } ], "295": [ @@ -1360,14 +1361,16 @@ "name": "blockscout", "url": "https://explorer.publicgoods.network", "icon": "blockscout", - "standard": "EIP3091" + "standard": "EIP3091", + "iframe": true } ], "444": [ { "name": "Synapse Chain Sepolia", "url": "https://sepolia.synapsescan.com", - "standard": "EIP3091" + "standard": "EIP3091", + "iframe": true } ], "456": [ @@ -1686,7 +1689,8 @@ { "name": "modescout", "url": "https://sepolia.explorer.mode.network", - "standard": "none" + "standard": "none", + "iframe": true } ], "927": [ @@ -3012,7 +3016,8 @@ "name": "basescout", "url": "https://explorerl2new-orderly-l2-4460-sepolia-8tc3sd7dvy.t.conduit.xyz", "icon": "blockscout", - "standard": "EIP3091" + "standard": "EIP3091", + "iframe": true } ], "4689": [ @@ -3425,8 +3430,7 @@ { "name": "Bitrock Testnet Explorer", "url": "https://testnetscan.bit-rock.io", - "standard": "EIP3091", - "iframe": true + "standard": "EIP3091" } ], "7777": [ @@ -3518,8 +3522,7 @@ { "name": "alphscan", "url": "https://explorer.alph.network", - "standard": "EIP3091", - "iframe": true + "standard": "EIP3091" } ], "8848": [ @@ -4530,8 +4533,7 @@ "name": "blockscout", "url": "https://blockexplorer.electroneum.com", "icon": "electroneum", - "standard": "EIP3091", - "iframe": true + "standard": "EIP3091" } ], "54211": [ @@ -4602,7 +4604,8 @@ "name": "blockscout", "url": "https://explorer.sepolia.publicgoods.network", "icon": "blockscout", - "standard": "EIP3091" + "standard": "EIP3091", + "iframe": true } ], "59140": [ @@ -4892,8 +4895,7 @@ { "name": "scoville-explorer", "url": "https://scoville-explorer.chiliz.com", - "standard": "none", - "iframe": true + "standard": "none" } ], "88888": [ @@ -5661,7 +5663,8 @@ { "name": "Zora Network Explorer", "url": "https://explorer.zora.energy", - "standard": "EIP3091" + "standard": "EIP3091", + "iframe": true } ], "8007736": [ @@ -5918,7 +5921,8 @@ { "name": "Zora Sepolia Testnet Network Explorer", "url": "https://sepolia.explorer.zora.energy", - "standard": "EIP3091" + "standard": "EIP3091", + "iframe": true } ], "1146703430": [ @@ -6051,7 +6055,8 @@ { "name": "a8scan-testnet", "url": "https://testnet.a8scan.io", - "standard": "EIP3091" + "standard": "EIP3091", + "iframe": true } ], "4216137055": [ diff --git a/scripts/getExplorerInfo.js b/scripts/getExplorerInfo.js index 99e8b1117..f6bd591e6 100644 --- a/scripts/getExplorerInfo.js +++ b/scripts/getExplorerInfo.js @@ -3,9 +3,9 @@ const path = require("path"); const config = require("../config/app"); const fetch = require("node-fetch"); -const BATCH_SIZE = 35; -const BATCH_TIMEOUT = 8; -const CALL_TIMEOUT = 16; +const BATCH_SIZE = 50; +const BATCH_TIMEOUT = 6; +const CALL_TIMEOUT = 14; const main = async () => { const startTime = Date.now(); @@ -31,8 +31,6 @@ const main = async () => { chain.rpc && chain.rpc.length > 0 ) { - if (chain.title && chain.title.length < 50) chain.name = chain.title; - rawChains.push(chain); } } catch (e) {} @@ -77,22 +75,30 @@ const main = async () => { promises.push( fetch(explorer.url, { + method: "HEAD", timeout: CALL_TIMEOUT * 1000, }) .then((res) => { - if ( - !res.headers.raw()["x-frame-options"] && - !res.headers.raw()["X-Frame-Options"] - ) { + const headers = res.headers.raw(); + let allowsIframes = true; + + if (headers["x-frame-options"] || headers["X-Frame-Options"]) { + allowsIframes = false; + } + const csp = + headers["content-security-policy"] || + headers["Content-Security-Policy"]; + if (csp && csp.length) { + csp.forEach((p) => { + if (p.includes("frame-ancestors")) allowsIframes = false; + }); + } + + if (allowsIframes === true) { chains[i].explorers[j].iframe = true; } - console.log( - "iframe:", - !!chains[i].explorers[j].iframe, - chain.name, - explorer.url - ); + console.log("iframe:", allowsIframes, chain.name, explorer.url); }) .catch(() => { chains[i].explorers[j].failed = true;