diff options
| -rw-r--r-- | lib/FORMATS | 94 | ||||
| -rw-r--r-- | lib/__init__.py (renamed from mat/__init__.py) | 0 | ||||
| -rw-r--r-- | lib/archive.py (renamed from mat/archive.py) | 0 | ||||
| -rw-r--r-- | lib/audio.py (renamed from mat/audio.py) | 0 | ||||
| -rw-r--r-- | lib/bencode/__init__.py (renamed from mat/bencode/__init__.py) | 0 | ||||
| -rw-r--r-- | lib/bencode/bencode.py (renamed from mat/bencode/bencode.py) | 0 | ||||
| -rw-r--r-- | lib/exiftool.py (renamed from mat/exiftool.py) | 0 | ||||
| -rw-r--r-- | lib/hachoir_editor/__init__.py (renamed from mat/hachoir_editor/__init__.py) | 0 | ||||
| -rw-r--r-- | lib/hachoir_editor/field.py (renamed from mat/hachoir_editor/field.py) | 0 | ||||
| -rw-r--r-- | lib/hachoir_editor/fieldset.py (renamed from mat/hachoir_editor/fieldset.py) | 0 | ||||
| -rw-r--r-- | lib/hachoir_editor/typed_field.py (renamed from mat/hachoir_editor/typed_field.py) | 0 | ||||
| -rw-r--r-- | lib/images.py (renamed from mat/images.py) | 0 | ||||
| -rw-r--r-- | lib/mat.py (renamed from mat/mat.py) | 0 | ||||
| -rw-r--r-- | lib/misc.py (renamed from mat/misc.py) | 0 | ||||
| -rw-r--r-- | lib/office.py (renamed from mat/office.py) | 0 | ||||
| -rw-r--r-- | lib/parser.py (renamed from mat/parser.py) | 0 | ||||
| -rw-r--r-- | lib/strippers.py (renamed from mat/strippers.py) | 0 | ||||
| -rw-r--r-- | lib/tarfile/__init__.py (renamed from mat/tarfile/__init__.py) | 0 | ||||
| -rw-r--r-- | lib/tarfile/tarfile.py (renamed from mat/tarfile/tarfile.py) | 0 | ||||
| -rwxr-xr-x | mat-cli | 161 | ||||
| -rw-r--r-- | mat-cli.1 | 78 | ||||
| -rwxr-xr-x | mat-gui | 4 | ||||
| l--------- | mat-gui.1 | 2 | ||||
| -rwxr-xr-x | setup.py | 8 | ||||
| -rw-r--r-- | test/clitest.py | 20 | ||||
| -rw-r--r-- | test/libtest.py | 2 |
26 files changed, 112 insertions, 257 deletions
diff --git a/lib/FORMATS b/lib/FORMATS new file mode 100644 index 0000000..c497524 --- /dev/null +++ b/lib/FORMATS | |||
| @@ -0,0 +1,94 @@ | |||
| 1 | <xml> | ||
| 2 | <format> | ||
| 3 | <name>Portable Network Graphics</name> | ||
| 4 | <extension>.png</extension> | ||
| 5 | <support>full</support> | ||
| 6 | <metadata>textual metadata + date</metadata> | ||
| 7 | <method>removal of harmful fields is done with hachoir</method> | ||
| 8 | </format> | ||
| 9 | |||
| 10 | <format> | ||
| 11 | <name>Jpeg</name> | ||
| 12 | <extension>.jpeg, .jpg</extension> | ||
| 13 | <support>full</support> | ||
| 14 | <metadata>comment + exif/photoshop/adobe</metadata> | ||
| 15 | <method>removal of harmful fields is done with hachoir</method> | ||
| 16 | </format> | ||
| 17 | |||
| 18 | <format> | ||
| 19 | <name>Open Document</name> | ||
| 20 | <extension>.odt, .odx, .ods, ...</extension> | ||
| 21 | <support>full</support> | ||
| 22 | <metadata>a meta.xml file</metadata> | ||
| 23 | <method>removal of the meta.xml file</method> | ||
| 24 | </format> | ||
| 25 | |||
| 26 | <format> | ||
| 27 | <name>Office Openxml</name> | ||
| 28 | <extension>.docx, .pptx, .xlsx, ...</extension> | ||
| 29 | <support>full</support> | ||
| 30 | <metadata>a docProps folder containings xml metadata files</metadata> | ||
| 31 | <method>removal of the docProps folder</method> | ||
| 32 | </format> | ||
| 33 | |||
| 34 | <format> | ||
| 35 | <name>Portable Document Fileformat</name> | ||
| 36 | <extension>.pdf</extension> | ||
| 37 | <support>full</support> | ||
| 38 | <metadata>a lot</metadata> | ||
| 39 | <method>rendering of the pdf file on a cairo surface with the help of | ||
| 40 | poppler in order to remove all the internal metadata, | ||
| 41 | then removal of the remaining metadata fields of the pdf itself with | ||
| 42 | pdfrw (the next version of python-cairo will support metadata, | ||
| 43 | so we should get rid of pdfrw)</method> | ||
| 44 | </format> | ||
| 45 | |||
| 46 | <format> | ||
| 47 | <name>Tape ARchive</name> | ||
| 48 | <extension>.tar, .tar.bz2, .tar.gz</extension> | ||
| 49 | <support>full</support> | ||
| 50 | <metadata>metadata from the file itself, metadata from the file contained | ||
| 51 | into the archive, and metadata added by tar to the file at then | ||
| 52 | creation of the archive</metadata> | ||
| 53 | <method>extraction of each file, treatement of the file, add treated file | ||
| 54 | to a new archive, right before the add, remove the metadata added by tar | ||
| 55 | itself. When the new archive is complete, remove all his metadata.</method> | ||
| 56 | </format> | ||
| 57 | |||
| 58 | <format> | ||
| 59 | <name>Zip</name> | ||
| 60 | <extension>.zip</extension> | ||
| 61 | <support>.partial</support> | ||
| 62 | <metadata>metadata from the file itself, metadata from the file contained | ||
| 63 | into the archive, and metadata added by zip to the file when added to | ||
| 64 | the archive. | ||
| 65 | </metadata> | ||
| 66 | <method>extraction of each file, treatement of the file, add treated file | ||
| 67 | to a new archive. When the new archive is complete, remove all his metadata</method> | ||
| 68 | <remaining>metadata added by zip itself to internal files</remaining> | ||
| 69 | </format> | ||
| 70 | |||
| 71 | <format> | ||
| 72 | <name>MPEG Audio</name> | ||
| 73 | <extension>.mp3, .mp2, .mp1</extension> | ||
| 74 | <support>full</support> | ||
| 75 | <metadata>id3</metadata> | ||
| 76 | <method>removal of harmful fields is done with hachoir</method> | ||
| 77 | </format> | ||
| 78 | |||
| 79 | <format> | ||
| 80 | <name>Ogg Vorbis</name> | ||
| 81 | <extension>.ogg</extension> | ||
| 82 | <support>full</support> | ||
| 83 | <metadata>Vorbis</metadata> | ||
| 84 | <method>removal of harmful fields is done with mutagen</method> | ||
| 85 | </format> | ||
| 86 | |||
| 87 | <format> | ||
| 88 | <name>Free Lossless Audio Codec</name> | ||
| 89 | <extension>.flac</extension> | ||
| 90 | <support>full</support> | ||
| 91 | <metadata>Flac, Vorbis</metadata> | ||
| 92 | <method>removal of harmful fields is done with mutagen</method> | ||
| 93 | </format> | ||
| 94 | </xml> | ||
diff --git a/mat/__init__.py b/lib/__init__.py index 8b13789..8b13789 100644 --- a/mat/__init__.py +++ b/lib/__init__.py | |||
diff --git a/mat/archive.py b/lib/archive.py index 9993102..9993102 100644 --- a/mat/archive.py +++ b/lib/archive.py | |||
diff --git a/mat/audio.py b/lib/audio.py index ed849ee..ed849ee 100644 --- a/mat/audio.py +++ b/lib/audio.py | |||
diff --git a/mat/bencode/__init__.py b/lib/bencode/__init__.py index 8b13789..8b13789 100644 --- a/mat/bencode/__init__.py +++ b/lib/bencode/__init__.py | |||
diff --git a/mat/bencode/bencode.py b/lib/bencode/bencode.py index 739ffe5..739ffe5 100644 --- a/mat/bencode/bencode.py +++ b/lib/bencode/bencode.py | |||
diff --git a/mat/exiftool.py b/lib/exiftool.py index 758a094..758a094 100644 --- a/mat/exiftool.py +++ b/lib/exiftool.py | |||
diff --git a/mat/hachoir_editor/__init__.py b/lib/hachoir_editor/__init__.py index 1835676..1835676 100644 --- a/mat/hachoir_editor/__init__.py +++ b/lib/hachoir_editor/__init__.py | |||
diff --git a/mat/hachoir_editor/field.py b/lib/hachoir_editor/field.py index 6b1efe3..6b1efe3 100644 --- a/mat/hachoir_editor/field.py +++ b/lib/hachoir_editor/field.py | |||
diff --git a/mat/hachoir_editor/fieldset.py b/lib/hachoir_editor/fieldset.py index a74c8e2..a74c8e2 100644 --- a/mat/hachoir_editor/fieldset.py +++ b/lib/hachoir_editor/fieldset.py | |||
diff --git a/mat/hachoir_editor/typed_field.py b/lib/hachoir_editor/typed_field.py index 0f0427b..0f0427b 100644 --- a/mat/hachoir_editor/typed_field.py +++ b/lib/hachoir_editor/typed_field.py | |||
diff --git a/mat/images.py b/lib/images.py index 3eb3544..3eb3544 100644 --- a/mat/images.py +++ b/lib/images.py | |||
diff --git a/mat/misc.py b/lib/misc.py index d084861..d084861 100644 --- a/mat/misc.py +++ b/lib/misc.py | |||
diff --git a/mat/office.py b/lib/office.py index e1d738e..e1d738e 100644 --- a/mat/office.py +++ b/lib/office.py | |||
diff --git a/mat/parser.py b/lib/parser.py index 6dc5d0b..6dc5d0b 100644 --- a/mat/parser.py +++ b/lib/parser.py | |||
diff --git a/mat/strippers.py b/lib/strippers.py index 7d27874..7d27874 100644 --- a/mat/strippers.py +++ b/lib/strippers.py | |||
diff --git a/mat/tarfile/__init__.py b/lib/tarfile/__init__.py index 8b13789..8b13789 100644 --- a/mat/tarfile/__init__.py +++ b/lib/tarfile/__init__.py | |||
diff --git a/mat/tarfile/tarfile.py b/lib/tarfile/tarfile.py index a40f9fc..a40f9fc 100644 --- a/mat/tarfile/tarfile.py +++ b/lib/tarfile/tarfile.py | |||
diff --git a/mat-cli b/mat-cli deleted file mode 100755 index 1058d46..0000000 --- a/mat-cli +++ /dev/null | |||
| @@ -1,161 +0,0 @@ | |||
| 1 | #!/usr/bin/env python | ||
| 2 | ''' | ||
| 3 | Metadata anonymisation toolkit - CLI edition | ||
| 4 | ''' | ||
| 5 | |||
| 6 | import sys | ||
| 7 | import xml.sax | ||
| 8 | import optparse | ||
| 9 | import os | ||
| 10 | |||
| 11 | import hachoir_core | ||
| 12 | |||
| 13 | from mat import mat | ||
| 14 | |||
| 15 | |||
| 16 | def parse(): | ||
| 17 | ''' | ||
| 18 | Get, and parse options passed to the program | ||
| 19 | ''' | ||
| 20 | parser = optparse.OptionParser(usage='%prog [options] files\n\ | ||
| 21 | The default behaviour is to clean files given in argument') | ||
| 22 | options = optparse.OptionGroup(parser, 'Options') | ||
| 23 | options.add_option('--add2archive', '-a', action='store_true', | ||
| 24 | default=False, help='Add to output archive non-supported filetypes') | ||
| 25 | options.add_option('--backup', '-b', action='store_true', default=False, | ||
| 26 | help='Keep a backup copy') | ||
| 27 | options.add_option('--force', '-f', action='store_true', default=False, | ||
| 28 | help='Don\'t check if files are clean before cleaning') | ||
| 29 | options.add_option('--strict', '-u', action='store_true', default=False, | ||
| 30 | help='Strict cleaning mode : loss can occur') | ||
| 31 | |||
| 32 | info = optparse.OptionGroup(parser, 'Informations') | ||
| 33 | info.add_option('--check', '-c', action='store_true', default=False, | ||
| 34 | help='Check if a file is free of harmful metadatas') | ||
| 35 | info.add_option('--display', '-d', action='store_true', default=False, | ||
| 36 | help='List all the harmful metadata of a file without removing them') | ||
| 37 | info.add_option('--list', '-l', action='store_true', default=False, | ||
| 38 | help='List all supported fileformat') | ||
| 39 | info.add_option('--version', '-v', action='callback', | ||
| 40 | callback=display_version, help='Display version and exit') | ||
| 41 | parser.add_option_group(options) | ||
| 42 | parser.add_option_group(info) | ||
| 43 | |||
| 44 | values, arguments = parser.parse_args() | ||
| 45 | if not arguments and values.list is False: | ||
| 46 | # if no argument and no files are passed, | ||
| 47 | # print help and exit | ||
| 48 | parser.print_help() | ||
| 49 | sys.exit(0) | ||
| 50 | return values, arguments | ||
| 51 | |||
| 52 | |||
| 53 | def display_version(*_): | ||
| 54 | ''' | ||
| 55 | Display the program's version, and exit | ||
| 56 | ''' | ||
| 57 | print('Metadata Anonymisation Toolkit version %s') % mat.__version__ | ||
| 58 | print('Hachoir version %s') % hachoir_core.__version__ | ||
| 59 | sys.exit(0) | ||
| 60 | |||
| 61 | |||
| 62 | def list_meta(class_file, filename, force): | ||
| 63 | ''' | ||
| 64 | Print all the metadata of 'filename' on stdout | ||
| 65 | ''' | ||
| 66 | print('[+] File %s :' % filename) | ||
| 67 | if force is False and class_file.is_clean(): | ||
| 68 | print('No harmful metadata found') | ||
| 69 | else: | ||
| 70 | meta = class_file.get_meta() | ||
| 71 | print ('Harmful metadata found:') | ||
| 72 | if meta is not None: | ||
| 73 | for key, value in class_file.get_meta().iteritems(): | ||
| 74 | print('\t' + key + ' : ' + str(value)) | ||
| 75 | |||
| 76 | |||
| 77 | def is_clean(class_file, filename, force): | ||
| 78 | ''' | ||
| 79 | Say if 'filename' is clean or not | ||
| 80 | ''' | ||
| 81 | if class_file.is_clean(): | ||
| 82 | print('[+] %s is clean' % filename) | ||
| 83 | else: | ||
| 84 | print('[+] %s is not clean' % filename) | ||
| 85 | |||
| 86 | |||
| 87 | def clean_meta(class_file, filename, force): | ||
| 88 | ''' | ||
| 89 | Clean the file 'filename' | ||
| 90 | ''' | ||
| 91 | print('[+] Cleaning %s' % filename) | ||
| 92 | if force is False and class_file.is_clean(): | ||
| 93 | print('%s is already clean' % filename) | ||
| 94 | else: | ||
| 95 | if class_file.remove_all(): | ||
| 96 | print('%s cleaned !' % filename) | ||
| 97 | else: | ||
| 98 | print('Unable to clean %s', filename) | ||
| 99 | |||
| 100 | def clean_meta_strict(class_file, filename, force): | ||
| 101 | ''' | ||
| 102 | Clean the file 'filename', strict way | ||
| 103 | ''' | ||
| 104 | print('[+] Cleaning %s' % filename) | ||
| 105 | if force is False and class_file.is_clean(): | ||
| 106 | print('%s is already clean' % filename) | ||
| 107 | else: | ||
| 108 | class_file.remove_all_strict() | ||
| 109 | print('%s cleaned' % filename) | ||
| 110 | |||
| 111 | |||
| 112 | def list_supported(): | ||
| 113 | ''' | ||
| 114 | Print all supported fileformat, and exit | ||
| 115 | ''' | ||
| 116 | handler = mat.XMLParser() | ||
| 117 | parser = xml.sax.make_parser() | ||
| 118 | parser.setContentHandler(handler) | ||
| 119 | path = os.path.join(mat.get_sharedir(), 'FORMATS') | ||
| 120 | with open(path, 'r') as xmlfile: | ||
| 121 | parser.parse(xmlfile) | ||
| 122 | |||
| 123 | for item in handler.list: | ||
| 124 | print('%s (%s)' % (item['name'], item['extension'])) | ||
| 125 | print('\tsupport : ' + item['support']) | ||
| 126 | print('\tmetadata : ' + item['metadata']) | ||
| 127 | print('\tmethod : ' + item['method']) | ||
| 128 | if item['support'] == 'partial': | ||
| 129 | print('\tremaining : ' + item['remaining']) | ||
| 130 | print('\n') | ||
| 131 | sys.exit(0) | ||
| 132 | |||
| 133 | |||
| 134 | def main(): | ||
| 135 | ''' | ||
| 136 | main function : get args, and launch the appropriate function | ||
| 137 | ''' | ||
| 138 | args, filenames = parse() | ||
| 139 | |||
| 140 | #func receive the function correponding to the options given as parameters | ||
| 141 | if args.display is True: # only print metadatas | ||
| 142 | func = list_meta | ||
| 143 | elif args.check is True: # only check if the file is clean | ||
| 144 | func = is_clean | ||
| 145 | elif args.strict is True: # destructive anonymisation method | ||
| 146 | func = clean_meta_strict | ||
| 147 | elif args.list is True: # print the list of all supported format | ||
| 148 | list_supported() | ||
| 149 | else: # clean the file | ||
| 150 | func = clean_meta | ||
| 151 | |||
| 152 | for filename in filenames: | ||
| 153 | class_file = mat.create_class_file(filename, args.backup, | ||
| 154 | args.add2archive) | ||
| 155 | if class_file is not None: | ||
| 156 | func(class_file, filename, args.force) | ||
| 157 | else: | ||
| 158 | print('Unable to process %s' % filename) | ||
| 159 | |||
| 160 | if __name__ == '__main__': | ||
| 161 | main() | ||
diff --git a/mat-cli.1 b/mat-cli.1 deleted file mode 100644 index 48ebf9a..0000000 --- a/mat-cli.1 +++ /dev/null | |||
| @@ -1,78 +0,0 @@ | |||
| 1 | .TH METADATA "1" "August 2011" "Metadata Anonymisation Toolkit" "User Commands" | ||
| 2 | |||
| 3 | |||
| 4 | .SH NAME | ||
| 5 | MAT \- Metadata Anonymisation Toolkit | ||
| 6 | |||
| 7 | |||
| 8 | .SH SYNOPSIS | ||
| 9 | .B mat-cli | ||
| 10 | [\fIoptions\fR] \fIfiles\fR | ||
| 11 | .TP | ||
| 12 | .B mat-gui | ||
| 13 | |||
| 14 | |||
| 15 | .SH DESCRIPTION | ||
| 16 | The \fBMetadata Anonymisation Toolkit\fR is a lib (with a CLI and a GUI) | ||
| 17 | created to anonymise file's \fBmetadata\fR. In essence, metadata answer who, | ||
| 18 | what, when, where, why, and how about every face of the data that are being | ||
| 19 | documented. They can be a \fBrisk for privacy\fR. | ||
| 20 | |||
| 21 | |||
| 22 | .SH OPTIONS | ||
| 23 | .TP | ||
| 24 | \fB\-h\fR, \fB\-\-help\fR | ||
| 25 | show this help message and exit | ||
| 26 | .TP | ||
| 27 | \fB\-a\fR, \fB\-\-add2archive\fR | ||
| 28 | Add to outputed archive non\-supported filetypes | ||
| 29 | .TP | ||
| 30 | \fB\-b\fR, \fB\-\-backup\fR | ||
| 31 | Keep a backup copy | ||
| 32 | .TP | ||
| 33 | \fB\-c\fR, \fB\-\-check\fR | ||
| 34 | Check if a file is free of harmful metadatas | ||
| 35 | .TP | ||
| 36 | \fB\-d\fR, \fB\-\-display\fR | ||
| 37 | List all the harmful meta of a file without removing them | ||
| 38 | .TP | ||
| 39 | \fB\-f\fR, \fB\-\-force\fR | ||
| 40 | Don't check if files are clean before cleaning | ||
| 41 | .TP | ||
| 42 | \fB\-l\fR, \fB\-\-list\fR | ||
| 43 | List all supported fileformat | ||
| 44 | .TP | ||
| 45 | \fB\-u\fR, \fB\-\-strict\fR | ||
| 46 | Remove harmful meta, but loss can occure | ||
| 47 | .TP | ||
| 48 | \fB\-v\fR, \fB\-\-version\fR | ||
| 49 | Display version and exit | ||
| 50 | |||
| 51 | |||
| 52 | .SH EXAMPLES | ||
| 53 | .TP | ||
| 54 | \fBmat-cli \-\-display\fR mydocument.pdf | ||
| 55 | Display the mydocument.pdf's harmful metadata | ||
| 56 | .TP | ||
| 57 | \fBmat-cli \-\-check *.jpg\fR | ||
| 58 | Check all the jpg images from the current folder | ||
| 59 | |||
| 60 | |||
| 61 | .SH NOTES | ||
| 62 | MAT \fBonly process metadata\fR, it does \fBnot\fR handle file data. | ||
| 63 | Blame yourself if you are traced back because of the data of your files. | ||
| 64 | MAT is not perfect : In most of the cases, a forensic expert with a lot | ||
| 65 | of time \fBcan trace back\fR your document. | ||
| 66 | If you want absolute privacy, use plain-text. | ||
| 67 | |||
| 68 | |||
| 69 | .SH AUTHOR | ||
| 70 | Julien (\fBjvoisin\fR) Voisin <pouicpouicpouic@gmail.com>, during the GSoC 2011 | ||
| 71 | |||
| 72 | |||
| 73 | .SH BUGS | ||
| 74 | MAT does not handle watermaking/tattoo for now. | ||
| 75 | |||
| 76 | |||
| 77 | .SH "SEE ALSO" | ||
| 78 | exiftool, hachoir-metadata | ||
| @@ -17,8 +17,8 @@ import mimetypes | |||
| 17 | import xml.sax | 17 | import xml.sax |
| 18 | import urllib2 | 18 | import urllib2 |
| 19 | 19 | ||
| 20 | from mat import mat | 20 | from lib import mat |
| 21 | from mat import strippers | 21 | from lib import strippers |
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | logging.basicConfig(level=mat.LOGGING_LEVEL) | 24 | logging.basicConfig(level=mat.LOGGING_LEVEL) |
| @@ -1 +1 @@ | |||
| mat-cli.1 \ No newline at end of file | mat.1 \ No newline at end of file | ||
| @@ -7,7 +7,7 @@ import subprocess | |||
| 7 | 7 | ||
| 8 | from distutils.core import setup | 8 | from distutils.core import setup |
| 9 | 9 | ||
| 10 | from mat import mat | 10 | from lib import mat |
| 11 | 11 | ||
| 12 | #Remove MANIFEST file, since distutils | 12 | #Remove MANIFEST file, since distutils |
| 13 | #doesn't properly update it when | 13 | #doesn't properly update it when |
| @@ -20,7 +20,7 @@ def l10n(): | |||
| 20 | ''' | 20 | ''' |
| 21 | Compile .po files to .mo | 21 | Compile .po files to .mo |
| 22 | ''' | 22 | ''' |
| 23 | for language in glob.glob('locale/*'): | 23 | for language in glob.glob('locale/*/'): |
| 24 | fpath = os.path.join(language, 'LC_MESSAGES', 'mat-gui.po') | 24 | fpath = os.path.join(language, 'LC_MESSAGES', 'mat-gui.po') |
| 25 | output = fpath[:-2] + 'mo' | 25 | output = fpath[:-2] + 'mo' |
| 26 | subprocess.call(['msgfmt', fpath, '-o', output]) | 26 | subprocess.call(['msgfmt', fpath, '-o', output]) |
| @@ -36,8 +36,8 @@ setup( | |||
| 36 | platforms = 'linux', | 36 | platforms = 'linux', |
| 37 | license = 'GPLv2', | 37 | license = 'GPLv2', |
| 38 | url = 'https://mat.boum.org', | 38 | url = 'https://mat.boum.org', |
| 39 | packages = ['mat', 'mat.hachoir_editor', 'mat.bencode', 'mat.tarfile'], | 39 | packages = ['lib', 'lib.hachoir_editor', 'lib.bencode', 'lib.tarfile'], |
| 40 | scripts = ['mat-cli', 'mat-gui'], | 40 | scripts = ['mat', 'mat-gui'], |
| 41 | data_files = [ | 41 | data_files = [ |
| 42 | ( 'share/applications', ['mat.desktop'] ), | 42 | ( 'share/applications', ['mat.desktop'] ), |
| 43 | ( 'share/mat', ['FORMATS'] ), | 43 | ( 'share/mat', ['FORMATS'] ), |
diff --git a/test/clitest.py b/test/clitest.py index 9232745..5b0f0c3 100644 --- a/test/clitest.py +++ b/test/clitest.py | |||
| @@ -8,7 +8,7 @@ import subprocess | |||
| 8 | import sys | 8 | import sys |
| 9 | 9 | ||
| 10 | sys.path.append('..') | 10 | sys.path.append('..') |
| 11 | from mat import mat | 11 | from lib import mat |
| 12 | import test | 12 | import test |
| 13 | 13 | ||
| 14 | 14 | ||
| @@ -19,14 +19,14 @@ class TestRemovecli(test.MATTest): | |||
| 19 | def test_remove(self): | 19 | def test_remove(self): |
| 20 | '''make sure that the cli remove all compromizing meta''' | 20 | '''make sure that the cli remove all compromizing meta''' |
| 21 | for _, dirty in self.file_list: | 21 | for _, dirty in self.file_list: |
| 22 | subprocess.call(['../mat-cli', dirty]) | 22 | subprocess.call(['../mat', dirty]) |
| 23 | current_file = mat.create_class_file(dirty, False, True) | 23 | current_file = mat.create_class_file(dirty, False, True) |
| 24 | self.assertTrue(current_file.is_clean()) | 24 | self.assertTrue(current_file.is_clean()) |
| 25 | 25 | ||
| 26 | def test_remove_empty(self): | 26 | def test_remove_empty(self): |
| 27 | '''Test removal with clean files''' | 27 | '''Test removal with clean files''' |
| 28 | for clean, _ in self.file_list: | 28 | for clean, _ in self.file_list: |
| 29 | subprocess.call(['../mat-cli', clean]) | 29 | subprocess.call(['../mat', clean]) |
| 30 | current_file = mat.create_class_file(clean, False, True) | 30 | current_file = mat.create_class_file(clean, False, True) |
| 31 | self.assertTrue(current_file.is_clean()) | 31 | self.assertTrue(current_file.is_clean()) |
| 32 | 32 | ||
| @@ -38,7 +38,7 @@ class TestListcli(test.MATTest): | |||
| 38 | def test_list_clean(self): | 38 | def test_list_clean(self): |
| 39 | '''check if get_meta returns meta''' | 39 | '''check if get_meta returns meta''' |
| 40 | for clean, _ in self.file_list: | 40 | for clean, _ in self.file_list: |
| 41 | proc = subprocess.Popen(['../mat-cli', '-d', clean], | 41 | proc = subprocess.Popen(['../mat', '-d', clean], |
| 42 | stdout=subprocess.PIPE) | 42 | stdout=subprocess.PIPE) |
| 43 | stdout, _ = proc.communicate() | 43 | stdout, _ = proc.communicate() |
| 44 | self.assertEqual(stdout.strip('\n'), "[+] File %s :\nNo harmful \ | 44 | self.assertEqual(stdout.strip('\n'), "[+] File %s :\nNo harmful \ |
| @@ -47,7 +47,7 @@ metadata found" % clean) | |||
| 47 | def test_list_dirty(self): | 47 | def test_list_dirty(self): |
| 48 | '''check if get_meta returns all the expected meta''' | 48 | '''check if get_meta returns all the expected meta''' |
| 49 | for _, dirty in self.file_list: | 49 | for _, dirty in self.file_list: |
| 50 | proc = subprocess.Popen(['../mat-cli', '-d', dirty], | 50 | proc = subprocess.Popen(['../mat', '-d', dirty], |
| 51 | stdout=subprocess.PIPE) | 51 | stdout=subprocess.PIPE) |
| 52 | stdout, _ = proc.communicate() | 52 | stdout, _ = proc.communicate() |
| 53 | self.assertNotEqual(stdout, "[+] File %s" % dirty) | 53 | self.assertNotEqual(stdout, "[+] File %s" % dirty) |
| @@ -60,7 +60,7 @@ class TestisCleancli(test.MATTest): | |||
| 60 | def test_clean(self): | 60 | def test_clean(self): |
| 61 | '''test is_clean on clean files''' | 61 | '''test is_clean on clean files''' |
| 62 | for clean, _ in self.file_list: | 62 | for clean, _ in self.file_list: |
| 63 | proc = subprocess.Popen(['../mat-cli', '-c', clean], | 63 | proc = subprocess.Popen(['../mat', '-c', clean], |
| 64 | stdout=subprocess.PIPE) | 64 | stdout=subprocess.PIPE) |
| 65 | stdout, _ = proc.communicate() | 65 | stdout, _ = proc.communicate() |
| 66 | self.assertEqual(stdout.strip('\n'), '[+] %s is clean' % clean) | 66 | self.assertEqual(stdout.strip('\n'), '[+] %s is clean' % clean) |
| @@ -68,7 +68,7 @@ class TestisCleancli(test.MATTest): | |||
| 68 | def test_dirty(self): | 68 | def test_dirty(self): |
| 69 | '''test is_clean on dirty files''' | 69 | '''test is_clean on dirty files''' |
| 70 | for _, dirty in self.file_list: | 70 | for _, dirty in self.file_list: |
| 71 | proc = subprocess.Popen(['../mat-cli', '-c', dirty], | 71 | proc = subprocess.Popen(['../mat', '-c', dirty], |
| 72 | stdout=subprocess.PIPE) | 72 | stdout=subprocess.PIPE) |
| 73 | stdout, _ = proc.communicate() | 73 | stdout, _ = proc.communicate() |
| 74 | self.assertEqual(stdout.strip('\n'), '[+] %s is not clean' % dirty) | 74 | self.assertEqual(stdout.strip('\n'), '[+] %s is not clean' % dirty) |
| @@ -79,19 +79,19 @@ class TestFileAttributes(unittest.TestCase): | |||
| 79 | test various stuffs about files (readable, writable, exist, ...) | 79 | test various stuffs about files (readable, writable, exist, ...) |
| 80 | ''' | 80 | ''' |
| 81 | def test_not_readable(self): | 81 | def test_not_readable(self): |
| 82 | proc = subprocess.Popen(['../mat-cli', 'not_readable'], | 82 | proc = subprocess.Popen(['../mat', 'not_readable'], |
| 83 | stdout=subprocess.PIPE) | 83 | stdout=subprocess.PIPE) |
| 84 | stdout, _ = proc.communicate() | 84 | stdout, _ = proc.communicate() |
| 85 | self.assertEqual(stdout.strip('\n'), 'Unable to pocess %s' % 'not_readable') | 85 | self.assertEqual(stdout.strip('\n'), 'Unable to pocess %s' % 'not_readable') |
| 86 | 86 | ||
| 87 | def test_not_writtable(self): | 87 | def test_not_writtable(self): |
| 88 | proc = subprocess.Popen(['../mat-cli', 'not_writtable'], | 88 | proc = subprocess.Popen(['../mat', 'not_writtable'], |
| 89 | stdout=subprocess.PIPE) | 89 | stdout=subprocess.PIPE) |
| 90 | stdout, _ = proc.communicate() | 90 | stdout, _ = proc.communicate() |
| 91 | self.assertEqual(stdout.strip('\n'), 'Unable to pocess %s' % 'not_writtable') | 91 | self.assertEqual(stdout.strip('\n'), 'Unable to pocess %s' % 'not_writtable') |
| 92 | 92 | ||
| 93 | def test_not_exist(self): | 93 | def test_not_exist(self): |
| 94 | proc = subprocess.Popen(['../mat-cli', 'ilikecookies'], | 94 | proc = subprocess.Popen(['../mat', 'ilikecookies'], |
| 95 | stdout=subprocess.PIPE) | 95 | stdout=subprocess.PIPE) |
| 96 | stdout, _ = proc.communicate() | 96 | stdout, _ = proc.communicate() |
| 97 | self.assertEqual(stdout.strip('\n'), 'Unable to pocess %s' % 'ilikecookies') | 97 | self.assertEqual(stdout.strip('\n'), 'Unable to pocess %s' % 'ilikecookies') |
diff --git a/test/libtest.py b/test/libtest.py index 6217b69..9ac12c0 100644 --- a/test/libtest.py +++ b/test/libtest.py | |||
| @@ -8,7 +8,7 @@ import unittest | |||
| 8 | import test | 8 | import test |
| 9 | import sys | 9 | import sys |
| 10 | sys.path.append('..') | 10 | sys.path.append('..') |
| 11 | from mat import mat | 11 | from lib import mat |
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | class TestRemovelib(test.MATTest): | 14 | class TestRemovelib(test.MATTest): |
