1017 Commits

Author SHA1 Message Date
Deimos
d3a84fe411 Fix issue if "most recent comment" not found
Not sure exactly how this can happen, but I've seen a few errors caused
by this.
2020-09-09 16:41:41 -06:00
Bauke
2d023cd659 Use CSS custom properties for theming 2020-09-08 19:27:35 -06:00
Deimos
68870119f4 Remove remnants of Redis breached-passwords check
We've been using pts_lbsearch on the text file for a few weeks now, and
it's working fine. Checks generally seem to take about 10 ms, and that's
totally fine for the relatively uncommon events of registrations and
password changes.

This removes everything related to the previous Redis-based method,
which means we no longer need the second Redis server or the ReBloom
module.
2020-09-06 18:32:10 -06:00
Deimos
624123929a Exclude removed comments from "last comment" link
The "last comment posted" link in the sidebar on a topic's comments page
was still considering removed comments, so if the last comment in a
topic was removed it would link to that one. That's not very useful for
anyone, so this excludes removed comments the same way that deleted ones
were already excluded.
2020-09-03 15:16:21 -06:00
Deimos
26b1d4dd9b Use pts_lbsearch to check for breached passwords
This replaces the current method of using a Bloom filter in Redis to
check for breached passwords with searching the text file directly using
pts_lbsearch (https://github.com/pts/pts-line-bisect/).

I'm not removing the Redis-based method yet because I want to test the
performance of this first, but this is *far* simpler and doesn't have
the possibility for false positives like the Bloom filter does.
2020-08-11 18:27:16 -06:00
Deimos
a70cc61499 Add metric to breached-password check 2020-08-10 13:16:04 -06:00
Deimos
d61b848816 Fix bug with trying to unnest non-webargs errors
When a ValidationError comes up for a reason unrelated to webargs (for
example, if a user tries to set a password that's in the breached list),
this crashes when trying to unnest it, since it doesn't have the extra
level that webargs adds.

This is a bit ugly, but checks to see whether the extra level is there
first.
2020-08-10 12:52:10 -06:00
Deimos
2e5a2d96bf Switch user permissions to use an enum
Previously, there wasn't any defined list of which permissions were
valid or not. You basically had to look through each model's __acl__
method to see what the possibilities were.

Using an enum will be less convenient when adding new permissions or
changing existing ones (since it will require a database migration), but
it makes it much easier to see what the valid options are, and will
prevent invalid permissions from being set up in the database.
2020-08-05 16:34:22 -06:00
Deimos
a46283436d Rename "post_topic" permission to "topic.post"
This permission was a strange exception, with every other permission
being of a format like "topic.lock", "comment.remove", and so on.
2020-08-04 18:29:17 -06:00
Deimos
036d46d589 Add marks to slower tests and don't run by default
This uses pytest's "markers" system to add markers to two special types
of tests:

* webtest - ones that use the WebTest library and are testing the actual
  HTTP app, instead of executing code/functions directly
* html_validation - ones that are generating HTML output (via webtest)
  and running it through the Nu HTML Checker to validate it.

The "webtest" marker is added automatically by checking whether a test
uses either of the webtest fixtures, and the html_validation one is
currently added manually to the only module that has those tests. In the
future, we could probably put HTML validation tests in their own folder
and mark them automatically based on the module's path or something
similar.

This also changes the default arguments for pytest to exclude these two
marked types of tests, and updates the git hooks so that webtests are
run pre-commit (but not HTML validation), and all tests are run
pre-push. Similar to the way we use prospector, this makes it so that
the very slow tests are only run before pushing.
2020-08-03 14:37:08 -06:00
Andrew Shu
87dce83f26 Install html5validator, validate HTML in tests
Installs the Nu Html Checker and starts using it to validate the home
page's HTML: https://validator.github.io/validator/

Also includes fixes to some lists that were nested in an invalid way.
2020-08-02 19:16:52 -06:00
Andrew Shu
9ff86bedb7 Fix HTML- and URL-encoding bugs on homepage 2020-08-02 14:42:56 -06:00
Deimos
3026d066d3 Set function scope for logged-out webtest fixture
I mistakenly assumed that not setting the cookiejar argument when
creating a webtest TestApp would mean that no cookies would be retained
between requests, but that's wrong. If you don't pass a cookiejar, it
just automatically creates one for you. Because of this, logged-out
webtests would end up being logged-in after any test logged in.

This reduces the webtest_loggedout fixture's scope to function-level so
that it will be re-initiated on every test instead. It also stops
passing a cookiejar for the logged-in webtest, since that's unnecessary.
2020-08-02 14:29:36 -06:00
Deimos
6f272fcd54 Revert "Build HTML Tidy, validate homepage HTML in tests"
This reverts commit cb7be83877.

HTML Tidy seems to have various gaps in its validation that we've found
already, including one that's pretty much a deal-breaker for Tildes's
HTML: it doesn't think that <menu> is a valid parent for <li>.

We're looking at alternative validators still.
2020-08-02 14:20:37 -06:00
Andrew Shu
cb7be83877 Build HTML Tidy, validate homepage HTML in tests
Adds the HTML Tidy library to the dev version, along with the pytidylib
wrapper for it, and a couple of tests that use it to validate the HTML
of the home page.

Includes a fix to the GitLab "Planned features" link that Tidy considers
invalid because it includes some un-encoded characters.
2020-08-01 14:20:57 -06:00
Deimos
f41bd1eabe Upgrade webargs to 6.1.0
This was not a fun upgrade. webargs made some major changes to its
approaches in 6.0, which are mostly covered here:
https://webargs.readthedocs.io/en/latest/upgrading.html

To keep using it on Tildes, this commit had to make the following
changes:

  - Write my own wrapper for use_kwargs that changes some of the default
    behavior. Specifically, we want the location that data is being
    loaded from to default to "query" (the query string) instead of
    webargs' default of "json". We also needed to set the "unknown"
    behavior on every schema to "exclude" so that the schemas would
    ignore any data fields they didn't need, since the default behavior
    is to throw an error, which happens almost everywhere because of
    Intercooler variables and/or multiple use_kwargs calls for different
    subsets of the data.

  - All @pre_load hooks in schemas needed to be rewritten so that they
    weren't modifying data in-place (copy to a new data dict first).
    Because webargs is now passing all data through all schemas,
    modifying in-place could result in an earlier schema modifying data
    that would then be passed in modified form to the later ones.
    Specifically, this caused an issue with tags on posting a new topic,
    where we just wanted to treat the tags as a string, but TopicSchema
    would convert it to a list in @pre_load.

  - use_kwargs on every endpoint using non-query data needed to be
    updated to support the new single-location approach, either replacing
    an existing locations= with location=, or adding location="form",
    since form data was no longer used by default.

  - The code that parsed the errors returned by webargs/Marshmallow
    ValidationErrors needed to update to handle the additional "level"
    in the dict of errors, where errors are now split out by location
    and then field, instead of only by field.

  - A few other minor updates, like always passing a schema object
    instead of a class, and never passing a callable (mostly just for
    simplicity in the wrapper).
2020-07-31 12:13:23 -06:00
Deimos
44a8699605 Upgrade prospector to 1.3.0
I thought this would be a larger task due to so many of the tools
updating to new versions, but the only thing necessary for this upgrade
was updating the name of one of the disabled pylint errors.
2020-07-29 17:11:46 -06:00
Deimos
5c70d8c980 Update pypi package versions (requirements.txt)
I temporarily pinned two packages that will require more significant
updates (webargs in requirements and prospector in requirements-dev).
Other than those, everything seemed to upgrade cleanly, except for an
issue with mypy that needed a "type: ignore" comment to circumvent.

Note that there is currently an issue with Salt's pip module being
unable to handle comments in a requirements file that include "-r", so I
had to manually edit the two .txt files after using pip-tools to remove
all lines with "via -r" comments in them. I've commented about this in
an issue on Salt's repo here:
https://github.com/saltstack/salt/issues/56514#issuecomment-665947887
2020-07-29 16:54:03 -06:00
Deimos
25656152a5 Vagrantfile: un-pin Salt version
Salt version 3000 (3000.3 specifically) seems to be working fine now, so
it should be safe to stop forcing the old version.
2020-07-27 17:19:05 -06:00
Deimos
c31c47d6b1 Restrict link topic repost check to last 6 months
Previously, when checking if a link had been posted before, there was no
restriction on the time limit, so even posts from years ago would come
up. This restricts it to only the last 6 months, which I think is a
pretty reasonable time period for reposting.
2020-07-24 19:29:20 -06:00
Deimos
6f1377fe0d Fix error from trying to log into no-password user
I think someone tried to log into the special internal account named
"Tildes", which isn't possible (since it has no password), but caused a
crash.
2020-07-24 18:12:04 -06:00
Deimos
9a82f2c640 Fix error with filtered topic tag including space
This isn't great, but will fix an error that's actively occurring when
someone filters to a single tag (tag= query var) and also has a filtered
topic tag with a space in it.
2020-07-24 14:10:51 -06:00
Deimos
3ada432a1a Stop fixing old Solarized theme cookies
This was done for over 10 months now, there shouldn't really be any old
ones left to fix at this point.
2020-07-24 13:55:09 -06:00
Deimos
a1e3052767 Add tildee.py to bot user agents 2020-07-24 13:21:42 -06:00
Deimos
a93c466614 Add specific error for invalid char in tag/group 2020-07-24 13:11:02 -06:00
Andrew Shu
6fa7718e06 Apply topic tag filters when viewing a single tag
Includes HTML updates to let user click into unfiltered view, when
viewing a single tag.
2020-07-22 19:41:32 -06:00
Deimos
e84c90533b Use "outer" sizes for checking dropdown overflow
The "outer" width/height functions also include padding and border. Not
including these didn't make a noticeable difference for the left/right
flipping (the omissions almost canceled each other out), but the
discrepancy is much more noticeable on the top/bottom flipping.
2020-07-21 16:06:36 -06:00
Andrew Shu
ca38cd67fd Push dropdown up if it's off bottom of screen/site
Use bottom: 100% to make sure the menu does not overlap the
button (as with bottom: 0). If it overlaps the button then
that interferes with the button click handler.
2020-07-21 15:40:39 -06:00
Andrew Shu
33f551fb21 Remove period chars from search query for multilevel tags
Tags are stored in the search index as space-separated strings
with the periods removed. Searches for "parent.child" tags
were failing because of the period.

Removing period is okay for now because URL domains are not
currently indexed for search.
2020-07-20 19:18:19 -06:00
Deimos
9531221b88 Salt: don't attempt to set mode on site-icons.css
Trying to change the mode of this file (which often already exists)
fails on Windows. It seems fine to just not set it and let it be set to
the default.
2020-07-20 14:56:14 -06:00
Deimos
6092a37946 Add yacybot to list of bot user agents 2020-07-17 12:07:43 -06:00
Andrew Shu
eaa7a0a34b Include "inner" subpath tags when tag filtering 2020-07-15 00:14:06 -07:00
Andrew Shu
bac168bb08 Clear previous error message on markdown preview 2020-07-14 16:03:06 -07:00
Deimos
a9d312d152 Remove welcome message sent on registration
This message is getting pretty outdated now, and should probably be done
in a different way regardless so that it doesn't need to be in the code,
especially since forks won't want the same message (or any message).

A better approach would probably be a consumer or cronjob watching for
new registrations in the event stream.
2020-07-14 15:09:51 -06:00
Andrew Shu
cf3e777fd8 Add bottom padding to topic full text
Prevents scrollbar from showing up when there is a
subscript on the last line of text.

Another option would have been overflow-y: hidden,
but that clips the text in the (pathological?) case
of deeply nested subscripts.
2020-07-12 15:59:51 -06:00
Andrew Shu
ac8e43876d Show (OP) in Topic Log changes 2020-07-12 15:53:49 -06:00
Deimos
e85dfa2492 Salt: ensure that the site-icons.css file exists
The generate_site_icons_css cronjob will create this file, but the site
won't work before it exists, so there's a (less than 5 min) gap where
the site is broken when first set up. This probably won't be noticeable
in dev/prod setups, but breaks things like CI setups where everything is
getting created freshly each time.

This makes sure that the file always exists on initial setup and
whenever the Salt states are re-run.
2020-07-12 14:33:15 -06:00
Andrew Shu
c330811fc9 Vagrantfile: relax Salt pinned version to 2019.2
Fixes provisioning of a new VM.

Old versions like 2019.2.3 may be moved to an archive
and get an HTTP 404 error.
Relaxing the pinned version allows setup to find
newer patches, such as 2019.2.5.

More info:
752768b1ff/accepted/0022-old-releases.md
2020-07-09 23:43:33 -07:00
Ry Jones
f8aa1f0a03 Fix link to boards view
Signed-off-by: Ry Jones <ry@linux.com>
2020-07-08 18:17:00 -07:00
Deimos
5b1addab9f Hide old-scheduled-topic message if not logged in 2020-07-06 17:03:34 -06:00
Deimos
080aadb131 Add backfill for topic_schedule.latest_topic_id
I doubt the absence of this would have ever been noticed or that adding
this will ever matter for anyone, but I might as well do it properly!
2020-07-06 15:51:29 -06:00
Deimos
c4af5c7d57 Prevent top-level comments in old scheduled topics
By default, new top-level comments will only be allowed in the latest
topic from a particular set of scheduled topics. Replies to existing
comments in old topics will still be allowed - this is just intended to
prevent the cases where an old scheduled topic gets bumped back up due
to a reply and people inadvertently start adding new top-level comments
to it instead of the latest one.

This should be the correct behavior for most scheduled topics, but it
can be disabled for a particular schedule if needed.
2020-07-06 13:52:32 -06:00
Deimos
a451b7fb03 Track latest topic for each schedule
This adds a new latest_topic_id column to topic_schedule and uses
triggers on the topics table to keep it correct.

This isn't really ideal, but it will simplify a few things related to
scheduled topics by quite a bit. For example, this commit also uses that
new data to much more easily populate the list of scheduled topics in a
group's sidebar, which previously required a subquery and windowing.
2020-07-05 13:26:26 -06:00
Deimos
96aaf50b04 Remove comment back-and-forth delay
I think overall this is triggering more than I want, and getting in the
way of perfectly reasonable conversations. I like the idea still, but
needs adjusting.
2020-06-19 13:26:56 -06:00
Deimos
a66e16d6c7 Remove specialized coronavirus views
Coronavirus topics have slowed down greatly now, with generally only
about 3 per day, and are almost all restricted to ~health.coronavirus,
so users can easily find (or avoid) them by just using that group.
2020-06-17 18:37:24 -06:00
Deimos
59b0f24e7b Add metric for back-and-forth warnings 2020-06-16 15:04:30 -06:00
Deimos
60f47cc3f2 Replace "whitelist" terminology 2020-06-16 14:42:18 -06:00
Deimos
15ced1a750 Add a delay to comment back-and-forths 2020-06-16 14:04:48 -06:00
Deimos
6227f747c1 Use intercooler for comment reply form
Previously, the comment reply form was being created entirely
client-side by cloning and modifying a <template>. This was nice because
it meant that a network request wasn't necessary to display the form,
but it also had downsides.

For example, if a topic was locked after a user had already loaded the
page (or their notifications page with a comment from that topic), they
would still be able to click Reply and type in a comment, and wouldn't
know that replying wasn't possible until they actually tried to submit
the comment.

By switching to using intercooler for this form, we can do server-side
validation to check permissions before showing the form, and it also
simplifies some other aspects, such as the warning about replying to an
old comment, which previously needed a data-js-old-warning-age attribute
in the HTML, but is now just part of generating the reply form template
server-side.
2020-06-15 19:10:09 -06:00
Deimos
e15359919d Prioritize showing comment removal over deletion
If a comment is removed and then deleted by its author, we should
continue showing it as removed, since that's the more significant action
(and the deletion is usually *because* of the removal).
2020-06-02 12:50:40 -06:00