Commit graph

953 commits

Author SHA1 Message Date
Lukas Fleischer
a7865ef5aa Make the locale directory configurable
Add a new configuration option to specify the locale directory to use.
This allows the Python scripts to find the translations, even when not
being run from the source code checkout. At the same time, multiple
parallel aurweb setups can still use different sets of translations.

Fixes FS#59278.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-08-06 06:03:52 +02:00
Eli Schwartz
c8d99bac8e Fix regression in translating anything at all
In commit 840ee20 (Rename translation resources from aur to aurweb,
2018-07-07) the translations file was renamed but we never actually
switched to using the renamed translations.

As a result, every single push to the AUR contains the following
traceback:

    remote: Traceback (most recent call last):
    remote:   File "/usr/bin/aurweb-notify", line 11, in <module>
    remote:     load_entry_point('aurweb==4.7.0', 'console_scripts', 'aurweb-notify')()
    remote:   File "/usr/lib/python3.6/site-packages/aurweb-4.7.0-py3.6.egg/aurweb/scripts/notify.py", line 541, in main
    remote:   File "/usr/lib/python3.6/site-packages/aurweb-4.7.0-py3.6.egg/aurweb/scripts/notify.py", line 69, in send
    remote:   File "/usr/lib/python3.6/site-packages/aurweb-4.7.0-py3.6.egg/aurweb/scripts/notify.py", line 56, in get_body_fmt
    remote:   File "/usr/lib/python3.6/site-packages/aurweb-4.7.0-py3.6.egg/aurweb/scripts/notify.py", line 192, in get_body
    remote:   File "/usr/lib/python3.6/site-packages/aurweb-4.7.0-py3.6.egg/aurweb/l10n.py", line 14, in translate
    remote:   File "/usr/lib/python3.6/gettext.py", line 514, in translation
    remote:     raise OSError(ENOENT, 'No translation file found for domain', domain)
    remote: FileNotFoundError: [Errno 2] No translation file found for domain: 'aur'

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-07-09 16:43:31 +02:00
Lukas Fleischer
2c03766841 Release 4.7.0
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-07-07 17:23:29 +02:00
Lukas Fleischer
5c48302aaf confparser.inc.php: Add missing dollar sign
Fixes a regression introduced in 97c5bce (config: allow reading both the
defaults file and the modified config, 2018-04-15).

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-05-12 12:37:16 +02:00
Lukas Fleischer
ad9422ca19 confparser.inc.php: Add missing semicolon
Fixes a regression introduced in 97c5bce (config: allow reading both the
defaults file and the modified config, 2018-04-15).

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-05-12 12:25:21 +02:00
Eli Schwartz
97c5bcec13 config: allow reading both the defaults file and the modified config
In the process, rename config.proto to config.defaults (because that is
what it is now).

Also use dict.get('key', default_value) when querying os.environ, rather
than an if block, as it is more pythonic/readable/concise, and reduces
the number of dict lookups.

This change allows aurweb configuration to be done via either:
- copying config.defaults to config and modifying values
- creating a new config only containing modified values, next to a
  config.defaults containing unmodified values

The motivation for this change is to enable ansible configuration in our
flagship deployment by storing only changed values, and deferring to
config.defaults otherwise.

A side benefit is, it is easier to see what has changed by inspecting
only the site configuration file.

If a config.defaults file does not exist next to $AUR_CONFIG or in
$AUR_CONFIG_DEFAULTS, it is ignored and *all* values are expected to
live in the modified config file.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-04-22 09:26:10 +02:00
nodivbyzero
eccd328d42 Handle empty resultset getting recent 10 packages
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-03-21 07:45:26 +01:00
nodivbyzero
3d90623154 Terminate execution if config file is missing
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-03-20 19:23:02 +01:00
Jelle van der Waa
ca6332de6e Update cache code to INI style configuration
Change the defines to config_get and add one cache option and one option
to define memcache_servers. Mention the required dependency to get
memcached working in the INSTALL file.

Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-03-10 16:48:14 +01:00
Jelle van der Waa
c3bca45973 Remove unused variable $dbh in pkgbase_display_details
Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-03-10 16:47:11 +01:00
Baptiste Jonglez
1ff409874e RPC: Allow to search packages by "*depends" fields
It is now possible to search for packages that depend on a given package,
for instance:

    /rpc/?v=5&type=search&by=depends&arg=ocaml

It is similarly possible to match on "makedepends", "checkdepends" and
"optdepends".

Signed-off-by: Baptiste Jonglez <git@bitsofnetworks.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-02-24 14:57:31 +01:00
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
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
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
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
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
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
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
136171e509 Rerender package comments after editing
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-24 17:41:35 +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
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
Lukas Fleischer
4f662c773d Check query return value in db_cache_value()
Instead of unconditionally calling fetch on the return value of query(),
error out early if the value evaluates to false.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-18 08:40:22 +02:00
Lukas Fleischer
6090c2ae8b Check query return value in search_results_page()
Instead of unconditionally calling fetch on the return value of query(),
error out early if the value evaluates to false. Also, make sure that
the results array is always initialized, even if the result set is
empty.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-18 08:38:13 +02:00
Lukas Fleischer
5553d01ab3 Check query return value in pkgbase_user_notify()
Instead of unconditionally calling fetch on the return value of query(),
error out early if the value evaluates to false.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-18 08:37:31 +02:00
Lukas Fleischer
a7606d0e1b Release 4.5.1
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-03-09 06:18:34 +01:00
Lukas Fleischer
06cf067d4f Squelch warning in pkgbase_vote()
Do not trigger a PHP warning if there are no votes to be added or
removed.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-27 20:11:15 +01:00
Lukas Fleischer
483c8f5178 Remove bogus if-statement from pkgbase_delete()
The variable $action is always undefined in pkgbase_delete() which makes
the if-statement always true and triggers a warning whenever a package
base is removed.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-27 19:56:30 +01:00
Lukas Fleischer
c557f348c4 Fix SQL query to retrieve language setting
In commit e171f6f (Migrate all DB code to use PDO, 2012-08-08),
PDOStatement::fetchAll() was introduced as a drop-in replacement for
mysql_fetch_array(). However, PDOStatement::fetchAll() returns a list of
all results while mysql_fetch_array() returns a single result only.
Instead of adding the missing indirection, simplify the code by using
PDO::fetchColumn().

Also add some safeguards to prevent warnings if the result set returned
by the query is empty.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-27 19:49:15 +01:00
Lukas Fleischer
62341a3b34 Fix warning with invalid time zone
The SQL query retrieving the time zone from the database may return an
empty result set if the session timeout was reached. Handle such cases
gracefully by leaving the timezone variable unset.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-27 18:20:00 +01:00
Lukas Fleischer
1bedf736e8 Fix more warnings occurring with unset SSH keys
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-27 18:20:00 +01:00
Lukas Fleischer
333689a885 Suppress warning on unset SSH key
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-27 18:19:08 +01:00
Lukas Fleischer
f2357a1724 Do not quote legacy variable
The $salt variable is no longer needed as of 29a4870 (Use bcrypt to hash
passwords, 2017-02-24).

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-27 18:19:08 +01:00
Lukas Fleischer
cda832cbf0 Fix SQL query used for creating new accounts
Fixes a regression introduced in 608c483 (Add user set timezones,
2017-01-20).

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-27 18:19:08 +01:00
Lukas Fleischer
5fd417d701 Release 4.5.0
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-26 10:28:34 +01:00
Lukas Fleischer
29a48708bb Use bcrypt to hash passwords
Replace the default hash function used for storing passwords by
password_hash() which internally uses bcrypt. Legacy MD5 hashes are
still supported and are immediately converted to the new format when a
user logs in.

Since big parts of the authentication system needed to be rewritten in
this context, this patch also includes some simplification and
refactoring of all code related to password checking and resetting.

Fixes FS#52297.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-24 22:04:49 +01:00
Lukas Fleischer
31754909b1 Fix user name in disown notifications
Do not overwrite the $uid variable when updating co-maintainers.

Fixes FS#52225.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-24 21:25:03 +01:00
Lukas Fleischer
b3fdd3f803 Add a parameter to skip old requests to pkgreq_list()
Allow for hiding requests which were opened before a given time stamp.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-15 07:13:01 +01:00
Michael Straube
f4176a8ce1 Make aurjson error messages consistent
All error messages in aurjson except two end with a period. Add the
missing periods to make the messages consistent.

Signed-off-by: Michael Straube <straubem@gmx.de>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-14 20:41:50 +01:00
Janne Heß
9df1bd5fe2 Add direct links to each source file
Currently, each source file which is an external link (http://,
https://, ...) is a clickable link.

This commit extends the behaviour by making files from the repository
clickable as well. The link brings the user to the corresponding cgit
page.

Also, the link to the PKGBUILD is altered to make the configuration more
consistent.

Signed-off-by: Janne Heß <jannehess@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-12 17:53:13 +01:00
Lukas Fleischer
ff8eb62a75 Add an option to filter by user to pkgreq_list()
When a user is specified, the function only returns package requests
which are either opened by the given user or affecting packages
maintained by the given user.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-08 19:18:27 +01:00
Lukas Fleischer
880d25e98c Allow to search for both maintainer and co-maintainer
As a follow-up to commit 6cb8c04 (Implement co-maintainer search,
2017-01-26), add an option to search for both maintainers and
co-maintainers at the same time.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-08 19:18:27 +01:00
Lukas Fleischer
1613bd2f29 confparser.inc.php: Support alternative config path
Add a AUR_CONFIG environment variable that can be used to specify an
alternative configuration file, similar to the feature introduced in
ecbf32f (git-interface: Add AUR_CONFIG environment variable,
2016-08-03).

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-08 19:18:27 +01:00
Lukas Fleischer
555cdac2db Return the number of results in pkg_search_page()
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-08 19:18:26 +01:00
Lukas Fleischer
3b4c6e72a9 Refactor pkg_search_page()
* Pass search parameters using an associative array instead of $_GET.
* Add a boolean parameter to enable and disable headers/footers.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-04 00:36:17 +01:00