CPESet1_1 class¶
-
class
cpe.cpeset1_1.
CPESet1_1
¶ 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 .cpeset1_1 import CPESet1_1 >>> from .cpe1_1 import CPE1_1 >>> uri1 = 'cpe://microsoft:windows:xp!vista' >>> c1 = CPE1_1(uri1) >>> s = CPESet1_1() >>> 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 identical CPE in set
>>> from .cpe1_1 import CPE1_1 >>> from .cpeset1_1 import CPESet1_1 >>> uri1 = 'cpe://microsoft:windows:xp!vista' >>> uri2 = 'cpe:/cisco::3825;cisco:2:44/cisco:ios:12.3:enterprise' >>> c1 = CPE1_1(uri1) >>> c2 = CPE1_1(uri2) >>> s = CPESet1_1() >>> s.append(c1) >>> s.append(c2) >>> s.name_match(c2) True