mirror of https://github.com/tootsuite/mastodon
Add remote interaction dialog for toots (#8202)
* Add remote interaction dialog for toots * Change AuthorizeFollow into AuthorizeInteraction, support statuses * Update brakeman.ignore * Adjust how interaction buttons are display on public pages * Fix testspull/8265/head
parent
bf1bde5d6a
commit
78fa926ed5
|
@ -1,66 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AuthorizeFollowsController < ApplicationController
|
||||
layout 'modal'
|
||||
|
||||
before_action :authenticate_user!
|
||||
before_action :set_body_classes
|
||||
|
||||
def show
|
||||
@account = located_account || render(:error)
|
||||
end
|
||||
|
||||
def create
|
||||
@account = follow_attempt.try(:target_account)
|
||||
|
||||
if @account.nil?
|
||||
render :error
|
||||
else
|
||||
render :success
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError
|
||||
render :error
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def follow_attempt
|
||||
FollowService.new.call(current_account, acct_without_prefix)
|
||||
end
|
||||
|
||||
def located_account
|
||||
if acct_param_is_url?
|
||||
account_from_remote_fetch
|
||||
else
|
||||
account_from_remote_follow
|
||||
end
|
||||
end
|
||||
|
||||
def account_from_remote_fetch
|
||||
FetchRemoteAccountService.new.call(acct_without_prefix)
|
||||
end
|
||||
|
||||
def account_from_remote_follow
|
||||
ResolveAccountService.new.call(acct_without_prefix)
|
||||
end
|
||||
|
||||
def acct_param_is_url?
|
||||
parsed_uri.path && %w(http https).include?(parsed_uri.scheme)
|
||||
end
|
||||
|
||||
def parsed_uri
|
||||
Addressable::URI.parse(acct_without_prefix).normalize
|
||||
end
|
||||
|
||||
def acct_without_prefix
|
||||
acct_params.gsub(/\Aacct:/, '')
|
||||
end
|
||||
|
||||
def acct_params
|
||||
params.fetch(:acct, '')
|
||||
end
|
||||
|
||||
def set_body_classes
|
||||
@body_classes = 'modal-layout'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,66 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AuthorizeInteractionsController < ApplicationController
|
||||
include Authorization
|
||||
|
||||
layout 'modal'
|
||||
|
||||
before_action :authenticate_user!
|
||||
before_action :set_body_classes
|
||||
before_action :set_resource
|
||||
|
||||
def show
|
||||
if @resource.is_a?(Account)
|
||||
render :show
|
||||
elsif @resource.is_a?(Status)
|
||||
redirect_to web_url("statuses/#{@resource.id}")
|
||||
else
|
||||
render :error
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
if @resource.is_a?(Account) && FollowService.new.call(current_account, @resource)
|
||||
render :success
|
||||
else
|
||||
render :error
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError
|
||||
render :error
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_resource
|
||||
@resource = located_resource || render(:error)
|
||||
authorize(@resource, :show?) if @resource.is_a?(Status)
|
||||
end
|
||||
|
||||
def located_resource
|
||||
if uri_param_is_url?
|
||||
ResolveURLService.new.call(uri_param)
|
||||
else
|
||||
account_from_remote_follow
|
||||
end
|
||||
end
|
||||
|
||||
def account_from_remote_follow
|
||||
ResolveAccountService.new.call(uri_param)
|
||||
end
|
||||
|
||||
def uri_param_is_url?
|
||||
parsed_uri.path && %w(http https).include?(parsed_uri.scheme)
|
||||
end
|
||||
|
||||
def parsed_uri
|
||||
Addressable::URI.parse(uri_param).normalize
|
||||
end
|
||||
|
||||
def uri_param
|
||||
params[:uri] || params.fetch(:acct, '').gsub(/\Aacct:/, '')
|
||||
end
|
||||
|
||||
def set_body_classes
|
||||
@body_classes = 'modal-layout'
|
||||
end
|
||||
end
|
|
@ -8,7 +8,7 @@ class IntentsController < ApplicationController
|
|||
if uri.scheme == 'web+mastodon'
|
||||
case uri.host
|
||||
when 'follow'
|
||||
return redirect_to authorize_follow_path(acct: uri.query_values['uri'].gsub(/\Aacct:/, ''))
|
||||
return redirect_to authorize_interaction_path(uri: uri.query_values['uri'].gsub(/\Aacct:/, ''))
|
||||
when 'share'
|
||||
return redirect_to share_path(text: uri.query_values['text'])
|
||||
end
|
||||
|
|
|
@ -42,5 +42,6 @@ class RemoteFollowController < ApplicationController
|
|||
|
||||
def set_body_classes
|
||||
@body_classes = 'modal-layout'
|
||||
@hide_header = true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoteInteractionController < ApplicationController
|
||||
include Authorization
|
||||
|
||||
layout 'modal'
|
||||
|
||||
before_action :set_status
|
||||
before_action :set_body_classes
|
||||
|
||||
def new
|
||||
@remote_follow = RemoteFollow.new(session_params)
|
||||
end
|
||||
|
||||
def create
|
||||
@remote_follow = RemoteFollow.new(resource_params)
|
||||
|
||||
if @remote_follow.valid?
|
||||
session[:remote_follow] = @remote_follow.acct
|
||||
redirect_to @remote_follow.interact_address_for(@status)
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def resource_params
|
||||
params.require(:remote_follow).permit(:acct)
|
||||
end
|
||||
|
||||
def session_params
|
||||
{ acct: session[:remote_follow] }
|
||||
end
|
||||
|
||||
def set_status
|
||||
@status = Status.find(params[:id])
|
||||
authorize @status, :show?
|
||||
rescue Mastodon::NotPermittedError
|
||||
# Reraise in order to get a 404
|
||||
raise ActiveRecord::RecordNotFound
|
||||
end
|
||||
|
||||
def set_body_classes
|
||||
@body_classes = 'modal-layout'
|
||||
@hide_header = true
|
||||
end
|
||||
end
|
|
@ -38,4 +38,14 @@ module HomeHelper
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def obscured_counter(count)
|
||||
if count <= 0
|
||||
0
|
||||
elsif count == 1
|
||||
1
|
||||
else
|
||||
'1+'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -67,13 +67,6 @@ function main() {
|
|||
}, datetime, now, datetime.getFullYear());
|
||||
});
|
||||
|
||||
[].forEach.call(document.querySelectorAll('.modal-button'), (content) => {
|
||||
content.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
window.open(e.target.href, 'mastodon-intent', 'width=445,height=600,resizable=no,menubar=no,status=no,scrollbars=yes');
|
||||
});
|
||||
});
|
||||
|
||||
const reactComponents = document.querySelectorAll('[data-component]');
|
||||
if (reactComponents.length > 0) {
|
||||
import(/* webpackChunkName: "containers/media_container" */ '../mastodon/containers/media_container')
|
||||
|
@ -119,6 +112,20 @@ function main() {
|
|||
return false;
|
||||
});
|
||||
|
||||
delegate(document, '.modal-button', 'click', e => {
|
||||
e.preventDefault();
|
||||
|
||||
let href;
|
||||
|
||||
if (e.target.nodeName !== 'A') {
|
||||
href = e.target.parentNode.href;
|
||||
} else {
|
||||
href = e.target.href;
|
||||
}
|
||||
|
||||
window.open(href, 'mastodon-intent', 'width=445,height=600,resizable=no,menubar=no,status=no,scrollbars=yes');
|
||||
});
|
||||
|
||||
delegate(document, '#account_display_name', 'input', ({ target }) => {
|
||||
const nameCounter = document.querySelector('.name-counter');
|
||||
const name = document.querySelector('.card .display-name strong');
|
||||
|
|
|
@ -628,6 +628,7 @@
|
|||
overflow: hidden;
|
||||
white-space: pre-wrap;
|
||||
padding-top: 2px;
|
||||
color: $primary-text-color;
|
||||
|
||||
&:focus {
|
||||
outline: 0;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
margin-bottom: 10px;
|
||||
text-align: left;
|
||||
|
||||
@media screen and (max-width: $no-gap-breakpoint) {
|
||||
margin-bottom: 0;
|
||||
|
@ -63,6 +64,10 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
&--highlighted .entry {
|
||||
background: lighten($ui-base-color, 8%);
|
||||
}
|
||||
}
|
||||
|
||||
.button.logo-button {
|
||||
|
|
|
@ -22,6 +22,10 @@ class RemoteFollow
|
|||
addressable_template.expand(uri: account.local_username_and_domain).to_s
|
||||
end
|
||||
|
||||
def interact_address_for(status)
|
||||
addressable_template.expand(uri: ActivityPub::TagManager.instance.uri_for(status)).to_s
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def populate_template
|
||||
|
|
|
@ -20,7 +20,7 @@ class WebfingerSerializer < ActiveModel::Serializer
|
|||
{ rel: 'self', type: 'application/activity+json', href: account_url(object) },
|
||||
{ rel: 'salmon', href: api_salmon_url(object.id) },
|
||||
{ rel: 'magic-public-key', href: "data:application/magic-public-key,#{object.magic_key}" },
|
||||
{ rel: 'http://ostatus.org/schema/1.0/subscribe', template: "#{authorize_follow_url}?acct={uri}" },
|
||||
{ rel: 'http://ostatus.org/schema/1.0/subscribe', template: "#{authorize_interaction_url}?uri={uri}" },
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
- content_for :page_title do
|
||||
= t('authorize_follow.title', acct: @account.acct)
|
||||
|
||||
.form-container
|
||||
.follow-prompt
|
||||
= render 'application/card', account: @account
|
||||
|
||||
- if current_account.following?(@account)
|
||||
.flash-message
|
||||
%strong
|
||||
= t('authorize_follow.already_following')
|
||||
= render 'post_follow_actions'
|
||||
|
||||
- else
|
||||
= form_tag authorize_follow_path, method: :post, class: 'simple_form' do
|
||||
= hidden_field_tag :acct, @account.acct
|
||||
= button_tag t('authorize_follow.follow'), type: :submit
|
|
@ -1,4 +1,4 @@
|
|||
.post-follow-actions
|
||||
%div= link_to t('authorize_follow.post_follow.web'), web_url("accounts/#{@account.id}"), class: 'button button--block'
|
||||
%div= link_to t('authorize_follow.post_follow.return'), TagManager.instance.url_for(@account), class: 'button button--block'
|
||||
%div= link_to t('authorize_follow.post_follow.web'), web_url("accounts/#{@resource.id}"), class: 'button button--block'
|
||||
%div= link_to t('authorize_follow.post_follow.return'), TagManager.instance.url_for(@resource), class: 'button button--block'
|
||||
%div= t('authorize_follow.post_follow.close')
|
|
@ -0,0 +1,18 @@
|
|||
- content_for :page_title do
|
||||
= t('authorize_follow.title', acct: @resource.acct)
|
||||
|
||||
.form-container
|
||||
.follow-prompt
|
||||
= render 'application/card', account: @resource
|
||||
|
||||
- if current_account.following?(@resource)
|
||||
.flash-message
|
||||
%strong
|
||||
= t('authorize_follow.already_following')
|
||||
|
||||
= render 'post_follow_actions'
|
||||
- else
|
||||
= form_tag authorize_interaction_path, method: :post, class: 'simple_form' do
|
||||
= hidden_field_tag :action, :follow
|
||||
= hidden_field_tag :acct, @resource.acct
|
||||
= button_tag t('authorize_follow.follow'), type: :submit
|
|
@ -1,13 +1,13 @@
|
|||
- content_for :page_title do
|
||||
= t('authorize_follow.title', acct: @account.acct)
|
||||
= t('authorize_follow.title', acct: @resource.acct)
|
||||
|
||||
.form-container
|
||||
.follow-prompt
|
||||
- if @account.locked?
|
||||
- if @resource.locked?
|
||||
%h2= t('authorize_follow.follow_request')
|
||||
- else
|
||||
%h2= t('authorize_follow.following')
|
||||
|
||||
= render 'application/card', account: @account
|
||||
= render 'application/card', account: @resource
|
||||
|
||||
= render 'post_follow_actions'
|
|
@ -2,7 +2,7 @@
|
|||
= javascript_pack_tag 'public', integrity: true, crossorigin: 'anonymous'
|
||||
|
||||
- content_for :content do
|
||||
- if user_signed_in?
|
||||
- if user_signed_in? && !@hide_header
|
||||
.account-header
|
||||
.avatar= image_tag current_account.avatar.url(:original)
|
||||
.name
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
.form-container
|
||||
.follow-prompt
|
||||
%h2= t('remote_interaction.prompt')
|
||||
|
||||
.public-layout
|
||||
.activity-stream.activity-stream--highlighted
|
||||
= render 'stream_entries/status', status: @status
|
||||
|
||||
= simple_form_for @remote_follow, as: :remote_follow, url: remote_interaction_path(@status) do |f|
|
||||
= render 'shared/error_messages', object: @remote_follow
|
||||
|
||||
= f.input :acct, placeholder: t('remote_follow.acct'), input_html: { autocapitalize: 'none', autocorrect: 'off' }
|
||||
|
||||
.actions
|
||||
= f.button :button, t('remote_interaction.proceed'), type: :submit
|
||||
|
||||
%p.hint.subtle-hint= t('remote_follow.no_account_html', sign_up_path: open_registrations? ? new_user_registration_path : 'https://joinmastodon.org/#getting-started')
|
|
@ -39,6 +39,11 @@
|
|||
- else
|
||||
= link_to status.application.name, status.application.website, class: 'detailed-status__application', target: '_blank', rel: 'noopener'
|
||||
·
|
||||
= link_to remote_interaction_path(status), class: 'modal-button detailed-status__link' do
|
||||
= fa_icon('reply')
|
||||
%span.detailed-status__reblogs>= number_to_human status.replies_count, strip_insignificant_zeros: true
|
||||
= " "
|
||||
·
|
||||
- if status.direct_visibility?
|
||||
%span.detailed-status__link<
|
||||
= fa_icon('envelope')
|
||||
|
@ -46,13 +51,15 @@
|
|||
%span.detailed-status__link<
|
||||
= fa_icon('lock')
|
||||
- else
|
||||
%span.detailed-status__link<
|
||||
= link_to remote_interaction_path(status), class: 'modal-button detailed-status__link' do
|
||||
= fa_icon('retweet')
|
||||
%span.detailed-status__reblogs= number_to_human status.reblogs_count, strip_insignificant_zeros: true
|
||||
%span.detailed-status__reblogs>= number_to_human status.reblogs_count, strip_insignificant_zeros: true
|
||||
= " "
|
||||
·
|
||||
%span.detailed-status__link<
|
||||
= link_to remote_interaction_path(status), class: 'modal-button detailed-status__link' do
|
||||
= fa_icon('star')
|
||||
%span.detailed-status__favorites= number_to_human status.favourites_count, strip_insignificant_zeros: true
|
||||
%span.detailed-status__favorites>= number_to_human status.favourites_count, strip_insignificant_zeros: true
|
||||
= " "
|
||||
|
||||
- if user_signed_in?
|
||||
·
|
||||
|
|
|
@ -29,14 +29,16 @@
|
|||
= react_component :media_gallery, height: 343, sensitive: status.sensitive? && !current_account&.user&.setting_display_sensitive_media, 'autoPlayGif': current_account&.user&.setting_auto_play_gif, media: status.media_attachments.map { |a| ActiveModelSerializers::SerializableResource.new(a, serializer: REST::MediaAttachmentSerializer).as_json }
|
||||
|
||||
.status__action-bar
|
||||
.status__action-bar-button.static-icon-button<
|
||||
.status__action-bar__counter
|
||||
= link_to remote_interaction_path(status), class: 'status__action-bar-button icon-button modal-button', style: 'font-size: 18px; width: 23.1429px; height: 23.1429px; line-height: 23.15px;' do
|
||||
= fa_icon 'reply fw'
|
||||
.status__action-bar__counter__label= obscured_counter status.replies_count
|
||||
= link_to remote_interaction_path(status), class: 'status__action-bar-button icon-button modal-button', style: 'font-size: 18px; width: 23.1429px; height: 23.1429px; line-height: 23.15px;' do
|
||||
- if status.public_visibility? || status.unlisted_visibility?
|
||||
= fa_icon 'retweet fw'
|
||||
%span.detailed-status__reblogs= number_to_human status.reblogs_count, strip_insignificant_zeros: true
|
||||
- elsif status.private_visibility?
|
||||
= fa_icon 'lock fw'
|
||||
- else
|
||||
= fa_icon 'envelope fw'
|
||||
.status__action-bar-button.static-icon-button<
|
||||
= link_to remote_interaction_path(status), class: 'status__action-bar-button icon-button modal-button', style: 'font-size: 18px; width: 23.1429px; height: 23.1429px; line-height: 23.15px;' do
|
||||
= fa_icon 'star fw'
|
||||
%span.detailed-status__favorites= number_to_human status.favourites_count, strip_insignificant_zeros: true
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
.grid
|
||||
.column-0
|
||||
.activity-stream.activity-stream-headless.h-entry
|
||||
.activity-stream.h-entry
|
||||
= render partial: "stream_entries/#{@type}", locals: { @type.to_sym => @stream_entry.activity, include_threads: true }
|
||||
.column-1
|
||||
= render 'application/sidebar'
|
||||
|
|
|
@ -37,7 +37,7 @@ doc << Ox::Element.new('XRD').tap do |xrd|
|
|||
|
||||
xrd << Ox::Element.new('Link').tap do |link|
|
||||
link['rel'] = 'http://ostatus.org/schema/1.0/subscribe'
|
||||
link['template'] = "#{authorize_follow_url}?acct={uri}"
|
||||
link['template'] = "#{authorize_interaction_url}?acct={uri}"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,25 @@
|
|||
{
|
||||
"ignored_warnings": [
|
||||
{
|
||||
"warning_type": "SQL Injection",
|
||||
"warning_code": 0,
|
||||
"fingerprint": "04dbbc249b989db2e0119bbb0f59c9818e12889d2b97c529cdc0b1526002ba4b",
|
||||
"check_name": "SQL",
|
||||
"message": "Possible SQL injection",
|
||||
"file": "app/models/report.rb",
|
||||
"line": 86,
|
||||
"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": "Cross-Site Scripting",
|
||||
"warning_code": 4,
|
||||
|
@ -7,8 +27,8 @@
|
|||
"check_name": "LinkToHref",
|
||||
"message": "Potentially unsafe model attribute in link_to href",
|
||||
"file": "app/views/admin/accounts/show.html.haml",
|
||||
"line": 147,
|
||||
"link": "http://brakemanscanner.org/docs/warning_types/link_to_href",
|
||||
"line": 167,
|
||||
"link": "https://brakemanscanner.org/docs/warning_types/link_to_href",
|
||||
"code": "link_to(Account.find(params[:id]).inbox_url, Account.find(params[:id]).inbox_url)",
|
||||
"render_path": [{"type":"controller","class":"Admin::AccountsController","method":"show","line":18,"file":"app/controllers/admin/accounts_controller.rb"}],
|
||||
"location": {
|
||||
|
@ -26,8 +46,8 @@
|
|||
"check_name": "LinkToHref",
|
||||
"message": "Potentially unsafe model attribute in link_to href",
|
||||
"file": "app/views/admin/accounts/show.html.haml",
|
||||
"line": 153,
|
||||
"link": "http://brakemanscanner.org/docs/warning_types/link_to_href",
|
||||
"line": 173,
|
||||
"link": "https://brakemanscanner.org/docs/warning_types/link_to_href",
|
||||
"code": "link_to(Account.find(params[:id]).shared_inbox_url, Account.find(params[:id]).shared_inbox_url)",
|
||||
"render_path": [{"type":"controller","class":"Admin::AccountsController","method":"show","line":18,"file":"app/controllers/admin/accounts_controller.rb"}],
|
||||
"location": {
|
||||
|
@ -45,8 +65,8 @@
|
|||
"check_name": "LinkToHref",
|
||||
"message": "Potentially unsafe model attribute in link_to href",
|
||||
"file": "app/views/admin/accounts/show.html.haml",
|
||||
"line": 57,
|
||||
"link": "http://brakemanscanner.org/docs/warning_types/link_to_href",
|
||||
"line": 75,
|
||||
"link": "https://brakemanscanner.org/docs/warning_types/link_to_href",
|
||||
"code": "link_to(Account.find(params[:id]).url, Account.find(params[:id]).url)",
|
||||
"render_path": [{"type":"controller","class":"Admin::AccountsController","method":"show","line":18,"file":"app/controllers/admin/accounts_controller.rb"}],
|
||||
"location": {
|
||||
|
@ -57,6 +77,26 @@
|
|||
"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": 86,
|
||||
"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,
|
||||
|
@ -65,9 +105,9 @@
|
|||
"message": "Render path contains parameter value",
|
||||
"file": "app/views/stream_entries/embed.html.haml",
|
||||
"line": 3,
|
||||
"link": "http://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
|
||||
"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 })",
|
||||
"render_path": [{"type":"controller","class":"StatusesController","method":"embed","line":45,"file":"app/controllers/statuses_controller.rb"}],
|
||||
"render_path": [{"type":"controller","class":"StatusesController","method":"embed","line":58,"file":"app/controllers/statuses_controller.rb"}],
|
||||
"location": {
|
||||
"type": "template",
|
||||
"template": "stream_entries/embed"
|
||||
|
@ -83,8 +123,8 @@
|
|||
"check_name": "Render",
|
||||
"message": "Render path contains parameter value",
|
||||
"file": "app/views/admin/action_logs/index.html.haml",
|
||||
"line": 5,
|
||||
"link": "http://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
|
||||
"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"}],
|
||||
"location": {
|
||||
|
@ -95,6 +135,26 @@
|
|||
"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": 20,
|
||||
"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": "Cross-Site Scripting",
|
||||
"warning_code": 4,
|
||||
|
@ -102,8 +162,8 @@
|
|||
"check_name": "LinkToHref",
|
||||
"message": "Potentially unsafe model attribute in link_to href",
|
||||
"file": "app/views/admin/accounts/show.html.haml",
|
||||
"line": 156,
|
||||
"link": "http://brakemanscanner.org/docs/warning_types/link_to_href",
|
||||
"line": 176,
|
||||
"link": "https://brakemanscanner.org/docs/warning_types/link_to_href",
|
||||
"code": "link_to(Account.find(params[:id]).followers_url, Account.find(params[:id]).followers_url)",
|
||||
"render_path": [{"type":"controller","class":"Admin::AccountsController","method":"show","line":18,"file":"app/controllers/admin/accounts_controller.rb"}],
|
||||
"location": {
|
||||
|
@ -121,8 +181,8 @@
|
|||
"check_name": "LinkToHref",
|
||||
"message": "Potentially unsafe model attribute in link_to href",
|
||||
"file": "app/views/admin/accounts/show.html.haml",
|
||||
"line": 130,
|
||||
"link": "http://brakemanscanner.org/docs/warning_types/link_to_href",
|
||||
"line": 149,
|
||||
"link": "https://brakemanscanner.org/docs/warning_types/link_to_href",
|
||||
"code": "link_to(Account.find(params[:id]).salmon_url, Account.find(params[:id]).salmon_url)",
|
||||
"render_path": [{"type":"controller","class":"Admin::AccountsController","method":"show","line":18,"file":"app/controllers/admin/accounts_controller.rb"}],
|
||||
"location": {
|
||||
|
@ -141,7 +201,7 @@
|
|||
"message": "Render path contains parameter value",
|
||||
"file": "app/views/admin/custom_emojis/index.html.haml",
|
||||
"line": 45,
|
||||
"link": "http://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
|
||||
"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"}],
|
||||
"location": {
|
||||
|
@ -160,7 +220,7 @@
|
|||
"message": "Possible SQL injection",
|
||||
"file": "lib/mastodon/snowflake.rb",
|
||||
"line": 87,
|
||||
"link": "http://brakemanscanner.org/docs/warning_types/sql_injection/",
|
||||
"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": {
|
||||
|
@ -180,7 +240,7 @@
|
|||
"message": "Render path contains parameter value",
|
||||
"file": "app/views/admin/accounts/index.html.haml",
|
||||
"line": 67,
|
||||
"link": "http://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
|
||||
"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"}],
|
||||
"location": {
|
||||
|
@ -191,25 +251,6 @@
|
|||
"confidence": "Weak",
|
||||
"note": ""
|
||||
},
|
||||
{
|
||||
"warning_type": "Cross-Site Request Forgery",
|
||||
"warning_code": 7,
|
||||
"fingerprint": "ab491f72606337a348482d006eb67a3b1616685fd48644d5ac909bbcd62a5000",
|
||||
"check_name": "ForgerySetting",
|
||||
"message": "'protect_from_forgery' should be called in WellKnown::HostMetaController",
|
||||
"file": "app/controllers/well_known/host_meta_controller.rb",
|
||||
"line": 4,
|
||||
"link": "http://brakemanscanner.org/docs/warning_types/cross-site_request_forgery/",
|
||||
"code": null,
|
||||
"render_path": null,
|
||||
"location": {
|
||||
"type": "controller",
|
||||
"controller": "WellKnown::HostMetaController"
|
||||
},
|
||||
"user_input": null,
|
||||
"confidence": "High",
|
||||
"note": ""
|
||||
},
|
||||
{
|
||||
"warning_type": "Redirect",
|
||||
"warning_code": 18,
|
||||
|
@ -218,7 +259,7 @@
|
|||
"message": "Possible unprotected redirect",
|
||||
"file": "app/controllers/media_controller.rb",
|
||||
"line": 10,
|
||||
"link": "http://brakemanscanner.org/docs/warning_types/redirect/",
|
||||
"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": {
|
||||
|
@ -237,8 +278,8 @@
|
|||
"check_name": "LinkToHref",
|
||||
"message": "Potentially unsafe model attribute in link_to href",
|
||||
"file": "app/views/admin/accounts/show.html.haml",
|
||||
"line": 119,
|
||||
"link": "http://brakemanscanner.org/docs/warning_types/link_to_href",
|
||||
"line": 138,
|
||||
"link": "https://brakemanscanner.org/docs/warning_types/link_to_href",
|
||||
"code": "link_to(Account.find(params[:id]).remote_url, Account.find(params[:id]).remote_url)",
|
||||
"render_path": [{"type":"controller","class":"Admin::AccountsController","method":"show","line":18,"file":"app/controllers/admin/accounts_controller.rb"}],
|
||||
"location": {
|
||||
|
@ -256,8 +297,8 @@
|
|||
"check_name": "Redirect",
|
||||
"message": "Possible unprotected redirect",
|
||||
"file": "app/controllers/remote_follow_controller.rb",
|
||||
"line": 18,
|
||||
"link": "http://brakemanscanner.org/docs/warning_types/redirect/",
|
||||
"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": {
|
||||
|
@ -276,8 +317,8 @@
|
|||
"check_name": "Render",
|
||||
"message": "Render path contains parameter value",
|
||||
"file": "app/views/admin/reports/index.html.haml",
|
||||
"line": 25,
|
||||
"link": "http://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
|
||||
"line": 22,
|
||||
"link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
|
||||
"code": "render(action => filtered_reports.page(params[:page]), {})",
|
||||
"render_path": [{"type":"controller","class":"Admin::ReportsController","method":"index","line":10,"file":"app/controllers/admin/reports_controller.rb"}],
|
||||
"location": {
|
||||
|
@ -288,25 +329,6 @@
|
|||
"confidence": "Weak",
|
||||
"note": ""
|
||||
},
|
||||
{
|
||||
"warning_type": "Cross-Site Request Forgery",
|
||||
"warning_code": 7,
|
||||
"fingerprint": "d4278f04e807ec58a23925f8ab31fad5e84692f2fb9f2f57e7931aff05d57cf8",
|
||||
"check_name": "ForgerySetting",
|
||||
"message": "'protect_from_forgery' should be called in WellKnown::WebfingerController",
|
||||
"file": "app/controllers/well_known/webfinger_controller.rb",
|
||||
"line": 4,
|
||||
"link": "http://brakemanscanner.org/docs/warning_types/cross-site_request_forgery/",
|
||||
"code": null,
|
||||
"render_path": null,
|
||||
"location": {
|
||||
"type": "controller",
|
||||
"controller": "WellKnown::WebfingerController"
|
||||
},
|
||||
"user_input": null,
|
||||
"confidence": "High",
|
||||
"note": ""
|
||||
},
|
||||
{
|
||||
"warning_type": "Cross-Site Scripting",
|
||||
"warning_code": 4,
|
||||
|
@ -314,8 +336,8 @@
|
|||
"check_name": "LinkToHref",
|
||||
"message": "Potentially unsafe model attribute in link_to href",
|
||||
"file": "app/views/admin/accounts/show.html.haml",
|
||||
"line": 150,
|
||||
"link": "http://brakemanscanner.org/docs/warning_types/link_to_href",
|
||||
"line": 170,
|
||||
"link": "https://brakemanscanner.org/docs/warning_types/link_to_href",
|
||||
"code": "link_to(Account.find(params[:id]).outbox_url, Account.find(params[:id]).outbox_url)",
|
||||
"render_path": [{"type":"controller","class":"Admin::AccountsController","method":"show","line":18,"file":"app/controllers/admin/accounts_controller.rb"}],
|
||||
"location": {
|
||||
|
@ -326,6 +348,26 @@
|
|||
"confidence": "Weak",
|
||||
"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": 42,
|
||||
"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,
|
||||
|
@ -333,10 +375,10 @@
|
|||
"check_name": "Render",
|
||||
"message": "Render path contains parameter value",
|
||||
"file": "app/views/stream_entries/show.html.haml",
|
||||
"line": 24,
|
||||
"link": "http://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
|
||||
"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":22,"file":"app/controllers/statuses_controller.rb"}],
|
||||
"render_path": [{"type":"controller","class":"StatusesController","method":"show","line":30,"file":"app/controllers/statuses_controller.rb"}],
|
||||
"location": {
|
||||
"type": "template",
|
||||
"template": "stream_entries/show"
|
||||
|
@ -346,6 +388,6 @@
|
|||
"note": ""
|
||||
}
|
||||
],
|
||||
"updated": "2018-02-16 06:42:53 +0100",
|
||||
"brakeman_version": "4.0.1"
|
||||
"updated": "2018-08-18 00:49:25 +0200",
|
||||
"brakeman_version": "4.2.1"
|
||||
}
|
||||
|
|
|
@ -655,11 +655,14 @@ en:
|
|||
publishing: Publishing
|
||||
web: Web
|
||||
remote_follow:
|
||||
acct: Enter your username@domain you want to follow from
|
||||
acct: Enter your username@domain you want to act from
|
||||
missing_resource: Could not find the required redirect URL for your account
|
||||
no_account_html: Don't have an account? You can <a href='%{sign_up_path}' target='_blank'>sign up here</a>
|
||||
proceed: Proceed to follow
|
||||
prompt: 'You are going to follow:'
|
||||
remote_interaction:
|
||||
proceed: Proceed to interact
|
||||
prompt: 'You want to interact with this toot:'
|
||||
remote_unfollow:
|
||||
error: Error
|
||||
title: Title
|
||||
|
|
|
@ -74,6 +74,9 @@ Rails.application.routes.draw do
|
|||
get '/@:account_username/:id', to: 'statuses#show', as: :short_account_status
|
||||
get '/@:account_username/:id/embed', to: 'statuses#embed', as: :embed_short_account_status
|
||||
|
||||
get '/interact/:id', to: 'remote_interaction#new', as: :remote_interaction
|
||||
post '/interact/:id', to: 'remote_interaction#create'
|
||||
|
||||
namespace :settings do
|
||||
resource :profile, only: [:show, :update]
|
||||
resource :preferences, only: [:show, :update]
|
||||
|
@ -120,7 +123,7 @@ Rails.application.routes.draw do
|
|||
|
||||
# Remote follow
|
||||
resource :remote_unfollow, only: [:create]
|
||||
resource :authorize_follow, only: [:show, :create]
|
||||
resource :authorize_interaction, only: [:show, :create]
|
||||
resource :share, only: [:show, :create]
|
||||
|
||||
namespace :admin do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe AuthorizeFollowsController do
|
||||
describe AuthorizeInteractionsController do
|
||||
render_views
|
||||
|
||||
describe 'GET #show' do
|
||||
|
@ -39,19 +39,19 @@ describe AuthorizeFollowsController do
|
|||
expect(service).to have_received(:call).with('missing@hostname')
|
||||
end
|
||||
|
||||
it 'sets account from url' do
|
||||
it 'sets resource from url' do
|
||||
account = Account.new
|
||||
service = double
|
||||
allow(FetchRemoteAccountService).to receive(:new).and_return(service)
|
||||
allow(ResolveURLService).to receive(:new).and_return(service)
|
||||
allow(service).to receive(:call).with('http://example.com').and_return(account)
|
||||
|
||||
get :show, params: { acct: 'http://example.com' }
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(assigns(:account)).to eq account
|
||||
expect(assigns(:resource)).to eq account
|
||||
end
|
||||
|
||||
it 'sets account from acct uri' do
|
||||
it 'sets resource from acct uri' do
|
||||
account = Account.new
|
||||
service = double
|
||||
allow(ResolveAccountService).to receive(:new).and_return(service)
|
||||
|
@ -60,7 +60,7 @@ describe AuthorizeFollowsController do
|
|||
get :show, params: { acct: 'acct:found@hostname' }
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(assigns(:account)).to eq account
|
||||
expect(assigns(:resource)).to eq account
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -75,8 +75,8 @@ describe AuthorizeFollowsController do
|
|||
end
|
||||
|
||||
describe 'when signed in' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:account) { Fabricate(:account, user: user) }
|
||||
let!(:user) { Fabricate(:user) }
|
||||
let!(:account) { user.account }
|
||||
|
||||
before do
|
||||
sign_in(user)
|
||||
|
@ -84,25 +84,26 @@ describe AuthorizeFollowsController do
|
|||
|
||||
it 'shows error when account not found' do
|
||||
service = double
|
||||
allow(FollowService).to receive(:new).and_return(service)
|
||||
allow(service).to receive(:call).with(account, 'user@hostname').and_return(nil)
|
||||
|
||||
allow(ResolveAccountService).to receive(:new).and_return(service)
|
||||
allow(service).to receive(:call).with('user@hostname').and_return(nil)
|
||||
|
||||
post :create, params: { acct: 'acct:user@hostname' }
|
||||
|
||||
expect(service).to have_received(:call).with(account, 'user@hostname')
|
||||
expect(response).to render_template(:error)
|
||||
end
|
||||
|
||||
it 'follows account when found' do
|
||||
target_account = Fabricate(:account)
|
||||
result_account = double(target_account: target_account)
|
||||
service = double
|
||||
allow(FollowService).to receive(:new).and_return(service)
|
||||
allow(service).to receive(:call).with(account, 'user@hostname').and_return(result_account)
|
||||
|
||||
allow(ResolveAccountService).to receive(:new).and_return(service)
|
||||
allow(service).to receive(:call).with('user@hostname').and_return(target_account)
|
||||
|
||||
post :create, params: { acct: 'acct:user@hostname' }
|
||||
|
||||
expect(service).to have_received(:call).with(account, 'user@hostname')
|
||||
expect(service).to have_received(:call).with('user@hostname')
|
||||
expect(account.following?(target_account)).to be true
|
||||
expect(response).to render_template(:success)
|
||||
end
|
||||
end
|
|
@ -13,7 +13,7 @@ RSpec.describe IntentsController, type: :controller do
|
|||
context 'when host is follow' do
|
||||
let(:uri) { 'web+mastodon://follow?uri=test' }
|
||||
|
||||
it { is_expected.to redirect_to authorize_follow_path(acct: 'test') }
|
||||
it { is_expected.to redirect_to authorize_interaction_path(uri: 'test') }
|
||||
end
|
||||
|
||||
context 'when host is share' do
|
||||
|
|
Loading…
Reference in New Issue