Skip to content

Commit

Permalink
Merge pull request #151 from fkie-cad/debian-package-unpacker
Browse files Browse the repository at this point in the history
Debian package unpacker
  • Loading branch information
Peter Weidenbach authored Aug 1, 2018
2 parents 976606d + d8e1fbe commit 061f5e1
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 0 deletions.
Empty file.
Empty file.
18 changes: 18 additions & 0 deletions src/plugins/unpacking/deb/code/deb.py
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 added src/plugins/unpacking/deb/test/data/test.deb
Binary file not shown.
17 changes: 17 additions & 0 deletions src/plugins/unpacking/deb/test/test_deb.py
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'])

0 comments on commit 061f5e1

Please sign in to comment.