* Add type, limit, offset, min_id, max_id, account_id to search API Fix #8939 * Make the offset work on accounts and hashtags search as well * Assure brakeman we are not doing mass assignment here * Do not allow paginating unless a type is chosen * Fix search query and index id field on statuses instead of created_at
		
			
				
	
	
		
			302 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			302 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| {
 | |
|   "ignored_warnings": [
 | |
|     {
 | |
|       "warning_type": "Mass Assignment",
 | |
|       "warning_code": 105,
 | |
|       "fingerprint": "0117d2be5947ea4e4fbed9c15f23c6615b12c6892973411820c83d079808819d",
 | |
|       "check_name": "PermitAttributes",
 | |
|       "message": "Potentially dangerous key allowed for mass assignment",
 | |
|       "file": "app/controllers/api/v1/search_controller.rb",
 | |
|       "line": 30,
 | |
|       "link": "https://brakemanscanner.org/docs/warning_types/mass_assignment/",
 | |
|       "code": "params.permit(:type, :offset, :min_id, :max_id, :account_id)",
 | |
|       "render_path": null,
 | |
|       "location": {
 | |
|         "type": "method",
 | |
|         "class": "Api::V1::SearchController",
 | |
|         "method": "search_params"
 | |
|       },
 | |
|       "user_input": ":account_id",
 | |
|       "confidence": "High",
 | |
|       "note": ""
 | |
|     },
 | |
|     {
 | |
|       "warning_type": "SQL Injection",
 | |
|       "warning_code": 0,
 | |
|       "fingerprint": "04dbbc249b989db2e0119bbb0f59c9818e12889d2b97c529cdc0b1526002ba4b",
 | |
|       "check_name": "SQL",
 | |
|       "message": "Possible SQL injection",
 | |
|       "file": "app/models/report.rb",
 | |
|       "line": 90,
 | |
|       "link": "https://brakemanscanner.org/docs/warning_types/sql_injection/",
 | |
|       "code": "Admin::ActionLog.from(\"(#{[Admin::ActionLog.where(:target_type => \"Report\", :target_id => id, :created_at => ((created_at..updated_at))).unscope(:order), Admin::ActionLog.where(:target_type => \"Account\", :target_id => target_account_id, :created_at => ((created_at..updated_at))).unscope(:order), Admin::ActionLog.where(:target_type => \"Status\", :target_id => status_ids, :created_at => ((created_at..updated_at))).unscope(:order)].map do\n \"(#{query.to_sql})\"\n end.join(\" UNION ALL \")}) AS admin_action_logs\")",
 | |
|       "render_path": null,
 | |
|       "location": {
 | |
|         "type": "method",
 | |
|         "class": "Report",
 | |
|         "method": "history"
 | |
|       },
 | |
|       "user_input": "Admin::ActionLog.where(:target_type => \"Status\", :target_id => status_ids, :created_at => ((created_at..updated_at))).unscope(:order)",
 | |
|       "confidence": "High",
 | |
|       "note": ""
 | |
|     },
 | |
|     {
 | |
|       "warning_type": "SQL Injection",
 | |
|       "warning_code": 0,
 | |
|       "fingerprint": "19df3740b8d02a9fe0eb52c939b4b87d3a2a591162a6adfa8d64e9c26aeebe6d",
 | |
|       "check_name": "SQL",
 | |
|       "message": "Possible SQL injection",
 | |
|       "file": "app/models/status.rb",
 | |
|       "line": 87,
 | |
|       "link": "https://brakemanscanner.org/docs/warning_types/sql_injection/",
 | |
|       "code": "result.joins(\"INNER JOIN statuses_tags t#{id} ON t#{id}.status_id = statuses.id AND t#{id}.tag_id = #{id}\")",
 | |
|       "render_path": null,
 | |
|       "location": {
 | |
|         "type": "method",
 | |
|         "class": "Status",
 | |
|         "method": null
 | |
|       },
 | |
|       "user_input": "id",
 | |
|       "confidence": "Weak",
 | |
|       "note": ""
 | |
|     },
 | |
|     {
 | |
|       "warning_type": "Mass Assignment",
 | |
|       "warning_code": 105,
 | |
|       "fingerprint": "28d81cc22580ef76e912b077b245f353499aa27b3826476667224c00227af2a9",
 | |
|       "check_name": "PermitAttributes",
 | |
|       "message": "Potentially dangerous key allowed for mass assignment",
 | |
|       "file": "app/controllers/admin/reports_controller.rb",
 | |
|       "line": 56,
 | |
|       "link": "https://brakemanscanner.org/docs/warning_types/mass_assignment/",
 | |
|       "code": "params.permit(:account_id, :resolved, :target_account_id)",
 | |
|       "render_path": null,
 | |
|       "location": {
 | |
|         "type": "method",
 | |
|         "class": "Admin::ReportsController",
 | |
|         "method": "filter_params"
 | |
|       },
 | |
|       "user_input": ":account_id",
 | |
|       "confidence": "High",
 | |
|       "note": ""
 | |
|     },
 | |
|     {
 | |
|       "warning_type": "Dynamic Render Path",
 | |
|       "warning_code": 15,
 | |
|       "fingerprint": "4b6a895e2805578d03ceedbe1d469cc75a0c759eba093722523edb4b8683c873",
 | |
|       "check_name": "Render",
 | |
|       "message": "Render path contains parameter value",
 | |
|       "file": "app/views/admin/action_logs/index.html.haml",
 | |
|       "line": 4,
 | |
|       "link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
 | |
|       "code": "render(action => Admin::ActionLog.page(params[:page]), {})",
 | |
|       "render_path": [{"type":"controller","class":"Admin::ActionLogsController","method":"index","line":7,"file":"app/controllers/admin/action_logs_controller.rb","rendered":{"name":"admin/action_logs/index","file":"/home/eugr/Projects/mastodon/app/views/admin/action_logs/index.html.haml"}}],
 | |
|       "location": {
 | |
|         "type": "template",
 | |
|         "template": "admin/action_logs/index"
 | |
|       },
 | |
|       "user_input": "params[:page]",
 | |
|       "confidence": "Weak",
 | |
|       "note": ""
 | |
|     },
 | |
|     {
 | |
|       "warning_type": "Redirect",
 | |
|       "warning_code": 18,
 | |
|       "fingerprint": "5fad11cd67f905fab9b1d5739d01384a1748ebe78c5af5ac31518201925265a7",
 | |
|       "check_name": "Redirect",
 | |
|       "message": "Possible unprotected redirect",
 | |
|       "file": "app/controllers/remote_interaction_controller.rb",
 | |
|       "line": 21,
 | |
|       "link": "https://brakemanscanner.org/docs/warning_types/redirect/",
 | |
|       "code": "redirect_to(RemoteFollow.new(resource_params).interact_address_for(Status.find(params[:id])))",
 | |
|       "render_path": null,
 | |
|       "location": {
 | |
|         "type": "method",
 | |
|         "class": "RemoteInteractionController",
 | |
|         "method": "create"
 | |
|       },
 | |
|       "user_input": "RemoteFollow.new(resource_params).interact_address_for(Status.find(params[:id]))",
 | |
|       "confidence": "High",
 | |
|       "note": ""
 | |
|     },
 | |
|     {
 | |
|       "warning_type": "Dynamic Render Path",
 | |
|       "warning_code": 15,
 | |
|       "fingerprint": "67afc0d5f7775fa5bd91d1912e1b5505aeedef61876347546fa20f92fd6915e6",
 | |
|       "check_name": "Render",
 | |
|       "message": "Render path contains parameter value",
 | |
|       "file": "app/views/stream_entries/embed.html.haml",
 | |
|       "line": 3,
 | |
|       "link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
 | |
|       "code": "render(action => \"stream_entries/#{Account.find_local!(params[:account_username]).statuses.find(params[:id]).stream_entry.activity_type.downcase}\", { Account.find_local!(params[:account_username]).statuses.find(params[:id]).stream_entry.activity_type.downcase.to_sym => Account.find_local!(params[:account_username]).statuses.find(params[:id]).stream_entry.activity, :centered => true, :autoplay => ActiveModel::Type::Boolean.new.cast(params[:autoplay]) })",
 | |
|       "render_path": [{"type":"controller","class":"StatusesController","method":"embed","line":63,"file":"app/controllers/statuses_controller.rb","rendered":{"name":"stream_entries/embed","file":"/home/eugr/Projects/mastodon/app/views/stream_entries/embed.html.haml"}}],
 | |
|       "location": {
 | |
|         "type": "template",
 | |
|         "template": "stream_entries/embed"
 | |
|       },
 | |
|       "user_input": "params[:id]",
 | |
|       "confidence": "Weak",
 | |
|       "note": ""
 | |
|     },
 | |
|     {
 | |
|       "warning_type": "SQL Injection",
 | |
|       "warning_code": 0,
 | |
|       "fingerprint": "6f075c1484908e3ec9bed21ab7cf3c7866be8da3881485d1c82e13093aefcbd7",
 | |
|       "check_name": "SQL",
 | |
|       "message": "Possible SQL injection",
 | |
|       "file": "app/models/status.rb",
 | |
|       "line": 92,
 | |
|       "link": "https://brakemanscanner.org/docs/warning_types/sql_injection/",
 | |
|       "code": "result.joins(\"LEFT OUTER JOIN statuses_tags t#{id} ON t#{id}.status_id = statuses.id AND t#{id}.tag_id = #{id}\")",
 | |
|       "render_path": null,
 | |
|       "location": {
 | |
|         "type": "method",
 | |
|         "class": "Status",
 | |
|         "method": null
 | |
|       },
 | |
|       "user_input": "id",
 | |
|       "confidence": "Weak",
 | |
|       "note": ""
 | |
|     },
 | |
|     {
 | |
|       "warning_type": "Dynamic Render Path",
 | |
|       "warning_code": 15,
 | |
|       "fingerprint": "8d843713d99e8403f7992f3e72251b633817cf9076ffcbbad5613859d2bbc127",
 | |
|       "check_name": "Render",
 | |
|       "message": "Render path contains parameter value",
 | |
|       "file": "app/views/admin/custom_emojis/index.html.haml",
 | |
|       "line": 45,
 | |
|       "link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
 | |
|       "code": "render(action => filtered_custom_emojis.eager_load(:local_counterpart).page(params[:page]), {})",
 | |
|       "render_path": [{"type":"controller","class":"Admin::CustomEmojisController","method":"index","line":11,"file":"app/controllers/admin/custom_emojis_controller.rb","rendered":{"name":"admin/custom_emojis/index","file":"/home/eugr/Projects/mastodon/app/views/admin/custom_emojis/index.html.haml"}}],
 | |
|       "location": {
 | |
|         "type": "template",
 | |
|         "template": "admin/custom_emojis/index"
 | |
|       },
 | |
|       "user_input": "params[:page]",
 | |
|       "confidence": "Weak",
 | |
|       "note": ""
 | |
|     },
 | |
|     {
 | |
|       "warning_type": "SQL Injection",
 | |
|       "warning_code": 0,
 | |
|       "fingerprint": "9ccb9ba6a6947400e187d515e0bf719d22993d37cfc123c824d7fafa6caa9ac3",
 | |
|       "check_name": "SQL",
 | |
|       "message": "Possible SQL injection",
 | |
|       "file": "lib/mastodon/snowflake.rb",
 | |
|       "line": 87,
 | |
|       "link": "https://brakemanscanner.org/docs/warning_types/sql_injection/",
 | |
|       "code": "connection.execute(\"        CREATE OR REPLACE FUNCTION timestamp_id(table_name text)\\n        RETURNS bigint AS\\n        $$\\n          DECLARE\\n            time_part bigint;\\n            sequence_base bigint;\\n            tail bigint;\\n          BEGIN\\n            time_part := (\\n              -- Get the time in milliseconds\\n              ((date_part('epoch', now()) * 1000))::bigint\\n              -- And shift it over two bytes\\n              << 16);\\n\\n            sequence_base := (\\n              'x' ||\\n              -- Take the first two bytes (four hex characters)\\n              substr(\\n                -- Of the MD5 hash of the data we documented\\n                md5(table_name ||\\n                  '#{SecureRandom.hex(16)}' ||\\n                  time_part::text\\n                ),\\n                1, 4\\n              )\\n            -- And turn it into a bigint\\n            )::bit(16)::bigint;\\n\\n            -- Finally, add our sequence number to our base, and chop\\n            -- it to the last two bytes\\n            tail := (\\n              (sequence_base + nextval(table_name || '_id_seq'))\\n              & 65535);\\n\\n            -- Return the time part and the sequence part. OR appears\\n            -- faster here than addition, but they're equivalent:\\n            -- time_part has no trailing two bytes, and tail is only\\n            -- the last two bytes.\\n            RETURN time_part | tail;\\n          END\\n        $$ LANGUAGE plpgsql VOLATILE;\\n\")",
 | |
|       "render_path": null,
 | |
|       "location": {
 | |
|         "type": "method",
 | |
|         "class": "Mastodon::Snowflake",
 | |
|         "method": "define_timestamp_id"
 | |
|       },
 | |
|       "user_input": "SecureRandom.hex(16)",
 | |
|       "confidence": "Medium",
 | |
|       "note": ""
 | |
|     },
 | |
|     {
 | |
|       "warning_type": "Dynamic Render Path",
 | |
|       "warning_code": 15,
 | |
|       "fingerprint": "9f31d941f3910dba2e9bfcd81aef4513249bd24c02d0f98e13ad44fdeeccd0e8",
 | |
|       "check_name": "Render",
 | |
|       "message": "Render path contains parameter value",
 | |
|       "file": "app/views/admin/accounts/index.html.haml",
 | |
|       "line": 47,
 | |
|       "link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
 | |
|       "code": "render(action => filtered_accounts.page(params[:page]), {})",
 | |
|       "render_path": [{"type":"controller","class":"Admin::AccountsController","method":"index","line":12,"file":"app/controllers/admin/accounts_controller.rb","rendered":{"name":"admin/accounts/index","file":"/home/eugr/Projects/mastodon/app/views/admin/accounts/index.html.haml"}}],
 | |
|       "location": {
 | |
|         "type": "template",
 | |
|         "template": "admin/accounts/index"
 | |
|       },
 | |
|       "user_input": "params[:page]",
 | |
|       "confidence": "Weak",
 | |
|       "note": ""
 | |
|     },
 | |
|     {
 | |
|       "warning_type": "Redirect",
 | |
|       "warning_code": 18,
 | |
|       "fingerprint": "ba699ddcc6552c422c4ecd50d2cd217f616a2446659e185a50b05a0f2dad8d33",
 | |
|       "check_name": "Redirect",
 | |
|       "message": "Possible unprotected redirect",
 | |
|       "file": "app/controllers/media_controller.rb",
 | |
|       "line": 14,
 | |
|       "link": "https://brakemanscanner.org/docs/warning_types/redirect/",
 | |
|       "code": "redirect_to(MediaAttachment.attached.find_by!(:shortcode => ((params[:id] or params[:medium_id]))).file.url(:original))",
 | |
|       "render_path": null,
 | |
|       "location": {
 | |
|         "type": "method",
 | |
|         "class": "MediaController",
 | |
|         "method": "show"
 | |
|       },
 | |
|       "user_input": "MediaAttachment.attached.find_by!(:shortcode => ((params[:id] or params[:medium_id]))).file.url(:original)",
 | |
|       "confidence": "High",
 | |
|       "note": ""
 | |
|     },
 | |
|     {
 | |
|       "warning_type": "Redirect",
 | |
|       "warning_code": 18,
 | |
|       "fingerprint": "bb7e94e60af41decb811bb32171f1b27e9bf3f4d01e9e511127362e22510eb11",
 | |
|       "check_name": "Redirect",
 | |
|       "message": "Possible unprotected redirect",
 | |
|       "file": "app/controllers/remote_follow_controller.rb",
 | |
|       "line": 19,
 | |
|       "link": "https://brakemanscanner.org/docs/warning_types/redirect/",
 | |
|       "code": "redirect_to(RemoteFollow.new(resource_params).subscribe_address_for(Account.find_local!(params[:account_username])))",
 | |
|       "render_path": null,
 | |
|       "location": {
 | |
|         "type": "method",
 | |
|         "class": "RemoteFollowController",
 | |
|         "method": "create"
 | |
|       },
 | |
|       "user_input": "RemoteFollow.new(resource_params).subscribe_address_for(Account.find_local!(params[:account_username]))",
 | |
|       "confidence": "High",
 | |
|       "note": ""
 | |
|     },
 | |
|     {
 | |
|       "warning_type": "Mass Assignment",
 | |
|       "warning_code": 105,
 | |
|       "fingerprint": "e867661b2c9812bc8b75a5df12b28e2a53ab97015de0638b4e732fe442561b28",
 | |
|       "check_name": "PermitAttributes",
 | |
|       "message": "Potentially dangerous key allowed for mass assignment",
 | |
|       "file": "app/controllers/api/v1/reports_controller.rb",
 | |
|       "line": 36,
 | |
|       "link": "https://brakemanscanner.org/docs/warning_types/mass_assignment/",
 | |
|       "code": "params.permit(:account_id, :comment, :forward, :status_ids => ([]))",
 | |
|       "render_path": null,
 | |
|       "location": {
 | |
|         "type": "method",
 | |
|         "class": "Api::V1::ReportsController",
 | |
|         "method": "report_params"
 | |
|       },
 | |
|       "user_input": ":account_id",
 | |
|       "confidence": "High",
 | |
|       "note": ""
 | |
|     },
 | |
|     {
 | |
|       "warning_type": "Dynamic Render Path",
 | |
|       "warning_code": 15,
 | |
|       "fingerprint": "fbd0fc59adb5c6d44b60e02debb31d3af11719f534c9881e21435bbff87404d6",
 | |
|       "check_name": "Render",
 | |
|       "message": "Render path contains parameter value",
 | |
|       "file": "app/views/stream_entries/show.html.haml",
 | |
|       "line": 23,
 | |
|       "link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
 | |
|       "code": "render(partial => \"stream_entries/#{Account.find_local!(params[:account_username]).statuses.find(params[:id]).stream_entry.activity_type.downcase}\", { :locals => ({ Account.find_local!(params[:account_username]).statuses.find(params[:id]).stream_entry.activity_type.downcase.to_sym => Account.find_local!(params[:account_username]).statuses.find(params[:id]).stream_entry.activity, :include_threads => true }) })",
 | |
|       "render_path": [{"type":"controller","class":"StatusesController","method":"show","line":34,"file":"app/controllers/statuses_controller.rb","rendered":{"name":"stream_entries/show","file":"/home/eugr/Projects/mastodon/app/views/stream_entries/show.html.haml"}}],
 | |
|       "location": {
 | |
|         "type": "template",
 | |
|         "template": "stream_entries/show"
 | |
|       },
 | |
|       "user_input": "params[:id]",
 | |
|       "confidence": "Weak",
 | |
|       "note": ""
 | |
|     }
 | |
|   ],
 | |
|   "updated": "2019-02-21 02:30:29 +0100",
 | |
|   "brakeman_version": "4.4.0"
 | |
| }
 |