Commit graph

2272 commits

Author SHA1 Message Date
Mark Weiman
f15c700ad2 Add capability for co-maintainers to disown packages
Implements FS#53832.

Signed-off-by: Mark Weiman <mark.weiman@markzz.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-02-24 14:57:31 +01:00
Florian Pritz
27654afadb Add rate limit support to API
This allows us to prevent users from hammering the API every few seconds
to check if any of their packages were updated. Real world users check
as often as every 5 or 10 seconds.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-02-24 14:57:31 +01:00
Florian Pritz
f51d4c32cd Remove disjunction in pkg_providers query
For some reason, running the SELECT .. WHERE .. OR .. query takes e.g.
58ms on a randomly generated db for some dependency name. Splitting the
OR into two dedicated queries and UNIONing the result takes only 0.42ms.

On the Arch Linux installation, searching for the providers of e.g.
mongodb takes >=110ms when not cached by the query cache. The new query
takes <1ms even when not cached.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-02-24 14:57:31 +01:00
Remy Marquis
34a0d39910 Document required PHP extensions in php.ini
To people unfamiliar with the code, it is not obvious that
the pdo_* PHP extensions must be enabled.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-01-26 20:17:04 +01:00
Johannes Löthberg
e5b43760c2 Move AUR_OVERWRITE privilege check from git/auth to git/update
git/auth is run as an AutherizedKeysCommand which does not get the
environment variables passed to it, so AUR_OVERWRITE always got
hard-set to '0' by it.  Instead we need to perform the actual privilege
check in git/update instead.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-01-21 18:09:10 +01:00
Eli Schwartz
ac29097ce8 Fix regression that stopped maintainers from pinning comments
In commit 8c98db0b82 support was added for
package co-maintainers to pin comments in addition to maintainers.

Due to a typo, the SQL query was reset halfway through and only added
the co-maintainer IDs to the list of allowed users.

Fixes FS#56783.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-12-23 22:51:39 +01:00
Lukas Fleischer
a04fe6a13e Add route for /users.gz
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-12-03 13:59:54 +01:00
Lukas Fleischer
4660892e58 Allow setting an empty home page
Since commit 4efba18 (Only allow valid HTTP(s) URLs as home page,
2017-11-05), the home page field in the account settings must be a valid
URL. However, this new check prevents from leaving the field empty. Keep
the check in place but skip it if the home page field is left empty.

Fixes FS#56550.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-12-03 13:52:28 +01:00
Lukas Fleischer
0333d475fa Release 4.6.0
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-12-03 10:23:46 +01:00
Lukas Fleischer
f44705a640 Translation updates from Transifex
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-12-02 21:30:44 +01:00
Lukas Fleischer
d09ee5fdd7 Update message catalog
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-11-28 08:52:22 +01:00
Lukas Fleischer
3be28d016f Sync CSS with archweb
This partially fixes FS#56472.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-11-28 08:52:12 +01:00
Lukas Fleischer
efa8da5ca2 Auto-link bug reports in comments
Automatically detect references to Flyspray bug reports in comments and
convert them to links to the Arch Linux bug tracker.

Implements FS#52008.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-11-08 07:51:09 +01:00
Lukas Fleischer
0aa67b278a Fix sorting order when clicking table headings
A bug introduced in commit 7d7e079 (Hide the table sorting links on the
dashboard, 2017-02-04) resulted in multiple clicks on a table heading in
the package search results table no longer having any effect, instead of
changing the sorting order. Fix this by removing erroneous spaces from
the GET parameters in the search URL.

Fixes FS#56261.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-11-07 21:36:42 +01:00
Lukas Fleischer
8c98db0b82 Allow package co-maintainers to pin comments
Implements FS#56255.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-11-06 17:03:37 +01:00
Lukas Fleischer
e2fa5ea6fa login.php: Escape quotes in the referer field
Replace special characters in the referer GET parameter using
htmlspecialchars() before inserting it into the login form fields to
prevent from XSS attacks.

Fixes FS#55286.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-11-05 11:28:11 +01:00
Lukas Fleischer
4efba18f86 Only allow valid HTTP(s) URLs as home page
The home page specified in the account settings is converted to a
clickable link on the user's profile. Make sure it is a valid URL which
uses the http or https scheme.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-11-05 08:55:24 +01:00
Lukas Fleischer
c859e371b0 Set X-Frame-Options to DENY for all pages
Do not allow to render aurweb pages in a frame to protect against
clickjacking.

Fixes FS#56168.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-11-05 08:36:23 +01:00
Lukas Fleischer
6c95fa3d1e Point out that the user name is public when registering
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-11-05 08:24:51 +01:00
Lukas Fleischer
36f26033d8 Add basic Travis CI support
Add a Travis CI configuration file to setup a test environment with all
the required dependencies and run the test suite.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-08-25 07:04:15 +02:00
Lukas Fleischer
7ef1427678 Fix use of test_must_fail with environment variables
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-08-25 07:04:15 +02:00
Lukas Fleischer
cb307bf01a Do not hardcode path to the Python interpreter
Use `/usr/bin/env python3` instead of `/usr/bin/python3` in the shebang
of Python scripts. This adds support for non-standard Python interpreter
paths such as the paths used in virtualenv environments.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-08-25 07:01:12 +02:00
Lukas Fleischer
2d2bef3513 t1100: Test AUR_OVERWRITE
Since c5302d3 (Require TUs to explicitly request to overwrite a pkgbase,
2017-07-24), non-fast-forward pushes require setting the AUR_OVERWRITE
environment variable. Make sure that git-auth passes this variable to
git-serve when it should (and does not pass it if it shouldn't).

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-08-10 15:17:31 +02:00
Lukas Fleischer
624d168b22 git-serve: Fix broken SQL statement
Add a missing space to the SQL statement performing the disown
operation.

Fixes FS#55068.

Note that the broken query was not discovered by the test suite since
SQLite parses "?AND" inside prepared statements gracefully while MySQL
does not.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-08-08 15:33:25 +02:00
Lukas Fleischer
e0d3fbfdf1 t1300: Fix test cases for non-fast-forward pushes
Since commit c5302d3 (Require TUs to explicitly request to overwrite a
pkgbase, 2017-07-24), non-fast-forward pushes are denied even for
Trusted Users, unless the AUR_OVERWRITE environment variable is set.
Mark the test case performing a non-fast-forward push from a TU
account as test_must_fail and add another test case performing the
same operation with AUR_OVERWRITE=1.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-08-08 15:28:40 +02:00
Lukas Fleischer
449909a872 INSTALL: Add new dependencies
Add installation instructions for python-bleach and python-markdown
which are required for the rendercomment script.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-08-01 07:11:25 +02:00
Lukas Fleischer
d9883ee642 mkpkglists: Generate a list of user names
In addition to the packages list and the package base list, also create
a list of registered user names.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-08-01 07:08:29 +02:00
Lukas Fleischer
e06773add6 Unset PackagerUID before deleting an account
When removing an account, remove the user from all last packager fields
before deletion to make sure that no package bases are deleted, even if
propagation constraints are missing.

Fixes FS#53956.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-08-01 07:02:44 +02:00
Eli Schwartz
c5302d3a33 Require TUs to explicitly request to overwrite a pkgbase
AUR_PRIVILEGED allows people with privileged AUR accounts to evade the
block on non-fast-forward commits. While valid in this case, we should
not do so by default, since in at least one case a TU did this without
realizing there was an existing package.
( https://aur.archlinux.org/packages/rtmidi/ )

Switch to using allow_overwrite to check for destructive actions.
Use .ssh/config "SendEnv" on the TU's side and and sshd_config
"AcceptEnv" in the AUR server to specifically request overwrite access.
TUs should use: `AUR_OVERWRITE=1 git push --force`

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-07-25 20:12:11 +02:00
Eli Schwartz
243fb92273 Fix setting keywords in the SSH interface
This was broken in commit 8914a41db9 which
refactored the argument parsing. Instead of checking for at least the
set-keywords command and a pkgbase name, we were checking for *exactly*
the command and pkgbase name, leaving no room for keywords...

As a result, while we could clear the keywords, we could not set them.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-07-22 17:47:34 +02:00
Lukas Fleischer
ad4acfb9aa Document new git-serve commands
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-07-22 17:46:54 +02:00
Mark Weiman
0c6a415cb3 gendummydata.py: Fix NOT NULL constraint problems
PackageBases.FlaggerComment and PackageComments.RenderedComment cannot
be NULL and would cause problems in the output file for sqlite users.
This patch adds empty strings ("") as values for these fields.

Signed-off-by: Mark Weiman <mark.weiman@markzz.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-05-02 16:29:40 +02:00
Lukas Fleischer
a8ac2004d3 Add support for Terms of Service documents
This allows for adding Terms of Service documents to the database that
registered users need to accept before using the AUR. A revision field
can be used to indicate whether a document was updated. If it is
increased, all users are again asked to accept the new terms.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-30 16:47:13 +02:00
Lukas Fleischer
6892ec7791 Call check_sid() from a central location
Instead of calling check_sid() from every single PHP script representing
a web page, add the call to aur.inc.php which is sourced by all of them.

Also, remove set_lang() calls from the scripts since these are also
already included in aur.inc.php.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-27 09:22:53 +02:00
Lukas Fleischer
e4dcd913d1 Support headings in package comments
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-26 06:43:12 +02:00
Lukas Fleischer
dec9077339 Initialize PackageRequests.{Comments,ClosureComment}
Since commit 09cb61a (schema: Remove invalid default values for TEXT
columns, 2017-04-15), the PackageRequests.Comments and
PackageRequests.ClosureComment fields no longer have a default value.
Initialize these fields explicitly whenever a new row is added to the
PackageRequests table.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-25 07:00:53 +02:00
Lukas Fleischer
f4e2d143ad Explicitly initialize PackageBases.FlaggerComment
Since commit 09cb61a (schema: Remove invalid default values for TEXT
columns, 2017-04-15), the PackageBases.FlaggerComment field no longer
has a default value. Initialize this field explicitly whenever a new row
is added to the PackageBases table.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-25 07:00:52 +02:00
Lukas Fleischer
90ab7c7b83 t1300: Factor out package dumping
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-25 07:00:23 +02:00
Lukas Fleischer
4be9aa6350 Fix the comment collapse feature
In commit 4abde89 (Use JavaScript to collapse long comments,
2017-04-19), support for collapsing/expanding long comments was added.
This was broken by the recent Markdown support since comments no longer
live inside a single HTML paragraph. Fix this by wrapping each comment
in another div container.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-24 21:10:02 +02:00
Lukas Fleischer
fd880a7a84 Support fenced code in package comments
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-24 21:10:02 +02:00
Lukas Fleischer
362ee754e7 Do not keep line breaks in comments
With the new Markdown support, text paragraphs are now properly
converted to HTML paragraphs, so we no longer need to keep line breaks.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-24 21:10:02 +02:00
Lukas Fleischer
136171e509 Rerender package comments after editing
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-24 17:41:35 +02:00
Lukas Fleischer
482bd10a8b t2600: Test Markdown and HTML sanitizing
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-24 17:41:35 +02:00
Lukas Fleischer
bb623fc545 Make references to Git commits clickable
Automatically detect Git commit identifiers, shorten them, and make them
link to the cgit interface.

Implements FS#43290.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-24 17:41:35 +02:00
Lukas Fleischer
a9ac385cb9 Reintroduce backwards-compatible hyperlink syntax
Before switching to the new comment rendering script and Markdown, no
special syntax was needed to make URLs clickable. Reintroduce this
feature and automatically detect links in addition to the hyperlink
syntax already supported by Markdown.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-23 18:43:26 +02:00
Lukas Fleischer
9aa4203c7e Add Markdown support to package comments
Support Markdown syntax in package comments. Among other things, this
makes it easier to paste command line output and patches.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-23 18:43:26 +02:00
Lukas Fleischer
016b40f99d Render comments when storing them in the database
Instead of converting package comments from plain text to HTML code when
they are displayed, do the conversion when the comment is posted and
store the rendered result in the database. The conversion itself is done
by a Python script which uses Bleach for sanitizing the text.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-23 18:43:26 +02:00
Lukas Fleischer
4abde895a5 Use JavaScript to collapse long comments
Instead of using CSS to limit the height of package comments as
implemented in 7b13203 (Limit comment height to 15 lines, 2016-03-12),
use JavaScript to collapse long comments and add a link to expand them.
Clicking the same link twice results in the corresponding comment being
collapsed again.

If JavaScript is disabled, the full comments are shown (without any
possibility to collapse or expand).

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-20 07:03:54 +02:00
Lukas Fleischer
44858e0618 Store dependency descriptions in a separate column
Split optional dependency descriptions from dependency names before
storing them in the database and use a separate column to store the
descriptions.

This allows us to simplify and optimize the SQL queries in
pkg_dependencies() as well as pkg_required().

Suggested-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-19 09:13:09 +02:00
Lukas Fleischer
15501972bc Check return value of get_extended_fields()
Make sure that the get_extended_fields() invocation succeeded before
merging regular and extended fields in process_query().

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-18 08:45:02 +02:00