test_dashboards.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. """Checks for the importable Grafana dashboards in dashboards/.
  2. The dashboards are shared, so they must carry no real endpoint. These tests
  3. keep that true: every data source is a template variable (no literal uid or
  4. data source name anywhere in the model), no query holds a URL, no address
  5. outside the documentation ranges (IPv4 or IPv6) appears, no host:port string
  6. or bare host name appears, and every dashboard has the `site` and `instance`
  7. variables. The rules live in `problems()` and `cross_problems()`; a hostile
  8. fixture per rule proves each one fails when it should (a guard that never
  9. fails guards nothing).
  10. What this proves and what it does not: the checks are structural and offline.
  11. They cannot prove a file imports into Grafana (no Grafana runs here), that a
  12. query is valid PromQL or Lucene, or that it returns data. `schemaVersion` is
  13. only a floor that says "not an ancient export"; the panel type allowlist and
  14. the gridPos, refId and query checks catch common breakage, nothing more.
  15. """
  16. import copy
  17. import ipaddress
  18. import json
  19. import re
  20. from pathlib import Path
  21. import pytest
  22. DASHBOARDS = Path(__file__).resolve().parent.parent / "dashboards"
  23. EXPECTED_UIDS = {"cah-sites-overview", "cah-droplet-health", "cah-wazuh-agents"}
  24. DOC_RANGES = [ipaddress.ip_network(n) for n in ("192.0.2.0/24", "198.51.100.0/24", "203.0.113.0/24")]
  25. DOC_V6 = ipaddress.ip_network("2001:db8::/32")
  26. IPV4 = re.compile(r"(?<![\d.])(?:\d{1,3}\.){3}\d{1,3}(?![\d.])")
  27. DS_VAR = re.compile(r"^\$\{DS_[A-Z0-9_]+\}$")
  28. URL = re.compile(r"[a-zA-Z][a-zA-Z0-9+.-]*://")
  29. MIN_SCHEMA = 41 # a structural floor for Grafana 12.x exports, not proof of importability
  30. # Panel types the dashboards use. A type outside this list is a typo or an
  31. # unreviewed plugin (a plugin panel would also fail an import without it).
  32. PANEL_TYPES = {"row", "stat", "gauge", "table", "timeseries", "state-timeline", "piechart", "bargauge", "text"}
  33. # Variables a query may use to scope itself. `instance` is itself filtered by
  34. # site; `monitored_agent` is the Wazuh monitoring index's own agent list.
  35. SCOPE_VARS = ("site", "instance", "monitored_agent")
  36. _SCOPE_ALT = "|".join(SCOPE_VARS)
  37. SITE_REF = re.compile(rf"\$(?:{_SCOPE_ALT})\b|\$\{{(?:{_SCOPE_ALT})[:}}]")
  38. # Names that may appear in text: documentation hosts and loopback.
  39. ALLOWED_HOST = re.compile(r"(?:^|\.)(?:example\.(?:com|net|org)|localhost)$", re.IGNORECASE)
  40. # A bare host name: dotted labels ending in a TLD a real host would use.
  41. # Dotted field names (agent.name, rule.groups, syscheck.path) are not hosts.
  42. TLDS = "com|net|org|io|co|uk|dev|app|cloud|local|lan|internal|home|corp|intranet|ca|us|de|eu|info|biz|xyz|ai|me|tv"
  43. HOSTNAME = re.compile(rf"(?<![\w.-])(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:{TLDS})(?![\w-])", re.IGNORECASE)
  44. HOST_PORT = re.compile(r"(?<![\w.-])(?=[\w.-]*[A-Za-z.])[\w.-]+:\d{2,5}(?![\w])")
  45. IPV6_CANDIDATE = re.compile(r"(?<![\w:])[0-9A-Fa-f:]{3,}(?![\w:])")
  46. BY_LIST = re.compile(r"\bby\s*\(([^)]*)\)")
  47. RATE_PLUS_RATE = re.compile(r"\)\s*\+\s*rate\(")
  48. def walk_panels(panels):
  49. for p in panels:
  50. yield p
  51. yield from walk_panels(p.get("panels") or [])
  52. def walk_strings(node, path="$"):
  53. if isinstance(node, dict):
  54. for k, v in node.items():
  55. yield from walk_strings(v, f"{path}.{k}")
  56. elif isinstance(node, list):
  57. for i, v in enumerate(node):
  58. yield from walk_strings(v, f"{path}[{i}]")
  59. elif isinstance(node, str):
  60. yield path, node
  61. def walk_keys(node, key, path="$"):
  62. """Yield (path, value) for every key with this name, at any depth."""
  63. if isinstance(node, dict):
  64. for k, v in node.items():
  65. if k == key:
  66. yield f"{path}.{k}", v
  67. yield from walk_keys(v, key, f"{path}.{k}")
  68. elif isinstance(node, list):
  69. for i, v in enumerate(node):
  70. yield from walk_keys(v, key, f"{path}[{i}]")
  71. def ds_error(ds):
  72. """None when ds is a {type, uid: ${DS_*}} reference, else why not."""
  73. if not isinstance(ds, dict) or not isinstance(ds.get("uid"), str) or not DS_VAR.match(ds["uid"]):
  74. return f"datasource is not a ${{DS_*}} variable: {ds!r}"
  75. return None
  76. def address_findings(path, s):
  77. out = []
  78. for m in IPV4.finditer(s):
  79. try:
  80. ip = ipaddress.ip_address(m.group(0))
  81. except ValueError:
  82. out.append(f"{path}: malformed address {m.group(0)}")
  83. continue
  84. if not any(ip in net for net in DOC_RANGES):
  85. out.append(f"{path}: address {ip} is outside the documentation ranges")
  86. for m in IPV6_CANDIDATE.finditer(s):
  87. if m.group(0).count(":") < 2:
  88. continue
  89. try:
  90. ip = ipaddress.ip_address(m.group(0))
  91. except ValueError:
  92. continue # a time such as 12:30:45 is not an address
  93. if ip.version == 6 and ip not in DOC_V6:
  94. out.append(f"{path}: IPv6 address {ip} is outside 2001:db8::/32")
  95. for m in HOST_PORT.finditer(s):
  96. host = m.group(0).rsplit(":", 1)[0]
  97. try:
  98. ipaddress.ip_address(host)
  99. continue # an address:port is judged by the address rules above
  100. except ValueError:
  101. pass
  102. if not ALLOWED_HOST.search(host):
  103. out.append(f"{path}: host:port string {m.group(0)!r}")
  104. for m in HOSTNAME.finditer(s):
  105. if not ALLOWED_HOST.search(m.group(0)):
  106. out.append(f"{path}: host name {m.group(0)!r} (only example.com, example.net, example.org and localhost are allowed)")
  107. return out
  108. def problems(d: dict) -> list[str]:
  109. out = []
  110. for key in ("uid", "title", "schemaVersion", "panels"):
  111. if key not in d:
  112. out.append(f"missing {key}")
  113. if out:
  114. return out
  115. if not isinstance(d["schemaVersion"], int) or d["schemaVersion"] < MIN_SCHEMA:
  116. out.append(f"schemaVersion {d['schemaVersion']!r} is below the floor {MIN_SCHEMA}")
  117. if "cah" not in d.get("tags", []):
  118. out.append("tag cah missing")
  119. if not d["panels"]:
  120. out.append("no panels")
  121. variables = d.get("templating", {}).get("list", [])
  122. ds_vars = {v["name"] for v in variables if v.get("type") == "datasource"}
  123. by_name = {v.get("name"): v for v in variables}
  124. for need in ("site", "instance"):
  125. if need not in by_name:
  126. out.append(f"variable {need} missing")
  127. if "site" in by_name and not by_name["site"].get("multi"):
  128. out.append("variable site is not multi-value")
  129. if not ds_vars:
  130. out.append("no datasource template variable")
  131. def ds_ok(ds, where):
  132. err = ds_error(ds)
  133. if err:
  134. out.append(f"{where}: {err}")
  135. elif ds["uid"][2:-1] not in ds_vars:
  136. out.append(f"{where}: datasource variable {ds['uid']} is not declared")
  137. for v in variables:
  138. if v.get("type") == "query":
  139. ds_ok(v.get("datasource"), f"variable {v.get('name')}")
  140. # A literal uid anywhere (including inside a panel option) is a leak.
  141. for path, value in walk_keys(d, "uid"):
  142. if path == "$.uid":
  143. continue
  144. if not (isinstance(value, str) and DS_VAR.match(value)):
  145. out.append(f"{path}: literal uid {value!r}")
  146. # So is a literal data source reference of any shape, at any depth.
  147. for path, value in walk_keys(d, "datasource"):
  148. if isinstance(value, dict):
  149. err = ds_error(value)
  150. if err:
  151. out.append(f"{path}: {err}")
  152. elif not (isinstance(value, str) and DS_VAR.match(value)):
  153. out.append(f"{path}: literal datasource {value!r}")
  154. # A `name` key only belongs to a template variable (a data source or host
  155. # name hides in one of these); elsewhere in the model it is a leak.
  156. var_paths = {f"$.templating.list[{i}].name" for i in range(len(variables))}
  157. for path, value in walk_keys(d, "name"):
  158. if path not in var_paths:
  159. out.append(f"{path}: literal name {value!r} outside a template variable")
  160. seen_ids = set()
  161. for p in walk_panels(d["panels"]):
  162. title = p.get("title", "?")
  163. if p.get("id") in seen_ids:
  164. out.append(f"{title}: duplicate panel id {p.get('id')}")
  165. seen_ids.add(p.get("id"))
  166. if p.get("type") not in PANEL_TYPES:
  167. out.append(f"{title}: panel type {p.get('type')!r} is not in the allowlist")
  168. gp = p.get("gridPos")
  169. if not (isinstance(gp, dict) and all(isinstance(gp.get(k), int) and gp[k] >= 0 for k in ("h", "w", "x", "y"))
  170. and gp["w"] >= 1 and gp["h"] >= 1 and gp["x"] + gp["w"] <= 24):
  171. out.append(f"{title}: gridPos missing or out of the 24 column grid: {gp!r}")
  172. if p.get("type") == "row":
  173. continue
  174. if len((p.get("description") or "").strip()) < 40:
  175. out.append(f"{title}: description missing or too short")
  176. ds_ok(p.get("datasource"), title)
  177. if not p.get("targets"):
  178. out.append(f"{title}: no targets")
  179. refs = [t.get("refId") for t in p.get("targets", [])]
  180. if len(set(refs)) != len(refs):
  181. out.append(f"{title}: duplicate refIds {refs}")
  182. for t in p.get("targets", []):
  183. where = f"{title} target {t.get('refId')}"
  184. if not t.get("refId"):
  185. out.append(f"{where}: no refId")
  186. ds_ok(t.get("datasource"), where)
  187. query = t.get("expr") or t.get("query") or ""
  188. if not query:
  189. out.append(f"{where}: empty query")
  190. elif not SITE_REF.search(query):
  191. out.append(f"{where}: query uses none of the scoping variables {SCOPE_VARS}")
  192. if RATE_PLUS_RATE.search(query):
  193. out.append(f"{where}: adds two rate() vectors directly; aggregate each side first (unmatched series vanish silently)")
  194. # Two scrape endpoints of one host share site and instance, so
  195. # anything per instance must also keep the endpoint label.
  196. legend = t.get("legendFormat") or ""
  197. if "{{instance}}" in legend and "{{endpoint}}" not in legend:
  198. out.append(f"{where}: legend names the instance but not the endpoint")
  199. for by in BY_LIST.findall(query):
  200. labels = [x.strip() for x in by.split(",")]
  201. if "instance" in labels and "endpoint" not in labels:
  202. out.append(f"{where}: aggregates by instance without endpoint")
  203. for path, s in walk_strings(d):
  204. if URL.search(s):
  205. out.append(f"{path}: contains a URL")
  206. out += address_findings(path, s)
  207. return out
  208. def cross_problems(dashboards: list[dict]) -> list[str]:
  209. out = []
  210. for key in ("uid", "title"):
  211. values = [d[key] for d in dashboards]
  212. out += [f"duplicate {key}: {v}" for v in sorted({v for v in values if values.count(v) > 1})]
  213. return out
  214. def load_all():
  215. return {p.name: json.loads(p.read_text()) for p in sorted(DASHBOARDS.glob("*.json"))}
  216. def queries(d, title):
  217. return [t.get("expr") or t.get("query") or "" for p in walk_panels(d["panels"]) if p.get("title") == title
  218. for t in p.get("targets", [])]
  219. # ---------------------------------------------------------------- the real files
  220. def test_the_expected_dashboards_exist():
  221. found = {d["uid"] for d in load_all().values()}
  222. assert found == EXPECTED_UIDS, f"dashboards/ holds {sorted(found)}"
  223. @pytest.mark.parametrize("name", sorted(p.name for p in DASHBOARDS.glob("*.json")) or ["<none collected>"])
  224. def test_each_dashboard_passes_every_rule(name):
  225. path = DASHBOARDS / name
  226. assert path.is_file(), "no dashboards collected"
  227. d = json.loads(path.read_text()) # also proves valid JSON
  228. assert problems(d) == []
  229. assert path.stem.replace("_", "-") == d["uid"], "file name should be the uid with underscores"
  230. def test_uids_and_titles_are_unique():
  231. assert cross_problems(list(load_all().values())) == []
  232. def test_files_use_no_em_or_en_dash():
  233. for name in load_all():
  234. text = (DASHBOARDS / name).read_text()
  235. assert "—" not in text and "–" not in text, f"{name}: em or en dash"
  236. def test_wazuh_panels_with_unverified_fields_say_so():
  237. d = load_all()["cah_wazuh_agents.json"]
  238. panels = [p for p in walk_panels(d["panels"]) if p["type"] != "row"]
  239. assert panels
  240. for p in panels:
  241. assert "UNVERIFIED" in p["description"], f"{p['title']}: field names not marked UNVERIFIED"
  242. def test_wazuh_status_panel_is_not_filtered_by_alert_derived_agents():
  243. """Quiet or never-reporting agents are only in the monitoring index, so that
  244. panel must not use the instance variable (built from alerts)."""
  245. d = load_all()["cah_wazuh_agents.json"]
  246. qs = queries(d, "Agent status and last keepalive")
  247. assert qs, "status panel not found"
  248. for q in qs:
  249. assert "monitored_agent" in q and "instance" not in q and "agent.labels.site" not in q
  250. var = {v["name"]: v for v in d["templating"]["list"]}["monitored_agent"]
  251. assert var["datasource"]["uid"] == "${DS_OPENSEARCH_MONITORING}"
  252. def test_sites_up_and_down_start_from_the_expected_target_inventory():
  253. d = load_all()["cah_sites_overview.json"]
  254. for title in ("Targets up per site", "Targets down per site"):
  255. qs = queries(d, title)
  256. assert qs and all("cah_expected_targets" in q for q in qs), f"{title}: does not use the inventory"
  257. assert "or on (site)" in queries(d, "Targets up per site")[0], "a fully down site needs an explicit 0"
  258. def test_relay_share_aggregates_each_direction_before_combining():
  259. d = load_all()["cah_sites_overview.json"]
  260. (q,) = queries(d, "Share of traffic through a relay")
  261. assert not RATE_PLUS_RATE.search(q)
  262. assert q.count("sum by (site) (rate(") == 4, "inbound and outbound, relay and total, each summed by site"
  263. assert q.count("or on (site)") >= 4, "each side needs explicit missing-series handling"
  264. def test_every_prometheus_panel_scopes_node_series_to_their_endpoint():
  265. d = load_all()["cah_droplet_health.json"]
  266. for p in walk_panels(d["panels"]):
  267. for t in p.get("targets", []):
  268. assert 'endpoint="node-exporter"' in t["expr"], f"{p['title']}: node series not scoped to the node exporter endpoint"
  269. # ---------------------------------------------------------------- the guard bites
  270. GOOD = {
  271. "uid": "cah-test",
  272. "title": "Test",
  273. "schemaVersion": 41,
  274. "tags": ["cah"],
  275. "templating": {"list": [
  276. {"type": "datasource", "name": "DS_PROMETHEUS", "query": "prometheus"},
  277. {"type": "query", "name": "site", "multi": True, "datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}},
  278. {"type": "query", "name": "instance", "multi": True, "datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}},
  279. ]},
  280. "panels": [
  281. {"id": 1, "type": "row", "title": "Row", "gridPos": {"h": 1, "w": 24, "x": 0, "y": 0}, "panels": []},
  282. {"id": 2, "type": "stat", "title": "Up", "description": "Shows how many targets answered the last scrape, per site.",
  283. "gridPos": {"h": 8, "w": 12, "x": 0, "y": 1},
  284. "datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
  285. "targets": [{"refId": "A", "expr": 'sum by (site, instance, endpoint) (up{site=~"$site"})',
  286. "legendFormat": "{{site}} / {{instance}} / {{endpoint}}",
  287. "datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}}]},
  288. ],
  289. }
  290. def mutated(fn):
  291. d = copy.deepcopy(GOOD)
  292. fn(d)
  293. return d
  294. def panel(d):
  295. return d["panels"][1]
  296. def with_option(d, key, value):
  297. panel(d).setdefault("options", {})[key] = value
  298. HOSTILE = {
  299. "literal panel datasource uid": (lambda d: panel(d)["datasource"].update(uid="abc123XYZ"), "not a ${DS_*}"),
  300. "literal target datasource uid": (lambda d: panel(d)["targets"][0]["datasource"].update(uid="abc123XYZ"), "not a ${DS_*}"),
  301. "undeclared datasource variable": (lambda d: panel(d)["datasource"].update(uid="${DS_OTHER}"), "not declared"),
  302. "datasource missing": (lambda d: panel(d).pop("datasource"), "not a ${DS_*}"),
  303. "literal uid hidden in an option": (lambda d: with_option(d, "x", {"uid": "P1234567"}), "literal uid"),
  304. "literal datasource name string in an option": (lambda d: with_option(d, "datasource", "Prometheus-Main"), "literal datasource"),
  305. "literal datasource object nested in an override": (
  306. lambda d: panel(d).update(fieldConfig={"overrides": [{"properties": [{"id": "x", "value": {"datasource": {"type": "prometheus", "uid": "zzz"}}}]}]}),
  307. "not a ${DS_*}"),
  308. "literal name hidden in an option": (lambda d: with_option(d, "source", {"name": "siem-prod"}), "literal name"),
  309. "url in a query": (lambda d: panel(d)["targets"][0].update(expr='up{site=~"$site"} # http://prom.example.net:9090'), "URL"),
  310. "url in a description": (lambda d: panel(d).update(description="See https://grafana.example.net/d/abc for the live one."), "URL"),
  311. "real public address": (lambda d: panel(d).update(description="Shows the target at 8.8.8.8 that answered the last scrape."), "outside the documentation"),
  312. "real private address": (lambda d: panel(d)["targets"][0].update(expr='up{site=~"$site", instance="10.0.0.5"}'), "outside the documentation"),
  313. "address in a variable": (lambda d: d["templating"]["list"][1].update(query="label_values(up{instance=\"172.16.4.9\"}, site)"), "outside the documentation"),
  314. "real ipv6 address": (lambda d: panel(d).update(description="Shows the target at 2001:4860:4860::8888 that answered the last scrape."), "IPv6"),
  315. "ipv6 loopback": (lambda d: panel(d).update(description="Shows the target at ::1 that answered the last scrape, per site."), "IPv6"),
  316. "host:port with a name": (lambda d: panel(d)["targets"][0].update(expr='up{site=~"$site", instance="grafana-prod:3000"}'), "host:port"),
  317. "host:port with a real host": (lambda d: panel(d).update(description="Scrape of prom01.mylab.net:9090 answered the last scrape, per site."), "host"),
  318. "bare host name": (lambda d: panel(d).update(description="Shows how siem.mylab.net answered the last scrape, per site and instance."), "host name"),
  319. "bare internal host name": (lambda d: panel(d).update(description="Shows how nas01.home answered the last scrape, per site and instance."), "host name"),
  320. "site variable missing": (lambda d: d["templating"]["list"].pop(1), "variable site missing"),
  321. "instance variable missing": (lambda d: d["templating"]["list"].pop(2), "variable instance missing"),
  322. "site variable single-value": (lambda d: d["templating"]["list"][1].update(multi=False), "not multi-value"),
  323. "query ignores scoping variables": (lambda d: panel(d)["targets"][0].update(expr="up"), "none of the scoping variables"),
  324. "description missing": (lambda d: panel(d).pop("description"), "description missing"),
  325. "duplicate panel id": (lambda d: panel(d).update(id=1), "duplicate panel id"),
  326. "old schema": (lambda d: d.update(schemaVersion=30), "schemaVersion"),
  327. "cah tag missing": (lambda d: d.update(tags=[]), "tag cah missing"),
  328. "no panels": (lambda d: d.update(panels=[]), "no panels"),
  329. "title missing": (lambda d: d.pop("title"), "missing title"),
  330. "panel type outside the allowlist": (lambda d: panel(d).update(type="vendor-fancy-panel"), "allowlist"),
  331. "gridPos missing": (lambda d: panel(d).pop("gridPos"), "gridPos"),
  332. "gridPos off the grid": (lambda d: panel(d)["gridPos"].update(x=20, w=12), "gridPos"),
  333. "target without refId": (lambda d: panel(d)["targets"][0].pop("refId"), "no refId"),
  334. "target without a query": (lambda d: panel(d)["targets"][0].pop("expr"), "empty query"),
  335. "duplicate refIds in a panel": (lambda d: panel(d)["targets"].append(copy.deepcopy(panel(d)["targets"][0])), "duplicate refIds"),
  336. "two rates added before aggregating": (
  337. lambda d: panel(d)["targets"][0].update(expr='sum by (site) (rate(a{site=~"$site"}[5m]) + rate(b{site=~"$site"}[5m]))'),
  338. "adds two rate()"),
  339. "legend names the instance without the endpoint": (lambda d: panel(d)["targets"][0].update(legendFormat="{{site}} / {{instance}}"), "not the endpoint"),
  340. "aggregation by instance drops the endpoint": (
  341. lambda d: panel(d)["targets"][0].update(expr='sum by (site, instance) (up{site=~"$site"})'), "without endpoint"),
  342. }
  343. def test_the_good_fixture_passes():
  344. assert problems(GOOD) == []
  345. def test_documentation_values_are_allowed():
  346. d = mutated(lambda d: panel(d).update(
  347. description="Example target 192.0.2.21:9100 in site-tor1; also 198.51.100.7, 203.0.113.9, 2001:db8::21 and "
  348. "prom.example.com or grafana.example.net or localhost, at 12:30:45 on a quiet day."))
  349. assert problems(d) == []
  350. def test_dotted_field_names_are_not_host_names():
  351. d = mutated(lambda d: panel(d).update(
  352. description="Filters on agent.labels.site, rule.groups, syscheck.path and agent.name, which are field names."))
  353. assert problems(d) == []
  354. @pytest.mark.parametrize("case", sorted(HOSTILE))
  355. def test_each_rule_bites(case):
  356. mutate, expect = HOSTILE[case]
  357. found = problems(mutated(mutate))
  358. assert any(expect in f for f in found), f"{case}: expected a problem containing {expect!r}, got {found}"
  359. def test_duplicate_uid_and_title_are_caught():
  360. a, b = copy.deepcopy(GOOD), copy.deepcopy(GOOD)
  361. found = cross_problems([a, b])
  362. assert "duplicate uid: cah-test" in found and "duplicate title: Test" in found
  363. b["uid"], b["title"] = "cah-other", "Other"
  364. assert cross_problems([a, b]) == []