def test_vulnerability_dependency_add():
	
	provides = 'test'
	version = '3.0.1'
	
	vuln = vulnerability(name, desc, provides, version)
	
	vuln.add_dependency(("app1", ">=1.0.0"))
	
	dep_list = vuln.get_dependencies()
	
	
	
	assert dep_list[0].get_links()[0][0] == "app1"
	assert dep_list[0].get_links()[0][1] == version_util.version_range(">=1.0.0")
	
	vuln.add_dependency( [("app2", ">=1.0.0"), ("app3", ">=1.0.0")] )
	
	dep_list = vuln.get_dependencies()
	
	#~ print(dep_list[1].get_links())
	
	assert dep_list[1].get_links()[0].provides_string == "app2"
	assert dep_list[1].get_links()[0].version_range == version_util.version_range(">=1.0.0")
	assert dep_list[1].get_links()[1].provides_string == "app3"
	assert dep_list[1].get_links()[1].version_range == version_util.version_range(">=1.0.0")
def test_vulnerability_dependency_add():

    provides = 'test'
    version = '3.0.1'

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

    vuln.add_dependency(("app1", ">=1.0.0"))

    dep_list = vuln.get_dependencies()

    assert dep_list[0].get_links()[0][0] == "app1"
    assert dep_list[0].get_links()[0][1] == version_util.version_range(
        ">=1.0.0")

    vuln.add_dependency([("app2", ">=1.0.0"), ("app3", ">=1.0.0")])

    dep_list = vuln.get_dependencies()

    #~ print(dep_list[1].get_links())

    assert dep_list[1].get_links()[0].provides_string == "app2"
    assert dep_list[1].get_links(
    )[0].version_range == version_util.version_range(">=1.0.0")
    assert dep_list[1].get_links()[1].provides_string == "app3"
    assert dep_list[1].get_links(
    )[1].version_range == version_util.version_range(">=1.0.0")
Exemplo n.º 3
0
	def is_in_range(self, required_range):

		if self.__version == None:
			return False

		if not isinstance(required_range, version_util.version_range):
			required_range = version_util.version_range(required_range)

		return required_range.in_range(self.__version)
Exemplo n.º 4
0
    def is_in_range(self, required_range):

        if self.__version == None:
            return False

        if not isinstance(required_range, version_util.version_range):
            required_range = version_util.version_range(required_range)

        return required_range.in_range(self.__version)
Exemplo n.º 5
0
	def __init__(self, provides_string, version_range):

		if not cross_version.isstring(provides_string):
			raise ValueError("Provides string is not a string")
		else:
			self.__provides_string = provides_string

		if cross_version.isstring(version_range):
			self.__version_range = version_util.version_range(version_range)
		elif isinstance(version_range, version_util.version_range):
			self.__version_range = version_range
Exemplo n.º 6
0
    def __init__(self, provides_string, version_range):

        if not cross_version.isstring(provides_string):
            raise ValueError("Provides string is not a string")
        else:
            self.__provides_string = provides_string

        if cross_version.isstring(version_range):
            self.__version_range = version_util.version_range(version_range)
        elif isinstance(version_range, version_util.version_range):
            self.__version_range = version_range
def test_test_range():

	test_range = version_util.version_range(">1.0.1")
	
	assert test_range.in_range("1.0.0") == False
	assert test_range.in_range("1.0.3") == True
	assert test_range.in_range("0.0.4") == False
	assert test_range.in_range("0.4") == False
	assert test_range.in_range("4") == True
	
	test_range = version_util.version_range("<=4.5.0.1")
	
	assert test_range.in_range("4.5.0.1") == True
	assert test_range.in_range("4.5.0.1-a") == True
	assert test_range.in_range("1.0.3") == True
	assert test_range.in_range("0.0.4") == True
	assert test_range.in_range("4.6") == False
	assert test_range.in_range("4.7.8.9") == False
	
	
	test_range = version_util.version_range(">=3.4.1a")
	
	assert test_range.in_range("4.5.0.1") == True
	assert test_range.in_range("3.4.2") == True
	assert test_range.in_range("3.4.1b") == True
	assert test_range.in_range("5.6.7.6b") == True
	assert test_range.in_range("3.3") == False
	assert test_range.in_range("3.4.1") == False
	
	
	test_range = version_util.version_range("=20.0.1")
	
	assert test_range.in_range("20.0.1") == True
	assert test_range.in_range("20.0.1a") == False
	assert test_range.in_range("1.0.3") == False
	assert test_range.in_range("0.0.4") == False
	assert test_range.in_range("4.6") == False
	assert test_range.in_range("4.7.8.9") == False
Exemplo n.º 8
0
    def __init__(self, os_type, flavor='*', version_range='*'):

        if valid_os(os_type):
            self.__os_type = os_type
        else:
            raise ValueError("Invalid OS type")

        if flavor == '*' or flavor == "-":
            self.__flavor = flavor
        elif valid_flavor(self.__os_type, flavor):
            self.__flavor = flavor
        else:
            raise ValueError("Invalid OS flavor")

        self.__version = version_util.version_range(version_range)
Exemplo n.º 9
0
def test_test_range():

    test_range = version_util.version_range(">1.0.1")

    assert test_range.in_range("1.0.0") == False
    assert test_range.in_range("1.0.3") == True
    assert test_range.in_range("0.0.4") == False
    assert test_range.in_range("0.4") == False
    assert test_range.in_range("4") == True

    test_range = version_util.version_range("<=4.5.0.1")

    assert test_range.in_range("4.5.0.1") == True
    assert test_range.in_range("4.5.0.1-a") == True
    assert test_range.in_range("1.0.3") == True
    assert test_range.in_range("0.0.4") == True
    assert test_range.in_range("4.6") == False
    assert test_range.in_range("4.7.8.9") == False

    test_range = version_util.version_range(">=3.4.1a")

    assert test_range.in_range("4.5.0.1") == True
    assert test_range.in_range("3.4.2") == True
    assert test_range.in_range("3.4.1b") == True
    assert test_range.in_range("5.6.7.6b") == True
    assert test_range.in_range("3.3") == False
    assert test_range.in_range("3.4.1") == False

    test_range = version_util.version_range("=20.0.1")

    assert test_range.in_range("20.0.1") == True
    assert test_range.in_range("20.0.1a") == False
    assert test_range.in_range("1.0.3") == False
    assert test_range.in_range("0.0.4") == False
    assert test_range.in_range("4.6") == False
    assert test_range.in_range("4.7.8.9") == False
Exemplo n.º 10
0
	def range_pass(self, provides_string, version_range):

		if not cross_version.isstring(provides_string):
			raise ValueError("Provides string is not a string")

		if not isinstance(version_range, version_util.version_range):
			range_obj = version_util.version_range(version_range)
		else:
			range_obj = version_range

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

		if range_obj.intersects(self.version_range()):
			return True

		return False
Exemplo n.º 11
0
	def __init__(self, os_type, flavor='*', version_range='*'):
		
		if valid_os(os_type):
			self.__os_type = os_type
		else:
			raise ValueError("Invalid OS type")
			
		
		if flavor == '*' or flavor == "-":
			self.__flavor = flavor
		elif valid_flavor(self.__os_type, flavor):
			self.__flavor = flavor
		else:
			raise ValueError("Invalid OS flavor")
			
			
		self.__version = version_util.version_range(version_range)
Exemplo n.º 12
0
    def range_pass(self, provides_string, version_range):

        if not cross_version.isstring(provides_string):
            raise ValueError("Provides string is not a string")

        if not isinstance(version_range, version_util.version_range):
            range_obj = version_util.version_range(version_range)
        else:
            range_obj = version_range

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

        if range_obj.intersects(self.version_range()):
            return True

        return False
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
Exemplo n.º 14
0
	def __init__(self, choice_list):

		#~ print("Choice List")
		#~ print(choice_list)
		#~ print(inspect.stack())
		self.__dep_links = []

		if len(choice_list) == 0:
			raise ValueError("No dependencies set")

		for choice in choice_list:

			if isinstance(choice, tuple) and len(choice) == 2 and cross_version.isstring(choice[0]) and cross_version.isstring(choice[1]):
				self.__dep_links.append(Dependency_Choice(choice[0], version_util.version_range(choice[1])))
			else:
				raise ValueError("Invalid tuple")

		self.__backup = copy.deepcopy(self.__dep_links)
Exemplo n.º 15
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
Exemplo n.º 16
0
    def __init__(self, choice_list):

        # ~ print("Choice List")
        # ~ print(choice_list)
        # ~ print(inspect.stack())
        self.__dep_links = []

        if len(choice_list) == 0:
            raise ValueError("No dependencies set")

        for choice in choice_list:

            if (
                isinstance(choice, tuple)
                and len(choice) == 2
                and cross_version.isstring(choice[0])
                and cross_version.isstring(choice[1])
            ):
                self.__dep_links.append(Dependency_Choice(choice[0], version_util.version_range(choice[1])))
            else:
                raise ValueError("Invalid tuple")

        self.__backup = copy.deepcopy(self.__dep_links)