A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Code scanning: fix the CodeQL issues #1582 #1584 #1585 (#1594)
Eyal Golan0d1f2ffba13e
diff --git a/scripts/oss/tests/test_readme.py b/scripts/oss/tests/test_readme.pyindex 74f28c1e1..8cabbd241 100644--- a/scripts/oss/tests/test_readme.py+++ b/scripts/oss/tests/test_readme.py@@ -1,5 +1,6 @@import refrom pathlib import Path+from urllib.parse import urlparseROOT = Path(__file__).resolve().parents[3]CONCEPT = "docs/images/hero-concept-1936.jpg"@@ -14,7 +15,7 @@ def read(rel: str) -> str:def images(text: str) -> list[str]:return [a or b for a, b in re.findall(r'<img src="([^"]+)"|!\[[^\]]*\]\(([^)]+)\)', text)- if not (a or b).startswith("https://img.shields.io")]+ if urlparse(a or b).hostname != "img.shields.io"]def section(text: str, heading: str) -> str:diff --git a/site/scripts/check-site.mjs b/site/scripts/check-site.mjsindex 23ada6374..29ff57812 100644--- a/site/scripts/check-site.mjs+++ b/site/scripts/check-site.mjs@@ -32,6 +32,7 @@ import { imageRules } from './people-in-images.mjs';const dist = path.resolve(process.argv[2] ?? 'dist');const problems = [];const fail = (file, msg) => problems.push(`${path.relative(dist, file)}: ${msg}`);+const reEscape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');function walk(dir) {return fs.readdirSync(dir, { withFileTypes: true }).flatMap((d) => {@@ -210,7 +211,7 @@ for (const z of [shotsZip, artZip]) {}for (const lang of ['en', 'he']) {const page = path.join(dist, lang, 'press', 'index.html');- if (!fs.existsSync(page) || !new RegExp(`href="[^"]*/downloads/${z.zip.replace(/\./g, '\\.')}"`).test(fs.readFileSync(page, 'utf8'))) {+ if (!fs.existsSync(page) || !new RegExp(`href="[^"]*/downloads/${reEscape(z.zip)}"`).test(fs.readFileSync(page, 'utf8'))) {problems.push(`${lang}/press/index.html: no link to downloads/${z.zip}`);}}@@ -222,7 +223,7 @@ if (!fs.existsSync(logoBuilt) || !fs.readFileSync(logoBuilt).equals(fs.readFileS}for (const lang of ['en', 'he']) {const page = path.join(dist, lang, 'press', 'index.html');- if (!fs.existsSync(page) || !new RegExp(`href="[^"]*/downloads/${LOGO.name.replace(/\./g, '\\.')}"`).test(fs.readFileSync(page, 'utf8'))) {+ if (!fs.existsSync(page) || !new RegExp(`href="[^"]*/downloads/${reEscape(LOGO.name)}"`).test(fs.readFileSync(page, 'utf8'))) {problems.push(`${lang}/press/index.html: no link to downloads/${LOGO.name}`);}}diff --git a/tools/tests/test_armistice.py b/tools/tests/test_armistice.pyindex 57c3e7caa..fbebfe2f0 100644--- a/tools/tests/test_armistice.py+++ b/tools/tests/test_armistice.py@@ -5,6 +5,7 @@ import jsonimport mathimport refrom pathlib import Path+from urllib.parse import urlparseimport numpy as npimport pytest@@ -124,7 +125,8 @@ def test_the_jordan_georeference_is_measured_not_assumed():def test_the_commons_copy_without_provenance_is_never_a_source():for f in SOURCE["features"]:- assert not any("commons.wikimedia.org" in s and "Green_Line" in s for s in f["properties"]["sources"])+ assert not any(urlparse(s).hostname == "commons.wikimedia.org" and "Green_Line" in s+ for s in f["properties"]["sources"])assert "not used" in " ".join(ad.JORDAN_SEARCH)diff --git a/tools/tests/test_control.py b/tools/tests/test_control.pyindex 3366f09a9..966c5d517 100644--- a/tools/tests/test_control.py+++ b/tools/tests/test_control.py@@ -147,12 +147,12 @@ def test_each_area_cites_the_source_it_comes_from_with_that_sources_accuracy():continue # tested in test_the_south_is_uncoloured_in_the_opening_period_but_its_settlementsif (p.get("snapshot") or "").startswith("arm_") or p.get("neutral_kind") in ("dmz", "not_sourced"):assert "armistice_lines_1949.geojson" in p["sources"], p["id"]- assert any("treaties.un.org" in s for s in p["sources"]), p["id"]+ assert any(host(s) == "treaties.un.org" for s in p["sources"]), p["id"]assert "ISA 6158/1: a 1:250,000" not in p["accuracy"], p["id"]else:assert p["sources"][0] == isa and "1-2 km" in p["accuracy"], p["id"]if p.get("neutral_kind") == "contested":- assert any("wikipedia.org" in s for s in p["sources"]), p["id"]+ assert any(host(s) == "wikipedia.org" or host(s).endswith(".wikipedia.org") for s in p["sources"]), p["id"]arm = [f["properties"] for f in SOURCE["features"] if (f["properties"].get("snapshot") or "").startswith("arm_")]for p in arm: # D-A ruling 2: low accuracy only where the Jordan line bounds the areajordan_in = p["snapshot"] >= "arm_1949-04-03"diff --git a/tools/tests/test_webgl_stale_page.py b/tools/tests/test_webgl_stale_page.pyindex 9cc0cf7df..99be558e8 100644--- a/tools/tests/test_webgl_stale_page.py+++ b/tools/tests/test_webgl_stale_page.py@@ -62,7 +62,7 @@ def test_the_packager_still_finds_every_file_of_a_rendered_page(tmp_path):def run_use_current_page(page_html: str, current_html: str) -> dict:"""Runs the page's own script (up to its fetch) in node, feeds useCurrentPage the current copy, and returns thenames the page would then load."""- script = re.search(r"<script>(.*)</script>", page_html, re.S).group(1).split("fetch(location.href")[0]+ script = re.search(r"<script>(.*)</script>", page_html, re.S | re.I).group(1).split("fetch(location.href")[0]driver = (script + "\nuseCurrentPage(" + json.dumps(current_html) + ");\n""console.log(JSON.stringify({loaderUrl: loaderUrl, config: config}));\n")out = subprocess.run(["node", "-e", driver], capture_output=True, text=True, check=True).stdout