0.0
No commit activity in last 3 years
No release in over 3 years
Detect fake file types using magic numbers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Magic Number

Ruby gem that allows to verify if file content is in accordance with it's extension and prevent fake uploads to your site.

Installation

Add this into your Gemfile and then run bundle install

gem 'MagicNumber', '~> 0.0.1'

What is a magic number?

Magic number is a digital signature that each filetype contains. It could be use to verify the format of a file, so this gem uses it to check whether a file is truly as its extension says

Supported file types

  • PDF
  • DOCX
  • XLSX
  • PPTX
  • VSDX
  • DOC
  • XLS
  • PPT
  • JPG
  • PNG
  • JPEG
  • GIF
  • TIF
  • TIFF
  • PIC
  • ICO
  • BMP
  • AVI
  • PSD
  • WAV
  • MP3
  • ISO
  • FLAC
  • MID
  • MIDI
  • ASF
  • OGG
  • OGA
  • OGV
  • MKV
  • MKA
  • MKS
  • MK3D
  • WEBM
  • Z
  • BZ2
  • CR2
  • ZIP
  • RAR
  • TAR
  • DMG
  • VMDK
  • EXE
  • JAR
  • CLASS
  • SEA
  • YTR
  • DBA
  • MSG
  • CRX
  • FH8

Usage

This gem provides is_real? method to check file authenticity

Example of usage

  file_real = MagicNumber.is_real?("/tmp/document.pdf")

TODO

· Add function to get real file type.

Author

Adrián Fernández adrian@adrian-fernandez.net

http://www.adrian-fernandez.net

@adrian-fernandez