forked from savon-noir/python-libnmap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpe.py
More file actions
90 lines (74 loc) · 2.14 KB
/
cpe.py
File metadata and controls
90 lines (74 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# -*- coding: utf-8 -*-
class CPE(object):
"""
CPE class offers an API for basic CPE objects.
These objects could be found in NmapService or in <os> tag
within NmapHost.
:todo: interpret CPE string and provide appropriate API
"""
def __init__(self, cpestring):
self._cpestring = cpestring
self.cpedict = {}
zk = ['cpe', 'part', 'vendor', 'product', 'version',
'update', 'edition', 'language']
self._cpedict = dict((k, '') for k in zk)
splitup = cpestring.split(':')
self._cpedict.update(dict(zip(zk, splitup)))
@property
def cpestring(self):
"""
Accessor for the full CPE string.
"""
return self._cpestring
def __repr__(self):
return self._cpestring
def get_part(self):
"""
Returns the cpe part (/o, /h, /a)
"""
return self._cpedict['part']
def get_vendor(self):
"""
Returns the vendor name
"""
return self._cpedict['vendor']
def get_product(self):
"""
Returns the product name
"""
return self._cpedict['product']
def get_version(self):
"""
Returns the version of the cpe
"""
return self._cpedict['version']
def get_update(self):
"""
Returns the update version
"""
return self._cpedict['update']
def get_edition(self):
"""
Returns the cpe edition
"""
return self._cpedict['edition']
def get_language(self):
"""
Returns the cpe language
"""
return self._cpedict['language']
def is_application(self):
"""
Returns True if cpe describes an application
"""
return (self.get_part() == '/a')
def is_hardware(self):
"""
Returns True if cpe describes a hardware
"""
return (self.get_part() == '/h')
def is_operating_system(self):
"""
Returns True if cpe describes an operating system
"""
return (self.get_part() == '/o')