aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2007-05-26 19:11:00 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2007-05-26 19:11:00 +0000
commit2dfff28604226456472edd45f755376f871d362c (patch)
tree610ef32d6d13dc84ea841737630bb424af86b7f3
parent73bc46049a80c13b0896e4267507330a28bc8fdd (diff)
downloadpaludis-2dfff28604226456472edd45f755376f871d362c.tar.gz
paludis-2dfff28604226456472edd45f755376f871d362c.tar.xz
Fix range="r*" in GLSAs, fix PortageRepository::sets_list(), add some tests.
-rw-r--r--paludis/repositories/gentoo/Makefile.am19
-rw-r--r--paludis/repositories/gentoo/portage_repository_sets.cc5
-rw-r--r--paludis/repositories/gentoo/portage_repository_sets_TEST.cc174
-rwxr-xr-xpaludis/repositories/gentoo/portage_repository_sets_TEST_cleanup.sh10
-rwxr-xr-xpaludis/repositories/gentoo/portage_repository_sets_TEST_setup.sh214
5 files changed, 418 insertions, 4 deletions
diff --git a/paludis/repositories/gentoo/Makefile.am b/paludis/repositories/gentoo/Makefile.am
index 52d9a4c..c071838 100644
--- a/paludis/repositories/gentoo/Makefile.am
+++ b/paludis/repositories/gentoo/Makefile.am
@@ -130,6 +130,20 @@ vdb_unmerger_TEST_LDADD = \
vdb_unmerger_TEST_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir)
+portage_repository_sets_TEST_SOURCES = portage_repository_sets_TEST.cc
+
+portage_repository_sets_TEST_LDADD = \
+ libpaludisgentoorepository.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(top_builddir)/paludis/util/test_extras.o \
+ $(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/paludis/environments/test/libpaludistestenvironment.la \
+ $(top_builddir)/paludis/repositories/fake/libpaludisfakerepository.la \
+ $(top_builddir)/test/libtest.a \
+ $(DYNAMIC_LD_LIBS)
+
+portage_repository_sets_TEST_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir)
+
EXTRA_DIST = \
ebuild.sr \
ebuild-sr.hh \
@@ -194,7 +208,8 @@ BUILT_SOURCES = \
check_SCRIPTS = \
portage_repository_TEST_setup.sh portage_repository_TEST_cleanup.sh \
xml_things_TEST_setup.sh xml_things_TEST_cleanup.sh \
- vdb_repository_TEST_setup.sh vdb_repository_TEST_cleanup.sh
+ vdb_repository_TEST_setup.sh vdb_repository_TEST_cleanup.sh \
+ portage_repository_sets_TEST_setup.sh portage_repository_sets_TEST_cleanup.sh
TESTS_ENVIRONMENT = env \
PALUDIS_EBUILD_DIR="`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_srcdir)/paludis/repositories/gentoo/ebuild/`" \
@@ -287,7 +302,7 @@ xml_things_TEST_LDADD = \
endif
-TESTS = portage_repository_TEST vdb_unmerger_TEST $(GLSA_TESTS)
+TESTS = portage_repository_TEST vdb_unmerger_TEST $(GLSA_TESTS) portage_repository_sets_TEST
check_PROGRAMS = $(TESTS)
built-sources : $(BUILT_SOURCES)
diff --git a/paludis/repositories/gentoo/portage_repository_sets.cc b/paludis/repositories/gentoo/portage_repository_sets.cc
index b95ad98..9f1732a 100644
--- a/paludis/repositories/gentoo/portage_repository_sets.cc
+++ b/paludis/repositories/gentoo/portage_repository_sets.cc
@@ -32,6 +32,7 @@
#include <paludis/util/fs_entry.hh>
#include <paludis/util/is_file_with_extension.hh>
#include <paludis/util/log.hh>
+#include <paludis/util/strip.hh>
#include <paludis/util/tokeniser.hh>
#include <list>
@@ -131,7 +132,7 @@ PortageRepositorySets::sets_list() const
for ( ; f != f_end ; ++f)
try
{
- result->insert(SetName(stringify(*f)));
+ result->insert(SetName(strip_trailing_string(f->basename(), ".conf")));
}
catch (const NameError & e)
{
@@ -203,7 +204,7 @@ namespace
if (0 == r.op.compare(0, 1, "r"))
{
- return (VersionOperator(our_op).as_version_spec_comparator()(e.version, VersionSpec(ver))) &&
+ return e.version.remove_revision() == VersionSpec(ver).remove_revision() &&
match_range(e, GLSARange::create().op(r.op.substr(1)).version(r.version));
}
diff --git a/paludis/repositories/gentoo/portage_repository_sets_TEST.cc b/paludis/repositories/gentoo/portage_repository_sets_TEST.cc
new file mode 100644
index 0000000..d82342c
--- /dev/null
+++ b/paludis/repositories/gentoo/portage_repository_sets_TEST.cc
@@ -0,0 +1,174 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 David Leverton <u01drl3@abdn.ac.uk>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/repositories/gentoo/portage_repository.hh>
+#include <paludis/repositories/gentoo/make_ebuild_repository.hh>
+#include <paludis/repositories/fake/fake_installed_repository.hh>
+#include <paludis/dep_spec_pretty_printer.hh>
+#include <paludis/util/collection_concrete.hh>
+#include <paludis/util/visitor-impl.hh>
+#include <paludis/environments/test/test_environment.hh>
+#include <paludis/util/system.hh>
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+#include "config.h"
+
+using namespace test;
+using namespace paludis;
+
+/** \file
+ * Test cases for PortageRepositorySets.
+ *
+ */
+
+namespace test_cases
+{
+ /**
+ * \test Test PortageRepositorySets sets list.
+ *
+ */
+ struct PortageRepositorySetsSetsListTest : TestCase
+ {
+ PortageRepositorySetsSetsListTest() : TestCase("sets list") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ tr1::shared_ptr<AssociativeCollection<std::string, std::string> > keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "portage_repository_sets_TEST_dir/repo1");
+ keys->insert("profiles", "portage_repository_sets_TEST_dir/repo1/profiles/profile");
+ tr1::shared_ptr<PortageRepository> repo(make_ebuild_repository(
+ &env, keys));
+
+ tr1::shared_ptr<const SetNameCollection> sets_list(repo->sets_interface->sets_list());
+ TEST_CHECK_EQUAL(sets_list->size(), 4U);
+ TEST_CHECK(sets_list->end() != sets_list->find(SetName("system")));
+ TEST_CHECK(sets_list->end() != sets_list->find(SetName("security")));
+ TEST_CHECK(sets_list->end() != sets_list->find(SetName("insecurity")));
+ TEST_CHECK(sets_list->end() != sets_list->find(SetName("set1")));
+ }
+ } test_portage_repository_sets_sets_list;
+
+ /**
+ * \test Test PortageRepositorySets maintainer-defined sets.
+ *
+ */
+ struct PortageRepositorySetsMaintainerDefinedSetsTest : TestCase
+ {
+ PortageRepositorySetsMaintainerDefinedSetsTest() : TestCase("maintainer-defined sets") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ tr1::shared_ptr<AssociativeCollection<std::string, std::string> > keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "portage_repository_sets_TEST_dir/repo1");
+ keys->insert("profiles", "portage_repository_sets_TEST_dir/repo1/profiles/profile");
+ tr1::shared_ptr<PortageRepository> repo(make_ebuild_repository(
+ &env, keys));
+ tr1::shared_ptr<FakeInstalledRepository> installed(
+ new FakeInstalledRepository(&env, RepositoryName("installed")));
+ installed->add_version("cat-two", "bar", "1.5");
+ env.package_database()->add_repository(0, installed);
+
+ tr1::shared_ptr<SetSpecTree::ConstItem> set1(repo->sets_interface->package_set(SetName("set1")));
+ DepSpecPrettyPrinter pretty(0, false);
+ set1->accept(pretty);
+ TEST_CHECK_STRINGIFY_EQUAL(pretty, "cat-one/foo >=cat-two/bar-2");
+ }
+ } test_portage_repository_sets_maintainer_defined_sets_list;
+
+ /**
+ * \test Test PortageRepositorySets insecurity set.
+ *
+ */
+ struct PortageRepositorySetsInsecuritySetTest : TestCase
+ {
+ PortageRepositorySetsInsecuritySetTest() : TestCase("insecurity set") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ tr1::shared_ptr<AssociativeCollection<std::string, std::string> > keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "portage_repository_sets_TEST_dir/repo1");
+ keys->insert("profiles", "portage_repository_sets_TEST_dir/repo1/profiles/profile");
+ tr1::shared_ptr<PortageRepository> repo(make_ebuild_repository(
+ &env, keys));
+ env.package_database()->add_repository(1, repo);
+
+ tr1::shared_ptr<SetSpecTree::ConstItem> insecurity(repo->sets_interface->package_set(SetName("insecurity")));
+ DepSpecPrettyPrinter pretty(0, false);
+ insecurity->accept(pretty);
+#if ENABLE_GLSA
+ TEST_CHECK_STRINGIFY_EQUAL(pretty, "=cat-one/foo-1::test-repo-1 =cat-two/bar-1.5::test-repo-1 "
+ "=cat-two/bar-1.5.1::test-repo-1 =cat-three/baz-1.0::test-repo-1 "
+ "=cat-three/baz-1.1-r2::test-repo-1 =cat-three/baz-1.2::test-repo-1");
+#else
+ TEST_CHECK_STRINGIFY_EQUAL(pretty, "");
+#endif
+ }
+ } test_portage_repository_sets_insecurity_set;
+
+ /**
+ * \test Test PortageRepositorySets security set.
+ *
+ */
+ struct PortageRepositorySetsSecuritySetTest : TestCase
+ {
+ PortageRepositorySetsSecuritySetTest() : TestCase("security set") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ tr1::shared_ptr<AssociativeCollection<std::string, std::string> > keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "portage_repository_sets_TEST_dir/repo1");
+ keys->insert("profiles", "portage_repository_sets_TEST_dir/repo1/profiles/profile");
+ tr1::shared_ptr<PortageRepository> repo(make_ebuild_repository(
+ &env, keys));
+ env.package_database()->add_repository(1, repo);
+ tr1::shared_ptr<FakeInstalledRepository> installed(
+ new FakeInstalledRepository(&env, RepositoryName("installed")));
+ installed->add_version("cat-one", "foo", "2.1");
+ installed->add_version("cat-two", "bar", "1.5");
+ installed->add_version("cat-three", "baz", "1.0");
+ env.package_database()->add_repository(0, installed);
+
+ tr1::shared_ptr<const SetSpecTree::ConstItem> security(repo->sets_interface->package_set(SetName("security")));
+ DepSpecPrettyPrinter pretty(0, false);
+ security->accept(pretty);
+#if ENABLE_GLSA
+ TEST_CHECK_STRINGIFY_EQUAL(pretty, "=cat-two/bar-2.0::test-repo-1 =cat-three/baz-1.3::test-repo-1");
+#else
+ TEST_CHECK_STRINGIFY_EQUAL(pretty, "");
+#endif
+ }
+ } test_portage_repository_sets_security_set;
+}
+
diff --git a/paludis/repositories/gentoo/portage_repository_sets_TEST_cleanup.sh b/paludis/repositories/gentoo/portage_repository_sets_TEST_cleanup.sh
new file mode 100755
index 0000000..26cfada
--- /dev/null
+++ b/paludis/repositories/gentoo/portage_repository_sets_TEST_cleanup.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d portage_repository_sets_TEST_dir ] ; then
+ rm -fr portage_repository_sets_TEST_dir
+else
+ true
+fi
+
+
diff --git a/paludis/repositories/gentoo/portage_repository_sets_TEST_setup.sh b/paludis/repositories/gentoo/portage_repository_sets_TEST_setup.sh
new file mode 100755
index 0000000..4111994
--- /dev/null
+++ b/paludis/repositories/gentoo/portage_repository_sets_TEST_setup.sh
@@ -0,0 +1,214 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir portage_repository_sets_TEST_dir || exit 1
+cd portage_repository_sets_TEST_dir || exit 1
+
+mkdir -p repo1/{eclass,distfiles,profiles/profile,sets,metadata/glsa} || exit 1
+cd repo1 || exit 1
+
+echo "test-repo-1" > profiles/repo_name || exit 1
+cat <<END > profiles/categories || exit 1
+cat-one
+cat-two
+cat-three
+END
+cat <<END > profiles/profile/make.defaults
+ARCH=test
+END
+
+cat <<END > sets/set1.conf
+* cat-one/foo
+? >=cat-two/bar-2
+? <cat-three/baz-1.2
+END
+
+mkdir -p cat-one/foo cat-two/bar cat-three/baz
+cat <<END > cat-one/foo/foo-1.ebuild
+SLOT="0"
+KEYWORDS="test"
+END
+cp cat-one/foo/foo-1.ebuild cat-one/foo/foo-2.ebuild
+cp cat-one/foo/foo-1.ebuild cat-one/foo/foo-2.1.ebuild
+cp cat-one/foo/foo-1.ebuild cat-two/bar/bar-1.5.ebuild
+cp cat-one/foo/foo-1.ebuild cat-two/bar/bar-1.5.1.ebuild
+cp cat-one/foo/foo-1.ebuild cat-two/bar/bar-2.0.ebuild
+cp cat-one/foo/foo-1.ebuild cat-three/baz/baz-1.0.ebuild
+cp cat-one/foo/foo-1.ebuild cat-three/baz/baz-1.1.ebuild
+cp cat-one/foo/foo-1.ebuild cat-three/baz/baz-1.1-r1.ebuild
+cp cat-one/foo/foo-1.ebuild cat-three/baz/baz-1.1-r2.ebuild
+cp cat-one/foo/foo-1.ebuild cat-three/baz/baz-1.2.ebuild
+cp cat-one/foo/foo-1.ebuild cat-three/baz/baz-1.2-r1.ebuild
+cp cat-one/foo/foo-1.ebuild cat-three/baz/baz-1.3.ebuild
+cat <<END > cat-three/baz/baz-1.3.1.ebuild
+SLOT="0"
+KEYWORDS="~test"
+END
+
+cat <<END > metadata/glsa/glsa-123456-78.xml
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet href="/xsl/glsa.xsl" type="text/xsl"?>
+<?xml-stylesheet href="/xsl/guide.xsl" type="text/xsl"?>
+<!DOCTYPE glsa SYSTEM "http://www.gentoo.org/dtd/glsa.dtd">
+
+<glsa id="123456-78">
+ <title>
+ Foo: insecure XYZ
+ </title>
+ <synopsis>
+ Foo can be made to XYZ insecurely.
+ </synopsis>
+ <product type="ebuild">foo</product>
+ <announced>May 26, 2007</announced>
+ <revised>May 26, 2007: 01</revised>
+ <bug>123456</bug>
+ <access>local</access>
+ <affected>
+ <package name="cat-one/foo" auto="yes" arch="*">
+ <unaffected range="ge">2</unaffected>
+ <vulnerable range="lt">2</vulnerable>
+ </package>
+ </affected>
+ <background>
+ <p>
+ Foo is a Foo.
+ </p>
+ </background>
+ <description>
+ <p>
+ Foo can be exploited to perform XYZ without authorisation.
+ </p>
+ </description>
+ <impact type="high">
+ <p>
+ XYZ could happen insecurely.
+ </p>
+ </impact>
+ <workaround>
+ <p>
+ There is no known workaround at this time.
+ </p>
+ </workaround>
+ <resolution>
+ <p>
+ All Foo users should upgrade to the latest version.
+ </p>
+ </resolution>
+ <references>
+ </references>
+</glsa>
+END
+
+cat <<END > metadata/glsa/glsa-314159-26.xml
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet href="/xsl/glsa.xsl" type="text/xsl"?>
+<?xml-stylesheet href="/xsl/guide.xsl" type="text/xsl"?>
+<!DOCTYPE glsa SYSTEM "http://www.gentoo.org/dtd/glsa.dtd">
+
+<glsa id="314159-26">
+ <title>
+ Bar: unauthenticated QWERTY
+ </title>
+ <synopsis>
+ Bar allows QWERTY by remote users.
+ </synopsis>
+ <product type="ebuild">bar</product>
+ <announced>May 26, 2007</announced>
+ <revised>May 26, 2007: 01</revised>
+ <bug>314159</bug>
+ <access>local</access>
+ <affected>
+ <package name="cat-two/bar" auto="yes" arch="*">
+ <unaffected range="gt">1.5.1</unaffected>
+ <vulnerable range="le">1.5.1</vulnerable>
+ </package>
+ </affected>
+ <background>
+ <p>
+ Bar is a Bar.
+ </p>
+ </background>
+ <description>
+ <p>
+ Remote users can bypass authentication to perform QWERTY.
+ </p>
+ </description>
+ <impact type="high">
+ <p>
+ QWERTY can be performed by remote users.
+ </p>
+ </impact>
+ <workaround>
+ <p>
+ There is no known workaround at this time.
+ </p>
+ </workaround>
+ <resolution>
+ <p>
+ All Bar users should upgrade to the latest version.
+ </p>
+ </resolution>
+ <references>
+ </references>
+</glsa>
+END
+
+cat <<END > metadata/glsa/glsa-987654-32.xml
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet href="/xsl/glsa.xsl" type="text/xsl"?>
+<?xml-stylesheet href="/xsl/guide.xsl" type="text/xsl"?>
+<!DOCTYPE glsa SYSTEM "http://www.gentoo.org/dtd/glsa.dtd">
+
+<glsa id="987654-32">
+ <title>
+ Baz: ABC overflow
+ </title>
+ <synopsis>
+ Baz can be made to ABC too many times.
+ </synopsis>
+ <product type="ebuild">bar</product>
+ <announced>May 26, 2007</announced>
+ <revised>May 26, 2007: 01</revised>
+ <bug>987654</bug>
+ <access>local</access>
+ <affected>
+ <package name="cat-three/baz" auto="yes" arch="*">
+ <unaffected range="ge">1.3.1</unaffected>
+ <vulnerable range="lt">1.3.1</vulnerable>
+ <unaffected range="rge">1.2-r1</unaffected>
+ <unaffected range="rle">1.1-r1</unaffected>
+ <unaffected range="eq">1.3</unaffected>
+ </package>
+ </affected>
+ <background>
+ <p>
+ Baz is a Baz.
+ </p>
+ </background>
+ <description>
+ <p>
+ Attempting to make Baz ABC too many times causes an overflow.
+ </p>
+ </description>
+ <impact type="high">
+ <p>
+ ABC can be overflowed.
+ </p>
+ </impact>
+ <workaround>
+ <p>
+ There is no known workaround at this time.
+ </p>
+ </workaround>
+ <resolution>
+ <p>
+ All Bar users should upgrade to the latest version.
+ </p>
+ </resolution>
+ <references>
+ </references>
+</glsa>
+END
+
+cd ..
+