本文整理汇总了Python中model.hosts.Interface类的典型用法代码示例。如果您正苦于以下问题:Python Interface类的具体用法?Python Interface怎么用?Python Interface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Interface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testAddServiceToInterface
def testAddServiceToInterface(self):
interface = Interface('coco')
serv = Service('cuca')
interface.addChild(serv)
self.assertIn(serv, interface.childs.values(), 'Service not in childs')
self.assertIn(serv, interface.getAllServices(), 'Service not accessible')
开发者ID:BecomingMore,项目名称:faraday,代码行数:7,代码来源:model_composite.py
示例2: test_interface_creation
def test_interface_creation(self):
name = "pepito"
os = "Windows"
host = Host(name, os)
when(self._model_controller).find(host.getID()).thenReturn(host)
name = ""
mac = "00:00:00:00:00:00"
ipv4_address = "0.0.0.0"
ipv4_mask = "0.0.0.0"
ipv4_gateway = "0.0.0.0"
ipv4_dns = []
ipv6_address = "0000:0000:0000:0000:0000:0000:0000:0000"
ipv6_prefix = "00"
ipv6_gateway = "0000:0000:0000:0000:0000:0000:0000:0000"
ipv6_dns = []
network_segment = ""
hostname_resolution = []
interface_id = self.client.createInterface(
name, mac, ipv4_address, ipv4_mask, ipv4_gateway, ipv4_dns,
ipv6_address, ipv6_prefix, ipv6_gateway, ipv6_dns, network_segment,
hostname_resolution, host.getID())
interface = Interface(
name, mac, ipv4_address, ipv4_mask, ipv4_gateway, ipv4_dns,
ipv6_address, ipv6_prefix, ipv6_gateway, ipv6_dns, network_segment,
hostname_resolution, parent_id=host.getID())
self.assertNotEquals(
interface_id, None, "interface created shouldn't be None")
self.assertEquals(
interface.getID(), interface_id, "ids should be the same")
开发者ID:BwRy,项目名称:faraday,代码行数:35,代码来源:integration_create_model_objects_api.py
示例3: testEditInterfaceSyncGetsMapperDispatchedSYNC
def testEditInterfaceSyncGetsMapperDispatchedSYNC(self):
inter = Interface("coquito")
params = ('new_name', 'new_desc', 'hostname1', "FF:AA:EE:11:00", None,
None, None, None, None, None, True)
self.genericEdit(inter, params, controller.ModelController.editInterfaceSYNC)
self.assertEquals(inter.getName(), 'new_name', "Name not updated")
self.assertEquals(inter.getDescription(), 'new_desc', "Description not updated")
self.assertEquals(inter.isOwned(), True, "Owned status not updated")
开发者ID:BwRy,项目名称:faraday,代码行数:11,代码来源:model_controller.py
示例4: testInterfaceSetServices
def testInterfaceSetServices(self):
inter = Interface('coco')
services = {}
for i in range(50, 60):
serv = Service('cuca%s' % i, ports=[i])
services[serv.getID()] = serv
inter.setServices(services)
self.assertEquals(len(inter.getChildsByType(Service.__name__)), 10, "not all services added")
for s in services.values():
self.assertIn(s, inter.getChildsByType(Service.__name__), "what happened with services?")
开发者ID:BecomingMore,项目名称:faraday,代码行数:11,代码来源:model_composite.py
示例5: testHostSetInterfaces
def testHostSetInterfaces(self):
host = Host('coco')
interfaces = {}
for i in range(50, 60):
inter = Interface('cuca%s' % i, ipv4_address="192.168.0.%d" % i)
interfaces[inter.getID()] = inter
host.setInterfaces(interfaces)
self.assertEquals(len(host.getChildsByType(Interface.__name__)), 10, "not all interfaces added")
for s in interfaces.values():
self.assertIn(s, host.getChildsByType(Interface.__name__), "what happened with interfaces?")
开发者ID:BecomingMore,项目名称:faraday,代码行数:11,代码来源:model_composite.py
示例6: testAddVulnToInterfaceGetsMapperDispatchSaveSYNC
def testAddVulnToInterfaceGetsMapperDispatchSaveSYNC(self):
interface = Interface("int0")
vuln = ModelObjectVuln("a_vuln")
mappersManager = self.createMapperMock()
objectMapper = mock()
when(mappersManager).getMapper(vuln).thenReturn(objectMapper)
when(objectMapper).saveObject(vuln).thenReturn(True)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.addVulnToInterfaceSYNC(None, interface.getID(), vuln)
verify(mappersManager).getMapper(vuln)
verify(objectMapper).saveObject(vuln)
开发者ID:BwRy,项目名称:faraday,代码行数:15,代码来源:model_controller.py
示例7: testAddNoteToInterfaceGetsMapperDispatchSaveSYNC
def testAddNoteToInterfaceGetsMapperDispatchSaveSYNC(self):
interface = Interface("pepito")
note = ModelObjectNote("a_note")
mappersManager = self.createMapperMock()
objectMapper = mock()
when(mappersManager).getMapper(note).thenReturn(objectMapper)
when(objectMapper).saveObject(note).thenReturn(True)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.addNoteToInterfaceSYNC(None, interface.getID(), note)
verify(mappersManager).getMapper(note)
verify(objectMapper).saveObject(note)
开发者ID:BwRy,项目名称:faraday,代码行数:15,代码来源:model_controller.py
示例8: testAddServiceGetsMapperDispatchSaveSYNC
def testAddServiceGetsMapperDispatchSaveSYNC(self):
interface = Interface("int_mock0")
service = Service("servi")
mappersManager = self.createMapperMock()
objectMapper = mock()
when(mappersManager).getMapper(service).thenReturn(objectMapper)
when(objectMapper).saveObject(service).thenReturn(True)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.addServiceToInterfaceSYNC(None, interface.getID(), service)
verify(mappersManager).getMapper(service)
verify(objectMapper).saveObject(service)
开发者ID:BwRy,项目名称:faraday,代码行数:15,代码来源:model_controller.py
示例9: test
def test(self):
"""
DELETE THIS BEFORE RELEASE
used for internal testing (not correct way but we need to use it like
this for now)
"""
global test_count
test_count += 1
model.api.showPopup("Creating test host %d" % test_count)
from utils.error_report import exception_handler
def raiser():
sys.excepthook = exception_handler
time.sleep(3)
raise Exception("Exception from a secondary thread...")
from model.hosts import Host
from model.hosts import Interface
from model.hosts import Service
from model.hosts import HostApplication
self._main_app.getLogger().log("testing..")
self._main_app.getLogger().log("creating test host %d" % test_count)
host = Host("TestHost-%d" % test_count, "Windows 2003")
service = Service( "TestService-%d" % test_count, "TCP", [80,8080], "running")
interface = Interface("eth%d" % test_count, mac = "00:00:00:00:00:00",
ipv4_address = "10.1.1.%d" % test_count, ipv4_mask = "255.255.0.0",
ipv4_gateway = "10.1.1.%d" % (test_count+1),
hostname_resolution = "TestHost-%d" % test_count)
app = HostApplication( "AppTest-%d" % test_count, "running", "1.0 beta")
host.addInterface(interface)
host.addService(service)
host.addApplication(app)
interface.addService(service)
app.addService(service)
service.addInterface(interface)
self._model_controller.addHostASYNC(host)
开发者ID:adityapooniya,项目名称:faraday,代码行数:48,代码来源:mainwindow.py
示例10: testAddNoteToInterfaceGetsMapperDispatchSaveASYNC
def testAddNoteToInterfaceGetsMapperDispatchSaveASYNC(self):
interface = Interface("int0")
note = ModelObjectNote("a_note")
mappersManager = self.createMapperMock()
objectMapper = mock()
when(mappersManager).getMapper(note.class_signature).thenReturn(objectMapper)
when(objectMapper).save(note).thenReturn(True)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.addNoteToServiceASYNC(None, interface.getID(), note)
model_controller.processAllPendingActions()
verify(mappersManager).getMapper(note.class_signature)
verify(objectMapper).save(note)
开发者ID:BecomingMore,项目名称:faraday,代码行数:16,代码来源:dont_run_but_update_model_controller.py
示例11: testAddVulnToInterfaceGetsMapperDispatchSaveASYNC
def testAddVulnToInterfaceGetsMapperDispatchSaveASYNC(self):
interface = Interface("int0")
vuln = ModelObjectVuln("a_vuln")
mappersManager = self.createMapperMock()
objectMapper = mock()
when(mappersManager).getMapper(vuln.class_signature).thenReturn(objectMapper)
when(objectMapper).save(vuln).thenReturn(True)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.addVulnToInterfaceASYNC(None, interface.getID(), vuln)
model_controller.processAllPendingActions()
verify(mappersManager).getMapper(vuln.class_signature)
verify(objectMapper).save(vuln)
开发者ID:BecomingMore,项目名称:faraday,代码行数:16,代码来源:dont_run_but_update_model_controller.py
示例12: test_interface_create_and_delete
def test_interface_create_and_delete(self):
iface = Interface(name="192.168.10.168", mac="01:02:03:04:05:06")
self.imapper.save(iface)
i_id = iface.getID()
self.assertNotEquals(
self.imapper.load(i_id),
None,
"Inteface should be saved")
self.imapper.delete(i_id)
self.assertEquals(
self.imapper.find(i_id),
None,
"Inteface shouldn't exist anymore")
开发者ID:BwRy,项目名称:faraday,代码行数:16,代码来源:mapper.py
示例13: test_service_creation
def test_service_creation(self):
name = "pepito"
os = "Windows"
host = Host(name, os)
name = ""
mac = "00:00:00:00:00:00"
ipv4_address = "0.0.0.0"
ipv4_mask = "0.0.0.0"
ipv4_gateway = "0.0.0.0"
ipv4_dns = []
ipv6_address = "0000:0000:0000:0000:0000:0000:0000:0000"
ipv6_prefix = "00"
ipv6_gateway = "0000:0000:0000:0000:0000:0000:0000:0000"
ipv6_dns = []
network_segment = ""
hostname_resolution = []
interface = Interface(
name, mac, ipv4_address, ipv4_mask, ipv4_gateway, ipv4_dns,
ipv6_address, ipv6_prefix, ipv6_gateway, ipv6_dns, network_segment,
hostname_resolution, parent_id=host.getID())
when(self._model_controller).find(
interface.getID()).thenReturn(interface)
name = "srv"
protocol = "tcp"
ports = []
status = "running"
version = "unknown"
description = ""
service_id = self.client.createService(
name, protocol, ports, status, version, description,
interface.getID())
service = Service(name, protocol, ports, status, version, description,
parent_id=interface.getID())
self.assertNotEquals(
service_id, None, "service created shouldn't be None")
self.assertEquals(
service.getID(), service_id, "ids should be the same")
开发者ID:BwRy,项目名称:faraday,代码行数:45,代码来源:integration_create_model_objects_api.py
示例14: testAddObjectSavesChildInParent
def testAddObjectSavesChildInParent(self):
host = Host('coco')
interface = Interface("int_mock0")
mappersManager = self.createMapperMock()
objectMapper = mock()
when(mappersManager).getMapper(interface).thenReturn(objectMapper)
when(objectMapper).saveObject(interface).thenReturn(True)
when(mappersManager).find(host.getID()).thenReturn(host)
model_controller = controller.ModelController(mock(), mappersManager)
model_controller.addInterfaceSYNC(host.getID(), interface)
verify(mappersManager).getMapper(interface)
verify(objectMapper).saveObject(interface)
self.assertEquals(interface, host.findChild(interface.getID()),
"Orphan child, what happen papi?")
开发者ID:BwRy,项目名称:faraday,代码行数:19,代码来源:model_controller.py
示例15: testInterfaceWithMultipleChildTypes
def testInterfaceWithMultipleChildTypes(self):
inter = Interface('coco')
serv = Service('cuca')
vuln = ModelObjectVuln('vuln')
inter.addChild(serv)
inter.addChild(vuln)
self.assertEquals(len(inter.getVulns()), 1, "Vulns added is not 1")
self.assertIn(vuln, inter.getVulns(), "Vuln not accessible")
self.assertEquals(len(inter.getAllServices()), 1, "Services added is not 1")
开发者ID:BecomingMore,项目名称:faraday,代码行数:10,代码来源:model_composite.py
示例16: testInterfaceFromHostRemovedSYNC
def testInterfaceFromHostRemovedSYNC(self):
service = Service('coco')
interface = Interface("int_mock0")
interface.addChild(service)
self.genericDelTest(interface, service,
controller.ModelController.delServiceFromInterfaceSYNC)
开发者ID:BecomingMore,项目名称:faraday,代码行数:6,代码来源:dont_run_but_update_model_controller.py
示例17: test_load_not_loaded_composite_host
def test_load_not_loaded_composite_host(self):
# add host
host = Host(name="pepito", os="linux")
host.setDescription("Some description")
host.setOwned(True)
self.mapper_manager.save(host)
# add inteface
iface = Interface(name="192.168.10.168", mac="01:02:03:04:05:06")
iface.setDescription("Some description")
iface.setOwned(True)
iface.addHostname("www.test.com")
iface.setIPv4({
"address": "192.168.10.168",
"mask": "255.255.255.0",
"gateway": "192.168.10.1",
"DNS": "192.168.10.1"
})
iface.setPortsOpened(2)
iface.setPortsClosed(3)
iface.setPortsFiltered(4)
host.addChild(iface)
self.mapper_manager.save(iface)
#create a set of mappers, so we have a clean map
self.mapper_manager = MapperManager()
self.mapper_manager.createMappers(self.connector)
h = self.mapper_manager.find(host.getID())
self.assertEquals(
len(h.getAllInterfaces()),
len(host.getAllInterfaces()),
"Interfaces from original host should be equals to retrieved host's interfaces")
i = self.mapper_manager.find(h.getAllInterfaces()[0].getID())
self.assertEquals(
i.getID(),
iface.getID(),
"Interface's id' from original host should be equals to retrieved host's interface's id")
开发者ID:BwRy,项目名称:faraday,代码行数:38,代码来源:mapper_integration.py
示例18: test_interface_serialization
def test_interface_serialization(self):
iface = Interface(name="192.168.10.168", mac="01:02:03:04:05:06")
iface.setDescription("Some description")
iface.setOwned(True)
iface.addHostname("www.test.com")
iface.setIPv4({
"address": "192.168.10.168",
"mask": "255.255.255.0",
"gateway": "192.168.10.1",
"DNS": "192.168.10.1"
})
iface.setPortsOpened(2)
iface.setPortsClosed(3)
iface.setPortsFiltered(4)
iserialized = self.imapper.serialize(iface)
# if serialization fails, returns None
self.assertNotEqual(
iserialized,
None,
"Serialized interface shouldn't be None")
# we check the interface attributes
self.assertEquals(
iserialized.get("_id"),
iface.getID(),
"Serialized ID is not the same as Interface ID")
self.assertEquals(
iserialized.get("name"),
iface.getName(),
"Serialized name is not the same as Interface name")
self.assertEquals(
iserialized.get("mac"),
iface.getMAC(),
"Serialized MAC is not the same as Interface MAC")
self.assertEquals(
iserialized.get("network_segment"),
iface.getNetworkSegment(),
"Serialized Network Segment is not the same as Interface Network Segment")
self.assertEquals(
iserialized.get("description"),
iface.getDescription(),
"Serialized description is not the same as Interface description")
self.assertEquals(
iserialized.get("owned"),
iface.isOwned(),
"Serialized owned flag is not the same as Interface owned flag")
开发者ID:BwRy,项目名称:faraday,代码行数:45,代码来源:mapper.py
示例19: testDelNoteFromInterfaceASYNC
def testDelNoteFromInterfaceASYNC(self):
interface = Interface('coco')
note = ModelObjectNote("int_mock0")
interface.addChild(note.getID(), note)
self.genericDelTest(interface, note,
controller.ModelController.delNoteFromInterfaceASYNC, process_pending=True)
开发者ID:BwRy,项目名称:faraday,代码行数:6,代码来源:model_controller.py
示例20: testInterfaceFromHostRemovedASYNC
def testInterfaceFromHostRemovedASYNC(self):
service = Service('coco')
interface = Interface("int_mock0")
interface.addChild(service.getID(), service)
self.genericDelTest(interface, service,
controller.ModelController.delServiceFromInterfaceASYNC, process_pending=True)
开发者ID:BwRy,项目名称:faraday,代码行数:6,代码来源:model_controller.py
注:本文中的model.hosts.Interface类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论