GPT-6.1 Sol · Heavy

feature-can-edit-category-host-relationships-for-embedding-discourse-cursor

Discourse · Ruby · M · 100–299 lines · 6 files

The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Haiku 5.5.

Gold bugs found
4 of 4
Comments published
8
Comments matching a bug
4
Comments not matching
4
Cost of this PR
$2.123

Published comments (8)

highsecuritydb/migrate/20150818190757_create_embeddable_hosts.rb:25

Unquoted host settings allow SQL injection during migration — An apostrophe in persisted `h` can break the SQL statement or inject SQL executed with migration privileges. Quote `h` with the database adapter or use a parameterized insert.

highbugapp/models/embeddable_host.rb:2

Host validation rejects valid top-level domains longer than five letters — The `host` validation rejects valid embedding domains such as `example.technology` and `example.museum`, which the previous hostname comparison supported. Remove the obsolete five-character top-level-domain limit.

highsecurityapp/models/embeddable_host.rb:14-17

Mixed-case URL hostnames are incorrectly rejected — Legitimate mixed-case URLs fail embedding authorization and topic retrieval because `URI.host` preserves case while `lower(host)` normalizes only the stored value. Compare against `host.downcase` and add mixed-case URL and configuration tests.

highbugdb/migrate/20150818190757_create_embeddable_hosts.rb:9-11

Empty embed category query result aborts the migration — An unset or stale `embed_category` produces no rows, so indexing the first result raises `NoMethodError` and aborts the migration before the `category_id` fallback. Read the row safely and fall back to the uncategorized category when no match exists.

highbugdb/migrate/20150818190757_create_embeddable_hosts.rb:24-25

Migrated embeddable hosts retain schemes and paths that prevent matching — Previously working scheme-prefixed hosts stop authorizing embedding because `EmbeddableHost.record_for_host` compares against `URI(url).host`, while these SQL inserts bypass model normalization. Strip the scheme and path from `h` consistently with the model before storing migrated entries.

highbugapp/models/embeddable_host.rb:14-17

Allowed hosts with ports never match request URLs — A saved `host` such as `example.com:8080` passes validation but never matches because `uri.host` excludes the port, causing embedding to be rejected. Either reject port-qualified entries or normalize and match them consistently.

mediumbugapp/assets/javascripts/admin/components/embeddable-host.js.es6:38

Saving Uncategorized clears the displayed host category — The server replaces a null chooser value with `uncategorized_category_id`, but `Category.findById(null)` clears the displayed category until reload. Resolve the category from the saved `host` object's returned `category_id` instead of `categoryId`.

mediumbugspec/models/topic_spec.rb:1401-1404

Host-absence test passes without exercising the expansion prerequisites — The test passes even if `expandable_first_post?` ignores host presence because `embed_truncate` and a topic embed are missing. Replace it with the intended no-host behavior, or enable those prerequisites if host absence should still prevent expansion.

Gold bugs found (4)

highThe migration reads execute(...)[0]['id'] for embed_category without checking for an empty result, so installs without that setting stored crash the migration instead of falling back to the uncategorized category.
mediumAfter saving a host, the component overwrites its category with findById(categoryId); when no category was chosen this is null even though the server saved the uncategorized category, so the row shows no category until reload.
highHosts saved with a port (allowed by the validation regex) are stored as host:port, but lookup compares only URI.host, so those configured hosts never match and embedding fails for them.
highEmbeddableHost's host format validation only accepts TLDs of 2-5 letters, so admins cannot add embeddable hosts on longer TLDs like example.technology.

Gold bugs missed (0)

None.