summaryrefslogtreecommitdiffstats
path: root/lib/python/sectracker_test
diff options
context:
space:
mode:
authorFlorian Weimer <fw@deneb.enyo.de>2010-05-08 09:16:30 +0000
committerFlorian Weimer <fw@deneb.enyo.de>2010-05-08 09:16:30 +0000
commit3f5602f9ec7f707c6835f997d66fd5d7a9da5781 (patch)
treeaefa0393139e0fe405ee614df969c6c4ec90429a /lib/python/sectracker_test
parentf94a073acb9bc5f0dc82a8b61638dd48e5def521 (diff)
sectracker.parsers: rename from parsers
git-svn-id: svn+ssh://svn.debian.org/svn/secure-testing@14638 e39458fd-73e7-0310-bf30-c45bca0a0e42
Diffstat (limited to 'lib/python/sectracker_test')
-rw-r--r--lib/python/sectracker_test/test_parsers.py119
1 files changed, 119 insertions, 0 deletions
diff --git a/lib/python/sectracker_test/test_parsers.py b/lib/python/sectracker_test/test_parsers.py
new file mode 100644
index 0000000000..8d3f49b4f6
--- /dev/null
+++ b/lib/python/sectracker_test/test_parsers.py
@@ -0,0 +1,119 @@
+# Test for sectracker.parsers
+# Copyright (C) 2010 Florian Weimer <fw@deneb.enyo.de>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+from sectracker.parsers import *
+import sectracker.parsers as p
+from sectracker.xpickle import safeunlink, EXTENSION
+
+o = binarypackages("../../data/packages/sid__main_i386_Packages")
+assert type(o) == type(())
+assert "bash" in o
+
+o = sourcepackages("../../data/packages/sid__main_Sources")
+assert type(o) == type({})
+assert "bash" in o
+
+safeunlink("../../data/CVE/list" + EXTENSION)
+o = cvelist("../../data/CVE/list")
+for err in o.messages:
+ print "%s:%d: %s: %s" % (err.file, err.line, err.level, err.message)
+
+Message = sectracker.diagnostics.Message
+for (line, res, xmsgs) in [
+ (' - foo <unfixed>',
+ PackageAnnotation(17, "package", None, "foo", "unfixed", None,
+ None, None, (), False), ()),
+ (' - foo',
+ PackageAnnotation(17, "package", None, "foo", "unfixed", None,
+ None, None, (), False), ()),
+ (' [lenny] - foo <unfixed>',
+ PackageAnnotation(17, "package", "lenny", "foo", "unfixed", None,
+ None, None, (), False), ()),
+ (' [lenny] - foo <undetermined> (bug #1234)',
+ PackageAnnotation(17, "package", "lenny", "foo", "undetermined",
+ None, None, None, (1234,), False), ()),
+ (' [lenny] - foo <itp> (bug #1234)',
+ PackageAnnotation(17, "package", "lenny", "foo", "itp", None,
+ None, None, (1234,), False), ()),
+ (' [lenny] - foo <itp>',
+ PackageAnnotation(17, "package", "lenny", "foo", "itp", None,
+ None, None, (), False),
+ (Message("CVE", 17, "error",
+ "<itp> needs Debian bug reference"),)),
+ (' [lenny] - foo 1.0',
+ PackageAnnotation(17, "package", "lenny", "foo", "fixed", "1.0" ,
+ None, None, (), False), ()),
+ (' [lenny] - foo <unfixed> (bug filed)',
+ PackageAnnotation(17, "package", "lenny", "foo", "unfixed", None,
+ None, None, (), True), ()),
+ (' [lenny] - foo <unfixed> (bug filed; bug #1234)',
+ PackageAnnotation(17, "package", "lenny", "foo", "unfixed", None,
+ None, None, (1234,), False),
+ (Message("CVE", 17, "error",
+ "'bug filed' and bug numbers listed"),)),
+ (' [lenny] - foo <unfixed> (low)',
+ PackageAnnotation(17, "package", "lenny", "foo", "unfixed", None,
+ None, "low", (), False), ()),
+ (' [lenny] - foo <unfixed> (low; low)',
+ PackageAnnotation(17, "package", "lenny", "foo", "unfixed", None,
+ None, "low", (), False),
+ (Message("CVE", 17, "error", "duplicate flag: 'low'"),)),
+ (' [lenny] - foo <unfixed> (bug #1234; garbled)',
+ PackageAnnotation(17, "package", "lenny", "foo", "unfixed", None,
+ None, None, (1234,), False),
+ (Message("CVE", 17, "error",
+ "invalid inner annotation: 'garbled'"),)),
+ (' [lenny] - foo <no-dsa> (explanation goes here)',
+ PackageAnnotation(17, "package", "lenny", "foo", "no-dsa", None,
+ "explanation goes here", None, (), False), ()),
+ (' [lenny] - foo <end-of-life> (explanation goes here)',
+ PackageAnnotation(17, "package", "lenny", "foo", "end-of-life",
+ None, "explanation goes here", None, (), False),
+ ()),
+ (' [lenny] - foo <not-affected> (explanation goes here)',
+ PackageAnnotation(17, "package", "lenny", "foo", "not-affected",
+ None,
+ "explanation goes here", None, (), False), ()),
+ ('\t{CVE-2009-1234 CVE-2009-1235}',
+ XrefAnnotation(17, "xref",
+ tuple("CVE-2009-1234 CVE-2009-1235".split())),
+ ()),
+ ('\t{}', None,
+ (Message("CVE", 17, "error", "empty cross-reference"),)),
+ (' NOT-FOR-US: Plan 9',
+ StringAnnotation(17, "NOT-FOR-US", "Plan 9"), ()),
+ (' TODO: to-do', StringAnnotation(17, "TODO", "to-do"), ()),
+ (' NOTE: note', StringAnnotation(17, "NOTE", "note"), ()),
+ (' RESERVED', FlagAnnotation(17, 'RESERVED'), ()),
+ (' REJECTED', FlagAnnotation(17, 'REJECTED'), ()),
+ (' garbled', None,
+ (Message("CVE", 17, "error", "invalid annotation"),)),
+ (' [lenny] - foo <garbled> (bug #1234)', None,
+ (Message("CVE", 17, "error",
+ "invalid pseudo-version: 'garbled'"),)),
+ ]:
+ anns = []
+ diag = sectracker.diagnostics.Diagnostics()
+ diag.setlocation("CVE", 17)
+ p._annotationdispatcher(line, diag, anns)
+ msgs = diag.messages()
+ assert tuple(msgs) == xmsgs, repr(msgs)
+ if anns:
+ r = anns[0]
+ else:
+ r = None
+ assert r == res, repr(anns)

© 2014-2024 Faster IT GmbH | imprint | privacy policy