[Yum-devel] yum-security plugin review, possible merge into yum-utils?

Luke Macken lmacken at redhat.com
Tue May 8 05:29:33 UTC 2007


On Tue, Apr 24, 2007 at 09:34:33AM -0400, James Antill wrote:
> >     o ysp_show_pkg_md_info() -- This looks like it would best fit into
> >       yum.update_md.UpdateNotice.__str__.  Right now the __str__ for
> >       UpdateNotices is a bit ugly, but improvements are definitely
> >       welcome, and that seems like the place to do something like this.
> 
>  Very much so, but I didn't want to just reassign parts of the class. If
> you think it's good to change it though, feel free to replace the
> __str__ function and then delete that function with a simple print.

I committed some cleanups to the yum.update_md.UpdateNotice.__str__ method.
Attached is a patch to utilize it for the yum-security plugin.  This patch is
generated against CVS HEAD + yum-security-plugin.patch from your last email.

So info-sec now looks like this:

[lmacken at tomservo ~]$ sudo yum --security info-sec
Loading "security" plugin
Loading "fastestmirror" plugin
Loading "installonlyn" plugin
Loading mirror speeds from cached hostfile

===============================================================================
  mutt-1.5.14-3.fc7
===============================================================================
  Update ID : FEDORA-2007-0001
    Release : Fedora Core 7
       Type : security
     Status : testing
     Issued : 2007-05-07 23:27:54.125243
       Bugs : 123 - netstat -M problem
            : 23425 - Bugzilla omits the bugzilla report item for bug reports
       CVEs : CVE-2007-0000
Description : foobar
      Files : mutt-debuginfo-1.5.14-3.fc7.i386.rpm
            : mutt-1.5.14-3.fc7.i386.rpm
            : mutt-1.5.14-3.fc7.src.rpm

info-sec done


Feel free to make any tweaks to the output that you want.

luke
-------------- next part --------------
--- security.py.patched	2007-05-08 00:28:22.000000000 -0400
+++ security.py	2007-05-08 00:33:27.000000000 -0400
@@ -103,39 +103,11 @@
     md = md.get_notice((pkg.name, pkg.ver, pkg.rel))
     if not md:
         return None
-    md = md.get_metadata()
 
     if rname and not ysp_has_info_md(rname, md):
         return None
     return ysp_should_filter_pkg(opts, pkg, md, used_map)
 
-def ysp_show_pkg_md_info(pkg, md, msg):
-    msg(pkg)
-    msg('  ID      ' + md['update_id'])
-    msg('  Type    ' + md['type'])
-    msg('  Issued  ' + md['issued'])
-    if md['issued'] != md['updated']:
-        msg('  Updated ' + md['updated'])
-    if md['references']:
-        msg('  References')
-        for ref in md['references']:
-            if ref['type'] == 'cve':
-                txt = "    CVE " + ref['id'];
-            elif ref['type'] == 'bugzilla':
-                txt = "    BZ  " + ref['id'];
-            else:
-                msg("   *" + ref['type'])
-            if 'summary' in ref:
-                if (len(txt) + len(ref['summary'])) <= 76:
-                    msg("%s: %s" % (txt, ref['summary']))
-                else:
-                    msg("%s: %.*s..." % (txt, 73 -len(txt), ref['summary']))
-            elif 'href' in ref and \
-                     (len(txt) + len(ref['href'])) <= 76:
-                msg("%s - %s" % (txt, ref['href']))
-            else:
-                msg(txt)
-
 def ysp_gen_used_map(opts):
     used_map = {'bugzilla' : {}, 'cve' : {}, 'id' : {}}
     for i in opts.advisory:
@@ -237,12 +209,7 @@
         return ['info-security', 'info-sec']
 
     def show_pkg(self, msg, pkg, md, disp=None):
-        ysp_show_pkg_md_info(pkg, md, msg)
-        if md['description'] != None:
-            msg('  Description')
-            msg(textwrap.fill(md['description'],
-                              width=75, expand_tabs=False,
-                              initial_indent="     ", subsequent_indent="    "))
+        msg(md)
         msg('')
     
 def config_hook(conduit):
@@ -305,7 +272,6 @@
     md = md.get_notice((pkg.name, pkg.ver, pkg.rel))
     if not md:
         return False
-    md = md.get_metadata()
     
     return ysp_should_filter_pkg(opts, pkg, md, used_map)
 


More information about the Yum-devel mailing list