MiniMax M3 · 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
0 of 4
Comments published
6
Comments matching a bug
0
Comments not matching
6
Cost of this PR
$0.281

Published comments (6)

highsecuritydb/migrate/20150818190757_create_embeddable_hosts.rb:25

SQL injection via string interpolation in INSERT — Interpolating `h` and `category_id` into the `INSERT` lets a stray `'` in legacy `site_settings.value` terminate the SQL literal. Use parameterized placeholders so the values cannot break out.

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

Migration breaks on host values containing a single quote — Single quotes in legacy `embeddable_hosts` values break the interpolated `INSERT` and abort the upgrade. Sanitize `h` (e.g. doubling quotes) or switch to parameterized insertion.

mediumbugapp/models/topic.rb:868-870

expandable_first_post? dropped embeddable_hosts guard — After dropping the `SiteSetting.embeddable_hosts.present?` check, `expandable_first_post?` returns true even when no `EmbeddableHost` rows exist and embedding is actually dead. Add `EmbeddableHost.exists?` so the flag reflects runtime capability.

mediumbugapp/controllers/admin/embeddable_hosts_controller.rb:14-18

destroy action crashes with NoMethodError when host id is missing — `host.destroy` runs without a nil check, so a bad id raises `NoMethodError` and returns 500. Raise `ActiveRecord::RecordNotFound unless host` before destroying.

mediumbugspec/models/topic_spec.rb:1402-1406

expandable_first_post? test with blank embeddable_host no longer tests anything meaningful — With the `SiteSetting.embeddable_hosts = nil` setup removed, "is false if embeddable_host is blank" only asserts defaults and would miss a regression reintroducing that dependency. Rename it or delete it.

mediumbugapp/models/embeddable_host.rb:5-8

before_validation crashes with NoMethodError when host is nil — `before_validation` calls `self.host.sub!` unconditionally, so a missing `:host` param from `Admin::EmbeddableHostsController#save_host` blows up as a 500. Guard with `self.host.to_s.sub!` or skip when blank.

Gold bugs found (0)

None.

Gold bugs missed (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.