summaryrefslogtreecommitdiff
path: root/patchwork
Commit message (Collapse)AuthorAge
...
* parser: Unmangle From: headers that have been mangled for DMARC purposesAndrew Donnellan2019-10-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | To avoid triggering spam filters due to failed signature validation, many mailing lists mangle the From header to change the From address to be the address of the list, typically where the sender's domain has a strict DMARC policy enabled. In this case, we should try to unmangle the From header. Add support for using the X-Original-From or Reply-To headers, as used by Google Groups and Mailman respectively, to unmangle the From header when necessary and associate the patch with the correct submitter based on the unmangled email address. When downloading mboxes, rewrite the From header using the unmangled address, and preserve the original header as X-Patchwork-Original-From in case someone needs it for some reason. The original From header will still be stored in the database and exposed via the API, as we want to keep messages as close to the original received format as possible. Closes: #64 ("Incorrect submitter when using googlegroups") Reported-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> Tested-by: Daniel Axtens <dja@axtens.net> # mailman only [dja: add release note] Signed-off-by: Daniel Axtens <dja@axtens.net>
* REST: Allow creating, updating, deleting of bundlesStephen Finucane2019-10-17
| | | | | | | | | | Allow users to create a new bundle, change the name, public flag and patches of an existing bundle, and delete an existing bundle. Some small nits with existing tests are resolved. Signed-off-by: Stephen Finucane <stephen@that.guru> Closes: #316
* REST: Add 'has_version' helperStephen Finucane2019-10-17
| | | | | | We're going to use this functionality elsewhere shortly. Signed-off-by: Stephen Finucane <stephen@that.guru>
* Use secrets and fall back to random.SystemRandom for keysJeremy Cline2019-10-17
| | | | | | | | | | | | | | | | | | The random module uses the Mersenne Twister pseudorandom number generator and is not a cryptographically secure random number generator[0]. The secrets[1] module is intended for generating cryptographically strong random numbers, so recommend using that to generate the secret key. It's new in Python 3, so if it's unavailable fall back to using the ``os.urandom()`` backed implementation of random. NOTE(stephenfin): Modified to include change to 'config.yaml'. Also renamed reno to just stick with hyphens for filenames. [0] https://docs.python.org/3/library/random.html [1] https://docs.python.org/3/library/secrets.html Signed-off-by: Jeremy Cline <jcline@redhat.com> Signed-off-by: Stephen Finucane <stephen@that.guru>
* Remove pwclient bashcompleteStephen Finucane2019-09-27
| | | | | | | This was also missed when moving pwclient to a separate repo. Fix it now. Signed-off-by: Stephen Finucane <stephen@that.guru> Fixes: 90e85f9d ("Remove pwclient")
* Remove invalid symlinkStephen Finucane2019-09-27
| | | | | | | This was missed when moving pwclient to a separate repo. Fix it now. Signed-off-by: Stephen Finucane <stephen@that.guru> Fixes: 90e85f9d ("Remove pwclient")
* trivial: Style fixesStephen Finucane2019-09-27
| | | | | | An assortment of fixes identified through the integration of pre-commit. Signed-off-by: Stephen Finucane <stephen@that.guru>
* Move to msgid based URLsDaniel Axtens2019-09-25
| | | | | | | | | | | | | | | | | | | | | | | | Migrate our URL schema as follows: Patches: /project/<linkname>/patch/<msgid>/ Cover Letters: /project/<linkname>/cover/<msgid>/ The usual sub-resources (mbox, raw) hang off those URLs. The old style URLs (/patch/NNN/*, /cover/NNN/*) redirect appropriately. I haven't attempted to do anything meaningful with series, and I have dropped any attempt to provide a generic message-id lookup or search functionality. One step at a time. Our database still stores message ids as with angle brackets; we just work around that rather than trying to migrate. That too can come later if we think the pain is justified. Partially-closes: #106 Reported-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org> Reported-by-but-I-don't-want-to-spam: Linus Torvalds <torvalds@linux-foundation.org> Reported-by: Stephen Finucane <stephen@that.guru> Signed-off-by: Daniel Axtens <dja@axtens.net>
* Fix issue with delegation of patch via REST APIStephen Finucane2019-09-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | There have been reports of people being unable to delegate patches to themselves, despite being a maintainer or the project to which the patch is associated. The issue is a result of how we do a check for whether the user is a maintainer of the patch's project [1]. This check is checking if a given 'User.id' is in the list of items referenced by 'Project.maintainer_project'. However, 'Project.maintainer_project' is a backref to 'UserProfile.maintainer_projects'. This means we're comparing 'User.id' and 'UserProfile.id'. Boo. This wasn't seen in testing since we've had a post-save callback [2] for some time that ensures we always create a 'UserProfile' object whenever we create a 'User' object. This also means we won't have an issue on deployments initially deployed after that post-save callback was added, a 'User' with id=N will always have a corresponding 'UserProfile' with id=N. However, that's not true for older deployments such as the ozlabs.org one. [1] https://github.com/getpatchwork/patchwork/blob/89c924f9bc/patchwork/api/patch.py#L108-L111 [2] https://github.com/getpatchwork/patchwork/blob/89c924f9bc/patchwork/models.py#L204-L210 Signed-off-by: Stephen Finucane <stephen@that.guru> Closes: #313 Reported-by: Bjorn Helgaas <helgaas@kernel.org>
* parsearchive, mail: use repr() to get a human readable exceptionDaniel Axtens2019-09-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently if we have particular types of error in mail parsing in parsearchive or parsemail, we print exc.message, which doesn't always work: Traceback (most recent call last): File ".../patchwork/management/commands/parsearchive.py", line 90, in handle obj = parse_mail(msg, options['list_id']) File ".../patchwork/parser.py", line 961, in parse_mail raise ValueError("Missing 'Message-Id' header") ValueError: Missing 'Message-Id' header During handling of the above exception, another exception occurred: Traceback (most recent call last): File "manage.py", line 11, in <module> execute_from_command_line(sys.argv) File ".../django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File ".../django/core/management/__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File ".../django/core/management/base.py", line 323, in run_from_argv self.execute(*args, **cmd_options) File ".../django/core/management/base.py", line 364, in execute output = self.handle(*args, **options) File ".../patchwork/management/commands/parsearchive.py", line 100, in handle logger.warning('Invalid mail: %s', exc.message) AttributeError: 'ValueError' object has no attribute 'message' repr(exc) will work. Use it. Signed-off-by: Daniel Axtens <dja@axtens.net> Reviewed-by: Stephen Finucane <stephen@that.guru>
* tests: make test suite pass with XML-RPC disabledDaniel Axtens2019-09-18
| | | | | | | Handy for development purposes. Signed-off-by: Daniel Axtens <dja@axtens.net> Reviewed-by: Stephen Finucane <stephen@that.guru>
* tests: Mark 'test_series.test_duplicated' as expected failureStephen Finucane2019-09-08
| | | | | | | | | This has been failing fairly frequently in Travis [1] but I'm not able to reproduce it locally. Skip things for now. [1] https://travis-ci.org/getpatchwork/patchwork/jobs/582342631 Signed-off-by: Stephen Finucane <stephen@that.guru>
* travis: Resolve issues with Python 3.7Stephen Finucane2019-09-08
| | | | | | | | | | | | | | 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")
* migrations: Correct 'unique_together' order in '0015'Stephen Finucane2019-08-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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")
* forms: Don't attempt to evaluate State at startupStephen Finucane2019-08-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* models: Add commit_url_format to ProjectMichael Ellerman2019-08-30
| | | | | | | | | | | | 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>
* mbox: do not copy Content-Type into exported mboxDaniel Axtens2019-08-22
| | | | | | | | | | | | | | | | | | 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>
* fixtures: Update Patchwork list IDAndrew Donnellan2019-08-22
| | | | | | | | 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>
* api: Add list archive fieldsAndrew Donnellan2019-08-22
| | | | | | | | | 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>
* templates: Add mailing list archive link to patch detail pageAndrew Donnellan2019-08-22
| | | | | | | | 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>
* models: Add list archive lookupAndrew Donnellan2019-08-22
| | | | | | | | | | | | | | | | 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>
* models, templates: Add project list archive URL fieldAndrew Donnellan2019-08-22
| | | | | | | | | | 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>
* Add 'dumparchive' management commandMete Polat2019-07-19
| | | | | | | | | 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>
* about: Display admin contact detailsAndrew Donnellan2019-07-05
| | | | | | | | | 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>
* filters: Escape State names when generating selector HTMLAndrew Donnellan2019-07-05
| | | | | | | 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>
* tests: Add test for unescaped values in patch detail pageAndrew Donnellan2019-07-05
| | | | | | | | | | | 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>
* templatetags: Do not mark output of msgid tag as safeAndrew Donnellan2019-07-05
| | | | | | | | | | | | | | | | | | 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>
* Remove pwclientStephen Finucane2019-06-17
| | | | | | | | | 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>
* templates: Fix pwclientrc sampleStephen Finucane2019-06-17
| | | | | | | | 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
* filters: re-add the possibility of filtering undelegated patchesMauro Carvalho Chehab2019-06-05
| | | | | | | | | | | | | | | 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]
* parser: Remove duplicityPetr Vorel2019-06-04
| | | | | | | | 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>
* parser: Include extended header lines in diffStephen Finucane2019-06-04
| | | | | | | | | | 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>
* parser: Add missing extended header linesPetr Vorel2019-06-04
| | | | | | | | | | | | | 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
* Revert "parser: Ensure whitespace is stripped for long headers"Daniel Axtens2019-05-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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]
* REST: A check must specify a stateDaniel Axtens2019-04-30
| | | | | | | | | | 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>
* REST: Handle regular form data requests for checksDaniel Axtens2019-04-30
| | | | | | | | | | | | | | | | | 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>
* notifications: fix notification expiry when no user is associatedJeremy Kerr2019-04-30
| | | | | | | | | | | | | | | | | | | 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>
* Fix YAML loader warningDaniel Axtens2019-03-21
| | | | | | | | | | | | | 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>
* parser: recognise git commit consisting only of empty new fileDaniel Axtens2019-03-02
| | | | | | | | | | | | | | | | | 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>
* Beautify check counts in the patch list viewAli Alnubani2019-02-25
| | | | | | | | | | | | | | | | | 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>
* Fix return code when getting patch information failsAli Alnubani2019-02-25
| | | | | | | | | | 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>
* admin: Further optimize queriesStephen Finucane2018-12-25
| | | | | | | 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>
* admin: Show series.submitter in admin viewStephen Finucane2018-12-25
| | | | | | | 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>
* tests: Configure User.first_name, User.last_nameStephen Finucane2018-12-25
| | | | | | | '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>
* parser: Ensure whitespace is stripped for long headersStephen Finucane2018-12-22
| | | | | | | | | | | | | | | | | | | | | | 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
* models: Ensure UserProfile.user is configuredStephen Finucane2018-12-22
| | | | | | | | | | 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
* Add REST API validation using OpenAPI schemaStephen Finucane2018-12-22
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* REST: Handle JSON requestsStephen Finucane2018-12-22
| | | | | | | | | | | | This was raising an attribute error when switching tests to use JSON bodies instead of form-data. AttributeError: 'dict' object has no attribute '_mutable' The easy fix is to check if it's a dictionary and avoid the mutability check if so. Signed-off-by: Stephen Finucane <stephen@that.guru>
* tests: Use project.id in requests, not objectStephen Finucane2018-12-22
| | | | | | The object is not serializable. Signed-off-by: Stephen Finucane <stephen@that.guru>
* tests: Use valid URLsStephen Finucane2018-12-22
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>