Commit graph

13783 commits

Author SHA1 Message Date
faul_sname
b06a481a0f [themotte/rDrama#451] Ability to disable secure session cookie with env var 2022-12-31 02:18:56 -08:00
faul_sname
8b7e637e6e [themotte/rDrama#451] The basic post/comment test should not fail no matter what env says 2022-12-31 02:07:18 -08:00
faul_sname
6905710b18 [themotte/rDrama#451] Sometimes we also want the user, not just their session 2022-12-31 02:06:42 -08:00
faul_sname
f78345a4fb [themotte/rDrama#451] Decorator when we do not want to rate limit in tests 2022-12-31 02:06:17 -08:00
faul_sname
0dcca12c04 [themotte/rDrama#451] New fixture for comments 2022-12-31 02:05:22 -08:00
faul_sname
4bfb66272c [themotte/rDrama#451] New fixture for submissions 2022-12-31 02:05:02 -08:00
faul_sname
9468e217f0 [themotte/rDrama#451] Allow explicitly setting the scheme to http or https in env 2022-12-30 23:39:46 -08:00
faul_sname
4010a0e752 [themotte/rDrama#451] Remove the import *
Fixes a bug if someone is serving localhost on a port that is not port 80
2022-12-30 20:25:57 -08:00
Ben Rog-Wilhelm
f4c6c7cf91 Fix: Deleted comments show up in the Janitor Volunter system. 2022-12-30 01:44:16 -06:00
Ben Rog-Wilhelm
fe800dd9a5 Add a grandchild comment test. 2022-12-28 09:14:33 -06:00
Ben Rog-Wilhelm
fb77cbcc2b Fix: Post view count does not update properly. 2022-12-22 20:09:57 -06:00
Ben Rog-Wilhelm
0454a64020 Fix: Janitor rule page incorrectly links to localhost. 2022-12-18 12:53:01 -08:00
Ben Rog-Wilhelm
90d4bd2b3c
Enable Janitor feature by default. (#448)
Co-authored-by: Ben Rog-Wilhelm <zorba@pavlovian.net>
2022-12-18 09:29:21 -06:00
Ben Rog-Wilhelm
e257db1542
Refactor test system to be more extendable, add comment test 2022-12-17 19:41:35 -06:00
Ben Rog-Wilhelm
b4efd75753 Merge branch 'frost' into pr-eager-content 2022-12-17 17:17:32 -06:00
justcool393
3f2e8629df ratelimiting: check after required request g attributes are set 2022-12-17 09:21:40 -08:00
justcool393
1ae3dc85c2
Fix: Redirect loop on formkey or nonce mismatch.
* fix 401-302-401-302-429 loop

* don't logout users on bad form key, just treat the request as unauthenticated

* Handle None/empty case in validate_formkey.

A supplied empty formkey, or the lack of a supplied formkey (None) is not a valid formkey. Handle this inside the function rather than at the call-site.

* Validate as false if no hashstr or string

Co-authored-by: Snakes <104547575+TLSM@users.noreply.github.com>
2022-12-17 11:20:27 -06:00
justcool393
a213396854
Solve blocking weaponization.
* allow anyone to reply to their blockers

* revert userblocks thing

* get rid of unnecessary template

* make blocking page accurate

* comment author things

* fix prev commit

* fix block page

* comma splice

Co-authored-by: Snakes <104547575+TLSM@users.noreply.github.com>
2022-12-17 11:11:51 -06:00
Ben Rog-Wilhelm
af31abd545 Fix: Volunteer config not parsed properly. 2022-12-05 00:49:34 -08:00
Ben Rog-Wilhelm
b7a8297669 Improve error output for util function. 2022-12-05 00:49:19 -08:00
justcool393
0c632d73b7
Rework error system a bit to remove a bunch of duplicated code (#434) 2022-12-01 20:58:27 -06:00
Ben Rog-Wilhelm
08602b4279 Volunteer Janitor: Minor cleanups. 2022-12-01 18:53:24 -08:00
Ben Rog-Wilhelm
8fd9177711 Volunteer Janitor: Minor phrasing tweak. 2022-12-01 18:53:24 -08:00
Ben Rog-Wilhelm
5fef5ca908 Volunteer Janitor: Add global enable/disable. 2022-12-01 18:53:24 -08:00
Ben Rog-Wilhelm
0f74f6a4e2 Volunteer Janitor: Warn on page exit. 2022-12-01 18:53:24 -08:00
Ben Rog-Wilhelm
f02ab5d27b Volunteer Janitor: Visual design for Work page. 2022-12-01 18:53:24 -08:00
Ben Rog-Wilhelm
e75634f40a Volunteer Janitor: Visual design for Submit page. 2022-12-01 18:53:24 -08:00
Ben Rog-Wilhelm
78cced0c37 Volunteer Janitor: Visual design for Teaser page. 2022-12-01 18:53:24 -08:00
Ben Rog-Wilhelm
b80fe29545 Volunteer Janitor: Initial checkin of images. 2022-12-01 18:53:24 -08:00
Ben Rog-Wilhelm
0f91324603 Volunteer Janitor: Response recording. 2022-12-01 18:53:24 -08:00
Ben Rog-Wilhelm
0a8bbae290 Volunteer Janitor: Record accepted tasks. 2022-12-01 18:53:24 -08:00
Ben Rog-Wilhelm
03b323c7a1 Volunteer Janitor: Initial duty acquisition. 2022-12-01 18:53:24 -08:00
Ben Rog-Wilhelm
e43db0535d Volunteer Janitor: Initial hooks. 2022-12-01 18:53:24 -08:00
TLSM
afe209d5d8
Eager load comments for post rendering.
GET /post/1/clever-unique-post-title-number-0
|----------|--------|--------|--------|--------|--------|------------|
| Database | SELECT | INSERT | UPDATE | DELETE | Totals | Duplicates |
|----------|--------|--------|--------|--------|--------|------------|
| default  |  942   |   0    |   1    |   0    |  943   |    921     |
|----------|--------|--------|--------|--------|--------|------------|
Total queries: 943 in 0.377s # request time in browser 17249ms

GET /post/1/clever-unique-post-title-number-0
|----------|--------|--------|--------|--------|--------|------------|
| Database | SELECT | INSERT | UPDATE | DELETE | Totals | Duplicates |
|----------|--------|--------|--------|--------|--------|------------|
| default  |   58   |   0    |   1    |   0    |   59   |     35     |
|----------|--------|--------|--------|--------|--------|------------|
Total queries: 59 in 0.0423s # request time in browser 544ms

Also, fixes seed_db not populating top_comment_id on generated
comments. If you want to test locally with seed_db test data, you need
to reseed.
2022-11-28 17:47:54 -05:00
TLSM
5aaef144cf
Deduplicate post/comment sorting & time filtering.
Ported in from upstream with adjustments for TheMotte, most notably
universal default to 'new' and fixes to 'hot'. Lumped into this PR
because eager comment loading uses it.
2022-11-28 14:33:24 -05:00
TLSM
4d22d9bce2
Eager load get_posts for submission_listings.
Ported in logic from upstream to use SQLAlchemy eager loading instead
of repeated queries when building a submission_listing. Adjusted
loaded relationships to include only those used on TheMotte.

Using test data from seed_db, before and after:

GET /
|----------|--------|--------|--------|--------|--------|------------|
| Database | SELECT | INSERT | UPDATE | DELETE | Totals | Duplicates |
|----------|--------|--------|--------|--------|--------|------------|
| default  |   83   |   0    |   0    |   0    |   83   |     72     |
|----------|--------|--------|--------|--------|--------|------------|
Total queries: 83 in 0.031s

GET /
|----------|--------|--------|--------|--------|--------|------------|
| Database | SELECT | INSERT | UPDATE | DELETE | Totals | Duplicates |
|----------|--------|--------|--------|--------|--------|------------|
| default  |   14   |   0    |   0    |   0    |   14   |     0      |
|----------|--------|--------|--------|--------|--------|------------|
Total queries: 14 in 0.00718s
2022-11-28 12:55:31 -05:00
TLSM
9953c5763c
Port get.py improvements from upstream.
Generally standardizes the get_* helpers:
 - Adds type hinting.
 - Deduplicates block property addition.
 - Respects `graceful` in more contexts.
 - More resilient to invalid user input / less boilerplate necessary
   at call-sites.
2022-11-28 12:36:04 -05:00
justcool393
8a9e1bc54a
titles: use rdrama's title finding code (#425)
* titles: use rdrama's title finding code
this fixes a potential DoS in some really weird pages (seems to be a bug with BS4)
we're not parsing arbitrary HTML
in addition we make some nice checks

* unescape title to fix bug from upstream

* fix nameerror

* Do not proxy requests, since no proxy available.

On the upstream, the `proxies` dict was intended to use a local SOCKS
proxy running on port 18080 with the express purpose of masking the
server IP address. TheMotte isn't running behind a reverse proxy, so
this purpose is moot. Additionally, we don't have a proxy running in
Docker nor do we appear to have one on prod, which breaks autotitle
and thumbnailing regardless--not sure it matters for TheMotte's
use case, but both codepaths have been inoperative because of it.

* use gevent to timeout the function to prevent a
second theoretical DoS by sending data rly slowly
ref: 816389cf28

Co-authored-by: TLSM <duolsm@outlook.com>
2022-11-28 07:52:15 -08:00
Ben Rog-Wilhelm
c3f4b540d0 Disable file caching in debug mode. 2022-11-28 07:48:14 -08:00
justcool393
6b832aba99 admin: remove unused admin pages 2022-11-21 13:06:29 -06:00
justcool393
23e64d176d
discord: remove 2022-11-21 12:39:27 -06:00
Ben Rog-Wilhelm
7e25af2fa0 Fix: Changes to the User table cause unavoidable breakages in the Leaderboard system. 2022-11-21 10:09:17 -06:00
Ben Rog-Wilhelm
18437003cf Beef up the Production check a little and do true comparison correctly. 2022-11-21 09:43:07 -06:00
justcool393
2067875c6a themes: remove /r/Drama theme ("classic" and "classic_dark") 2022-11-21 06:13:12 -06:00
justcool393
86c0eea85a security: add ENFORCE_PRODUCTION
can provide a safety check so debug mode never gets enabled on production environments by accident
2022-11-21 06:11:03 -06:00
Ben Rog-Wilhelm
0db174b90b Fix: An unfortunately-placed linebreak. 2022-11-21 06:10:10 -06:00
justcool393
65fada8155 awards: remove grass 2022-11-19 10:21:30 -06:00
Ben Rog-Wilhelm
12881b02e2 Fix: Users with underscores in their name can't log in by underscore. 2022-11-13 18:20:24 -06:00
Ben Rog-Wilhelm
060e3967fd Minor tweak to usernote click handle. 2022-11-13 14:44:20 -06:00
Ben Rog-Wilhelm
dcf11531c1 Fix: One more spot with usernote leakage. 2022-11-13 14:38:23 -06:00