Ejemplo n.º 1
0
def test_cve_2015_4470_mszip_over_read():
    f = read_libmspack_cab('cve-2015-4470-mszip-over-read.cab')
    cab = cabinet.Cabinet(f)

    entries = cab.folder_and_datas[0]
    data_blocks = entries[2]

    with pytest.raises(data.InvalidChecksum):
        data_blocks[0].data()
Ejemplo n.º 2
0
def test_cve_2010_2800_mszip_infinite_loop():
    f = read_libmspack_cab('cve-2010-2800-mszip-infinite-loop.cab')
    cab = cabinet.Cabinet(f)

    entries = cab.folder_and_datas[0]
    data_blocks = entries[2]

    with pytest.raises(data.InvalidChecksum):
        data_blocks[0].data()
Ejemplo n.º 3
0
	def test_system(self):
		# Test the system of cabinets model
		# Slot with the north port slightly offset on the z axis
		s = cabinet.Slot((1,10,10), {topology.NORTH : (0.0,0.0,1.0)})
		# A rack with 10 slots. The bay should be centered with offset (2.75, 2.5, 0)
		r = cabinet.Rack(s, (20,15,15), 10, 0.5)
		# A cabinet with 10 racks. The bay should have offset (1,1,1)
		c = cabinet.Cabinet(r, (25, 120, 20), 5, 5.0, (1,1,1))
		# A system of 10 cabinets.
		sys = cabinet.System(c, 10, 100)
		
		# Check accessing racks via the cabinet via the system...
		self.assertEqual(sys.get_position((0,0,0)), (3.75,3.5,1.0))
		self.assertEqual(sys.get_position((0,0,1)), (5.25,3.5,1.0))
		
		# Access a subsequent rack
		self.assertEqual(sys.get_position((0,1,0)), (3.75,23.5,1.0))
		
		# Access a subsequent cabinet
		self.assertEqual(sys.get_position((1,1,0)), (128.75,23.5,1.0))
		
		# Check accessing a particular link
		self.assertEqual(sys.get_position((0,0,2), topology.NORTH), (6.75,3.5,2.0))
Ejemplo n.º 4
0
	def test_cabinet(self):
		# Test the cabinet model
		# Slot with the north port slightly offset on the z axis
		s = cabinet.Slot((1,10,10), {topology.NORTH : (0.0,0.0,1.0)})
		# A rack with 10 slots. The bay should be centered with offset (2.75, 2.5, 0)
		r = cabinet.Rack(s, (20,15,15), 10, 0.5)
		# A cabinet with 10 racks. The bay should have offset (1,1,1)
		c = cabinet.Cabinet(r, (25, 120, 20), 5, 5.0, (1,1,1))
		
		# Check the various dimensions
		self.assertEqual(c.width,  25)
		self.assertEqual(c.height, 120)
		self.assertEqual(c.depth,  20)
		
		# Check accessing racks via the cabinet...
		self.assertEqual(c.get_position(0, 0), (3.75,3.5,1.0))
		self.assertEqual(c.get_position(0, 1), (5.25,3.5,1.0))
		
		# Access a subsequent rack
		self.assertEqual(c.get_position(1, 0), (3.75,23.5,1.0))
		
		
		# Check accessing a particular link
		self.assertEqual(c.get_position(0, 2, topology.NORTH), (6.75,3.5,2.0))
Ejemplo n.º 5
0
def test_bad_signature():
    f = read_libmspack_cab('bad_signature.cab')

    with pytest.raises(folder.InvalidFolderHeader):
        cabinet.Cabinet(f)
Ejemplo n.º 6
0
def test_bad_nofiles():
    f = read_libmspack_cab('bad_nofiles.cab')
    cab = cabinet.Cabinet(f)
    assert len(cab.files) == 0
Ejemplo n.º 7
0
def test_filename_read_violation_4():
    f = read_libmspack_cab('filename-read-violation-4.cab')
    with pytest.raises(data.DataHeaderError):
        cab = cabinet.Cabinet(f)
Ejemplo n.º 8
0
def test_filename_read_violation_1():
    f = read_libmspack_cab('filename-read-violation-1.cab')
    with pytest.raises(cabinet.EmptyFileName):
        cab = cabinet.Cabinet(f)
Ejemplo n.º 9
0
def test_bad_folderindex():
    f = read_libmspack_cab('bad_folderindex.cab')
    with pytest.raises(cabinet.InvalidFileAllocation):
        cab = cabinet.Cabinet(f)