aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-12-14 18:16:00 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-12-14 18:16:00 +0000
commitc2ac51f9632a8e46ef701a8b2d07f82d6fed69a7 (patch)
tree299a0478863c6a79b65b8d3bd66d31bdd83b090a
parent3d0b865e6ca5431b621e2537395c973829366b42 (diff)
downloadpaludis-c2ac51f9632a8e46ef701a8b2d07f82d6fed69a7.tar.gz
paludis-c2ac51f9632a8e46ef701a8b2d07f82d6fed69a7.tar.xz
Add glsa_file to GLSADepTag. Fixes: ticket:456. (Stefan Kögl)
-rw-r--r--paludis/dep_tag.cc11
-rw-r--r--paludis/dep_tag.hh14
-rw-r--r--paludis/report_task.cc6
-rw-r--r--paludis/report_task.hh3
-rw-r--r--paludis/repositories/e/e_repository_sets.cc2
-rw-r--r--python/dep_tag.cc5
-rwxr-xr-xpython/dep_tag_TEST.py3
-rw-r--r--ruby/dep_tag.cc29
-rw-r--r--ruby/dep_tag_TEST.rb7
-rw-r--r--src/clients/paludis/report.cc10
10 files changed, 70 insertions, 20 deletions
diff --git a/paludis/dep_tag.cc b/paludis/dep_tag.cc
index e904a35..107390a 100644
--- a/paludis/dep_tag.cc
+++ b/paludis/dep_tag.cc
@@ -274,9 +274,10 @@ DepTag::operator< (const DepTag & other) const
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 @@ GLSADepTag::category() const
return "glsa";
}
+const FSEntry
+GLSADepTag::glsa_file() const
+{
+ return _glsa_file;
+}
+
std::string
GLSADepTag::glsa_title() const
{
diff --git a/paludis/dep_tag.hh b/paludis/dep_tag.hh
index a8e5a7b..349c9ca 100644
--- a/paludis/dep_tag.hh
+++ b/paludis/dep_tag.hh
@@ -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 @@ namespace paludis
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;
+
+ ///\}
};
/**
diff --git a/paludis/report_task.cc b/paludis/report_task.cc
index 6fa4c2f..10cbd86 100644
--- a/paludis/report_task.cc
+++ b/paludis/report_task.cc
@@ -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 @@ namespace
_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 @@ ReportTask::execute()
{
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 @@ ReportTask::execute()
on_report_all_post();
}
-
diff --git a/paludis/report_task.hh b/paludis/report_task.hh
index 165157b..c268d45 100644
--- a/paludis/report_task.hh
+++ b/paludis/report_task.hh
@@ -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 @@ namespace paludis
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;
diff --git a/paludis/repositories/e/e_repository_sets.cc b/paludis/repositories/e/e_repository_sets.cc
index bf09393..a43eab1 100644
--- a/paludis/repositories/e/e_repository_sets.cc
+++ b/paludis/repositories/e/e_repository_sets.cc
@@ -265,7 +265,7 @@ ERepositorySets::security_set(bool insecurity) const
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)
{
diff --git a/python/dep_tag.cc b/python/dep_tag.cc
index fe77bbf..7087f6f 100644
--- a/python/dep_tag.cc
+++ b/python/dep_tag.cc
@@ -137,11 +137,14 @@ void expose_dep_tag()
(
"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"
+ )
;
/**
diff --git a/python/dep_tag_TEST.py b/python/dep_tag_TEST.py
index bcde430..1b3a2ac 100755
--- a/python/dep_tag_TEST.py
+++ b/python/dep_tag_TEST.py
@@ -28,7 +28,7 @@ class TestCase_01_DepTag(unittest.TestCase):
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 @@ class TestCase_02_GLSADepTag(unittest.TestCase):
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):
diff --git a/ruby/dep_tag.cc b/ruby/dep_tag.cc
index a0bf2d2..084a8e8 100644
--- a/ruby/dep_tag.cc
+++ b/ruby/dep_tag.cc
@@ -110,13 +110,14 @@ namespace
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 @@ namespace
}
};
+ /*
+ * 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 @@ namespace
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
diff --git a/ruby/dep_tag_TEST.rb b/ruby/dep_tag_TEST.rb
index 60c04f3..a3b456a 100644
--- a/ruby/dep_tag_TEST.rb
+++ b/ruby/dep_tag_TEST.rb
@@ -68,7 +68,7 @@ module Paludis
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 @@ module Paludis
end
assert_raise TypeError do
- GLSADepTag.new(1,1)
+ GLSADepTag.new(1,1,3)
end
end
@@ -94,7 +94,8 @@ module Paludis
{
: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)
diff --git a/src/clients/paludis/report.cc b/src/clients/paludis/report.cc
index ee23fc1..47cc5f8 100644
--- a/src/clients/paludis/report.cc
+++ b/src/clients/paludis/report.cc
@@ -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 @@ namespace
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 @@ namespace
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;
}