[paludis-commits] r4076 - in trunk: . paludis paludis/repositories/e python ruby src/clients/paludis

ciaranm at svn.pioto.org ciaranm at svn.pioto.org
Fri Dec 14 18:16:11 UTC 2007


Author: ciaranm
Date: 2007-12-14 18:16:00 +0000 (Fri, 14 Dec 2007)
New Revision: 4076

Modified:
   trunk/ChangeLog
   trunk/paludis/dep_tag.cc
   trunk/paludis/dep_tag.hh
   trunk/paludis/report_task.cc
   trunk/paludis/report_task.hh
   trunk/paludis/repositories/e/e_repository_sets.cc
   trunk/python/dep_tag.cc
   trunk/python/dep_tag_TEST.py
   trunk/ruby/dep_tag.cc
   trunk/ruby/dep_tag_TEST.rb
   trunk/src/clients/paludis/report.cc
Log:
Add glsa_file to GLSADepTag. Fixes: ticket:456. (Stefan K?\195?\182gl)


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-12-14 18:15:40 UTC (rev 4075)
+++ trunk/ChangeLog	2007-12-14 18:16:00 UTC (rev 4076)
@@ -5,6 +5,13 @@
 only listed in SVN log. For a summary of what has changed between releases,
 see the NEWS file. This file is occasionally pruned to ChangeLog.old.bz2.
 
+2007-12-14 Stefan Kögl
+
+	* paludis/, python/, ruby/, src/clients/paludis/: Add glsa_file to
+	GLSADepTag.
+
+	+ Fixes: ticket:456
+
 2007-12-13 Richard Brown
 
 	* paludis/repositories/e/ebuild/src_test.bash: Fix faq location given

Modified: trunk/paludis/dep_tag.cc
===================================================================
--- trunk/paludis/dep_tag.cc	2007-12-14 18:15:40 UTC (rev 4075)
+++ trunk/paludis/dep_tag.cc	2007-12-14 18:16:00 UTC (rev 4076)
@@ -274,9 +274,10 @@
     return c1.value < c2.value;
 }
 
-GLSADepTag::GLSADepTag(const std::string & id, const std::string & our_glsa_title) :
+GLSADepTag::GLSADepTag(const std::string & id, const std::string & our_glsa_title, const FSEntry& our_glsa_file) :
     _id(id),
-    _glsa_title(our_glsa_title)
+    _glsa_title(our_glsa_title),
+    _glsa_file(our_glsa_file)
 {
 }
 
@@ -296,6 +297,12 @@
     return "glsa";
 }
 
+const FSEntry
+GLSADepTag::glsa_file() const
+{
+    return _glsa_file;
+}
+
 std::string
 GLSADepTag::glsa_title() const
 {

Modified: trunk/paludis/dep_tag.hh
===================================================================
--- trunk/paludis/dep_tag.hh	2007-12-14 18:15:40 UTC (rev 4075)
+++ trunk/paludis/dep_tag.hh	2007-12-14 18:16:00 UTC (rev 4076)
@@ -43,6 +43,7 @@
 #include <paludis/util/virtual_constructor.hh>
 #include <paludis/util/exception.hh>
 #include <paludis/util/sr.hh>
+#include <paludis/util/fs_entry.hh>
 #include <paludis/util/operators.hh>
 
 #include <string>
@@ -227,25 +228,36 @@
         private:
             const std::string _id;
             const std::string _glsa_title;
+            const FSEntry _glsa_file;
 
         public:
             ///\name Basic operations
             ///\{
 
-            GLSADepTag(const std::string & id, const std::string & glsa_title);
+            GLSADepTag(const std::string & id, const std::string & glsa_title, const FSEntry&);
             ~GLSADepTag();
 
             ///\}
 
+            ///\name Content information
+            ///\{
+
             virtual std::string short_text() const;
 
             virtual std::string category() const;
 
             /**
+             * The full path to the glsa announcement file.
+             */
+            const FSEntry glsa_file() const;
+
+            /**
              * Fetch our GLSA title (for example, 'Yet another PHP remote access
              * hole').
              */
             std::string glsa_title() const;
+
+            ///\}
     };
 
     /**

Modified: trunk/paludis/report_task.cc
===================================================================
--- trunk/paludis/report_task.cc	2007-12-14 18:15:40 UTC (rev 4075)
+++ trunk/paludis/report_task.cc	2007-12-14 18:16:00 UTC (rev 4076)
@@ -27,6 +27,7 @@
 #include <paludis/package_id.hh>
 #include <paludis/util/private_implementation_pattern-impl.hh>
 #include <paludis/util/visitor-impl.hh>
+#include <paludis/util/visitor_cast.hh>
 #include <paludis/util/set.hh>
 #include <paludis/package_database.hh>
 #include <paludis/version_requirements.hh>
@@ -94,7 +95,7 @@
                 _env.package_database()->query(query::Matches(a), qo_order_by_version));
         for (PackageIDSequence::ConstIterator i(insecure->begin()),
                 i_end(insecure->end()) ; i != i_end ; ++i)
-            if (a.tag())
+            if (a.tag() && visitor_cast<const GLSADepTag>(*a.tag()))
                 _found.insert(std::make_pair(*i, a.tag()));
             else
                 throw InternalError(PALUDIS_HERE, "didn't get a tag");
@@ -232,7 +233,7 @@
                         {
                             on_report_package_is_vulnerable_pre(*v);
                             for (VulnerableChecker::ConstIterator itag(pi.first) ; itag != pi.second ; ++itag)
-                                on_report_package_is_vulnerable(*v, itag->second->short_text());
+                                on_report_package_is_vulnerable(*v, *static_cast<const GLSADepTag *>(itag->second.get()) );
                             on_report_package_is_vulnerable_post(*v);
                         }
                         if (is_missing)
@@ -252,4 +253,3 @@
 
     on_report_all_post();
 }
-

Modified: trunk/paludis/report_task.hh
===================================================================
--- trunk/paludis/report_task.hh	2007-12-14 18:15:40 UTC (rev 4075)
+++ trunk/paludis/report_task.hh	2007-12-14 18:16:00 UTC (rev 4076)
@@ -23,6 +23,7 @@
 #include <paludis/util/instantiation_policy.hh>
 #include <paludis/util/private_implementation_pattern.hh>
 #include <paludis/repository.hh>
+#include <paludis/dep_tag-fwd.hh>
 
 /** \file
  * Declarations for ReportTask.
@@ -74,7 +75,7 @@
             virtual void on_report_package_is_masked(const tr1::shared_ptr<const PackageID> & id,
                     const tr1::shared_ptr<const PackageID> & origin) = 0;
             virtual void on_report_package_is_vulnerable_pre(const tr1::shared_ptr<const PackageID> & id) = 0;
-            virtual void on_report_package_is_vulnerable(const tr1::shared_ptr<const PackageID> & id, const std::string & tag) = 0;
+            virtual void on_report_package_is_vulnerable(const tr1::shared_ptr<const PackageID> & id, const GLSADepTag & glsa_tag) = 0;
             virtual void on_report_package_is_vulnerable_post(const tr1::shared_ptr<const PackageID> & id) = 0;
             virtual void on_report_package_is_missing(const tr1::shared_ptr<const PackageID> & id,
                     const RepositoryName & repo_name) = 0;

Modified: trunk/paludis/repositories/e/e_repository_sets.cc
===================================================================
--- trunk/paludis/repositories/e/e_repository_sets.cc	2007-12-14 18:15:40 UTC (rev 4075)
+++ trunk/paludis/repositories/e/e_repository_sets.cc	2007-12-14 18:16:00 UTC (rev 4076)
@@ -265,7 +265,7 @@
 
                     if (glsa_tags.end() == glsa_tags.find(glsa->id()))
                         glsa_tags.insert(std::make_pair(glsa->id(), tr1::shared_ptr<GLSADepTag>(
-                                        new GLSADepTag(glsa->id(), glsa->title()))));
+                                        new GLSADepTag(glsa->id(), glsa->title(), *f))));
 
                     if (insecurity)
                     {

Modified: trunk/python/dep_tag.cc
===================================================================
--- trunk/python/dep_tag.cc	2007-12-14 18:15:40 UTC (rev 4075)
+++ trunk/python/dep_tag.cc	2007-12-14 18:16:00 UTC (rev 4076)
@@ -137,11 +137,14 @@
         (
          "GLSADepTag",
          "DepTag subclass for GLSAs.",
-         bp::init<const std::string &, const std::string &>("__init__(id_str, glsa_title_str)")
+         bp::init<const std::string &, const std::string &, const FSEntry &>("__init__(id_str, glsa_title_str, glsa_file_str)")
         )
         .add_property("glsa_title", &GLSADepTag::glsa_title,
                 "Our GLSA title (for example, 'Yet another PHP remote access hole')"
                 )
+        .add_property("glsa_file", &GLSADepTag::glsa_file,
+                "Our GLSA filename"
+                )
         ;
 
     /**

Modified: trunk/python/dep_tag_TEST.py
===================================================================
--- trunk/python/dep_tag_TEST.py	2007-12-14 18:15:40 UTC (rev 4075)
+++ trunk/python/dep_tag_TEST.py	2007-12-14 18:16:00 UTC (rev 4076)
@@ -28,7 +28,7 @@
 class TestCase_02_GLSADepTag(unittest.TestCase):
     def setUp(self):
         global dt
-        dt = GLSADepTag("id", "title")
+        dt = GLSADepTag("id", "title", "/path")
 
     def test_01_instance(self):
         self.assert_(isinstance(dt, DepTag))
@@ -37,6 +37,7 @@
         self.assertEquals(dt.category, "glsa")
         self.assertEquals(dt.short_text, "GLSA-id")
         self.assertEquals(dt.glsa_title, "title")
+        self.assertEquals(dt.glsa_file, "/path")
 
 class TestCase_03_GeneralSetDepTag(unittest.TestCase):
     def setUp(self):

Modified: trunk/ruby/dep_tag.cc
===================================================================
--- trunk/ruby/dep_tag.cc	2007-12-14 18:15:40 UTC (rev 4075)
+++ trunk/ruby/dep_tag.cc	2007-12-14 18:16:00 UTC (rev 4076)
@@ -110,13 +110,14 @@
     VALUE
     glsa_dep_tag_new(int argc, VALUE * argv, VALUE self)
     {
-        if (2 != argc)
-            rb_raise(rb_eArgError, "GLSADepTag expects two arguments, but got %d",argc);
+        if (3 != argc)
+            rb_raise(rb_eArgError, "GLSADepTag expects three arguments, but got %d",argc);
 
         tr1::shared_ptr<const DepTag> * ptr(0);
         try
         {
-            ptr = new tr1::shared_ptr<const DepTag>(new GLSADepTag(StringValuePtr(argv[0]), StringValuePtr(argv[1])));
+            ptr = new tr1::shared_ptr<const DepTag>(new GLSADepTag(StringValuePtr(argv[0]), StringValuePtr(argv[1]),
+                        FSEntry(StringValuePtr(argv[2]))));
             VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<const DepTag> >::free, ptr));
             rb_obj_call_init(tdata, argc, argv);
             return tdata;
@@ -212,6 +213,26 @@
         }
     };
 
+    /*
+     * Document-method: glsa_file
+     *
+     * call-seq:
+     *     glsa_file -> String
+     *
+     * Fetch our GLSA file.
+     */
+    template <typename T_, const FSEntry (T_::* m_) () const>
+    struct DepTagFSEntryThings
+    {
+        static VALUE
+        fetch(VALUE self)
+        {
+            tr1::shared_ptr<const DepTag> * ptr;
+            Data_Get_Struct(self, tr1::shared_ptr<const DepTag>, ptr);
+            return rb_str_new2(stringify(((*tr1::static_pointer_cast<const T_>(*ptr)).*m_)()).c_str());
+        }
+    };
+
     void do_register_dep_tag()
     {
         /*
@@ -244,6 +265,8 @@
         rb_define_singleton_method(c_glsa_dep_tag, "new", RUBY_FUNC_CAST(&glsa_dep_tag_new), -1);
         rb_define_method(c_glsa_dep_tag, "glsa_title", RUBY_FUNC_CAST((&DepTagThings<GLSADepTag,
                         &GLSADepTag::glsa_title>::fetch)), 0);
+        rb_define_method(c_glsa_dep_tag, "glsa_file", RUBY_FUNC_CAST((&DepTagFSEntryThings<GLSADepTag,
+                        &GLSADepTag::glsa_file>::fetch)), 0);
 
         /*
          * Document-class: Paludis::GeneralSetDepTag

Modified: trunk/ruby/dep_tag_TEST.rb
===================================================================
--- trunk/ruby/dep_tag_TEST.rb	2007-12-14 18:15:40 UTC (rev 4075)
+++ trunk/ruby/dep_tag_TEST.rb	2007-12-14 18:16:00 UTC (rev 4076)
@@ -68,7 +68,7 @@
 
     class TestCase_GLSADepTag < Test::Unit::TestCase
         def get_dt
-            GLSADepTag.new("id", "title")
+            GLSADepTag.new("id", "title", "/path")
         end
 
         def test_create
@@ -85,7 +85,7 @@
             end
 
             assert_raise TypeError do
-                GLSADepTag.new(1,1)
+                GLSADepTag.new(1,1,3)
             end
         end
 
@@ -94,7 +94,8 @@
             {
                 :short_text => 'GLSA-id',
                 :category=>'glsa',
-                :glsa_title => 'title'
+                :glsa_title => 'title',
+                :glsa_file => "/path"
             }.each do |method, val|
                 assert_respond_to dt, method
                 assert_equal val, dt.send(method)

Modified: trunk/src/clients/paludis/report.cc
===================================================================
--- trunk/src/clients/paludis/report.cc	2007-12-14 18:15:40 UTC (rev 4075)
+++ trunk/src/clients/paludis/report.cc	2007-12-14 18:16:00 UTC (rev 4076)
@@ -22,6 +22,7 @@
 #include <src/output/mask_displayer.hh>
 #include <paludis/report_task.hh>
 #include <paludis/mask.hh>
+#include <paludis/dep_tag.hh>
 #include <paludis/package_id.hh>
 #include <paludis/util/visitor-impl.hh>
 #include <iostream>
@@ -59,7 +60,7 @@
             virtual void on_report_package_failure_pre(const tr1::shared_ptr<const PackageID> & id);
             virtual void on_report_package_is_masked(const tr1::shared_ptr<const PackageID> & id, const tr1::shared_ptr<const PackageID> & origin);
             virtual void on_report_package_is_vulnerable_pre(const tr1::shared_ptr<const PackageID> & id);
-            virtual void on_report_package_is_vulnerable(const tr1::shared_ptr<const PackageID> & id, const std::string & tag);
+            virtual void on_report_package_is_vulnerable(const tr1::shared_ptr<const PackageID> & id, const GLSADepTag & glsa_tag);
             virtual void on_report_package_is_vulnerable_post(const tr1::shared_ptr<const PackageID> & id);
             virtual void on_report_package_is_missing(const tr1::shared_ptr<const PackageID> & id, const RepositoryName & repo_name);
             virtual void on_report_package_is_unused(const tr1::shared_ptr<const PackageID> & id);
@@ -121,13 +122,14 @@
     void
     OurReportTask::on_report_package_is_vulnerable_pre(const tr1::shared_ptr<const PackageID> &)
     {
-        cout << endl << "    Affected by:";
+        cout << endl << "this package has following security issues:" << endl;
     }
 
     void
-    OurReportTask::on_report_package_is_vulnerable(const tr1::shared_ptr<const PackageID> &, const std::string & tag)
+    OurReportTask::on_report_package_is_vulnerable(const tr1::shared_ptr<const PackageID> &, const GLSADepTag & glsa_tag)
     {
-        cout << " " << colour(cl_tag, tag);
+        cout << "    " << colour(cl_error, glsa_tag.short_text() + ": \"" + glsa_tag.glsa_title() +"\"")
+                    << endl << colour(cl_error, "        -> " + stringify(glsa_tag.glsa_file())) << endl;
         ++_n_errors;
     }
 



More information about the paludis-commits mailing list