Remove flags as a fully-fledged object until it's been discussed

This commit is contained in:
Mike Auty
2016-12-18 19:38:05 +00:00
parent a8b4db3ee3
commit be075939d2
2 changed files with 26 additions and 24 deletions
-24
View File
@@ -296,30 +296,6 @@ class Enumeration(interfaces.objects.ObjectInterface, int):
return template._vol['base_type'].size
class Flags(Integer):
"""Object that converts an integer into a set of flags based on their masks"""
def __init__(self, context, type_name, object_info, struct_format, choices = None):
super().__init__(context, type_name, object_info, struct_format)
self._check_type(choices, collections.Mapping)
for k, v in choices.items():
self._check_type(k, str)
self._check_type(v, int)
self._vol['choices'] = choices
@property
def choices(self):
return self._vol['choices']
@property
def flags(self):
result = []
for k, v in self.choices.items():
if self & v:
result.append(k)
return result
class Array(interfaces.objects.ObjectInterface, collections.Sequence):
"""Object which can contain a fixed number of an object type"""
+26
View File
@@ -0,0 +1,26 @@
import collections
from volatility.framework import interfaces, validity
class Flags(validity.ValidityRoutines):
"""Object that converts an integer into a set of flags based on their masks"""
def __init__(self, choices = None):
self._check_type(choices, collections.Mapping)
for k, v in choices.items():
self._check_type(k, str)
self._check_type(v, int)
self._choices = interfaces.objects.ReadOnlyMapping(choices)
@property
def choices(self):
return self._choices
def __call__(self, value):
"""Return the appropriate Flags """
result = []
for k, v in self.choices.items():
if value & v:
result.append(k)
return result