firefox_zip 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.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.travis.yml +2 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +32 -0
- data/README.md +34 -0
- data/Rakefile +5 -0
- data/example/example.rb +12 -0
- data/example/hello.zip +0 -0
- data/firefox_zip.gemspec +21 -0
- data/lib/firefox_zip/files/project.rb +88 -0
- data/lib/firefox_zip/parses/manifest.rb +21 -0
- data/lib/firefox_zip/version.rb +3 -0
- data/lib/firefox_zip.rb +21 -0
- data/spec/firefox_zip/files/project_spec.rb +28 -0
- data/spec/firefox_zip/parses/manifest_spec.rb +47 -0
- data/spec/firefox_zip_spec.rb +41 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/test_files/hello.zip +0 -0
- data/spec/test_files/manifest.webapp +13 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fb14ca881dc2fe92525c56b0d4b843dbc4f995c1
|
4
|
+
data.tar.gz: 2af2a48c5c42c9595e5648763fff115d1d397a3c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d509d45bd2501389ddd80d039aaf8058f4d7e4b9b664c53a10cb3c7897774d6a0293a53376d87a55910366e99ee354cd16d0e83ccd44ab7d419ae5216ac990cb
|
7
|
+
data.tar.gz: 6cda3a0e5aba0e643915bd27911213d8c9549f898e7ec0b1efd63fe83ec4c5ca7ec3f315c404bd1acf1e6521c4e059a2cb2aedf17a233d0c693c0a380b1109d3
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
firefox_zip (0.0.0)
|
5
|
+
rubyzip
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://production.cf.rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.2.5)
|
11
|
+
rake (10.4.2)
|
12
|
+
rspec (3.1.0)
|
13
|
+
rspec-core (~> 3.1.0)
|
14
|
+
rspec-expectations (~> 3.1.0)
|
15
|
+
rspec-mocks (~> 3.1.0)
|
16
|
+
rspec-core (3.1.7)
|
17
|
+
rspec-support (~> 3.1.0)
|
18
|
+
rspec-expectations (3.1.2)
|
19
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
20
|
+
rspec-support (~> 3.1.0)
|
21
|
+
rspec-mocks (3.1.3)
|
22
|
+
rspec-support (~> 3.1.0)
|
23
|
+
rspec-support (3.1.2)
|
24
|
+
rubyzip (1.1.6)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
firefox_zip!
|
31
|
+
rake
|
32
|
+
rspec (~> 3.1.0)
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Firefox Zip
|
2
|
+
[](https://travis-ci.org/henteko/firefox_zip)
|
3
|
+
|
4
|
+
This gem library is Firefox os application package file (.zip) analyzer. you can read any information of zip files.
|
5
|
+
|
6
|
+
## Install
|
7
|
+
|
8
|
+
```sh
|
9
|
+
$ gem install firefox_zip
|
10
|
+
|
11
|
+
# or
|
12
|
+
|
13
|
+
gem 'firefox_zip'
|
14
|
+
$ bundle install
|
15
|
+
```
|
16
|
+
|
17
|
+
## How to use
|
18
|
+
|
19
|
+
```rb
|
20
|
+
require 'firefox_zip'
|
21
|
+
|
22
|
+
app = FirefoxZip.analyze('/path/to/firefox_app.zip')
|
23
|
+
|
24
|
+
app.name # [String] app name
|
25
|
+
app.description # [String] app description
|
26
|
+
app.launch_path # [String] app launch path
|
27
|
+
app.icon # [File] app default icon
|
28
|
+
app.icons # [Array] app icons
|
29
|
+
app.type # [String] app type
|
30
|
+
app.permissions # [Array] app permissons
|
31
|
+
```
|
32
|
+
|
33
|
+
## License
|
34
|
+
MIT
|
data/Rakefile
ADDED
data/example/example.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'firefox_zip'
|
2
|
+
|
3
|
+
app = FirefoxZip.analyze(File.expand_path('../hello.zip', __FILE__))
|
4
|
+
|
5
|
+
p app.name # [String] app name
|
6
|
+
p app.description # [String] app description
|
7
|
+
p app.launch_path # [String] app launch path
|
8
|
+
p app.icon # [File] app default icon
|
9
|
+
p app.icons # [Array] app icons
|
10
|
+
p app.type # [String] app type
|
11
|
+
p app.permissions # [Array] app permissons
|
12
|
+
|
data/example/hello.zip
ADDED
Binary file
|
data/firefox_zip.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'firefox_zip/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'firefox_zip'
|
7
|
+
s.version = FirefoxZip::VERSION
|
8
|
+
s.summary = "Firefox os app analyzer"
|
9
|
+
s.authors = ["henteko"]
|
10
|
+
s.email = 'henteko07@gmail.com'
|
11
|
+
s.homepage = 'https://github.com/henteko/firefox_zip'
|
12
|
+
s.license = 'MIT'
|
13
|
+
|
14
|
+
s.files = `git ls-files -z`.split("\x0")
|
15
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
|
18
|
+
s.add_dependency "rubyzip"
|
19
|
+
s.add_development_dependency "rake"
|
20
|
+
s.add_development_dependency "rspec", "~> 3.1.0"
|
21
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'tmpdir'
|
2
|
+
require 'zip'
|
3
|
+
|
4
|
+
module FirefoxZip
|
5
|
+
module Files
|
6
|
+
class Project
|
7
|
+
attr_reader :manifest_data, :icon, :icons
|
8
|
+
MANIFEST_FILE_NAME = 'manifest.webapp'
|
9
|
+
|
10
|
+
def initialize(zip_file_path)
|
11
|
+
return raise 'not zip file' unless File.exists? zip_file_path
|
12
|
+
|
13
|
+
@zip_file_path = zip_file_path
|
14
|
+
|
15
|
+
Dir.mktmpdir do |dir|
|
16
|
+
project_dir_name = get_root_dir_name(@zip_file_path)
|
17
|
+
make_zip_files(@zip_file_path, dir)
|
18
|
+
|
19
|
+
manifest_file = get_manifest_file(dir, project_dir_name)
|
20
|
+
@manifest_data = FirefoxZip::Parses::Manifest.new(manifest_file.read)
|
21
|
+
manifest_file.close
|
22
|
+
@icons = get_icons_file(@manifest_data, dir, project_dir_name)
|
23
|
+
@icon = get_icon_file(@manifest_data, dir, project_dir_name)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def get_root_dir_name(file_path)
|
30
|
+
Zip::File.open(file_path) do |zip_file|
|
31
|
+
return zip_file.first.name
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def make_zip_files(file_path, dir)
|
36
|
+
Zip::File.open(file_path) do |zip_file|
|
37
|
+
zip_file.each do |entry|
|
38
|
+
path = "#{dir}/#{entry.name}"
|
39
|
+
|
40
|
+
# dir 作成
|
41
|
+
if dir?(path) && !File.exists?(path)
|
42
|
+
FileUtils.mkdir_p(path)
|
43
|
+
next
|
44
|
+
end
|
45
|
+
|
46
|
+
file = File.open(path, 'w')
|
47
|
+
file.write(entry.get_input_stream.read)
|
48
|
+
file.close
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def dir?(entry_name)
|
54
|
+
entry_name.match(/.+\/$/) != nil
|
55
|
+
end
|
56
|
+
|
57
|
+
def get_manifest_file(dir, project_dir_name)
|
58
|
+
File.open("#{dir}/#{project_dir_name}/#{MANIFEST_FILE_NAME}", 'r')
|
59
|
+
end
|
60
|
+
|
61
|
+
def get_icon_file(manifest_data, dir, project_dir_name)
|
62
|
+
get_file(dir, project_dir_name, manifest_data.icon)
|
63
|
+
end
|
64
|
+
|
65
|
+
def get_icons_file(manifest_data, dir, project_dir_name)
|
66
|
+
icons = manifest_data.icons
|
67
|
+
|
68
|
+
icons_file = []
|
69
|
+
icons.each do |icon|
|
70
|
+
icon_size = icon[0]
|
71
|
+
icon_file_name = icon[1]
|
72
|
+
icon_file_name.slice!(0) # 先頭の/を削除
|
73
|
+
|
74
|
+
icons_file.push({
|
75
|
+
:size => icon_size,
|
76
|
+
:file => get_file(dir, project_dir_name, icon_file_name)
|
77
|
+
})
|
78
|
+
end
|
79
|
+
|
80
|
+
icons_file
|
81
|
+
end
|
82
|
+
|
83
|
+
def get_file(dir, project_dir_name, target_file_name)
|
84
|
+
File.open("#{dir}/#{project_dir_name}#{target_file_name}", 'r')
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module FirefoxZip
|
4
|
+
module Parses
|
5
|
+
class Manifest
|
6
|
+
attr_reader :name, :description, :launch_path, :icons, :icon, :type, :permissions
|
7
|
+
|
8
|
+
def initialize(manifest_data)
|
9
|
+
data = JSON.parse(manifest_data)
|
10
|
+
|
11
|
+
@name = data['name']
|
12
|
+
@description = data['description']
|
13
|
+
@launch_path = data['launch_path']
|
14
|
+
@icons = data['icons']
|
15
|
+
@icon = data['icons']['16']
|
16
|
+
@type = data['type']
|
17
|
+
@permissions = data['permissions']
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/firefox_zip.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'firefox_zip/parses/manifest'
|
2
|
+
require 'firefox_zip/files/project'
|
3
|
+
|
4
|
+
module FirefoxZip
|
5
|
+
class << self
|
6
|
+
attr_reader :name, :description, :launch_path, :icons, :icon, :type, :permissions
|
7
|
+
|
8
|
+
def analyze(file_path)
|
9
|
+
project = Files::Project.new(file_path)
|
10
|
+
@name = project.manifest_data.name
|
11
|
+
@description = project.manifest_data.description
|
12
|
+
@launch_path = project.manifest_data.launch_path
|
13
|
+
@icons = project.icons
|
14
|
+
@icon = project.icon
|
15
|
+
@type = project.manifest_data.type
|
16
|
+
@permissions = project.manifest_data.permissions
|
17
|
+
|
18
|
+
self
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FirefoxZip::Files::Project do
|
4
|
+
context 'initialize' do
|
5
|
+
before do
|
6
|
+
@project = FirefoxZip::Files::Project.new(File.expand_path('../../../test_files/hello.zip', __FILE__))
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'get manifest data' do
|
10
|
+
expect(@project.manifest_data).not_to be_nil
|
11
|
+
expect(@project.manifest_data.class).to eq FirefoxZip::Parses::Manifest
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'get icon' do
|
15
|
+
expect(@project.icon).not_to be_nil
|
16
|
+
expect(@project.icon.class).to eq File
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'get icons' do
|
20
|
+
expect(@project.icons).not_to be_nil
|
21
|
+
expect(@project.icons.class).to eq Array
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'nil' do
|
25
|
+
expect{ FirefoxZip::Files::Project.new(File.expand_path('nil', __FILE__)) }.to raise_error
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FirefoxZip::Parses::Manifest do
|
4
|
+
context 'initialize' do
|
5
|
+
before do
|
6
|
+
file = File.open(File.expand_path('../../../test_files/manifest.webapp', __FILE__), 'r')
|
7
|
+
@manifest = FirefoxZip::Parses::Manifest.new(file.read)
|
8
|
+
|
9
|
+
file.close
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'get name' do
|
13
|
+
expect(@manifest.name).to eq 'hello'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'get description' do
|
17
|
+
expect(@manifest.description).to eq 'A Hello World app'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'get launch_path' do
|
21
|
+
expect(@manifest.launch_path).to eq '/index.html'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'get icons' do
|
25
|
+
expect(@manifest.icons).to include("16" => "/icons/icon16x16.png",
|
26
|
+
"48" => "/icons/icon48x48.png",
|
27
|
+
"60" => "/icons/icon60x60.png",
|
28
|
+
"128" => "/icons/icon128x128.png")
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'get icon' do
|
32
|
+
expect(@manifest.icon).to eq "/icons/icon16x16.png"
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'get type' do
|
36
|
+
expect(@manifest.type).to eq 'privileged'
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'get permissions' do
|
40
|
+
expect(@manifest.permissions).to match []
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'blank' do
|
44
|
+
expect{ FirefoxZip::Parses::Manifest.new('') }.to raise_error
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FirefoxZip do
|
4
|
+
context 'self.analyze' do
|
5
|
+
before do
|
6
|
+
@app = FirefoxZip.analyze(File.expand_path('../test_files/hello.zip', __FILE__))
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'get name' do
|
10
|
+
expect(@app.name).to eq 'hello'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'get description' do
|
14
|
+
expect(@app.description).to eq 'A Hello World app'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'get launch_path' do
|
18
|
+
expect(@app.launch_path).to eq '/index.html'
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'get icons' do
|
22
|
+
expect(@app.icons).not_to be_nil
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'get icon' do
|
26
|
+
expect(@app.icon).not_to be_nil
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'get type' do
|
30
|
+
expect(@app.type).to eq 'privileged'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'get permissions' do
|
34
|
+
expect(@app.permissions).to match []
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'raise' do
|
38
|
+
expect{ FirefoxZip.analyze('') }.to raise_error
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/spec/spec_helper.rb
ADDED
Binary file
|
@@ -0,0 +1,13 @@
|
|
1
|
+
{
|
2
|
+
"name": "hello",
|
3
|
+
"description": "A Hello World app",
|
4
|
+
"launch_path": "/index.html",
|
5
|
+
"icons": {
|
6
|
+
"16": "/icons/icon16x16.png",
|
7
|
+
"48": "/icons/icon48x48.png",
|
8
|
+
"60": "/icons/icon60x60.png",
|
9
|
+
"128": "/icons/icon128x128.png"
|
10
|
+
},
|
11
|
+
"type": "privileged",
|
12
|
+
"permissions": {}
|
13
|
+
}
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: firefox_zip
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- henteko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubyzip
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
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: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.1.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.1.0
|
55
|
+
description:
|
56
|
+
email: henteko07@gmail.com
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- ".gitignore"
|
62
|
+
- ".travis.yml"
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- example/example.rb
|
68
|
+
- example/hello.zip
|
69
|
+
- firefox_zip.gemspec
|
70
|
+
- lib/firefox_zip.rb
|
71
|
+
- lib/firefox_zip/files/project.rb
|
72
|
+
- lib/firefox_zip/parses/manifest.rb
|
73
|
+
- lib/firefox_zip/version.rb
|
74
|
+
- spec/firefox_zip/files/project_spec.rb
|
75
|
+
- spec/firefox_zip/parses/manifest_spec.rb
|
76
|
+
- spec/firefox_zip_spec.rb
|
77
|
+
- spec/spec_helper.rb
|
78
|
+
- spec/test_files/hello.zip
|
79
|
+
- spec/test_files/manifest.webapp
|
80
|
+
homepage: https://github.com/henteko/firefox_zip
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.2.2
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: Firefox os app analyzer
|
104
|
+
test_files:
|
105
|
+
- spec/firefox_zip/files/project_spec.rb
|
106
|
+
- spec/firefox_zip/parses/manifest_spec.rb
|
107
|
+
- spec/firefox_zip_spec.rb
|
108
|
+
- spec/spec_helper.rb
|
109
|
+
- spec/test_files/hello.zip
|
110
|
+
- spec/test_files/manifest.webapp
|