CPESet2_2 class¶
-
class
cpe.cpeset2_2.
CPESet2_2
¶ Represents a set of CPE Names.
This class allows:
- create set of CPE Names.
- match a CPE element against a set of CPE Names.
-
append
(cpe)¶ Adds a CPE Name to the set if not already.
Parameters: cpe (CPE) – CPE Name to store in set Returns: None Exception: ValueError - invalid version of CPE Name TEST:
>>> from .cpeset2_2 import CPESet2_2 >>> from .cpe2_2 import CPE2_2 >>> uri1 = 'cpe:/h:hp' >>> c1 = CPE2_2(uri1) >>> s = CPESet2_2() >>> s.append(c1)
-
name_match
(cpe)¶ Accepts a set of known instances of CPE Names and a candidate CPE Name, and returns ‘True’ if the candidate can be shown to be an instance based on the content of the known instances. Otherwise, it returns ‘False’.
Parameters: Returns: True if X matches K, otherwise False.
Return type: boolean
TEST: matching with ANY values explicit
>>> from .cpe2_2 import CPE2_2 >>> uri1 = 'cpe:/o:microsoft:windows:vista' >>> uri2 = 'cpe:/o:cisco:ios:12.3:enterprise' >>> c1 = CPE2_2(uri1) >>> c2 = CPE2_2(uri2) >>> s = CPESet2_2() >>> s.append(c1) >>> s.append(c2) >>> uri3 = 'cpe:/o:microsoft::vista' >>> c3 = CPE2_2(uri3) >>> s.name_match(c3) True