]> git.ipfire.org Git - thirdparty/patchwork.git/log
thirdparty/patchwork.git
6 years agotravis: Resolve issues with Python 3.7
Stephen Finucane [Sun, 8 Sep 2019 15:03:17 +0000 (16:03 +0100)] 
travis: Resolve issues with Python 3.7

Bump the distro version to xenial, as this is the first version to
include Python 3.7 support. Bionic is also available but it doesn't
support Python 3.5 [1].

In addition, skip a test that was valid on Python 3.4 - 3.6 but does not
appear to be an issue for Python 3.7.

[1] https://docs.travis-ci.com/user/reference/bionic/#python-support

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 6267a5fa ("Drop support for Python 3.4, add Python 3.7")
6 years agoUpdate django from 1.11.22 to 1.11.24
Stephen Finucane [Sun, 8 Sep 2019 14:43:18 +0000 (15:43 +0100)] 
Update django from 1.11.22 to 1.11.24

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoDrop support for Python 3.4, add Python 3.7
Stephen Finucane [Tue, 3 Sep 2019 13:35:15 +0000 (14:35 +0100)] 
Drop support for Python 3.4, add Python 3.7

It's no longer supported upstream and the *second* last Ubuntu LTS
release provides something newer. Time to move on.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agosql: Fix table lists
Ali Alnubani [Wed, 4 Sep 2019 13:40:31 +0000 (13:40 +0000)] 
sql: Fix table lists

The patch adds missing commas in the table lists where missing, and
removes where unnecessary. This fixes errors such as the following when
feeding the script to psql:

  psql:lib/sql/grant-all.postgres.sql:37: ERROR: syntax error at or near "patchwork_emailconfirmation"
  LINE 19:  patchwork_emailconfirmation,
  ...

Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
Fixes: ca0e79d4db34 ("sql: Sort 'grant-all' scripts alphabetically")
6 years agoUpdate django from 2.2.3 to 2.2.5
pyup-bot [Mon, 2 Sep 2019 11:03:46 +0000 (12:03 +0100)] 
Update django from 2.2.3 to 2.2.5

6 years agoUpdate django from 2.2.3 to 2.2.5
pyup-bot [Mon, 2 Sep 2019 11:03:45 +0000 (12:03 +0100)] 
Update django from 2.2.3 to 2.2.5

6 years agomigrations: Correct 'unique_together' order in '0015'
Stephen Finucane [Sat, 8 Jun 2019 15:44:13 +0000 (16:44 +0100)] 
migrations: Correct 'unique_together' order in '0015'

This was resulting in exceptions like the following when used with MySQL
8.0:

  Traceback (most recent call last):
    File "../patchwork/manage.py", line 11, in <module>
      execute_from_command_line(sys.argv)
    ...
    File "../.tox/py27-django111/lib/python2.7/site-packages/django/db/backends/mysql/schema.py", line 88, in _delete_composed_index
      return super(DatabaseSchemaEditor, self)._delete_composed_index(model, fields, *args)
    File "../.tox/py27-django111/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 394, in _delete_composed_index
      ", ".join(columns),
  ValueError: Found wrong number (0) of constraints for patchwork_seriespatch(series_id, number)

This error was being raised by the following lines in the 0033
migration:

  migrations.AlterUniqueTogether(
      name='seriespatch',
      unique_together=set([]),
  )

It appears that this is because of a mismatch between the order of
fields in a 'unique_together' constraint [1]. Correct the order in the
original migration and see the issue disappear.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: d67d859f40f ("models: Add 'Series' model")
6 years agoforms: Don't attempt to evaluate State at startup
Stephen Finucane [Tue, 4 Sep 2018 10:03:00 +0000 (11:03 +0100)] 
forms: Don't attempt to evaluate State at startup

As was designed, starting the interpreter would cause the State model
and its entries to be evaluated. This was an issue if, for example, the
model had been modified and you were attempting to apply the migration.

  Traceback (most recent call last):
    File "manage.py", line 11, in <module>
      execute_from_command_line(sys.argv)
    ...
    File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py", line 1199, in _set_queryset
      self.widget.choices = self.choices
    File "/home/patchwork/patchwork/patchwork/forms.py", line 157, in _get_choices
      super(OptionalModelChoiceField, self)._get_choices())
    File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py", line 1143, in __len__
      return (len(self.queryset) + (1 if self.field.empty_label is not None else 0))
    File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 232, in __len__
      self._fetch_all()
    File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 1118, in _fetch_all
      self._result_cache = list(self._iterable_class(self))
    File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 53, in __iter__
      results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
    File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 899, in execute_sql
      raise original_exception
  django.db.utils.OperationalError: (1054, "Unknown column 'patchwork_state.slug' in 'field list'")

Resolve this by moving the evaluation into '__init__', meaning it will
only occur when a new form is created.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agomodels: Add commit_url_format to Project
Michael Ellerman [Tue, 27 Aug 2019 06:13:13 +0000 (16:13 +1000)] 
models: Add commit_url_format to Project

Add a new field to Project, commit_url_format, which specifies a
format string that can be used to generate a link to a particular
commit for a project.

This is used in the display of a patch, to render the patch's commit
as a clickable link back to the commit on the SCM website.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agombox: do not copy Content-Type into exported mbox
Daniel Axtens [Wed, 21 Aug 2019 05:15:44 +0000 (15:15 +1000)] 
mbox: do not copy Content-Type into exported mbox

Daniel reports a patch + comment combination that breaks in
git am. The patch reports a Content-Type of US-ASCII, while
the comment adds a Ack with UTF-8 characters. The exported
mbox contains both the original Content-Type, and a UTF-8
Content-Type that we set. However, because the US-ASCII one
occurs later, git am honours it instead of ours, and chokes
on the UTF-8 characters.

Strip out any subsequent Content-Type:s. We normalise things
to UTF-8 and should not allow it to be overridden.

Add a test for this, based on the original report.

Reported-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agofixtures: Update Patchwork list ID
Andrew Donnellan [Thu, 22 Aug 2019 07:13:03 +0000 (17:13 +1000)] 
fixtures: Update Patchwork list ID

The patchwork list uses patchwork.lists.ozlabs.org as its list ID nowadays.
Fix it in the example fixture.

Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agoreleasenotes: Add release note for new list archive fields
Andrew Donnellan [Thu, 22 Aug 2019 07:13:02 +0000 (17:13 +1000)] 
releasenotes: Add release note for new list archive fields

Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agodocs: Add API v1.2
Andrew Donnellan [Thu, 22 Aug 2019 07:13:01 +0000 (17:13 +1000)] 
docs: Add API v1.2

Add API v1.2, including the new fields for list archive URLs.

Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agoapi: Add list archive fields
Andrew Donnellan [Thu, 22 Aug 2019 07:13:00 +0000 (17:13 +1000)] 
api: Add list archive fields

Add the new list archive fields to the API. As this is a
backwards-compatible change, this requires only a minor version increment
to v1.2.

Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agotemplates: Add mailing list archive link to patch detail page
Andrew Donnellan [Thu, 22 Aug 2019 07:12:59 +0000 (17:12 +1000)] 
templates: Add mailing list archive link to patch detail page

Add a link to the mailing list archive link to the patch detail page.

Suggested-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agomodels: Add list archive lookup
Andrew Donnellan [Thu, 22 Aug 2019 07:12:58 +0000 (17:12 +1000)] 
models: Add list archive lookup

Add a list_archive_url_format field to Project, which will contain the
address of a Message-ID redirector, e.g. "https://lore.kernel.org/r/{}".

Add a list_archive_url property to Submission and Comment, to generate an
archive lookup URL based on the Message-ID.

We will use this to display links to mailing list archives.

Also add the new field to the default patchwork project fixture.

Suggested-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agomodels, templates: Add project list archive URL field
Andrew Donnellan [Thu, 22 Aug 2019 07:12:57 +0000 (17:12 +1000)] 
models, templates: Add project list archive URL field

Add a field to link to a project's mailing list archive, and display it on
the project info page.

Add the new field to the patchwork project in the supplied example fixture.

Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agodocker: *Actually* don't require rebuilding if unnecessary
Stephen Finucane [Sat, 6 Jul 2019 20:25:25 +0000 (21:25 +0100)] 
docker: *Actually* don't require rebuilding if unnecessary

Because we were using 'set -e', we were erroring out as soon as
something - a diff in this case - failed. Temporarily disable it for
this one check.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 0b5b4e8c ("docker: Don't require rebuilding if unnecessary")
Cc: Daniel Axtens <dja@axtens.net>
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agoAdd 'dumparchive' management command
Mete Polat [Mon, 15 Jul 2019 14:50:28 +0000 (16:50 +0200)] 
Add 'dumparchive' management command

Introduces a new management command which can export all patches in a
project as one mbox file. Export of multiple projects is supported.
Additionally allows to compress the output.

Signed-off-by: Mete Polat <metepolat2000@gmail.com>
Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoRemove pwclient release note
Stephen Finucane [Sat, 6 Jul 2019 19:50:33 +0000 (20:50 +0100)] 
Remove pwclient release note

We will remove 'pwclient' in v2.3 so it doesn't make much sense to keep
a release note for it around. Remove that too.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoUpdate django from 2.2.2 to 2.2.3
pyup-bot [Mon, 1 Jul 2019 14:33:58 +0000 (15:33 +0100)] 
Update django from 2.2.2 to 2.2.3

6 years agoUpdate django from 1.11.21 to 1.11.22
Stephen Finucane [Sat, 6 Jul 2019 19:44:18 +0000 (20:44 +0100)] 
Update django from 1.11.21 to 1.11.22

6 years agodocs: Rework configuration document
Stephen Finucane [Fri, 5 Jul 2019 10:55:09 +0000 (11:55 +0100)] 
docs: Rework configuration document

- Remove some newlines between terms and definitions that were causing
  the latter to be rendered as blockquotes instead
- Order list of settings alphabetically
- Update URLs to use latest version of Django we support

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoabout: Display admin contact details
Andrew Donnellan [Wed, 3 Jul 2019 03:39:53 +0000 (13:39 +1000)] 
about: Display admin contact details

Display the list of admins on the about page. Add an ADMINS_HIDE option if
you don't want the details displayed publicly.

Closes: #282 ("Display contact details for patchwork instance admins")
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Add a release note for CVE-2019-13122
Daniel Axtens [Fri, 5 Jul 2019 05:21:26 +0000 (15:21 +1000)] 
docs: Add a release note for CVE-2019-13122

Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agofilters: Escape State names when generating selector HTML
Andrew Donnellan [Fri, 5 Jul 2019 03:27:41 +0000 (13:27 +1000)] 
filters: Escape State names when generating selector HTML

States with names containing special characters are not correctly escaped
when generating the select list. Use escape() to fix this.

Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
6 years agotests: Add test for unescaped values in patch detail page
Andrew Donnellan [Mon, 1 Jul 2019 08:04:53 +0000 (18:04 +1000)] 
tests: Add test for unescaped values in patch detail page

Add a test to check whether we are escaping values from the Patch model on
the patch detail page.

This test shouldn't be relied upon as proof that we've escaped everything
correctly, but may help catch regressions.

Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agotemplatetags: Do not mark output of msgid tag as safe
Andrew Donnellan [Mon, 1 Jul 2019 05:28:03 +0000 (15:28 +1000)] 
templatetags: Do not mark output of msgid tag as safe

The msgid template tag exists to remove angle brackets from either side of
the Message-ID header.

It also marks its output as safe, meaning it does not get autoescaped by
Django templating.

Its output is not safe. A maliciously crafted email can include HTML tags
inside the Message-ID header, and as long as the angle brackets are not at
the start and end of the header, we will quite happily render them.

Rather than using mark_safe(), use escape() to explicitly escape the
Message-ID.

Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agoUpdate django from 1.11.20 to 1.11.21
Stephen Finucane [Mon, 17 Jun 2019 14:11:43 +0000 (15:11 +0100)] 
Update django from 1.11.20 to 1.11.21

6 years agoRemove pwclient
Stephen Finucane [Sun, 21 Oct 2018 11:05:58 +0000 (12:05 +0100)] 
Remove pwclient

Let's start managing this via a separate project, which will allow the
client to evolve separately from the server. No redirect is added for
the old '/pwclient' URL as it seems wiser to return a HTTP 404 error
code.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotemplates: Fix pwclientrc sample
Stephen Finucane [Sun, 21 Oct 2018 10:51:25 +0000 (11:51 +0100)] 
templates: Fix pwclientrc sample

INI files should use 'key = value' values, not 'key: value'. Correct
this and fix some other whitespace issues.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #277
6 years agofilters: re-add the possibility of filtering undelegated patches
Mauro Carvalho Chehab [Tue, 4 Jun 2019 21:31:39 +0000 (18:31 -0300)] 
filters: re-add the possibility of filtering undelegated patches

The filters.py redesign that happened for patchwork 1.1 removed
a functionality that we use a lot: to filter patches that weren't
delegated to anyone.

Also, it is a way harder to find someone to delegate with a free
text input. Use, instead a combo-box just like before.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: f439f541 ("Add delegate filter autocomplete support")
Closes: #60
[stephenfin: Rework release note and fix some style issues]

6 years agoFix typo in release note
Stephen Finucane [Wed, 5 Jun 2019 10:06:23 +0000 (11:06 +0100)] 
Fix typo in release note

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoAdd support for Django 2.2
Stephen Finucane [Tue, 4 Jun 2019 16:07:05 +0000 (17:07 +0100)] 
Add support for Django 2.2

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoparser: Remove duplicity
Petr Vorel [Tue, 4 Jun 2019 15:56:39 +0000 (17:56 +0200)] 
parser: Remove duplicity

commit fc1d750 copied lines added in 753e457.
Make sense to define it on single place (DRY).

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
6 years agoparser: Include extended header lines in diff
Stephen Finucane [Tue, 4 Jun 2019 11:55:38 +0000 (12:55 +0100)] 
parser: Include extended header lines in diff

Commit 753e4572d updated the parser to consider additional header lines
when deciding where a patch message ends and the diff begins. However,
these additional lines were not captured meaning these patches didn't
have a diff associated with them and they therefore weren't patches in
the Patchwork sense of the term. Correct this and add a test.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoparser: Add missing extended header lines
Petr Vorel [Sun, 5 May 2019 20:20:05 +0000 (22:20 +0200)] 
parser: Add missing extended header lines

Patchwork didn't recognise some patches due missing some extended header
lines (e.g. "old mode" and "new mode" for renaming file mode, see [1]).
Thus adding all modes from git doc [2].

[1] https://lists.ozlabs.org/pipermail/patchwork/2019-April/005741.html
[2] https://git-scm.com/docs/git-diff#_generating_patches_with_p

Suggested-by: Veronika Kabatova <vkabatov@redhat.com>
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
Closes: #267
6 years agodocs: Document backport criteria
Stephen Finucane [Tue, 14 May 2019 14:56:53 +0000 (15:56 +0100)] 
docs: Document backport criteria

Explain why we don't want to be in the business of backport certain
patches, in the long run. It took me a while to put this into words but
I was helped by a similar discussion ongoing in the OpenStack community
at the moment [1].

[1] http://lists.openstack.org/pipermail/openstack-discuss/2019-May/006220.html

Signed-off-by: Stephen Finucane <stephen@that.guru>
Acked-by: Daniel Axtens <dja@axtens.net>
6 years agoRevert "parser: Ensure whitespace is stripped for long headers"
Daniel Axtens [Tue, 14 May 2019 06:11:25 +0000 (16:11 +1000)] 
Revert "parser: Ensure whitespace is stripped for long headers"

This reverts commit 841f966b8d54b2f51ab1c498eed6e5391f2546a9.

In July 2018, we received a report of OzLabs patchwork mangling
emails that have subjects containing words with internal commas,
like "Insert DT binding for foo,bar" (#197).

Stephen took a look and came up with the comment this reverts. Quoting
the commit message:

    RFC2822 states that long headers can be wrapped using CRLF followed by
    WSP [1]. For example:

        Subject: Foo bar,
         baz

    Should be parsed as:

        Foo bar,baz

As it turns out, this is not the case. Journey with me to
section 2.2.3 of RFC 2822:

2.2.3. Long Header Fields

   Each header field is logically a single line of characters comprising
   the field name, the colon, and the field body.  For convenience
   however, and to deal with the 998/78 character limitations per line,
   the field body portion of a header field can be split into a multiple
   line representation; this is called "folding".  The general rule is
   that wherever this standard allows for folding white space (not
   simply WSP characters), a CRLF may be inserted before any WSP.  For
   example, the header field:

           Subject: This is a test

   can be represented as:

           Subject: This
            is a test

So the issue with the example in the reverted commit is that there is no
folding white space in "bar,baz", so it's not valid to split it.

These are valid:

        Subject: Foo bar,baz
        Subject: Foo
 bar,baz

but splitting "bar,baz" into "bar,\n baz" is not valid.

What then is correct unfolding behaviour? Quoting the RFC again:

   The process of moving from this folded multiple-line representation
   of a header field to its single line representation is called
   "unfolding". Unfolding is accomplished by simply removing any CRLF
   that is immediately followed by WSP.  Each header field should be
   treated in its unfolded form for further syntactic and semantic
   evaluation.

In other words, the unfolding rule requires you to strip the CRLF, but
it does not permit you to strip the WSP. Indeed, if "bar,\n baz" is
received, the correct unfolding is "bar, baz".

If you do strip the WSP, you end up mashing words together, such as in
https://patchwork.ozlabs.org/patch/1097852/

So revert the commit, restoring original behaviour, but keep a corrected
version of the test.

This presents a big question though: how did Rob's email up with a
mangled subject line?

To answer this question, you end up having to learn about OzLabs
Patchwork and how it differs from Patchwork the project.

OzLabs Patchwork (patchwork.ozlabs.org) is an installation of Patchwork.
Part of what makes it so useful for so many projects is a little
intervening layer that can massage some mail to make it end up in the
right project. Email that lands in the device tree project is an example
of email that goes through this process.  I only learned about this
today and I haven't looked in any detail at precisely what is done to
the mail. The script is not part of the Patchwork project.

This intervening filter is a Python script that runs - and this is an
important detail - in Python 2.7.

Ignoring all the details, the filter basically operates in a pipe
between the mail program and patchwork's parsemail, like

   (mail from system) | filter.py | parsemail

At it's very simplest, filter.py acts as follows:

   import email
   import sys
   mail = email.parse_from_file(sys.stdin)
   sys.stdout.write(mail.as_string())

Fascinatingly, if you take Rob's email from #197 and put it through this
process, you can see that it is getting mangled:

Before:
Subject: [PATCH v2 3/4] dt-bindings: sound: wm8994: document wlf,csnaddr-pd property

After:
Subject: [PATCH v2 3/4] dt-bindings: sound: wm8994: document wlf,
 csnaddr-pd property

You can see that python27 has incorrectly wrapped the header, breaking
where there is not a foldable space. Python3 does not have this issue.

To summarise:

- part of the magic of OzLabs PW is a filter to make sure mail gets to
  the right place. This isn't part of the Patchwork project and so is
  usually invisible to patchwork developers.

- the filter is written in python27. The email module in py27 has a bug
  that incorrectly breaks subjects around commas within words.

- patchwork correctly unfolds those broken subjects with a space after
  the comma.

- the extra space was interpreted as a bug in patchwork, leading to a
  misinterpretation of the spec to strip out the whitespace that was
  believed to be in error.

- that broke other wrapped subjects.

To solve this, revert the commit and I'll work with jk to get the filter
script into py3 compatibility. (Given that py27 sunsets in ~7mo, trying
to fix it is not worth it.)

Closes: #273
Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Stephen Finucane <stephen@that.guru>
[stephenfin: Use a new release note instead of editing the original one]

6 years agodocs: Mention Postgres for Docker development install
Russell Currey [Wed, 1 May 2019 06:27:18 +0000 (16:27 +1000)] 
docs: Mention Postgres for Docker development install

Might as well since it's there, and it gives some clue to anyone trying
to use Docker on non-x86.  I figured it was best to leave this out of
the README since it's incredibly niche.

Signed-off-by: Russell Currey <ruscur@russell.cc>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agodocker: Use Ubuntu ports repositories on non-x86 architectures
Russell Currey [Wed, 1 May 2019 06:27:17 +0000 (16:27 +1000)] 
docker: Use Ubuntu ports repositories on non-x86 architectures

This should allow Patchwork to run "out of the box" in Docker on any
architecture with a) an Ubuntu port and b) support in the Postgres
multiarch Docker image, which includes at least arm64 and ppc64le.

It's a little gross hacking the Dockerfile like this, but I'm not sure
there's a more elegant way to do it.  Unfortunately it doesn't seem like
there's any way to do conditional COPY, and anything in RUN is plain
/bin/sh, so that's why it looks like it does.

Tested on ppc64le and on x86_64.

Signed-off-by: Russell Currey <ruscur@russell.cc>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agodocker: Install libpq-dev to fix psycopg2-binary build
Russell Currey [Wed, 1 May 2019 04:35:53 +0000 (14:35 +1000)] 
docker: Install libpq-dev to fix psycopg2-binary build

psycopg2-binary fails if pg_config isn't installed, which is provided by
libpq-dev.

This seems strange to me since psycopg2-binary suggests that
you use psycopg2-binary instead (of itself) if you don't want to build
psycopg2 so you wouldn't need pg_config, which is very confusing.

It's possible that psycopg2-binary only needs to compile itself on
non-x86 platforms, since I hit this on ppc64le.

Anyway, it works when this is added.

Signed-off-by: Russell Currey <ruscur@russell.cc>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agoREADME: add .env file to installation instructions
Russell Currey [Wed, 1 May 2019 03:16:43 +0000 (13:16 +1000)] 
README: add .env file to installation instructions

Creating the .env file is mentioned in the installation documentation
but not in the README, so following only the steps mentioned there will
fail.  Add this and add a `cd patchwork` in there for good measure so
you could straight up copy paste the steps.

Signed-off-by: Russell Currey <ruscur@russell.cc>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agoREST: A check must specify a state
Daniel Axtens [Mon, 29 Apr 2019 16:57:01 +0000 (02:57 +1000)] 
REST: A check must specify a state

The Ozlabs crew noticed that a check without a state caused a
KeyError in data['state']. Mark state as mandatory, check for
it, and add a test.

Reported-by: Russell Currey <ruscur@russell.cc>
Reported-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agoREST: Handle regular form data requests for checks
Daniel Axtens [Mon, 29 Apr 2019 15:33:16 +0000 (01:33 +1000)] 
REST: Handle regular form data requests for checks

08d1459a4a40 ("Add REST API validation using OpenAPI schema") moved
all API requests to JSON blobs rather than form data.

dc48fbce99ef ("REST: Handle JSON requests") attempted to change the
check serialiser to handle this. However, because both a JSON dict
and a QueryDict satisfy isinstance(data, dict), everything was handled
as JSON and the old style requests were broken.

Found in the process of debugging issues from the OzLabs PW & Snowpatch
crew - I'm not sure if they actually hit this one, but kudos to them
anyway as we wouldn't have found it without them.

Fixes: dc48fbce99ef ("REST: Handle JSON requests")
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agonotifications: fix notification expiry when no user is associated
Jeremy Kerr [Sat, 27 Apr 2019 11:12:16 +0000 (19:12 +0800)] 
notifications: fix notification expiry when no user is associated

It's possible that an EmailConfirmation object will have no associated
user (eg, for email opt-out, which does not require a user object). In
this case, we will see a NULL value for EmailConfirmation.user_id.

However, having a NULL value appear in a SQL 'IN' clause will match
every value. This means that once one of these null-user
EmailConfirmations is present, we will never expire any non-active user
accounts.

This change adds a filter for a valid user_id when we query for active
EmailConfirmation objects. This means we'll have a valid values set to
use in the pending_confs set.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
[dja: fix pep8 issue]
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agoUpdate psycopg2-binary from 2.8.1 to 2.8.2
pyup-bot [Mon, 15 Apr 2019 18:13:32 +0000 (19:13 +0100)] 
Update psycopg2-binary from 2.8.1 to 2.8.2

6 years agoUpdate psycopg2-binary from 2.8.1 to 2.8.2
pyup-bot [Mon, 15 Apr 2019 18:13:31 +0000 (19:13 +0100)] 
Update psycopg2-binary from 2.8.1 to 2.8.2

6 years agoUpdate psycopg2-binary from 2.7.7 to 2.8.1
pyup-bot [Sat, 6 Apr 2019 20:58:39 +0000 (21:58 +0100)] 
Update psycopg2-binary from 2.7.7 to 2.8.1

6 years agoUpdate psycopg2-binary from 2.7.7 to 2.8.1
pyup-bot [Sat, 6 Apr 2019 20:58:38 +0000 (21:58 +0100)] 
Update psycopg2-binary from 2.7.7 to 2.8.1

6 years agoUpdate jinja2 from 2.10 to 2.10.1
pyup-bot [Sat, 6 Apr 2019 20:58:35 +0000 (21:58 +0100)] 
Update jinja2 from 2.10 to 2.10.1

6 years agoFix YAML loader warning
Daniel Axtens [Fri, 15 Mar 2019 06:27:40 +0000 (17:27 +1100)] 
Fix YAML loader warning

In my tests I'm seeing:
/home/patchwork/patchwork/patchwork/tests/api/validator.py:229:
YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated,
as the default Loader is unsafe. Please read https://msg.pyyaml.org/load
for full details.

Fix this by using the safe loader in the tests.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
6 years agoUpdate sphinx_rtd_theme from 0.4.2 to 0.4.3
pyup-bot [Tue, 12 Feb 2019 21:45:36 +0000 (21:45 +0000)] 
Update sphinx_rtd_theme from 0.4.2 to 0.4.3

6 years agoUpdate sqlparse from 0.2.4 to 0.3.0
pyup-bot [Mon, 11 Mar 2019 19:42:59 +0000 (20:42 +0100)] 
Update sqlparse from 0.2.4 to 0.3.0

6 years agoUpdate sqlparse from 0.2.4 to 0.3.0
pyup-bot [Mon, 11 Mar 2019 19:42:58 +0000 (20:42 +0100)] 
Update sqlparse from 0.2.4 to 0.3.0

6 years agoUpdate django from 1.11.18 to 1.11.20
Stephen Finucane [Thu, 7 Mar 2019 11:55:04 +0000 (11:55 +0000)] 
Update django from 1.11.18 to 1.11.20

6 years agoui: Space in filter radio buttons
Thomas Monjalon [Tue, 8 Jan 2019 12:38:46 +0000 (12:38 +0000)] 
ui: Space in filter radio buttons

There was no space between radio button and associated text
in the filters form.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
6 years agoui: Shrink vertical space of patch list
Thomas Monjalon [Tue, 8 Jan 2019 12:38:45 +0000 (12:38 +0000)] 
ui: Shrink vertical space of patch list

The margin above the filter box is removed because there is
already a margin below the navigation bar.

The vertical padding between rows is reduced
while the horizontal padding between columns is increased.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
6 years agoUpdate djangorestframework from 3.9.1 to 3.9.2
pyup-bot [Sun, 3 Mar 2019 21:13:38 +0000 (21:13 +0000)] 
Update djangorestframework from 3.9.1 to 3.9.2

6 years agoUpdate djangorestframework from 3.9.1 to 3.9.2
pyup-bot [Sun, 3 Mar 2019 21:13:37 +0000 (21:13 +0000)] 
Update djangorestframework from 3.9.1 to 3.9.2

6 years agoparser: recognise git commit consisting only of empty new file
Daniel Axtens [Thu, 28 Feb 2019 04:29:53 +0000 (15:29 +1100)] 
parser: recognise git commit consisting only of empty new file

Commits with only an empty new file are liable to be missed.
The parser state machine doesn't recognise the headers "new
file mode" and "index": teach it about them.

Add a test to demonstrate.

It's a little bit academic as you don't usually send patches like
that but sometimes you do, especially if you're a snowpatch dev :)

Closes: #256
Reported-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
6 years agoUpdate openapi-core from 0.7.1 to 0.8.0
pyup-bot [Thu, 28 Feb 2019 14:37:30 +0000 (14:37 +0000)] 
Update openapi-core from 0.7.1 to 0.8.0

6 years agoBeautify check counts in the patch list view
Ali Alnubani [Tue, 8 Jan 2019 12:38:47 +0000 (12:38 +0000)] 
Beautify check counts in the patch list view

This patch [1] adds colors to the checks in the patch list view.
The colors are set based on the check's priority, with FAILURE
having the highest priority, followed by WARNING, and then SUCCESS.
Only the check with the highest priority and non-zero count
will be colored. This is to make failures and warnings more visible.

The patch also [2] replaces zero counts with a '-' for
FAILUREs and WARNINGs.
The SUCCESS count will only be replaced by a '-'
when all other checks have zero counts too.

Suggested-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoFix return code when getting patch information fails
Ali Alnubani [Tue, 8 Jan 2019 12:38:45 +0000 (12:38 +0000)] 
Fix return code when getting patch information fails

The `info` command always exits with success, even if
the patch didn't exist.
Modified to exit with a non-zero exit status and
print an error message in that case.

Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Fix user's profile url
Ali Alnubani [Mon, 25 Feb 2019 08:09:29 +0000 (08:09 +0000)] 
docs: Fix user's profile url

Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
6 years agoUpdate django from 2.1.5 to 2.1.7
pyup-bot [Mon, 11 Feb 2019 19:03:13 +0000 (19:03 +0000)] 
Update django from 2.1.5 to 2.1.7

6 years agoUpdate django from 2.1.5 to 2.1.7
pyup-bot [Mon, 11 Feb 2019 19:03:11 +0000 (19:03 +0000)] 
Update django from 2.1.5 to 2.1.7

6 years agoUpdate python-dateutil from 2.7.5 to 2.8.0
pyup-bot [Tue, 5 Feb 2019 17:06:00 +0000 (18:06 +0100)] 
Update python-dateutil from 2.7.5 to 2.8.0

6 years agodocs: Integrate API schema into docs
Stephen Finucane [Sat, 27 Oct 2018 00:31:43 +0000 (01:31 +0100)] 
docs: Integrate API schema into docs

This takes advantage of the sphinxcontrib-openapi Sphinx extension,
which allows us to embed the REST API documentation into our docs quite
nicely.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Move REST API guide to subfolder
Stephen Finucane [Sat, 27 Oct 2018 00:39:38 +0000 (01:39 +0100)] 
docs: Move REST API guide to subfolder

We're going to dramatically expand these docs, so let's set up room to
do so.

This shouldn't break any links as we're using 'htmldir' output on
ReadTheDocs.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotox: Use 'dirhtml' builder for docs
Stephen Finucane [Mon, 28 Jan 2019 21:09:40 +0000 (21:09 +0000)] 
tox: Use 'dirhtml' builder for docs

This is what we use for 'patchwork.readthedocs.io'.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Remove crud from conf.py
Stephen Finucane [Sat, 27 Oct 2018 00:36:40 +0000 (01:36 +0100)] 
docs: Remove crud from conf.py

Most of this was removed in a previous release but there is yet more to
go. These values are all (a) defaults or (b) never triggered. Remove
them.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoUpdate psycopg2-binary from 2.7.6.1 to 2.7.7
pyup-bot [Tue, 22 Jan 2019 18:48:02 +0000 (19:48 +0100)] 
Update psycopg2-binary from 2.7.6.1 to 2.7.7

6 years agoUpdate psycopg2-binary from 2.7.6.1 to 2.7.7
pyup-bot [Tue, 22 Jan 2019 18:48:01 +0000 (19:48 +0100)] 
Update psycopg2-binary from 2.7.6.1 to 2.7.7

6 years agoUpdate django (Py2) from 1.11.15 to 1.11.18
Stephen Finucane [Mon, 28 Jan 2019 20:55:16 +0000 (20:55 +0000)] 
Update django (Py2) from 1.11.15 to 1.11.18

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoUpdate django-filter from 2.0.0 to 2.1.0
pyup-bot [Sun, 20 Jan 2019 20:56:58 +0000 (21:56 +0100)] 
Update django-filter from 2.0.0 to 2.1.0

6 years agoUpdate django-filter from 2.0.0 to 2.1.0
pyup-bot [Sun, 20 Jan 2019 20:56:56 +0000 (21:56 +0100)] 
Update django-filter from 2.0.0 to 2.1.0

6 years agoUpdate djangorestframework from 3.9.0 to 3.9.1
pyup-bot [Wed, 16 Jan 2019 15:30:55 +0000 (15:30 +0000)] 
Update djangorestframework from 3.9.0 to 3.9.1

6 years agoUpdate djangorestframework from 3.9.0 to 3.9.1
pyup-bot [Wed, 16 Jan 2019 15:30:54 +0000 (15:30 +0000)] 
Update djangorestframework from 3.9.0 to 3.9.1

6 years agoUpdate django from 2.1.4 to 2.1.5
pyup-bot [Fri, 4 Jan 2019 17:43:35 +0000 (18:43 +0100)] 
Update django from 2.1.4 to 2.1.5

6 years agoUpdate django from 2.1.4 to 2.1.5
pyup-bot [Fri, 4 Jan 2019 17:43:34 +0000 (18:43 +0100)] 
Update django from 2.1.4 to 2.1.5

6 years agoadmin: Further optimize queries
Stephen Finucane [Fri, 2 Nov 2018 17:45:20 +0000 (17:45 +0000)] 
admin: Further optimize queries

To count the amount of received patches for a series, we only need the
patch's series field.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoadmin: Show series.submitter in admin view
Stephen Finucane [Fri, 2 Nov 2018 17:34:10 +0000 (17:34 +0000)] 
admin: Show series.submitter in admin view

Display this by default and allow filtering by it. While we're here,
also allow patches to be filtered by submitter.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Configure User.first_name, User.last_name
Stephen Finucane [Mon, 29 May 2017 14:42:45 +0000 (15:42 +0100)] 
tests: Configure User.first_name, User.last_name

'User.name' is not a valid attribute. This also highlights a small issue
with the existing tests.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Detail JSON PATCH requests
Stephen Finucane [Thu, 1 Jun 2017 13:48:22 +0000 (14:48 +0100)] 
docs: Detail JSON PATCH requests

It turns out it is possible to make PATCH requests with JSON bodies
rather than form-encoded data - you just need to include a Content-Type
header. Document this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Reformat schemas
Stephen Finucane [Mon, 24 Dec 2018 13:40:02 +0000 (13:40 +0000)] 
docs: Reformat schemas

Tested using 'yamllint'.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Add parameter descriptions, types
Stephen Finucane [Sun, 23 Dec 2018 15:38:51 +0000 (15:38 +0000)] 
docs: Add parameter descriptions, types

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Move 'parameter.schema.description' to 'parameter'
Stephen Finucane [Sun, 23 Dec 2018 14:58:25 +0000 (14:58 +0000)] 
docs: Move 'parameter.schema.description' to 'parameter'

As noted in a bug against the spec [1], there is some duplication here.
Go with the more obvious path until that confusion is cleared up.

[1] https://github.com/OAI/OpenAPI-Specification/issues/1788

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoUpdate mysqlclient from 1.3.13 to 1.3.14
pyup-bot [Sat, 22 Dec 2018 23:09:58 +0000 (23:09 +0000)] 
Update mysqlclient from 1.3.13 to 1.3.14

6 years agoPin jinja2 to latest version 2.10
pyup-bot [Sat, 22 Dec 2018 17:44:36 +0000 (17:44 +0000)] 
Pin jinja2 to latest version 2.10

6 years agoUpdate psycopg2-binary from 2.7.6 to 2.7.6.1
pyup-bot [Sun, 11 Nov 2018 15:42:40 +0000 (16:42 +0100)] 
Update psycopg2-binary from 2.7.6 to 2.7.6.1

6 years agoUpdate psycopg2-binary from 2.7.6 to 2.7.6.1
pyup-bot [Sun, 11 Nov 2018 15:42:38 +0000 (16:42 +0100)] 
Update psycopg2-binary from 2.7.6 to 2.7.6.1

6 years agoUpdate django-debug-toolbar from 1.10.1 to 1.11
pyup-bot [Mon, 3 Dec 2018 18:11:33 +0000 (23:56 +0545)] 
Update django-debug-toolbar from 1.10.1 to 1.11

6 years agoUpdate django from 2.1.3 to 2.1.4
pyup-bot [Mon, 3 Dec 2018 18:11:28 +0000 (23:56 +0545)] 
Update django from 2.1.3 to 2.1.4

6 years agoUpdate django from 2.1.3 to 2.1.4
pyup-bot [Mon, 3 Dec 2018 18:11:27 +0000 (23:56 +0545)] 
Update django from 2.1.3 to 2.1.4

6 years agoparser: Ensure whitespace is stripped for long headers
Stephen Finucane [Sun, 4 Nov 2018 14:06:03 +0000 (14:06 +0000)] 
parser: Ensure whitespace is stripped for long headers

RFC2822 states that long headers can be wrapped using CRLF followed by
WSP [1]. For example:

    Subject: Foo bar,
     baz

Should be parsed as:

    Foo bar,baz

While we were stripping the former, we were not stripping the
latter. This mean that we ended up with the following:

    Foo bar, baz

Resolve this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #197
6 years agomodels: Ensure UserProfile.user is configured
Stephen Finucane [Sat, 3 Nov 2018 21:47:51 +0000 (21:47 +0000)] 
models: Ensure UserProfile.user is configured

Django Admin seems to be doing something funky with how it's handling
the creation of a User's corresponding UserProfile instance when
modelled as an inline field. Re-setting the UserProfile.user attribute
seems to resolve the issue, so do just that.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #110
6 years agoAdd REST API validation using OpenAPI schema
Stephen Finucane [Thu, 15 Nov 2018 12:57:58 +0000 (13:57 +0100)] 
Add REST API validation using OpenAPI schema

Add validation using the rather excellent 'openapi_core' library. The
biggest issue we have to contend with is the fact that 'openapi_core'
expects us to be able to provide a templated URL string for each request
(e.g. '/api/patches/123/' would become '/api/patches/<id>/') and Django
doesn't provide a way to do this [*]. We work around this by
reverse-engineering some of the Django code to turn a URL to its
matching regex, which we can then easily convert into a template string.
It's kind of hacky and not at all portable but, crucially, it does work
and has highlighted some nice bugs in the API that have already merged.

Going forward, we can probably modify 'openapi_core' somewhat to remove
the need for the templated URL string. If and when this happens, most of
the funkier code here can happily go away.

[*] Django 2.0+ [1] does actually provide a way to do template
string-based URLs and in fact recommends them now, with regexes being
reserved for more advanced corner cases. However, we don't want to drop
support for the Django 1.11 yet as it is the most recent LTS release.

[1] https://docs.djangoproject.com/en/2.1/ref/urls/#django.urls.path

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Remove old Swagger 2.0 spec
Stephen Finucane [Fri, 7 Dec 2018 12:25:49 +0000 (12:25 +0000)] 
docs: Remove old Swagger 2.0 spec

This was incomplete and wrong in many places. It's since been replaced
by the OpenAPI 3.0.0 specs, so we have happily remove this now.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Store versioned OpenAPI schemas
Stephen Finucane [Mon, 10 Dec 2018 10:46:15 +0000 (10:46 +0000)] 
docs: Store versioned OpenAPI schemas

Signed-off-by: Stephen Finucane <stephen@that.guru>