Граф коммитов

9289 Коммитов

Автор SHA1 Сообщение Дата
Ed Morley 5986749757
Bug 1530602 - Adjust Content-Security-Policy to fix ajv.compile() (#4703)
Unfortunately the "Custom Actions" usage of `ajv.compile()` requires that
the `script-src` CSP directive contain `'unsafe-eval'`, otherwise the
whole feature breaks.

Using `'unsafe-eval'` defeats much of the point of CSP, so it should be
removed as soon as possible. Bug 1530607 is filed to track.
2019-02-26 08:04:53 +00:00
Renovate Bot 0ab0fca646 Lock file maintenance 2019-02-25 15:41:18 -08:00
dependabot[bot] e752be8d71 Bump flake8 from 3.7.6 to 3.7.7 in /requirements
Bumps [flake8](https://gitlab.com/pycqa/flake8) from 3.7.6 to 3.7.7.
- [Release notes](https://gitlab.com/pycqa/flake8/tags)
- [Commits](https://gitlab.com/pycqa/flake8/compare/3.7.6...3.7.7)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-02-25 14:43:31 -08:00
dependabot[bot] 0ccc38bf4f Bump pluggy from 0.8.1 to 0.9.0 in /requirements
Bumps [pluggy](https://github.com/pytest-dev/pluggy) from 0.8.1 to 0.9.0.
- [Release notes](https://github.com/pytest-dev/pluggy/releases)
- [Changelog](https://github.com/pytest-dev/pluggy/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pluggy/compare/0.8.1...0.9.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-02-25 14:42:52 -08:00
Sarah Clements 6186844a4c fix duplicate entries 2019-02-25 14:17:27 -08:00
Renovate Bot 738c185835 Update react monorepo to v16.8.3 2019-02-25 14:17:27 -08:00
Ed Morley 4704764a89 Bug 1530267 - Remove explicit class inheritance from `object`
Since with Python 3 all classes inherit from it by default.
2019-02-25 20:39:03 +00:00
Ed Morley 769cded9a8 Bug 1530267 - Use Python 3 `super()` syntax 2019-02-25 20:39:03 +00:00
Ed Morley e54acccb25 Bug 1530267 - Mark treeherder-client as requiring Python 3
The latest client release still supports Python 2, and given the rarity
of client releases, it's unlikely that a new release will be made any
time soon - so requiring Python 3 on `master` will have little effect.
2019-02-25 20:39:03 +00:00
Ed Morley 27e45c940f Bug 1530267 - Remove Python 2 support from astral_filter
The check for whether Python has been compiled in the wrong mode has
also been removed, since Python 3 defaults to the correct mode unlike
Python 2.
2019-02-25 20:39:03 +00:00
Ed Morley f2f17e4a29 Bug 1530267 - Remove use of six.stringtypes 2019-02-25 20:39:03 +00:00
Ed Morley 1f894da782 Bug 1530267 - Remove use of six.moves.* 2019-02-25 20:39:03 +00:00
Ed Morley 248733bc69 Bug 1530267 - Remove use of six.iteritems() 2019-02-25 20:39:03 +00:00
Ed Morley e3e17266e6 Bug 1530267 - Remove use of Django's `smart_text` 2019-02-25 20:39:03 +00:00
Ed Morley 368be2befa Bug 1530267 - Remove use of Django's `python_2_unicode_compatible` 2019-02-25 20:39:03 +00:00
Ed Morley d726fe7313 Bug 1530267 - Remove __future_ imports
Since they are a no-op on Python 3.
2019-02-25 20:39:03 +00:00
Ed Morley ed49fabd66 Bug 1530267 - Remove Python 2-only requirements entries
Since they aren't installed/needed under Python 3.
2019-02-25 20:39:03 +00:00
Ed Morley 41b2bc6cbf Bug 1529223 - Auth: Remove NoEmailException
Since it's no longer used after the Auth0 SSO switch.
2019-02-25 20:16:59 +00:00
Ed Morley 2c61ea3082 Bug 1529223 - Auth: Move expiry calculation to its own function 2019-02-25 20:16:59 +00:00
Ed Morley ca99c3cca8 Bug 1529223 - Auth: Rename `IdToken` header to `Id-Token`
For consistency with the other headers (and seeing as we already have
to have a fallback for `ExpiresAt`, we can remove both later at the
same time).
2019-02-25 20:16:59 +00:00
Ed Morley e643b8e4e7 Bug 1529223 - Auth: Use seconds not milliseconds for expiration handling
Previously the frontend would calculate the access token expiry timestamp
in milliseconds and pass it to the `/login/` API via an `ExpiresAt` header.
The backend would then convert both the Id Token's `exp` and current time
to milliseconds, when calculating the earliest expiry. The result then
had to be converted back to seconds for use with Django's session
`.set_expiry()`.

It is instead much simpler to leave everything in seconds, since none of
the Auth0-provided inputs were in milliseconds to start with, so there is
no loss of precision, just fewer conversions required. Timestamps are also
more commonly in seconds, so use of seconds is less surprising.

After this is deployed there will initially be users who have old frontend
pages open that are still sending the expiry as milliseconds. In order to
be able to differentiate between new and old clients, the header has been
renamed to `Access-Token-Expires-At` (which also makes it clearer as to
what the expiry is for, given there is also an Id Token expiry), and a
temporary fall-back added to the backend that can be removed after a few
days has passed.
2019-02-25 20:16:59 +00:00
Ed Morley 6c05a78eb4 Bug 1529223 - Auth: Gracefully handle invalid Id Tokens
Rather than returning an HTTP 500.
2019-02-25 20:16:59 +00:00
Ed Morley f99d181b2e Bug 1529223 - Auth: Gracefully handle missing IdToken header
Rather than returning an HTTP 500.
2019-02-25 20:16:59 +00:00
Ed Morley 8a0c34ca0b Bug 1529223 - Auth: Simplify handling of the Authorization header
And add more tests.
2019-02-25 20:16:59 +00:00
Ed Morley b7f7530845 Bug 1529223 - Auth: Correctly set Django session expiry for new users
Since previously the session length was only set for returning users.
The tests have been updated to now cover both cases.
2019-02-25 20:16:59 +00:00
Ed Morley 55943cac98 Bug 1529223 - Tests: Merge test_backends.py into test_auth.py
Since `test_get_username_from_userinfo` is a little too narrowly-scoped
and would be better as an API test. It has been combined with two other
tests in `test_auth.py` to give a more representative workflow test.
2019-02-25 20:16:59 +00:00
Ed Morley aec7b5bde7 Bug 1529223 - Tests: Move test_existing_email_create_user to test_auth.py
Since it's testing using the API so doesn't belong in test_backends.py.
The test has also been rewritten to be clearer about what it's checking.
2019-02-25 20:16:59 +00:00
Ed Morley 48a4c1a0b3 Bug 1529223 - Tests: Clean up user fixtures
Since:
* They don't need to use the slower `transactional_db` fixture that has
  advanced transaction-inspecting support.
* They don't need to add a request finalizer, since the `db` fixture
  cleans up the User during test teardown automatically.
* `User` does not need to be imported locally.

This speeds up `test_auth.py` by 4x.
2019-02-25 20:16:59 +00:00
Ed Morley 8253f9991b Bug 1529223 - Tests: Correct name/description for test_login_no_email
Since the name/description references the pre-auth0 implementation that
was removed in #3144. The `test_user` fixture has also been removed,
since it is not required for the test to run (the error referenced in
the comment no longer occurs).
2019-02-25 20:16:59 +00:00
Ed Morley d9de41bf4b
Bug 1270157 - Convert the report-only CSP header to the real thing (#4687)
The latest policy used in the report-only header has been working well
on production (the violation reports logged to New Relic are only from
scripts injected by browser addons), so we're ready to start enforcing
the policy by using the real `Content-Security-Policy` header name.

NB: When features are added in the future, PR authors and reviewers will
need to remember to update the policy if needed (for example to add domains
to the `connect-src` directive). The CSP header is not enabled when using
`webpack-dev-server` (it would break dev source maps and react-hot-loader)
so if in doubt test locally (using `yarn build` and serving via Django
runserver) or on prototype first.

See:
https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
2019-02-25 19:47:45 +00:00
Ed Morley c7cc7eba47
Bug 1489212 - Update django-filter from 1.1.0 to 2.1.0 (#4693)
Notably this adds support for Django 2.1, unblocking upgrading from 2.0.

The custom job details API `NumberInFilter` has been removed, since it
wasn't working after the breaking changes in django-filter, and is not
really needed now that the job details API has pagination enabled, so
has a default `LIMIT 2001` applied to queries.

Changes:
https://github.com/carltongibson/django-filter/blob/master/CHANGES.rst#version-20-2018-7-13
2019-02-25 19:44:14 +00:00
Ed Morley 52d6017c5b
Bug 1295997 - Skip parsing logs whose compressed size exceeds 5MB (#4700)
Occasionally failing build/test runs can fail in such a way that results
in a significant amount of log spam and therefore log files that are
hundreds of MB in size each. This can cause log parsing backlogs,
particularly when many jobs on the same push fail in such a way.

The log parser now checks the `Content-Length` of log files prior to
streaming them, and skips the download/parse if it exceeds the set
threshold. The frontend has been adjusted to display an appropriate
message explaining why the parsed log is not available.

The threshold has been set to 5MB, since:
* the 99th percentile of download size on New Relic was ~2.8MB:
  https://insights.newrelic.com/accounts/677903/dashboards/339080
* `Content-Length` is the size of the log prior to decompression, and
  the chronic logspam cases have been known to have compression ratios
  of 20-50x, which would translate to an uncompressed size limit of
  up to 250MB (which is already much larger than buildbot's former 50MB
  uncompressed size limit).
2019-02-25 19:04:38 +00:00
Renovate Bot 047c90228e Update dependency jest-dom to v3.1.2 2019-02-25 10:55:04 -08:00
Renovate Bot db2f390069 Update dependency react-day-picker to v7.3.0 2019-02-25 10:54:18 -08:00
Renovate Bot 9ec5a9e618 Update dependency react-testing-library to v6 2019-02-25 10:50:40 -08:00
Renovate Bot 3137bfa5b8 Update dependency ajv to v6.9.2 2019-02-25 10:49:14 -08:00
dependabot[bot] 3227b2eb63 Bump isort from 4.3.4 to 4.3.8 in /requirements (#4696)
Bumps [isort](https://github.com/timothycrosley/isort) from 4.3.4 to 4.3.8.
- [Release notes](https://github.com/timothycrosley/isort/releases)
- [Changelog](https://github.com/timothycrosley/isort/blob/develop/CHANGELOG.md)
- [Commits](https://github.com/timothycrosley/isort/commits)

And also:
* Remove no longer required isort config workarounds.
* Sort imports correctly in __init__.py (since previously isort skipped these files).
2019-02-25 11:12:40 +00:00
Ed Morley ff3213911f
Bug 1527336 - Update more-itertools from 5.0.0 to 6.0.0 (#4695)
The new version has dropped support for Python 2, so this was previously
blocked on bug 1330474.
2019-02-25 09:26:59 +00:00
Ed Morley 23c3a4b8d0
Bug 1426683 - Update Django from 1.11 to 2.0 (#4676)
https://docs.djangoproject.com/en/2.0/releases/2.0/
2019-02-25 07:14:50 +00:00
Ed Morley a0d1f5fccf
Bug 1330474 - Travis: Stop testing against Python 2 (#4675)
Since we've been using Python 3 in production for long enough that we're
confident we won't need to roll back to Python 2.
2019-02-25 06:54:46 +00:00
dependabot[bot] 33b82f875c Bump markupsafe from 1.1.0 to 1.1.1 in /requirements
Bumps [markupsafe](https://github.com/pallets/markupsafe) from 1.1.0 to 1.1.1.
- [Release notes](https://github.com/pallets/markupsafe/releases)
- [Changelog](https://github.com/pallets/markupsafe/blob/1.1.1/CHANGES.rst)
- [Commits](https://github.com/pallets/markupsafe/compare/1.1.0...1.1.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-02-25 06:31:04 +00:00
dependabot[bot] f15a6b9257 Bump django-extensions from 2.1.5 to 2.1.6 in /requirements
Bumps [django-extensions](https://github.com/django-extensions/django-extensions) from 2.1.5 to 2.1.6.
- [Release notes](https://github.com/django-extensions/django-extensions/releases)
- [Changelog](https://github.com/django-extensions/django-extensions/blob/master/CHANGELOG.md)
- [Commits](https://github.com/django-extensions/django-extensions/compare/2.1.5...2.1.6)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-02-25 06:29:27 +00:00
Sarah Clements 5a47eca3c3
Add tests for Perfherder's compare table using react-testing-library (#4647) 2019-02-24 15:37:11 -08:00
Ed Morley ecabd76f96
Bug 1453837 - Use correct value for id token expiry in auth tests (#4667)
The id token payload contains an `exp` property, which is an integer
representing the number of seconds past the epoch at which the id token
expires.

However the mocked value in our authentication tests was the string `'500'`,
which is neither the correct data type, nor a timestamp. This meant that
during tests only, the `min(accesstoken_exp_in_ms, idtoken_exp_in_ms)`
in `AuthBackend.authenticate()` was comparing an int and a string, which
under Python 3 results in:

`TypeError: '<' not supported between instances of 'str' and 'int'`

A later bug/PR will refactor the auth backend to fix issues unrelated to
Python 3 compatibility and add more test coverage.
2019-02-22 13:50:01 +00:00
dependabot[bot] 5bec1d3942 Bump py from 1.7.0 to 1.8.0 in /requirements
Bumps [py](https://github.com/pytest-dev/py) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/pytest-dev/py/releases)
- [Changelog](https://github.com/pytest-dev/py/blob/master/CHANGELOG)
- [Commits](https://github.com/pytest-dev/py/compare/1.7.0...1.8.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-02-22 13:46:45 +00:00
Ed Morley d5494a7848 Bug 1270157 - Make the CSP report collector skip CSRF checks
Since otherwise report submissions will fail with an HTTP 403 on browsers
that send the Django session cookie but not the CSRF token.

The collector has also been rewritten to be a standard Django view rather
than a django-rest-framework APIView, since the latter is more of a
hindrance than a help for this use-case (particularly now we're wanting
to disable CSRF checks).
2019-02-22 12:17:33 +00:00
Ed Morley 7833ba2bb7 Bug 1270157 - Update the report-only CSP header
Makes the following changes to the initial header added in #4678:

1) Adds a `frame-src` directive

Whilst the Auth0 domain is already whitelisted in `connect-src` allowing
initial logins to work, Auth0.js renewals are performed in an iframe, so
need both the auth0 domain and `'self'` (for the `/login.html` callback)
to be permitted via `frame-src`.

2) Adds https://taskcluster-artifacts.net to `connect-src`

Since some requests to `queue.taskcluster.net` redirect to it (eg for the
"Add new jobs" feature), and for redirects both the original and new domain
need whitelisting.

3) Adds `'report-sample'` to `script-src` and `style-src`, which makes
the browser send JS/CSS samples for any violations of the "inline" rules,
making it easier to debug collected CSP violation reports.
2019-02-22 12:17:33 +00:00
ionutgoldan d7e3f7636d
Bug 1529270 - Rename alert summaries last_updated field to created 2019-02-22 11:31:15 +02:00
Ed Morley 5b7209be29
Bug 1270157 - Add a report-only CSP header and report collection API (#4678)
This adds a `Content-Security-Policy-Report-Only` header for static assets
served by WhiteNoise (such as our frontend), which includes a first pass
at a possible policy that should work for Treeherder.

The header also includes a `report-uri` directive, which points at a newly
added API for collecting CSP violation reports. Reports are logged as
warnings (so will appear in Papertrail) and sent to New Relic as a custom
event. This will allow us to see whether the policy would block valid
requests, so we can refine it prior to converting to the real (ie blocks
things) `Content-Security-Policy` header.

The addition of `ng-csp` to `perf.html` is to enable AngularJS's ngCSP
feature, which turns off use of `eval()` and automatic stylesheet
injection, so that the policy directives `unsafe-eval` and
`unsafe-inline` don't have to be used. This requires us to then manually
import the AngularJS stylesheet to include the styles that would have
previously been injected:
https://docs.angularjs.org/api/ng/directive/ngCsp

See:
https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
2019-02-22 06:48:12 +00:00
Renovate Bot 81d39ba8e0 Update dependency react-redux to v6.0.1 2019-02-21 17:47:14 -08:00