handle dangerous extensions

This commit is contained in:
Pete Matsyburka
2026-05-18 17:51:50 +03:00
parent 6806772346
commit 354bccd6e8
5 changed files with 53 additions and 11 deletions
@@ -11,6 +11,7 @@ module Api
before_action :set_noindex_headers
before_action :set_security_headers
# rubocop:disable Metrics
def show
blob_uuid, purp, exp = ApplicationRecord.signed_id_verifier.verified(params[:signed_uuid])
@@ -22,6 +23,12 @@ module Api
blob = ActiveStorage::Blob.find_by!(uuid: blob_uuid)
if Submitters::DANGEROUS_EXTENSIONS.include?(blob.filename.extension.to_s.downcase)
Rollbar.error('Dangerous extension') if defined?(Rollbar)
return head :unprocessable_content
end
attachment = blob.attachments.take
@record = attachment.record
@@ -46,6 +53,7 @@ module Api
end
end
end
# rubocop:enable Metrics
private