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: Limit user profile field length (#18302)
Adds limits to location and website fields at model and DB level to match the bio_raw field limits. A limit cannot be added at the DB level for bio_raw because it is a postgres text field. Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
- Loading branch information
1 parent
b98cd73
commit e69f7d2
Showing
3 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
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
11 changes: 11 additions & 0 deletions
11
db/migrate/20220920044310_enforce_user_profile_max_limits.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,11 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class EnforceUserProfileMaxLimits < ActiveRecord::Migration[7.0] | ||
| def change | ||
| execute "UPDATE user_profiles SET location = LEFT(location, 3000) WHERE location IS NOT NULL" | ||
| execute "UPDATE user_profiles SET website = LEFT(website, 3000) WHERE website IS NOT NULL" | ||
|
|
||
| change_column :user_profiles, :location, :string, limit: 3000 | ||
| change_column :user_profiles, :website, :string, limit: 3000 | ||
| 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