Package portage :: Module glsa
[hide private]

Module glsa

source code

Classes [hide private]
  GlsaTypeException
  GlsaFormatException
  GlsaArgumentException
  Glsa
This class is a wrapper for the XML data and provides methods to access and display the contained data.
Functions [hide private]
list
get_applied_glsas(settings)
Return a list of applied or injected GLSA IDs
source code
String
wrap(text, width, caption=u'')
Wraps the given text at column width, optionally indenting it so that no text is under caption.
source code
List of Strings
get_glsa_list(myconfig)
Returns a list of all available GLSAs in the given repository by comparing the filelist there with the pattern described in the config.
source code
List of Strings
getListElements(listnode)
Get all <li> elements for a given <ol> or <ul> node.
source code
String
getText(node, format, textfd=None)
This is the main parser function.
source code
List of Strings
getMultiTagsText(rootnode, tagname, format)
Returns a list with the text of all subnodes of type tagname under rootnode (which itself is not parsed) using the given format.
source code
String
makeAtom(pkgname, versionNode)
creates from the given package name and information in the versionNode a (syntactical) valid portage atom.
source code
String
makeVersion(versionNode)
creates from the information in the versionNode a version string (format <op><version>).
source code
list of strings
match(atom, dbapi, match_type=u'default')
wrapper that calls revisionMatch() or portage.dbapi.dbapi.match() depending on the given atom.
source code
list of strings
revisionMatch(revisionAtom, dbapi, match_type=u'default')
handler for the special >~, >=~, <=~ and <~ atoms that are supposed to behave as > and < except that they are limited to the same version, the range only applies to the revision part.
source code
String | None
getMinUpgrade(vulnerableList, unaffectedList, portdbapi, vardbapi, minimize=True)
Checks if the systemstate is matching an atom in vulnerableList and returns string describing the lowest version for the package that matches an atom in unaffectedList and is greater than the currently installed version.
source code
String
format_date(datestr)
Takes a date (announced, revised) date from a GLSA and formats it as readable text (i.e.
source code
Variables [hide private]
  opMapping = {u'eq': u'=', u'ge': u'>=', u'gt': u'>', u'le': u'...
  NEWLINE_ESCAPE = u'!;\n'
  SPACE_ESCAPE = u'!;_'
  __package__ = None
hash(x)

Imports: io, sys, urllib_request_urlopen, codecs, re, operator, xml, StringIO, reduce, portage, os, _encodings, _unicode_decode, _unicode_encode, pkgsplit, vercmp, grabfile, PRIVATE_PATH, _, _slot_separator


Function Details [hide private]

get_applied_glsas(settings)

source code 

Return a list of applied or injected GLSA IDs

Parameters:
  • settings (portage.config) - portage config instance
Returns: list
list of glsa IDs

wrap(text, width, caption=u'')

source code 

Wraps the given text at column width, optionally indenting it so that no text is under caption. It's possible to encode hard linebreaks in text with NEWLINE_ESCAPE.

Parameters:
  • text (String) - the text to be wrapped
  • width (Integer) - the column at which the text should be wrapped
  • caption (String) - this string is inserted at the beginning of the return value and the paragraph is indented up to len(caption).
Returns: String
the wrapped and indented paragraph

get_glsa_list(myconfig)

source code 

Returns a list of all available GLSAs in the given repository by comparing the filelist there with the pattern described in the config.

Parameters:
  • myconfig (portage.config) - Portage settings instance
Returns: List of Strings
a list of GLSA IDs in this repository

getListElements(listnode)

source code 

Get all <li> elements for a given <ol> or <ul> node.

Parameters:
  • listnode (xml.dom.Node) - <ul> or <ol> list to get the elements for
Returns: List of Strings
a list that contains the value of the <li> elements

getText(node, format, textfd=None)

source code 

This is the main parser function. It takes a node and traverses recursive over the subnodes, getting the text of each (and the link attribute for <uri> and <mail>). Depending on the format parameter the text might be formatted by adding/removing newlines, tabs and spaces. This function is only useful for the GLSA DTD, it's not applicable for other DTDs.

Parameters:
  • node (xml.dom.Node) - the root node to start with the parsing
  • format (String) - this should be either strip, keep or xml keep just gets the text and does no formatting. strip replaces newlines and tabs with spaces and replaces multiple spaces with one space. xml does some more formatting, depending on the type of the encountered nodes.
  • textfd (writable file-like object) - the file-like object to write the output to
Returns: String
the (formatted) content of the node and its subnodes except if textfd was not none

getMultiTagsText(rootnode, tagname, format)

source code 

Returns a list with the text of all subnodes of type tagname under rootnode (which itself is not parsed) using the given format.

Parameters:
  • rootnode (xml.dom.Node) - the node to search for tagname
  • tagname (String) - the name of the tags to search for
  • format (String) - see getText
Returns: List of Strings
a list containing the text of all tagname childnodes

makeAtom(pkgname, versionNode)

source code 

creates from the given package name and information in the versionNode a (syntactical) valid portage atom.

Parameters:
  • pkgname (String) - the name of the package for this atom
  • versionNode (xml.dom.Node) - a <vulnerable> or <unaffected> Node that contains the version information for this atom
Returns: String
the portage atom

makeVersion(versionNode)

source code 

creates from the information in the versionNode a version string (format <op><version>).

Parameters:
  • versionNode (xml.dom.Node) - a <vulnerable> or <unaffected> Node that contains the version information for this atom
Returns: String
the version string

match(atom, dbapi, match_type=u'default')

source code 

wrapper that calls revisionMatch() or portage.dbapi.dbapi.match() depending on the given atom.

Parameters:
  • atom (string) - a <~ or >~ atom or a normal portage atom that contains the atom to match against
  • dbapi (portage.dbapi.dbapi) - one of the portage databases to use as information source
  • match_type (string) - if != "default" passed as first argument to dbapi.xmatch to apply the wanted visibility filters
Returns: list of strings
a list with the matching versions

revisionMatch(revisionAtom, dbapi, match_type=u'default')

source code 

handler for the special >~, >=~, <=~ and <~ atoms that are supposed to behave as > and < except that they are limited to the same version, the range only applies to the revision part.

Parameters:
  • revisionAtom (string) - a <~ or >~ atom that contains the atom to match against
  • dbapi (portage.dbapi.dbapi) - one of the portage databases to use as information source
  • match_type (string) - if != "default" passed as first argument to portdb.xmatch to apply the wanted visibility filters
Returns: list of strings
a list with the matching versions

getMinUpgrade(vulnerableList, unaffectedList, portdbapi, vardbapi, minimize=True)

source code 

Checks if the systemstate is matching an atom in vulnerableList and returns string describing the lowest version for the package that matches an atom in unaffectedList and is greater than the currently installed version. It will return an empty list if the system is affected, and no upgrade is possible or None if the system is not affected. Both vulnerableList and unaffectedList should have the same base package.

Parameters:
  • vulnerableList (List of Strings) - atoms matching vulnerable package versions
  • unaffectedList (List of Strings) - atoms matching unaffected package versions
  • portdbapi (portage.dbapi.porttree.portdbapi) - Ebuild repository
  • vardbapi (portage.dbapi.vartree.vardbapi) - Installed package repository
  • minimize (Boolean) - True for a least-change upgrade, False for emerge-like algorithm
Returns: String | None
the lowest unaffected version that is greater than the installed version.

format_date(datestr)

source code 

Takes a date (announced, revised) date from a GLSA and formats it as readable text (i.e. "January 1, 2008").

Parameters:
  • date (String) - the date string to reformat
Returns: String
a reformatted string, or the original string if it cannot be reformatted.

Variables Details [hide private]

opMapping

Value:
{u'eq': u'=',
 u'ge': u'>=',
 u'gt': u'>',
 u'le': u'<=',
 u'lt': u'<',
 u'rge': u'>=~',
 u'rgt': u' >~',
 u'rle': u'<=~',
...