-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from fkie-cad/debian-package-unpacker
Debian package unpacker
- Loading branch information
Showing
6 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
''' | ||
This plugin unpacks debian packages | ||
''' | ||
from common_helper_process import execute_shell_command | ||
|
||
name = 'Deb' | ||
mime_patterns = ['application/vnd.debian.binary-package'] | ||
version = '0.1' | ||
|
||
|
||
def unpack_function(file_path, tmp_dir): | ||
return {'output': execute_shell_command('fakeroot dpkg-deb -v -x {} {}'.format(file_path, tmp_dir))} | ||
|
||
|
||
# ----> Do not edit below this line <---- | ||
def setup(unpack_tool): | ||
for item in mime_patterns: | ||
unpack_tool.register_plugin(item, (unpack_function, name, version)) |
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
from test.unit.unpacker.test_unpacker import TestUnpackerBase | ||
|
||
|
||
TEST_DATA_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data') | ||
|
||
|
||
class TestDebUnpacker(TestUnpackerBase): | ||
|
||
def test_unpacker_selection_generic(self): | ||
self.check_unpacker_selection('application/vnd.debian.binary-package', 'Deb') | ||
|
||
def test_extraction(self): | ||
files, meta_data = self.unpacker.extract_files_from_file(os.path.join(TEST_DATA_DIR, 'test.deb'), self.tmp_dir.name) | ||
|
||
self.assertEqual(len(files), 3, 'file number incorrect') | ||
self.assertIn('./usr/bin/test_elf_sfx', meta_data['output']) |