-
Notifications
You must be signed in to change notification settings - Fork 695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic message filtering in the SI #6306
Conversation
Do we also want to use |
6026689
to
2a37036
Compare
Yep, that'd be a nice addition. |
0955939
to
0c5db78
Compare
Looking at that minlength addition with @eaon, it occurred to me that it would prevent initial submissions with a file attachment but no message (which are currently allowed). So, in the absence of client-side logic to allow for that case I think we can't include it except for the edge case upon an edge case of message-only configs. Length checks will be server-side only. |
fc0c7a5
to
2fea4d7
Compare
This pull request fixes 2 alerts when merging 2fea4d7 into 2236d3d - view on LGTM.com fixed alerts:
|
2fea4d7
to
82a76ca
Compare
This pull request fixes 2 alerts when merging 82a76ca into 2236d3d - view on LGTM.com fixed alerts:
|
82a76ca
to
6b31fd7
Compare
This pull request fixes 2 alerts when merging 6b31fd7 into 2236d3d - view on LGTM.com fixed alerts:
|
Codecov Report
@@ Coverage Diff @@
## develop #6306 +/- ##
===========================================
- Coverage 84.03% 83.76% -0.27%
===========================================
Files 60 61 +1
Lines 4227 4293 +66
Branches 511 521 +10
===========================================
+ Hits 3552 3596 +44
- Misses 552 571 +19
- Partials 123 126 +3
Continue to review full report at Codecov.
|
All seems doable, had planned to restrict that length field size via CSS, could probably just add an attribute directly as well. I'm thinking that the extra para in the SI about message lengths might be what's pushing the flash error out of viewport - for neatness sake I was already thinking of moving that into the placeholder text in the textarea instead. Will push up something tomorrow. |
@eloquence a revision with some UX-related changes addressing your points above is working its way thru CI. Note that it does not update the placeholder text in the submission textarea as I mentioned above - instead the same design language/placement as is currently used for file size limits was applied. |
This pull request fixes 2 alerts when merging 2939066 into 8e61004 - view on LGTM.com fixed alerts:
|
2939066
to
e170d3d
Compare
This pull request fixes 2 alerts when merging e170d3d into 8e61004 - view on LGTM.com fixed alerts:
|
bd93db1
to
940edf5
Compare
This pull request fixes 2 alerts when merging 940edf5 into 8e61004 - view on LGTM.com fixed alerts:
|
940edf5
to
75f4aad
Compare
This pull request fixes 2 alerts when merging 75f4aad into 8e61004 - view on LGTM.com fixed alerts:
|
75f4aad
to
e5a565c
Compare
@eloquence further tweaks applied. |
This pull request fixes 2 alerts when merging e5a565c into 842bfb8 - view on LGTM.com fixed alerts:
|
Regarding |
9e8e6f7
to
e7c1d7e
Compare
This pull request fixes 2 alerts when merging e7c1d7e into be16809 - view on LGTM.com fixed alerts:
|
Test plan all checks out (and pointed out a gap in the tests I wrote)! |
(for whoever ends up merging, this can probably be rebased into a single commit first) |
securedrop/source_app/main.py
Outdated
flash(gettext( | ||
"Your first message must be at least {} characters long.".format(min_len)), | ||
"error") | ||
return redirect(f"{url_for('main.lookup')}#flashed") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per #6336 I think we'll want to now redirect without the #flashed fragment.
securedrop/source_app/main.py
Outdated
escape(gettext("Keep your codename secret, and use it to log in later" | ||
" to check for replies.")) | ||
)), "error") | ||
return redirect(f"{url_for('main.lookup')}#flashed") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
I've pushed up a branch rebased to |
I'm assuming Kev had nothing left locally, so I'm going to cherry-pick 540a693 over to this branch, push, then squash+rebase it all and push again. |
This pull request fixes 2 alerts when merging a2ee4ef into 970aab5 - view on LGTM.com fixed alerts:
|
a2ee4ef
to
500531d
Compare
This pull request fixes 2 alerts when merging 500531d into 970aab5 - view on LGTM.com fixed alerts:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're set to land this but I'd like someone else to confirm that they reviewed the test cases I wrote (so I'm not merging them without review), and double check my squash and commit message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed test cases and rebase/squash at @legoktm's request. All looks good to me except for the following nit about the commit message on the squashed 500531d:
When trying to do the schema change for the InstanceConfig table, it was
discovered that SQLAlchemy/Alembic don't support the partial index on
the table, so it's dropped and the valid_until column is now
nullable=False. The current/active config is represented by a
valid_until of the unix epoch (0).
On first reading, if one isn't already familiar with this problem, it might be unclear whether the clause beginning "so it's dropped" describes (a) SQLAlchemy's behavior in not supporting the partial index prior to this commit or (b) the fix made by this commit. Up to you, @legoktm, whether it's worth revising, but since the commit (once merged) is the immutable thing here I thought I'd mention it. :-)
- Updated instance_config table, removing partial index on valid_until field that was used to force NULL values to be unique, and using unix epoch start as the valid_until value for the active configuration instead. (Partial indexes are not fully supported by the Alembic version currently in use.) - Added optional message filtering: - A minimum length can now be set for a source's initial message. Messages shorter than this length are rejected with an error in the SI. This feature is managed via the Admin interface and is disabled by default. - Initial messages can now be rejected if their content matches the source's codename. This feature is managed via the Admin interface and is disabled by default. Fixes #6297. Fixes #6298.
500531d
to
fb36b50
Compare
Agreed, reworded. |
This pull request fixes 2 alerts when merging fb36b50 into 970aab5 - view on LGTM.com fixed alerts:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-blessing for merge after requested changes were made. 😎
Status
Work in progress (tests required)
Description of Changes
Fixes #6297.
Fixes #6298.
adds options in the JI instance config, and in the SI, to:
Testing
make dev
minimum message length
codename messages
Deployment
DB migration script required, but new functionality is disabled by default.
Checklist
If you made changes to the server application code:
make lint
) and tests (make test
) pass in the development containerIf you made non-trivial code changes:
Choose one of the following: