Commit Graph

8283 Commits

Author SHA1 Message Date
Ben Thorner
b04bb51971 Merge pull request #4090 from alphagov/limit-csv-file-size-177535141
Reject CSV / Spreadsheet files larger than 10Mb
2021-12-07 17:00:05 +00:00
Ben Thorner
1a4204fed1 Merge pull request #4086 from alphagov/small-spreadsheet-refactor-177535141
Small refactoring to the Spreadsheet class
2021-12-07 16:59:46 +00:00
Ben Thorner
0ce7f72b07 Reject CSV / Spreadsheet files larger than 10Mb
This is a quick additional check to protect the user:

- From getting a CloudFront 502 error if the file takes too
long to upload. I was surprised to find it takes about 1 minute
to upload a 70Mb file to S3.*

- From getting a CloudFront 502 error when we follow the redirect
and run through the slow processing code in utils that builds a
RecipientCSV [1].

For context, a CSV with 100K rows and a few columns is around 5Mb,
so a 10Mb limit should be enough. Analysis over the past week shows
that the vast majority of CSV uploads are actually < 2.5Mb.

I haven't added any tests for this because:

- The check isn't critical, as the worst case scenario is the user
gets a worse error than this in-app one.

- There's no easy way to mock the validation, and I didn't want to
have a test that depends on a 10Mb+ file.

*We're using "key.put" to upload the file, when we could be doing
a multipart upload [2]. However, I tried this myself with a chunk
size of 1000 bytes and found it only led to a marginal improvement.

[1]: https://github.com/alphagov/notifications-utils/pull/930
[2]: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-uploading-files.html
2021-12-07 15:33:34 +00:00
David McDonald
925f86aa70 Merge pull request #4088 from alphagov/security-policy
Add security policy page
2021-12-07 15:29:33 +00:00
Chris Hill-Scott
b34a9f2c91 Merge pull request #4091 from alphagov/fix-combining-polygons-from-multiple-areas
Don’t combine polygons with different projections
2021-12-07 15:13:45 +00:00
Chris Hill-Scott
fb441e1f09 Merge pull request #4084 from alphagov/dont-confirm-password-service-name-change
Don’t force users to re-enter their password when renaming a service
2021-12-07 15:02:21 +00:00
David McDonald
fea5596234 Add security policy page
This follows the guidance in
https://gds-way.cloudapps.digital/standards/vulnerability-disclosure.html#vulnerability-disclosure-and-security-txt
2021-12-07 14:53:42 +00:00
Chris Hill-Scott
99a8a4fd48 Don’t combine polygons with different projections
When we combine simplified polygons from different areas we try to use
the polygons that are defined in metres as a speed optimisation.

This doesn’t work when those polygons are in several different
projections because the distance in metres is relative to the edge of
the projection. Just naively choosing one projection means that some
of the polygons will shift position on the earth by 100s of kilometers
once they are converted back to degrees.

To avoid this we need to:
- check for situations where we have polygons in multiple different
  projections
- transforms these polygons back into degrees and let `Polygons` pick a
  common projection for all of them before doing any
  merging/smoothing/etc.
2021-12-07 14:16:54 +00:00
Chris Hill-Scott
787cb3ef1f Merge pull request #3994 from alphagov/update-utils-coordinate-transformation
Update utils to bring in coordinate transformation
2021-12-07 11:07:07 +00:00
Ben Thorner
3c79675ba2 Remove unused properties in Spreadsheet class
These are no longer used anywhere. Note that pyexcel-xlsx is still
a necessary dependency: it acts as an implicit plugin to pyexcel
that, surprisingly, allows pyexcel to...read excel files [1].

[1]: https://github.com/pyexcel/pyexcel-xlsx#as-a-pyexcel-plugin
2021-12-03 17:25:17 +00:00
Ben Thorner
c0da7a27ed Fix not showing errors for invalid contact uploads
This code should behave the same way as other CSV uploads [1],
but we had to write it in a hurry [2] and the way we show an
error with the upload field was based off that for PDF uploads,
where we show custom button text instead of an error [3].

This fixes the inconsistency, so that we see the same errors
for CSV uploads here as in other parts of the app.

[1]: 6b52735dac/app/templates/views/send.html (L25)
[2]: 1c02476ee7 (diff-aedd12af78c9737f1c3344d2afbb9c00878eccbcc754b2b3d9e6864c2ad2f7c3R32)
[3]: 3b3f74bbf0
2021-12-01 16:59:30 +00:00
Chris Hill-Scott
1190e4541b Remove re-enter password step from rename service
The original idea behind was to always ask users to re-enter their
password any time:
- we want them to be sure that they want to do what they’re about to do
- we want to be sure it’s really the user trying to do the thing (and
  not someone malicious)

In reality we:
- removed this from the initial place it was added (a descendent of the
  ‘suspend service’ feature)
- only ever added it to the ‘rename service’ feature

So in reality it’s not a pattern we have persisted with. Arguably there
are several things you can now do in the admin app without re-entering
your password which are much more high consequence than changing the
service name.

Also, with browser autofill there’s a lot less chance that forcing
someone to re-enter a password really gives much defence against an
unatteneded laptop, for example.

I also wonder whether we might get people to give better service names
if we make the process of renaming the service less intimidating.

So this commit removes the need to re-enter your password when renaming
a service.

Note that re-naming an organisation still has the same check, but I
haven’t removed that too for the sake of keeping scope of the PR small.
2021-12-01 15:25:53 +00:00
Chris Hill-Scott
6a3aba3bc5 Store CRS to avoid costly lookup
Looking up the coordinate reference system for a given polygon’s bounds
is surprisingly expensive.

We can make things run faster by precomputing it at the time of
generating the simplified polygons, then storing it in the SQLite
database alongside the polygon data.
2021-12-01 14:10:55 +00:00
Chris Hill-Scott
0cf443e9a6 Use already-transformed polygons wherever possible
Transforming full resolution polygons to linear coordinates is somewhat
expensive. We can make things run faster by:
- looking at `simple_polygons` which have fewer points and are therefore
  faster to transform.
- reusing polygons that have already been transformed where possible
2021-12-01 14:10:55 +00:00
Chris Hill-Scott
6cb326f153 Update utils to do linear transformation of polygons
Brings in https://github.com/alphagov/notifications-utils/pull/889/files

At the moment, we are not doing any transformation of features before
applying geometric algorithms to them. This is, in effect, assuming that
the earth is flat.

This new version of utils implements the transformation of our polygons
to a Cartesian plane. In other words, it converts them from being
defined in spherical degrees to metres.

For the admin app this means we need to convert places where the code
expects things to be measured in degrees to work in metres instead.
2021-12-01 14:10:54 +00:00
karlchillmaid
6b52735dac Merge pull request #4076 from alphagov/update-roadmap
Update roadmap content
2021-12-01 09:55:58 +00:00
karlchillmaid
4010888571 small content change 2021-11-30 19:15:52 +00:00
karlchillmaid
00e97e166a Update content
Co-authored-by: Ben Thorner <benthorner@users.noreply.github.com>
2021-11-30 18:12:19 +00:00
karlchillmaid
89a86b04dd Add missing </a> tag
Co-authored-by: Ben Thorner <benthorner@users.noreply.github.com>
2021-11-30 18:12:07 +00:00
Chris Hill-Scott
b74fcf2570 Bump WTForms and Flask-WTF to latest versions
WTForms versions less than 3.0.0 have a security vulnerability where
arbitrary HTML can be inserted into the label of a form, allowing the
possibility of a cross-site scripting attack.

I don’t know if there’s anywhere we put user-generated content into form
labels but it’s possible we are vulnerable somewhere.

This require moving some imports because as of
https://github.com/wtforms/wtforms/pull/614/files
there is no longer a separate module for HTML 5 fields, they are now
considered core fields.

As of https://github.com/wtforms/wtforms/issues/445/files custom
implementations of `pre_validate` or `post_validate` must raise
`ValidationError` to trigger a validation message, where we were raising
`ValueError` this was no longer being caught.

As of https://github.com/wtforms/wtforms/pull/355/files `StringField`
returns `None` for empty data, not `''` but our `validate_email_address`
function only accepts strings.
2021-11-30 17:33:13 +00:00
karlchillmaid
cae17bac9d Fix date 2021-11-30 16:40:42 +00:00
karlchillmaid
9c935ef5b9 Add inset text html 2021-11-30 16:40:03 +00:00
karlchillmaid
8f82a8748c Add ID 2021-11-30 16:38:57 +00:00
karlchillmaid
4fa900eb26 Update figures 2021-11-30 15:45:10 +00:00
karlchillmaid
68e0327901 Update ‘things we’ve done’ 2021-11-30 13:54:29 +00:00
karlchillmaid
01cd97b639 Update the order of the things 2021-11-30 13:36:28 +00:00
karlchillmaid
0018ef79b4 fix paragraph formatting
Co-authored-by: Ben Thorner <benthorner@users.noreply.github.com>
2021-11-30 12:53:26 +00:00
karlchillmaid
9277adab48 Fix links
Swap dashes for underscores and add `main.`
2021-11-30 12:30:05 +00:00
karlchillmaid
47aaeaf05a update link 2021-11-30 12:23:35 +00:00
karlchillmaid
3c4dc1ef46 Update app/templates/views/roadmap.html
Co-authored-by: Ben Thorner <benthorner@users.noreply.github.com>
2021-11-30 12:22:22 +00:00
karlchillmaid
0c7c7d16de Add ‘What we’ve done’ section 2021-11-30 09:03:58 +00:00
Chris Hill-Scott
c9767fc179 Remove free text allowance column from org report
We think that the API is returning incorrect data for this column.

It’s going to take a while to figure out what’s going on with the
queries in the API, so this pull request temporarily removes the column
so we’ve not giving people incorrect data.
2021-11-25 18:08:31 +00:00
David McDonald
64515555a8 Merge pull request #4079 from alphagov/2dp-performance-page
Change performance stats to be 2 decimal places
2021-11-25 16:12:11 +00:00
David McDonald
30330d86b1 Change performance stats to be 2 decimal places
We are starting to see lots of 100.0%s in the current table
and we think this looks suspiciously too good so think it is
beneficial to change it to be 2dp such that we get a few more
non 100.0% values.

This will put all the values in to having 2dp, however it will
also require the API to have a change to
https://github.com/alphagov/notifications-api/blob/master/app/performance_dashboard/rest.py#L81
where it is currently losing the granularity down to a single
decimal place (meaning that if we were really at 99.894% then that
would be shown on the page as 99.90% rather than 99.89%). However,
I don't think it is a blocker that we get that sorted before this
can be merged.
2021-11-25 14:49:38 +00:00
Chris Hill-Scott
adcd1d3e3e Merge pull request #4075 from alphagov/change-send-button-content
Update ‘Send’ button content
2021-11-25 14:42:29 +00:00
Chris Hill-Scott
5c33fbd48a Format monetary values to two decimal places
This means that the data in the report will match what’s on the page,
where the values are rounded to the nearest penny.

This uses the same string formatting to round the numbers which the
`big_number` component does, so it should round the numbers in the same
way.
2021-11-25 10:34:18 +00:00
Chris Hill-Scott
0eb967bb7c Refactor into list expression
This is maybe a bit of personal preference but generally I find list
expressions a bit more Pythonic that `append`-ing.
2021-11-25 10:30:23 +00:00
Chris Hill-Scott
0e13cda9e5 Split out unit and monetary columns
This is so we can treat them slightly differently later on.
2021-11-25 10:30:05 +00:00
karlchillmaid
77991b5893 Update roadmap content 2021-11-24 16:15:02 +00:00
karlchillmaid
90a959463f Update ‘Send’ button content 2021-11-24 15:10:21 +00:00
Pea Tyczynska
ded7fa524f Merge pull request #4071 from alphagov/downloadable-org-use-report
Add downloadable report for org usage
2021-11-23 11:10:53 +00:00
Pea Tyczynska
47e303b8c3 Add downloadable report for org usage
This is so org level users can use this data easier for things
like determining spending per service.

We do not include sms fragments sent column and remove other sms columns

consistency.

Do not add sms fragments sent column for now until we agree on an
unambiguous name for it. The data in this column is sms billing units
multiplied by international sms weighing. My favourite for a clear
name would be 'text message credits used', but we need a naming
strategy for this.
2021-11-23 10:57:48 +00:00
Tom Byers
2e53a2b6f8 Add GOVUK visually hidden style for map key
The sentences in the key to the map have 2 forms:
1. the visual form, with an graphic pattern
   alongside text saying what the pattern means
   in the map
2. the semantic form, with text describing what
   the pattern means and how big an area it covers
   for this alert

This is achieved by making the graphic
non-semantic and having hidden words in the
sentence for each paragraph.

While the spaces between words are correct for
both forms of these sentences, we observed screen
readers speaking some groups of words as one when
they spoke the sentence. Most noticably, 'the
alert' was spoken as 'thealert'.

Swapping the class used to hide the visually
hidden words from ours to the GOVUK one seemed to
fix this. It's unclear why it does but the
`govuk-visually-hidden` class adds the following
styles to those in ours:
- width: 1px
- height: 1px
- white-space: nowrap

It also has `margin: 0` instead of `margin: -1px`.
2021-11-18 11:40:37 +00:00
Tom Byers
bc22c206b9 Make images in key of map SVGs
At the moment, the icons in the key of the map
showing what each type of area drawn on the map
means change colour in high contrast mode. This
causes a mismatch between the areas on the map and
the key.

These changes remake the images in SVG to prevent
the colours changing in high contrast modes. They
also add a white background to the icons, to make
sure they match the areas they refer to in the
map.
2021-11-18 11:40:36 +00:00
Tom Byers
c82b78941e Merge pull request #4067 from alphagov/high-contrast-issues-alerts-pages
High contrast issues alerts pages
2021-11-18 11:39:27 +00:00
Pea Tyczynska
00a629befc Link to downloadable report for org usage
Link is sticky so that it is easy to spot even when
an org has many services.
2021-11-17 17:58:06 +00:00
Chris Hill-Scott
223b275507 Merge pull request #4010 from alphagov/refactor-duplicate-method
Refactor `get_simple_polygons` method for reuse
2021-11-15 11:21:50 +00:00
Chris Hill-Scott
47797cf686 Merge pull request #4034 from alphagov/refactor-services-models
Refactor services and organisations models for users
2021-11-15 11:21:43 +00:00
Chris Hill-Scott
0c2b586e40 Make organisations natively sortable 2021-11-11 14:59:06 +00:00
Chris Hill-Scott
18dfc44899 Sort services on user information page
Since the model doesn’t sort automatically we need to do this in the
presentation layer now.
2021-11-11 14:23:07 +00:00