<commit_before>from oletools import olevba
from oletools.thirdparty import olefile

class Plugin:

	__NAME__ = 'doc'

	def __init__(self, args):
		self.args = args
		self.analyzed_mimes = ['application/msword',
								'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
								'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
								'application/vnd.openxmlformats-officedocument.presentationml.presentation',
								'application/vnd.ms-excel',
								'application/vnd.ms-powerpoint',
								'application/vnd.openxmlformats-officedocument.presentationml.presentation',
								'application/vnd.ms-office']
		self.alert_on_macro = True
		self.suspicious_on_macro = True

	def analyze(self, afile):
		'''Analyze OLE files and extract metadata about the file into the 
		FileAnalysis object.

		Args:
			afile (FileAnalysis): The file to be analyzed.
		
		Returns:
			None
		'''
		if afile.mime_type in self.analyzed_mimes:

			# Parse the metadata for the ole file and add all ole metadata
			# attributes to the FileAnalysis object. This should add a ton
			# of contectual information to the file.
			try:
				ole = olefile.OleFileIO(afile.path)
				process_metadata = True
			except IOError:
				afile.errors = afile.errors + ['doc plugin: unsupported filetype']
				output = 'None'
				afile.plugin_output[self.__NAME__] = output

			if process_metadata:
				meta = ole.get_metadata()
				# These loops iterate through the meta for attributes and then 
				# set attributes with the same name in the FileAnalysis object
				for prop in meta.SUMMARY_ATTRIBS:
					value = getattr(meta, prop)
					setattr(afile, prop, value)

				for prop in meta.DOCSUM_ATTRIBS:
					value = getattr(meta, prop)
					setattr(afile, prop, value)

			# Explicitly call close to ensure that the ole object gets closed
			ole.close()
<commit_msg>yet another fix...<commit_after>from oletools import olevba
from oletools.thirdparty import olefile

class Plugin:

	__NAME__ = 'doc'

	def __init__(self, args):
		self.args = args
		self.analyzed_mimes = ['application/msword',
								'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
								'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
								'application/vnd.openxmlformats-officedocument.presentationml.presentation',
								'application/vnd.ms-excel',
								'application/vnd.ms-powerpoint',
								'application/vnd.openxmlformats-officedocument.presentationml.presentation',
								'application/vnd.ms-office']
		self.alert_on_macro = True
		self.suspicious_on_macro = True

	def analyze(self, afile):
		'''Analyze OLE files and extract metadata about the file into the 
		FileAnalysis object.

		Args:
			afile (FileAnalysis): The file to be analyzed.
		
		Returns:
			None
		'''
		if afile.mime_type in self.analyzed_mimes:

			# Parse the metadata for the ole file and add all ole metadata
			# attributes to the FileAnalysis object. This should add a ton
			# of contectual information to the file.
			try:
				ole = olefile.OleFileIO(afile.path)
				process_metadata = True
			except IOError:
				afile.errors = afile.errors + ['doc plugin: unsupported filetype']
				output = 'None'
				afile.plugin_output[self.__NAME__] = output

			if process_metadata:
				meta = ole.get_metadata()
				# These loops iterate through the meta for attributes and then 
				# set attributes with the same name in the FileAnalysis object
				for prop in meta.SUMMARY_ATTRIBS:
					value = getattr(meta, prop)
					setattr(afile, prop, value)

				for prop in meta.DOCSUM_ATTRIBS:
					value = getattr(meta, prop)
					setattr(afile, prop, value)

				# Explicitly call close to ensure that the ole object gets closed
				ole.close()

{'fraction_non_alphanumeric': 0.08353221957040573, 'fraction_numerical': 0.0, 'mean_word_length': 3.4904761904761905, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1301469', 'n_tokens_mistral': 1451, 'n_tokens_neox': 1115, 'n_words': 324}