Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
SECURITY: Prevent XSS in local oneboxes (#20009)
Co-authored-by: OsamaSayegh <asooomaasoooma90@gmail.com>
- Loading branch information
1 parent
15a2af1
commit 1a5a6f6
Showing
3 changed files
with
97 additions
and
4 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
db/post_migrate/20230105153520_trigger_post_rebake_local_onebox_xss.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class TriggerPostRebakeLocalOneboxXss < ActiveRecord::Migration[7.0] | ||
| def up | ||
| val = | ||
| DB.query_single( | ||
| "SELECT value FROM site_settings WHERE name = 'content_security_policy'", | ||
| ).first | ||
|
|
||
| return if val == nil || val == "t" | ||
|
|
||
| DB.exec(<<~SQL) | ||
| UPDATE posts | ||
| SET baked_version = NULL | ||
| WHERE cooked LIKE '%<a href=%' | ||
| SQL | ||
| end | ||
|
|
||
| def down | ||
| raise ActiveRecord::IrreversibleMigration | ||
| end | ||
| end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters