filemagick-signatures 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 34a7d7fa7a20c1b6a51ceae221c7376416d9a30e
4
+ data.tar.gz: 6fbc00d57ca785e604392257b8583276990f4007
5
+ SHA512:
6
+ metadata.gz: b06331d5b98064a8a3a245ed3648a2b8fe1dc4074cd1cb7259bbec3d7030726bcaa80e28eb7bfff864cb8eb78659b76c34fa21cafe5d980480413131d14e58a8
7
+ data.tar.gz: fd8f1434aaf20ec3ef84bb21408b53911c96046f93457397853d9d5961c63d80934258678918044b72e124fcb7b8f5d9ab5e8b3dd15d6e78ff1d3a7d01496f44
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in filemagick-signatures.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Kashyap
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,66 @@
1
+ # Filemagick::Signatures
2
+
3
+ This module contains the signatures for use
4
+ either independently or via the `filemagick` library. The various file
5
+ signatures currently supported are taken from [Gary Kessler's
6
+ website][2]
7
+
8
+ The signatures are stored in a YAML file in the following format:
9
+
10
+ ```yaml
11
+ - mime: 'application/pdf'
12
+ extensions:
13
+ - 'pdf'
14
+ signatures:
15
+ starting:
16
+ offset: 0
17
+ hexcodes:
18
+ - '25504446'
19
+ trailing:
20
+ offset: 0
21
+ hexcodes:
22
+ - '0a2525454f46'
23
+ - '0a2525454f460a'
24
+ - '0d0a2525454f460d0a'
25
+ - '0d2525454f460d'
26
+ ```
27
+
28
+ * The files typically have a `starting` and a `trailing` signatures.
29
+ * The `offset` part is the number of bytes to ignore from the beginning
30
+ in the case of starting signature and from the end in case of trailing
31
+ signature. This will be a number.
32
+ * `hexcodes` key holds a list of possible signatures. The validation
33
+ logic takes into account all the signatures and it will be a `true`
34
+ case if the file has any one of the specified signatures.
35
+
36
+ If a new signature has to be added, then the details have to be
37
+ specified in the same manner.
38
+
39
+ [2]: http://www.garykessler.net/library/file_sigs.html
40
+
41
+ ## Installation
42
+
43
+ Add this line to your application's Gemfile:
44
+
45
+ ```ruby
46
+ gem 'filemagick-signatures'
47
+ ```
48
+
49
+ And then execute:
50
+
51
+ $ bundle
52
+
53
+ Or install it yourself as:
54
+
55
+ $ gem install filemagick-signatures
56
+
57
+ ## Usage
58
+
59
+
60
+ ## Contributing
61
+
62
+ 1. Fork it ( https://github.com/[my-github-username]/filemagick-signatures/fork )
63
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
64
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
65
+ 4. Push to the branch (`git push origin my-new-feature`)
66
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,54 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "filemagick-signatures"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["Kashyap"]
9
+ spec.email = ["kashyap.kmbc@gmail.com"]
10
+ spec.summary = %q{
11
+ This module contains the signatures for use either independently or via the
12
+ `filemagick` gem. The various file signatures currently supported are taken
13
+ from [Gary Kessler's website][http://www.garykessler.net/library/file_sigs.html]
14
+ }
15
+ spec.description = %q{
16
+
17
+ This module contains the signatures for use either independently or via the
18
+ `filemagick` gem. The various file signatures currently supported are taken
19
+ from [Gary Kessler's website][http://www.garykessler.net/library/file_sigs.html]
20
+
21
+
22
+ The signatures are stored in a YAML file in the following format:
23
+
24
+ ```yaml
25
+ - mime: 'application/pdf'
26
+ extensions:
27
+ - 'pdf'
28
+ signatures:
29
+ starting:
30
+ offset: 0
31
+ hexcodes:
32
+ - '25504446'
33
+ trailing:
34
+ offset: 0
35
+ hexcodes:
36
+ - '0a2525454f46'
37
+ - '0a2525454f460a'
38
+ - '0d0a2525454f460d0a'
39
+ - '0d2525454f460d'
40
+ ```
41
+ }
42
+ spec.homepage = ""
43
+ spec.license = "MIT"
44
+
45
+ spec.files = `git ls-files -z`.split("\x0")
46
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
47
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
48
+ spec.require_paths = ["lib"]
49
+
50
+ spec.add_development_dependency 'rspec'
51
+ spec.add_development_dependency "bundler", "~> 1.7"
52
+ spec.add_development_dependency "rake", "~> 10.0"
53
+ spec.add_development_dependency "pry"
54
+ end
@@ -0,0 +1,37 @@
1
+ require 'yaml'
2
+ require 'singleton'
3
+
4
+ module Filemagick
5
+ class Signatures
6
+
7
+ SIGNATURES_FILE = ::File.expand_path('../signatures.yml', __FILE__)
8
+ attr_reader :signatures, :known_extensions, :known_mime_types
9
+ include ::Singleton
10
+
11
+ def known_mime_types
12
+ read_signatures_file!
13
+
14
+ @known_mime_types ||= @signatures.map { |sig| sig['mime'] }
15
+ end
16
+
17
+ def known_extensions
18
+ read_signatures_file!
19
+
20
+ @known_extensions ||= @signatures.map do |sig|
21
+ sig['extensions']
22
+ end.flatten
23
+ end
24
+
25
+ def signatures
26
+ read_signatures_file!
27
+
28
+ @signatures
29
+ end
30
+
31
+ private
32
+
33
+ def read_signatures_file!
34
+ @signatures ||= YAML.load_file SIGNATURES_FILE
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,398 @@
1
+ ---
2
+ - mime: 'application/pdf'
3
+ extensions:
4
+ - 'pdf'
5
+ signatures:
6
+ starting:
7
+ offset: 0
8
+ hexcodes:
9
+ - '25504446'
10
+ trailing:
11
+ offset: 0
12
+ hexcodes:
13
+ - '0a2525454f46'
14
+ - '0a2525454f460a'
15
+ - '0d0a2525454f460d0a'
16
+ - '0d2525454f460d'
17
+
18
+ - mime: 'image/jpeg'
19
+ extensions:
20
+ - 'jpg'
21
+ - 'jpeg'
22
+ - 'jfif'
23
+ - 'jpe'
24
+ signatures:
25
+ starting:
26
+ offset: 0
27
+ hexcodes:
28
+ - 'ffd8ffe0xxxx4a46494600'
29
+ trailing:
30
+ offset: 0
31
+ hexcodes:
32
+ - 'ffd9'
33
+
34
+ - mime: 'image/jpg'
35
+ extensions:
36
+ - 'jp2'
37
+ signatures:
38
+ trailing:
39
+ offset: 0
40
+ hexcodes:
41
+ - '0000000c6a5020200d0a'
42
+ # add 3gp
43
+
44
+ # mp4
45
+ # * iso base media file
46
+ # * mpeg-4 video file
47
+ - mime: ''
48
+ extensions:
49
+ - 'mp4'
50
+ signatures:
51
+ starting:
52
+ offset: 0
53
+ hexcodes:
54
+ - '000000146674797069736f6d'
55
+ - '000000186674797033677035'
56
+
57
+ # quicktime movie
58
+ - mime: ''
59
+ extensions:
60
+ - 'mov'
61
+ signatures:
62
+ starting:
63
+ offset: 0
64
+ hexcodes:
65
+ - '000000146674797071742020'
66
+
67
+ # m4v mpeg-4 video/quicktime file
68
+ - mime: ''
69
+ extensions:
70
+ - 'm4v'
71
+ signatures:
72
+ starting:
73
+ offset: 0
74
+ hexcodes:
75
+ - '00000018667479706d703432'
76
+
77
+ # mp4 mpeg-4 video file
78
+ - mime: ''
79
+ extensions:
80
+ - 'mp4'
81
+ signatures:
82
+ starting:
83
+ offset: 0
84
+ hexcodes:
85
+ - '0000001c667479704d534e56012900464d534e566d703432'
86
+
87
+ # m4a apple lossless audio codec file
88
+ - mime: ''
89
+ extensions:
90
+ - 'm4a'
91
+ signatures:
92
+ starting:
93
+ offset: 0
94
+ hexcodes:
95
+ - '00000020667479704d344120'
96
+
97
+ # UTF-16
98
+ - mime: ''
99
+ extensions:
100
+ - 'txt'
101
+ signatures:
102
+ starting:
103
+ offset: 0
104
+ hexcodes:
105
+ - '0000feff'
106
+
107
+ # True type fonts
108
+ - mime: ''
109
+ extensions:
110
+ - 'ttf'
111
+ signatures:
112
+ starting:
113
+ offset: 0
114
+ hexcodes:
115
+ - '0001000000'
116
+
117
+ # MS powerpoint
118
+ - mime: ''
119
+ extensions:
120
+ - 'ppt'
121
+ signatures:
122
+ starting:
123
+ offset: 512
124
+ hexcodes:
125
+ - '006E1EF0'
126
+ - '0F00E803'
127
+
128
+ # DRW file
129
+ - mime: ''
130
+ extensions:
131
+ - 'drw'
132
+ signatures:
133
+ starting:
134
+ offset: 0
135
+ hexcodes:
136
+ - '07'
137
+
138
+ # Excel file
139
+ - mime: ''
140
+ extensions:
141
+ - 'xls'
142
+ signatures:
143
+ starting:
144
+ offset: 512
145
+ hexcodes:
146
+ - '0908100000060500'
147
+
148
+ # Deskmate document file
149
+ - mime: ''
150
+ extensions:
151
+ - 'doc'
152
+ signatures:
153
+ starting:
154
+ offset: 0
155
+ hexcodes:
156
+ - '0d444f43'
157
+
158
+ # WebM video file
159
+ - mime: ''
160
+ extensions:
161
+ - 'webm'
162
+ signatures:
163
+ starting:
164
+ offset: 0
165
+ hexcodes:
166
+ - '1a45dfa3'
167
+
168
+ # Matroska stream file
169
+ - mime: ''
170
+ extensions:
171
+ - 'mkv'
172
+ signatures:
173
+ starting:
174
+ offset: 0
175
+ hexcodes:
176
+ - '45dfa3934282886d6174726f736b61'
177
+
178
+ # GZIP, VLC skin file
179
+ - mime: ''
180
+ extensions:
181
+ - 'gz'
182
+ - 'tgz'
183
+ - 'vlt'
184
+ signatures:
185
+ starting:
186
+ offset: 0
187
+ hexcodes:
188
+ - '1f8b08'
189
+
190
+ # TAR file
191
+ - mime: ''
192
+ extensions:
193
+ - 'tar'
194
+ signatures:
195
+ starting:
196
+ offset: 0
197
+ hexcodes:
198
+ - '1f9d'
199
+ - '1fA0'
200
+
201
+ # EPS
202
+ - mime: ''
203
+ extensions:
204
+ - 'eps'
205
+ signatures:
206
+ starting:
207
+ offset: 0
208
+ hexcodes:
209
+ - '252150532d41646f62652d332e3020455053462d332030'
210
+
211
+ # PDF
212
+ - mime: ''
213
+ extensions:
214
+ - 'pdf'
215
+ signatures:
216
+ starting:
217
+ offset: 0
218
+ hexcodes:
219
+ - '38425053'
220
+
221
+ # XUL file
222
+ - mime: ''
223
+ extensions:
224
+ - 'xul'
225
+ signatures:
226
+ starting:
227
+ offset: 0
228
+ hexcodes:
229
+ - '3c3f786d6c2076657273696f6e3d22312e30223f3e'
230
+
231
+ # Generic AutoCAD drawing
232
+ - mime: ''
233
+ extensions:
234
+ - 'dwg'
235
+ signatures:
236
+ starting:
237
+ offset: 0
238
+ hexcodes:
239
+ - '41433130'
240
+
241
+ # VCF vCard file
242
+ - mime: ''
243
+ extensions:
244
+ - 'vcf'
245
+ signatures:
246
+ starting:
247
+ offset: 0
248
+ hexcodes:
249
+ - '424547494E3A56434152440D0A'
250
+
251
+ # Bzip
252
+ - mime: ''
253
+ extensions:
254
+ - 'bz2'
255
+ - 'tar.bz2'
256
+ - 'tbz2'
257
+ - 'tb2'
258
+ signatures:
259
+ starting:
260
+ offset: 0
261
+ hexcodes:
262
+ - '425a68'
263
+
264
+ # ISO image
265
+ - mime: ''
266
+ extensions:
267
+ - 'iso'
268
+ signatures:
269
+ starting:
270
+ offset: 0
271
+ hexcodes:
272
+ - '4344303031'
273
+
274
+ # SWF file
275
+ - mime: ''
276
+ extensions:
277
+ - 'swf'
278
+ signatures:
279
+ starting:
280
+ offset: 0
281
+ hexcodes:
282
+ - '435753'
283
+ - '465753'
284
+
285
+ # GIF
286
+ - mime: ''
287
+ extensions:
288
+ - 'gif'
289
+ signatures:
290
+ starting:
291
+ offset: 0
292
+ hexcodes:
293
+ - '474946383761'
294
+ - '474946383961'
295
+ trailing:
296
+ offset: 0
297
+ hexcodes:
298
+ - '003b'
299
+
300
+ # TIFF
301
+ - mime: ''
302
+ extensions:
303
+ - 'tif'
304
+ - 'tiff'
305
+ signatures:
306
+ starting:
307
+ offset: 0
308
+ hexcodes:
309
+ - '492049'
310
+ - '49492a00'
311
+ - '4d4d002a'
312
+ - '4d4d002b'
313
+
314
+ # MP3
315
+ - mime: ''
316
+ extensions:
317
+ - 'mp3'
318
+ signatures:
319
+ starting:
320
+ offset: 0
321
+ hexcodes:
322
+ - '494433'
323
+
324
+ # DOS executables
325
+ - mime: ''
326
+ extensions:
327
+ - 'com'
328
+ - 'dll'
329
+ - 'drv'
330
+ - 'exe'
331
+ - 'pif'
332
+ - 'qts'
333
+ - 'qtx'
334
+ - 'sys'
335
+ - 'acm'
336
+ - 'ax'
337
+ - 'cpl'
338
+ - 'fon'
339
+ - 'ocx'
340
+ - 'olb'
341
+ - 'scr'
342
+ - 'vbx'
343
+ signatures:
344
+ starting:
345
+ offset: 0
346
+ hexcodes:
347
+ - '4d5a'
348
+
349
+ # ZIP
350
+ - mime: ''
351
+ extensions:
352
+ - 'zip'
353
+ - 'jar'
354
+ - 'kmz'
355
+ - 'kwd'
356
+ - 'odt'
357
+ - 'odp'
358
+ - 'ott'
359
+ - 'sxc'
360
+ - 'sxd'
361
+ - 'sxi'
362
+ - 'sxw'
363
+ - 'sxc'
364
+ - 'wmz'
365
+ - 'xpi'
366
+ - 'xps'
367
+ - 'xpt'
368
+ signatures:
369
+ starting:
370
+ offset: 0
371
+ hexcodes:
372
+ - '504b030414000100630000000000'
373
+
374
+ # EPUB
375
+ - mime: ''
376
+ extensions:
377
+ - 'epub'
378
+ signatures:
379
+ starting:
380
+ offset: 0
381
+ hexcodes:
382
+ - '504b03040a000200'
383
+
384
+ # DOCX
385
+ - mime: ''
386
+ extensions:
387
+ - 'docx'
388
+ - 'pptx'
389
+ - 'xlsx'
390
+ signatures:
391
+ starting:
392
+ offset: 0
393
+ hexcodes:
394
+ - '504b030414000600'
395
+ trailing:
396
+ offset: 18
397
+ hexcodes:
398
+ - '504b0506'
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: filemagick-signatures
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kashyap
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: |2
70
+
71
+
72
+ This module contains the signatures for use either independently or via the
73
+ `filemagick` gem. The various file signatures currently supported are taken
74
+ from [Gary Kessler's website][http://www.garykessler.net/library/file_sigs.html]
75
+
76
+
77
+ The signatures are stored in a YAML file in the following format:
78
+
79
+ ```yaml
80
+ - mime: 'application/pdf'
81
+ extensions:
82
+ - 'pdf'
83
+ signatures:
84
+ starting:
85
+ offset: 0
86
+ hexcodes:
87
+ - '25504446'
88
+ trailing:
89
+ offset: 0
90
+ hexcodes:
91
+ - '0a2525454f46'
92
+ - '0a2525454f460a'
93
+ - '0d0a2525454f460d0a'
94
+ - '0d2525454f460d'
95
+ ```
96
+ email:
97
+ - kashyap.kmbc@gmail.com
98
+ executables: []
99
+ extensions: []
100
+ extra_rdoc_files: []
101
+ files:
102
+ - ".gitignore"
103
+ - Gemfile
104
+ - LICENSE.txt
105
+ - README.md
106
+ - Rakefile
107
+ - filemagick-signatures.gemspec
108
+ - lib/filemagick/signatures.rb
109
+ - lib/filemagick/signatures.yml
110
+ homepage: ''
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.2.2
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: This module contains the signatures for use either independently or via the
134
+ `filemagick` gem. The various file signatures currently supported are taken from
135
+ [Gary Kessler's website][http://www.garykessler.net/library/file_sigs.html]
136
+ test_files: []