summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--VERSION1
-rw-r--r--bin/kernel-check26
-rw-r--r--lib/guidexml.py311
-rw-r--r--setup.py21
-rw-r--r--src/kernelcheck/__init__.py (renamed from lib/__init__.py)0
-rwxr-xr-xsrc/kernelcheck/kernelcheck.py (renamed from kernel-check.py)0
-rw-r--r--src/kernelcheck/lib/__init__.py0
-rw-r--r--src/kernelcheck/lib/kernellib.py (renamed from lib/kernellib.py)0
8 files changed, 48 insertions, 311 deletions
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..2080591
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+0.3.11
diff --git a/bin/kernel-check b/bin/kernel-check
new file mode 100644
index 0000000..bc19907
--- /dev/null
+++ b/bin/kernel-check
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+# kernel-check -- Kernel security information
+# Copyright 2009-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import sys
+from kernelcheck import kernelcheck
+
+try:
+ import signal
+
+ def exithandler(signum,frame):
+ signal.signal(signal.SIGINT, signal.SIG_IGN)
+ signal.signal(signal.SIGTERM, signal.SIG_IGN)
+ print
+ sys.exit(1)
+
+ signal.signal(signal.SIGINT, exithandler)
+ signal.signal(signal.SIGTERM, exithandler)
+ signal.signal(signal.SIGPIPE, signal.SIG_DFL)
+
+except KeyboardInterrupt:
+ print
+ sys.exit(1)
+
+kernelcheck.main(sys.argv[1:])
diff --git a/lib/guidexml.py b/lib/guidexml.py
deleted file mode 100644
index d6babb8..0000000
--- a/lib/guidexml.py
+++ /dev/null
@@ -1,311 +0,0 @@
-#!/usr/bin/env python
-# guidexml -- guidexml class for python
-# Copyright 2009-2009 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-import datetime
-import os
-import xml.etree.cElementTree
-
-MAXLENGTH = 80
-
-LANGUAGES = ['en', 'de']
-
-LICENSE = ''.join(['<!-- The content of this document is licensed under the CC-BY-SA license -->\n',
-'<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->\n<license/>'])
-
-TAGTYPES = ['p', 'c', 'b', 'e', 'i', 'pre', 'path', 'uri', 'note', 'warn', 'impo',
- 'comment', 'sub', 'sup', 'keyword', 'ident', 'const', 'stmt', 'var']
-
-#pre only in first body
-#<pre caption="Code Sample">
-
-class Document(object):
- title = str()
- abstract = str()
- docversion = str()
- encoding = str()
- doctype = str()
- date = str()
- version = str()
- license = str()
- link = str()
- lang = str()
-
- chapters = list()
- authors = list()
-
-
- def __init__(self, title, version, abstract, lang, link, docversion='1.0',
- encoding='UTF-8', doctype='/dtd/guide.dtd', date=None, license=None):
-
- if type(title) is not str:
- raise TypeError
- if type(abstract) is not str:
- raise TypeError
- if type(docversion) is not str:
- raise TypeError
- if type(encoding) is not str:
- raise TypeError
- if type(doctype) is not str:
- raise TypeError
- if type(version) is not str:
- raise TypeError
- if type(date) is not str and date is not None:
- raise TypeError
- if type(license) is not str and license is not None:
- raise TypeError
- if type(link) is not str:
- raise TypeError
- if type(lang) is not str:
- raise TypeError
- if lang not in LANGUAGES:
- raise ValueError
-
- self.title = title
- self.abstract = abstract
- self.docversion = docversion
- self.encoding = encoding
- self.doctype = doctype
- self.version = version
- self.link = link
- self.lang = lang
-
- if date is None:
- self.date = datetime.datetime.now().isoformat()[:10]
- else:
- self.date = date #TODO check YYYY-MM-DD
-
- if license is None:
- self.license = LICENSE
- else:
- self.license = license
-
-
- def addAuthor(self, title, name, email=None):
- self.authors.append(Author(title, name, email))
-
-
- def append(self, chapter):
- if type(chapter) is not Chapter:
- raise TypeError
- else:
- self.chapters.append(chapter)
-
-
- def create(self, path, filename):
- xmlfile = os.path.join(path, filename) #TODO
-
- output = list()
-
- if len(self.authors) == 0:
- raise ValueError
-
- output.append('<?xml version="%s" encoding="%s"?>\n' % (self.docversion, self.encoding))
- output.append('<!DOCTYPE guide SYSTEM "%s">\n<!-- $Header$ -->\n\n' % (self.doctype))
- output.append('<guide>\n<title>%s</title>\n\n' % (self.title))
-
- for item in self.authors:
- output.append('<author title="%s">\n' % (item.title))
- if item.email is not None:
- output.append(' <mail link="%s">%s</mail>\n</author>' % (item.email, item.name))
- else:
- output.append(' %s\n</author>' % (item.name))
-
- output.append('\n\n<abstract>\n%s\n</abstract>' % (linebreak(self.abstract)))
- output.append('\n\n%s\n\n<version>%s</version>\n' % (self.license, self.version))
- output.append('<date>%s</date>\n\n' % (self.date))
-
- if len(self.chapters) > 0:
- for chapter in self.chapters:
- output.append('<chapter>\n')
- if len(chapter.sections) > 0:
- for section in chapter.sections:
- output.append('<section>\n')
- output.append('<body>\n')
- for tag in section.tags:
- if tag.tagtype in ['pre', 'p']:
- output.append('\n%s\n' % repr(tag))
- else:
- output.append(repr(tag))
-
- output.append('\n</body>\n')
- output.append('</section>\n')
- output.append('</chapter>\n')
-
- output.append('</guide>')
-
- print ''.join(output)
-
-
-#TODO
-def linebreak(text):
- if len(text) <= MAXLENGTH:
- return text
-
- linebreak = str()
- i = 0;
- while i < len(text):
- if i + MAXLENGTH < len(text):
- linebreak += ''.join([text[i:i + MAXLENGTH], '\n'])
- else:
- linebreak += text[i:i + MAXLENGTH]
- i += MAXLENGTH
- return linebreak
-
-
-class Author(object):
- title = str()
- name = str()
- email = str()
-
- def __init__(self, title, name, email=None):
- if type(title) is not str:
- raise TypeError
- if type(name) is not str:
- raise TypeError
- if type(email) is not str and email is not None:
- raise TypeError
-
- self.title = title
- self.name = name
- self.email = email
-
-
-class Chapter(object):
- title = None
- sections = list()
-
- def __init__(self, title):
- if type(title) is not str:
- raise TypeError
-
- self.title = title
-
-
- def append(self, section):
- if type(section) is not Section:
- raise TypeError
- else:
- self.sections.append(section)
-
-
-class Section(object):
- title = None
- bodys = list()
-
- def __init__(self, title):
- if type(title) is not str:
- raise TypeError
-
- self.title = title
-
-
- tags = list()
-
- def append(self, tag):
- if type(tag) is Tag:
- self.tags.append(tag)
- elif type(tag) is list:
- for item in tag:
- self.append(item)
- elif type(tag) is str:
- self.tags.append(Tag('text', tag))
- else:
- raise TypeError
-
-
-class Tag(object):
- tagtype = str()
- text = str()
-
- def __init__(self, tagtype, text):
- if tagtype not in TAGTYPES:
- raise TypeError
- if type(text) is not str:
- raise TypeError
-
- self.tagtype = tagtype
- self.text = text
-
- def __repr__(self):
- if (len(self.tagtype) * 2 + 5 + len(self.text)) > MAXLENGTH:
- return '<%s>\n%s\n</%s>' % (self.tagtype, self.text, self.tagtype)
- else:
- return '<%s>%s</%s>' % (self.tagtype, self.text, self.tagtype)
-
-def preserve(text):
- return Tag('pre', text)
-
-
-def paragraph(text):
- return Tag('p', text)
-
-
-def warning(text):
- return Tag('warn', text)
-
-
-def important(text):
- return Tag('impo', text)
-
-
-def note(text):
- return Tag('note', text)
-
-
-def comment(text):
- return Tag('comment', text)
-
-
-def path(text):
- return Tag('path', text)
-
-
-def command(text):
- return Tag('c', text)
-
-
-def userinput(text):
- return Tag('i', text)
-
-
-def keyword(text):
- return Tag('keyword', text)
-
-
-def identifier(text):
- return Tag('ident', text)
-
-
-def constant(text):
- return Tag('const', text)
-
-
-def statement(text):
- return Tag('stmt', text)
-
-
-def variable(text):
- return Tag('var', text)
-
-
-def bold(text):
- return Tag('b', text)
-
-
-def emphasize(text):
- return Tag('e', text)
-
-
-def subscript(text):
- return Tag('sub', text)
-
-
-def superscript(text):
- return Tag('sup', text)
-
-
-def uri(text):
- return Tag('uri', text)
-
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..b28221e
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+# kernel-check -- Kernel security information
+# Copyright 2009-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from distutils.core import setup
+
+__version__ = open("VERSION").read().strip()
+
+setup(
+ name='Kernel-check',
+ version=__version__,
+ description='Gentoo kernel tracking tool',
+ author='Bjoern Trop',
+ author_email='asym@gentoo.org',
+ url='http://www.python.org/sigs/distutils-sig/', #TODO
+ package_dir={'': 'src'},
+ packages=['kernelcheck', 'kernelcheck.lib'],
+ scripts=['bin/kernel-check']
+)
+
diff --git a/lib/__init__.py b/src/kernelcheck/__init__.py
index e69de29..e69de29 100644
--- a/lib/__init__.py
+++ b/src/kernelcheck/__init__.py
diff --git a/kernel-check.py b/src/kernelcheck/kernelcheck.py
index 1587b98..1587b98 100755
--- a/kernel-check.py
+++ b/src/kernelcheck/kernelcheck.py
diff --git a/src/kernelcheck/lib/__init__.py b/src/kernelcheck/lib/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/kernelcheck/lib/__init__.py
diff --git a/lib/kernellib.py b/src/kernelcheck/lib/kernellib.py
index cf2e6ab..cf2e6ab 100644
--- a/lib/kernellib.py
+++ b/src/kernelcheck/lib/kernellib.py