annotate parse_cvrf @ 40:1d9b2b06067e

Add a CPE parser (and tests)
author Benoît Allard <benoit.allard@greenbone.net>
date Mon, 29 Dec 2014 14:30:39 +0100
parents e18b61a73a68
children
rev   line source
0
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
1 #! /usr/bin/env python
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
3 #
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
4 # Authors:
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
5 # BenoƮt Allard <benoit.allard@greenbone.net>
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
6 #
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
7 # Copyright:
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
8 # Copyright (C) 2014 Greenbone Networks GmbH
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
9 #
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
10 # This program is free software; you can redistribute it and/or
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
11 # modify it under the terms of the GNU General Public License
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
12 # as published by the Free Software Foundation; either version 2
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
13 # of the License, or (at your option) any later version.
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
14 #
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
15 # This program is distributed in the hope that it will be useful,
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
18 # GNU General Public License for more details.
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
19 #
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
20 # You should have received a copy of the GNU General Public License
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
21 # along with this program; if not, write to the Free Software
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
22 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
23
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
24 import sys
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
25
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
26 from farolluz.parsers.cvrf import parse
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
27
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
28 if __name__ == "__main__":
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
29 with open(sys.argv[1], 'rt') as f:
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
30 cvrf = parse(f)
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
31 cvrf.validate()
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
32 print(cvrf)
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
33 print(cvrf.getHighestCVSS()._vector)
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
34 print(cvrf.getProductList())
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
35 print(cvrf._producttree._branches)
e18b61a73a68 Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
36 # print(cvrf._producttree._branches[0]._childs)
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)