def test_invalid_version():
	
	try:
		test = version_util.version("1.0.0.0.0.0")
		assert False
	except ValueError:
		assert True
		
	try:
		test = version_util.version("1.0,0")
		assert False
	except ValueError:
		assert True
		
	try:
		test = version_util.version("a.b.c")
		assert False
	except ValueError:
		assert True

	try:
		test = version_util.version("1.0.0")
		
		test == "abc"
		
		assert False
	except ValueError:
		assert True
Пример #2
0
def test_invalid_version():

    try:
        test = version_util.version("1.0.0.0.0.0")
        assert False
    except ValueError:
        assert True

    try:
        test = version_util.version("1.0,0")
        assert False
    except ValueError:
        assert True

    try:
        test = version_util.version("a.b.c")
        assert False
    except ValueError:
        assert True

    try:
        test = version_util.version("1.0.0")

        test == "abc"

        assert False
    except ValueError:
        assert True
def test_version():
	
	test = version_util.version("1.0a")
	assert test.get_tuple() == (1,0,'a')
	
	test = version_util.version("1.0.1")
	assert test.get_tuple() == (1,0, '',1, '')
	
	test = version_util.version("5.9.0.1beta")
	assert test.get_tuple() == (5,9, '',0, '', 1, 'beta')
Пример #4
0
def test_version():

    test = version_util.version("1.0a")
    assert test.get_tuple() == (1, 0, 'a')

    test = version_util.version("1.0.1")
    assert test.get_tuple() == (1, 0, '', 1, '')

    test = version_util.version("5.9.0.1beta")
    assert test.get_tuple() == (5, 9, '', 0, '', 1, 'beta')
Пример #5
0
    def __fill(self):
        raw_type = platform.system()
        if raw_type == "Linux":
            self.__os_type = validate_os('linux')
        elif raw_type == "Windows":
            #self.__os_type = OS.WINDOWS
            self.__os_type = None
        else:
            self.__os_type = None

        if self.__os_type == None:
            return

        if self.__os_type == validate_os('linux'):

            my_dist = platform.linux_distribution()

            if 'ubuntu' in my_dist[0].lower():
                self.__os_flavor = validate_flavor('linux', 'ubuntu')
                #print("!:" + self.__os_flavor)
            elif 'centos' in my_dist[0].lower():
                self.__os_flavor = validate_flavor('linux', 'centos')
            else:
                self.__os_flavor = None

            if not self.__os_flavor == None:
                self.__os_version = version_util.version(my_dist[1])
Пример #6
0
	def __fill(self):
		raw_type = platform.system()
		if raw_type == "Linux":
			self.__os_type = validate_os('linux')
		elif raw_type == "Windows":
			#self.__os_type = OS.WINDOWS
			self.__os_type = None
		else:
			self.__os_type = None

		if self.__os_type == None:
			return
			
		if self.__os_type == validate_os('linux'):
			
			my_dist = platform.linux_distribution()
			
			if 'ubuntu' in my_dist[0].lower():
				self.__os_flavor = validate_flavor('linux', 'ubuntu')
				#print("!:" + self.__os_flavor)
			elif 'centos' in my_dist[0].lower():
				self.__os_flavor = validate_flavor('linux', 'centos')
			else:
				self.__os_flavor = None

			if not self.__os_flavor == None:
				self.__os_version = version_util.version(my_dist[1])
def test_invalid_range():
	try:
		test = version_util.version_range(">a.b")
		assert False
	except ValueError:
		assert True
		
	try:
		test = version_util.version("-012")
		assert False
	except ValueError:
		assert True
		
	try:
		test = version_util.version("<=>1.0.0")
		assert False
	except ValueError:
		assert True
Пример #8
0
def test_invalid_range():
    try:
        test = version_util.version_range(">a.b")
        assert False
    except ValueError:
        assert True

    try:
        test = version_util.version("-012")
        assert False
    except ValueError:
        assert True

    try:
        test = version_util.version("<=>1.0.0")
        assert False
    except ValueError:
        assert True
def test_vulnerability_create():

    provides = 'test'
    version = '1.0.0'

    vuln = vulnerability(name, desc, provides, version)

    assert vuln.name() == name
    assert vuln.description() == desc
    assert vuln.provides() == provides
    assert vuln.version() == version_util.version(version)
def test_vulnerability_create():
	
	
	provides = 'test'
	version = '1.0.0'
	
	vuln = vulnerability(name, desc, provides, version)
	
	assert vuln.name() == name
	assert vuln.description() == desc
	assert vuln.provides() == provides
	assert vuln.version() == version_util.version(version)
Пример #11
0
	def version_pass(self, provides_string, version_string):

		if not self.provides_string() == provides_string:
			return False

		if version_string == None:
			return True

		if isinstance(version_string, version_util.version):
			version_obj = version_string
		elif cross_version.isstring(provides_string):
			version_obj = version_util.version(version_string)
		else:
			raise ValueError("Provides string is not a string or version object")

		if self.version_range().in_range(version_obj):
			return True

		return False
Пример #12
0
    def version_pass(self, provides_string, version_string):

        if not self.provides_string() == provides_string:
            return False

        if version_string == None:
            return True

        if isinstance(version_string, version_util.version):
            version_obj = version_string
        elif cross_version.isstring(provides_string):
            version_obj = version_util.version(version_string)
        else:
            raise ValueError("Provides string is not a string or version object")

        if self.version_range().in_range(version_obj):
            return True

        return False
Пример #13
0
	def __init__(self, name, description, provides='', provides_version=''):
		if (not cross_version.isstring(name) or not cross_version.isstring(description)
			or not cross_version.isstring(provides) or not cross_version.isstring(provides_version)):
			raise ValueError("All values must be strings")

		self.__name = name
		self.__description = description
		if provides.strip() == "":
			self.__provides = None
		else:
			self.__provides = provides
		if provides_version.strip() == '':
			self.__version = None
		else:
			self.__version = version_util.version(provides_version)
		self.__dependencies = []
		self.__cmd_uses = []
		self.__cmd_modifies = []
		self.__supported_os_list = []
		self.__difficulty = None
Пример #14
0
    def __init__(self, name, description, provides="", provides_version=""):
        if (
            not cross_version.isstring(name)
            or not cross_version.isstring(description)
            or not cross_version.isstring(provides)
            or not cross_version.isstring(provides_version)
        ):
            raise ValueError("All values must be strings")

        self.__name = name
        self.__description = description
        if provides.strip() == "":
            self.__provides = None
        else:
            self.__provides = provides
        if provides_version.strip() == "":
            self.__version = None
        else:
            self.__version = version_util.version(provides_version)
        self.__dependencies = []
        self.__cmd_uses = []
        self.__cmd_modifies = []
        self.__supported_os_list = []
        self.__difficulty = None