mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
Fix crashes found by fuzzing malformed input
- Components can't be made into a parent loop, and the parts tree walks stop safely if one exists (logbook entry and squawk resolution pages crashed). - A rejected aircraft photo no longer breaks the edit page; empty photos are refused; images that can't be read aren't resized, and a failed resize sends the original instead of an error. - Unsupported formats (/report.pdf…) answer 406; tampered upload references, out-of-range numbers and constraint violations get a form message instead of a 500; requests with null bytes are refused (400). - Blank values in required columns with defaults take the default; optional links to records that don't exist are validation errors. - Imports (oil report, logbook scans, .sam.zip) accept only uploaded files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5876c07a1a
commit
908c943e21
15 files changed
+201
-15
No files matched your search
@@ -82,16 +82,20 @@ class Aircraft < ApplicationRecord
|
||||
events.create!(category: category, event_name: event_name, user: user, notes: notes)
|
||||
end
|
||||
|
||||
# A saved photo to show (not one just rejected by validation, which has no
|
||||
# address yet).
|
||||
def picture_shown? = picture.attached? && picture.attachment.persisted?
|
||||
|
||||
# The photo at a page's size (:thumb or :card), or the original when it
|
||||
# isn't a kind that can be resized.
|
||||
# can't be resized (see ActiveStorage::Blob#resizable_image?).
|
||||
def picture_for(size)
|
||||
picture.variable? ? picture.variant(size) : picture
|
||||
picture.blob.resizable_image? ? picture.variant(size) : picture
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def picture_is_image
|
||||
if picture.attached? && !picture.content_type.to_s.start_with?("image/")
|
||||
if picture.attached? && (!picture.content_type.to_s.start_with?("image/") || picture.blob.byte_size.zero?)
|
||||
errors.add(:picture, :not_image)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user