示例#1
0
 def __init__(self, info={}, session=None, person=None):
     self.session = session or TembooSession(
         "jordanemedlock", "jordanemedlockcom",
         "aB8hQizrTLhyOUitwNdnxvddWa3Fw6ZG")
     self.weather = None
     PowerDict.__init__(self, info)
     Capability.__init__(self, person)
示例#2
0
 def __init__(self, traits={}, person=None):
     """
     So this is a representation of a recursive tree shaped personality trait
     which is just a glorified dict.
     """
     PowerDict.__init__(self, traits)
     Capability.__init__(self, person)
示例#3
0
def main():
	file = open("test.xml","r")
	line = file.readline()

	while not startDevices(line):
		line = file.readline()

	line = file.readline().strip()
	
	devices = []
	device = ""
	group = ""
	capability = ""
	
	while not endDevices(line):
		if beginDevice(line):
			line = deleteTags(line,"<device ",">")
			att_id = getAttrId(line)
			att_user = getAttrUser(line)
			att_fall = getAttrFall(line)
			
			device = Device(att_id, att_user, att_fall)
			line = file.readline()

		if endDevice(line):
			devices.append(device)
			line = file.readline()

		if beginGroup(line):
			line = deleteTags(line,"<group ",">")
			att_id = getAttrId(line)

			group = Group(att_id)
			group.setDevice(device)
			line = file.readline()

		if endGroup(line):
			device.addGroup(group)
			line = file.readline()

		if beginCapability(line):
			line = deleteTags(line, "<capability ", "/>")
			att_name = getAttrName(line)
			att_value = getAttrValue(line)

			capability = Capability(att_name, att_value)
			capability.setGroup(group)
			group.addCapability(capability)
			line = file.readline()

	print "Devices\n"
	printDevices(devices)
	print "End Devices\n"
	
	file.close()
	return 0
示例#4
0
    def __init__(self, gen=lambda: 0.5, person=None):

        # init its two base classes
        PowerDict.__init__(self)
        Capability.__init__(self, person)

        self['joy'] = gen()
        self['contempt'] = gen()
        self['surprise'] = gen()
        self['shame'] = gen()
        self['sadness'] = gen()
        self['fear'] = gen()
        self['anger'] = gen()
        self['guilt'] = gen()
        self['disgust'] = gen()
        self['interest'] = gen()
示例#5
0
    def _get_declared_capabilities(self,
                                   container_config: Dict) -> Set[Capability]:
        # If container is privileged it has all the capabilities
        is_privileged: bool = container_config[self.PRIVILEGED_CONFIG_KEY]
        if is_privileged:
            return ALL_CAPABILITIES

        # If no added/dropped capabilities were passed to the container use empty list
        added_capabilities_strings: List[str] = container_config[
            self.CAP_ADD_CONFIG_KEY] or []
        dropped_capabilities_strings: List[str] = container_config[
            self.CAP_DROP_CONFIG_KEY] or []

        # The rule of thumb is that dropped capabilities are applied after added capabilities
        # If both added and dropped capabilities are set to all then drop every capability:
        # --cap-add ALL --cap-drop ALL
        if (self.ALL_CAPABILITIES_KEY in added_capabilities_strings
                and self.ALL_CAPABILITIES_KEY in dropped_capabilities_strings):
            return set()
        # If all capabilities are dropped but some are added then use only the added one:
        # --cap-add <CAP> --cap-drop ALL
        elif (self.ALL_CAPABILITIES_KEY not in added_capabilities_strings
              and self.ALL_CAPABILITIES_KEY in dropped_capabilities_strings):
            return Capability.from_strings(added_capabilities_strings)
        # If all capabilities are added but some are dropped then use all capabilities beside the dropped:
        # --cap-add ALL --cap-drop <CAP>
        elif (self.ALL_CAPABILITIES_KEY in added_capabilities_strings and
              self.ALL_CAPABILITIES_KEY not in dropped_capabilities_strings):
            dropped_capabilities: Set[Capability] = Capability.from_strings(
                dropped_capabilities_strings)

            return ALL_CAPABILITIES.difference(dropped_capabilities)
        # Otherwise, apply added and dropped capabilities to the default set:
        # --cap-add <CAP> --cap-drop <CAP>
        else:
            added_capabilities: Set[Capability] = Capability.from_strings(
                added_capabilities_strings)
            dropped_capabilities: Set[Capability] = Capability.from_strings(
                dropped_capabilities_strings)

            return DEFAULT_CAPABILITIES \
                .union(added_capabilities) \
                .difference(dropped_capabilities)
    def _event_callback(self, _core, data, _size):
        # Convert the event and put it into the queue
        event = self._bpf[self.BPF_EVENTS_KEY].event(data)

        capability = Capability(event.cap)
        was_granted = event.ret == 0
        process_ids = list(event.tree)

        capability_event = CapabilityEvent(capability, was_granted,
                                           process_ids)
        self._queue.put(capability_event)
示例#7
0
 def __init__(self, parent=None, info={}):
     Capability.__init__(self, parent)
     PowerDict.__init__(self, info)
示例#8
0
 def __init__(self, person=None):
     Capability.__init__(self, person)
示例#9
0
 def __init__(self, info={}, person=None):
     PowerDict.__init__(self, info)
     self.update(Memories.calculated(self))
     Capability.__init__(self, person)
示例#10
0
 def __init__(self, capabilities={}):
     for v in capabilities.values():
         v.parent = self
     Capability.__init__(self, self)
     PowerDict.__init__(self, capabilities)