Commit graph

953 commits

Author SHA1 Message Date
Kevin Morris
b52059d437
RPC: add deprecation warning for v1-v4 usage
With FastAPI starting to come closer to a close, we've got to advertise
this deprecation so that users have some time to adjust before making
the changes. We have not specified a specific time here, but we'd like
this message to reach users of the RPC API for at least a month before
any modifications are made to the interface.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-08-31 17:18:10 -07:00
Kevin Morris
4442ba6703 bugfix: return null if config key doesn't exist
This was previously causing a PHP warning due to returning
a missing key.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-29 10:48:45 -07:00
Leonidas Spyropoulos
2f5d9c63c4 [php] Support DB mysql backend with port instead of socket
Signed-off-by: Leonidas Spyropoulos <artafinde@gmail.com>
2021-06-29 17:59:46 +01:00
Kevin Morris
be3bab2ce0 Merge branch 'master' into pu 2021-06-12 20:11:48 -07:00
Justin Kromlinger
4330fe4f33 Add RSS feed for modified packages 2021-06-12 20:09:48 -07:00
Justin Kromlinger
e7db894eb7 RSS: Add ability to specify isPermaLink="false" for GUID 2021-06-12 20:09:39 -07:00
Justin Kromlinger
2bb30f9bf5 Add RSS feed for modified packages 2021-06-12 19:14:43 -07:00
Justin Kromlinger
18ec8e3cc8 RSS: Add ability to specify isPermaLink="false" for GUID 2021-06-12 19:14:43 -07:00
Steven Guikal
a625df07e2
Source valid ssh prefixes from config
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2021-06-10 15:32:02 -04:00
Leonidas Spyropoulos
21140e28a8 Filter out current username from co-maintainers list.
Closes: #8

Signed-off-by: Leonidas Spyropoulos <artafinde@gmail.com>
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2021-06-05 19:49:42 -07:00
Eli Schwartz
8ec170b3e0
dos2unix a file with Windows linebreaks that editors and human reviewers hate
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2021-05-02 21:46:35 -04:00
Jelle van der Waa
d668ef0bcd Resolve SQL Error when deleting an account
The account deletion code tries to remove user from PackageNotifications
using the wrong column UsersID to identify the user by id. In the
PackagePackageNotifications table the foreign key is called UserID. In
the future ideally this would be unified into UserID for all tables.

Closes: #12
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-03-29 18:39:02 -04:00
Justin Kromlinger
568e0d2fa3 RSS: Add atom self link
https://validator.w3.org/feed/docs/warning/MissingAtomSelfLink.html
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:25:21 -05:00
Jakub Klinkovský
bc972089a1 Fix WHERE clause for keyword search queries with empty keywords
When the keyword parameter is empty, the AND clause has to be omitted,
otherwise we get an SQL syntax error:

... WHERE PackageBases.PackagerUID IS NOT NULL AND () ...

This got broken in commit 9e30013aa4fc6ce3a3c9f6f83a6fe789c1fc2456
Author: Kevin Morris <kevr.gtalk@gmail.com>
Date:   Sun Jul 5 18:19:06 2020 -0700

Support conjunctive keyword search in RPC interface

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:25:21 -05:00
Frédéric Mangano-Tarumi
87815d37c0 Remove the per-user session limit
This feature was originally introduced by
f961ffd9c7 as a fix for FS#12898
<https://bugs.archlinux.org/task/12898>.

As of today, it is broken because of the `q.SessionID IS NULL` condition
in the WHERE clause, which can’t be true because SessionID is not
nullable. As a consequence, the session limit was not applied.

The fact the absence of the session limit hasn’t caused any issue so
far, and hadn’t even been noticed, suggests the feature is unneeded.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:25:19 -05:00
Frédéric Mangano-Tarumi
9290eee138 Stop redirecting stderr with proc_open
Error outputs were piped to a temporary buffer that wasn’t read by
anyone, making debugging hard because errors were completely silenced.
By not explicitly redirecting stderr on proc_open, the subprocess
inherits its parent stderr.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:24:30 -05:00
Kevin Morris
efe99dc16f Support conjunctive keyword search in RPC interface
Newly supported API Version 6 modifies `type=search` for _by_ type
`name-desc`: it now behaves the same as `name-desc` search through the
https://aur.archlinux.org/packages/ search page.

Search for packages containing the literal keyword `blah blah` AND `haha`:
https://aur.archlinux.org/rpc/?v=6&type=search&arg="blah blah"%20haha

Search for packages containing the literal keyword `abc 123`:
https://aur.archlinux.org/rpc/?v=6&type=search&arg="abc 123"

The following example searches for packages that contain `blah` AND `abc`:
https://aur.archlinux.org/rpc/?v=6&type=search&arg=blah%20abc

The legacy method still searches for packages that contain `blah abc`:
https://aur.archlinux.org/rpc/?v=5&type=search&arg=blah%20abc
https://aur.archlinux.org/rpc/?v=5&type=search&arg=blah%20abc

API Version 6 is currently only considered during a `search` of `name-desc`.

Note: This change was written as a solution to
https://bugs.archlinux.org/task/49133.

PS: + Some spacing issues fixed in comments.

Signed-off-by: Kevin Morris <kevr.gtalk@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:24:30 -05:00
Eli Schwartz
71740a75a2 rewrite query to support both mysql/sqlite
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:22:11 -05:00
Eli Schwartz
be5197a5fe prevent running mysql-specific query in sqlite
We usually guard such queries and have both mysql and sqlite branches.
But I have not implemented the sqlite branch. Given sqlite is typically
used for local dev setups, the fact that "users with more than the
configured max simultaneous logins" can avoid getting some logins
annulled is probably not a huge risk.

And this always *used* to fail on sqlite, silently. Now, in php 8, it
raises PDOException, which prevents running the test server

Document this as a FIXME for now, until someone reimplements the query
for sqlite.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:22:11 -05:00
Eli Schwartz
d92dd69aa3 fix broken SQL query that always failed
Due to missing whitespace at the end of strings during joining, we ended
up with the query fragment

"DelTS IS NULLAND NOT PinnedTS"

which should be

"DelTS IS NULL AND NOT PinnedTS"

So the check for pinned comments > 5 likely always failed.

In php 7, a completely broken query that raises exceptions in the
database engine was silently ignored... in php 8, it raises

Uncaught PDOException: SQLSTATE[HY000]: General error: 1 near "PinnedTS": syntax error in <file>

and aborts the page building. End result: users with permission to pin
comments cannot see any comments, or indeed page content below the first
comment header

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:22:11 -05:00
Morten Linderud
613364b773 pkg_search_page: Limit number of results on package search
The current package search query is quite poorly optimized and becomes a
resource hog when the offsets gets large enough. This DoSes the service.

A quick fix is to just ensure we have some limit to the number of hits
we return. The current hardcoding of 2500 is based on the following:

    * 250 hits per page max
    * 10 pages

We can maybe consider having it lower, but it seems easier to just have
this a multiple of 250 in the first iteration.

Signed-off-by: Morten Linderud <morten@linderud.pw>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-09-05 10:21:16 -04:00
Lukas Fleischer
1369eb87b3 Fix invalid session ID check
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-04-05 15:59:55 -04:00
Lukas Fleischer
853ed9a950 Release 5.0.0
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-03-27 08:51:15 -04:00
Eli Schwartz
050b08081a Fix more PHP 7.4 warnings
The try_login() function documents it returns an array containing an
'error' key, and our only caller *only* consults the 'error' key. Then
the function returns null instead of an array, if the login succeeded!

I question why we bother returning the new SID if we never use it,
surely we could either return the error or return default null. But, for
now, I'm just going to fix it to return what it's actually supposed to,
without changing the API.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-02-13 09:11:34 +01:00
Eli Schwartz
5ca1e271f9 Fix PHP 7.4 warnings
If a db query returned NULL instead of an array, then accessing $row[0]
now throws a warning. The undocumented behavior of evaluating to NULL
is maintained, and we want to return NULL anyway, so add a check for the
value and fall back on the default function return type.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-02-13 09:11:28 +01:00
Lukas Fleischer
ee2aa9755f Add support for backup email addresses
Support secondary email addresses that can be used to recover an account
in case access to the primary email address is lost. Reset keys for an
account are always sent to both the primary and the backup email
address.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-02-02 12:12:42 +01:00
Lukas Fleischer
e5a839bf0b Add option to send reset key for a given user name
In addition to supporting email addresses in the reset key form, also
support user names. The reset key is then sent to the email address in
the user's profile.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-02-02 12:12:42 +01:00
Lukas Fleischer
def2787b45 Require password when changing account information
Since commits daee20c (Require current password when setting a new one,
2020-01-30) and 8fc8898 (Require password when deleting an account,
2020-01-30), changing a password and deleting an account require the
current password. Extend this to all other profile changes.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-01-30 14:05:24 +01:00
Lukas Fleischer
7aa420d24d Verify current password against logged in user
When changing the password of an account, instead of asking for the old
password of the account, ask for the password of the currently logged in
user. This allows privileged users to edit other accounts without
knowing their passwords.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-01-30 13:25:15 +01:00
Lukas Fleischer
f090896fa1 Undo accidental code addition
Rollback an accidental change that sneaked into commit daee20c (Require
current password when setting a new one, 2020-01-30).

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-01-30 13:25:15 +01:00
Lukas Fleischer
daee20c694 Require current password when setting a new one
Prevent from easily taking over an account by changing the password with
a stolen session ID.

Fixes FS#65325.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-01-30 10:31:26 +01:00
Lukas Fleischer
2422fb020b Store timestamp and user ID when closing requests
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-11-23 12:30:46 -05:00
Lukas Fleischer
86e4cd0731 aurjson: use APCu/memcached for rate limiting
There's no need to use permanent storage for rate limiting information;
try to keep it in memory if caching is enabled.

From experiments with our live setup, this reduces the number of
INSERT/DELETE operations per second from 15 to almost 0. Disk writes on
the server hosting the AUR are reduced by 90% (from ~3MB/s to ~300kB/s).

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-11-02 18:32:07 -04:00
Lukas Fleischer
c1e5ffb12a Release 4.8.0
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-10-19 00:20:40 -04:00
Lukas Fleischer
3ec0f6bfbf Cache package requirements and sources
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-10-09 15:13:15 -04:00
Lukas Fleischer
734527370d Make package details cache TTL configurable
The TTL for package details can be much longer than for generic values
since they never change. Note that when an update is pushed via Git, all
packages belonging to that package base are deleted and new packages are
created.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-10-07 12:21:03 -04:00
Lukas Fleischer
f804ea4abb Cache package licenses, groups and relations
Cache more package details if the global caching mechanism is enabled.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-10-07 09:31:18 -04:00
Lukas Fleischer
6493d00db5 aurjson: cache extended fields
Cache the results of the extended fields computation if the global
caching mechanism is enabled.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-10-06 16:13:38 -04:00
Lukas Fleischer
1283fe4918 Cache package provider and dependency information
The package provider and dependency queries are quite CPU-intensive and
usually yield rather small result sets. Cache these values if the global
caching mechanism is enabled.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-10-06 16:13:38 -04:00
Lukas Fleischer
ef8bad5bbf Make CAPTCHA salt invalidation more robust
With the previous implementation, unlucky users could have their CAPTCHA
be invalidated by a single account creation while filling out their
account registration form.

Make this more robust by allowing up to five account registrations
before rejecting a CAPTCHA salt.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-10-05 14:21:53 -04:00
Lukas Fleischer
d6ae970785 Add a simple CAPTCHA to the sign up form
Add a CAPTCHA to protect against automated account creation. The CAPTCHA
changes whenever three new accounts are registered.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-10-05 13:44:00 -04:00
Eli Schwartz
3ac958ac01
Move permission for LIST_COMMENTS to dev/tu block
In commit 3578e77ad4 we implemented
listing of comments from the account details page , but this was
intended to only be available to TUs and Devs. As the comment says:
"display the comment list if they're a TU/dev"

The credential checking code, however, set this credential for all
users, contrary to the intention of the commit.

In order to preserve the ability to list a person's own comments, also
declare the allowed uids based on the profile being viewed.
2019-08-18 13:01:37 -04:00
Johannes Löthberg
7f008b0bc4 pkgreqfuncs: Don't leave out non-default ClosureComment column
Since 09cb61a (schema: Remove invalid default values for TEXT columns,
2017-04-15) the PackageRequests.ClosureComment field no longer has a
default value.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-07-30 13:51:27 -04:00
Lukas Fleischer
fc9c519852 Display warning when flagging VCS packages
VCS packages should not be flagged out-of-date when the package version
does not match the most recent commit.

Implements FS#62733.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-05-25 19:01:33 -04:00
Lukas Fleischer
952e61a79c Use native language name for Finnish
Addresses FS#61803.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-05-24 12:37:08 -04:00
Lukas Fleischer
69deea9f2f Ignore merge target for non-merge requests
Fixes FS#59837.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-05-24 12:24:46 -04:00
Florian Pritz
042f3f2622
Quote MySql 8.0 reserved keywords
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2019-01-14 14:45:37 -05:00
Eli Schwartz
f1d109e9b6
Fix notifications emails going to the right people, part #2
Notifications are still going to the wrong people. We tried to fix this
in commit b702e5c0e7, but only fixed it
for the python callers. There's another caller in the php code, which
needs to use the right order of arguments as well.

Fixes FS#60601

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2018-10-26 10:10:00 -04:00
Johannes Löthberg
257115943e Allow paginating package comments
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-08-06 06:03:58 +02:00
Johannes Löthberg
3578e77ad4 Allow listing all comments from a user
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-08-06 06:03:58 +02:00