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

1067 Коммитов

Автор SHA1 Сообщение Дата
Lucas Garron bb167fa2f1
Update `.ruby-version` to `3.1.1`
I'm having trouble using `2.6.6`, so it would be more straightforward to use a newer version by default.
2022-10-24 20:30:40 -07:00
Lucas Garron 0678a7405e
v6.5.0 (#501)
Release notes:

- CSP: Remove source expression deduplication. (@lgarron)
https://github.com/github/secure_headers/pull/499
2022-10-24 12:08:19 -07:00
Lucas Garron 3adb9ba26c v6.5.0
Release notes:

- CSP: Remove source expression deduplication. (@lgarron) https://github.com/github/secure_headers/pull/499
2022-10-24 12:06:30 -07:00
Lucas Garron b6ef2ed67a
Remove source expression deduplication. (#499)
This PR removes `dedup_source_list` and replaces it with a simple
`.uniq` call. This resolves
https://github.com/github/secure_headers/issues/491, which is only the
latest in a series of ongoing issues with source expression
deduplication.

`secure_headers` has had this feature [since
2015](32bb3f51e8)
that [deduplicates redundant URL source
expressions](494b75ff92/lib/secure_headers/headers/content_security_policy.rb (L157-L170)).
For example, if `*.github.com` is listed as a source expression for a
given
[directive](https://w3c.github.io/webappsec-csp/#framework-directives),
then the addition of `example.github.com` would have no effect, and so
the latter can be safely removed by `secure_headers` to save bytes.

Unfortunately, this implementation has had various bugs due to the use
of "impedance mismatched" APIs like
[`URI`](https://docs.ruby-lang.org/en/2.1.0/URI.html)[^1] and
[`File.fnmatch`](https://apidock.com/ruby/v2_5_5/File/fnmatch/class)[^2].
For example, it made incorrect assumptions about source expression
schemes, leading to the following series of events:

[^1]: Which allows wildcards in domains but not for ports, as it is not
designed to parse URL source expressions.
[^2]: Which has general glob matching that is not designed for URL
source expressions either.

- 2017-03: A [bug was reported and
confirmed](https://github.com/github/secure_headers/issues/317)
- 2022-04: The bug was finally [fixed by `@keithamus` (a Hubber) in
2022](https://github.com/github/secure_headers/pull/478) due to our use
of web sockets.
- 2022-06: This fix in turn triggered a [new
bug](https://github.com/github/secure_headers/issues/491) with source
expressions like `data:`.
- 2022-06: An external contributor [submitted a fix for the bew
bug](https://github.com/github/secure_headers/pull/490), but this still
doesn't address some of the "fast and loose" semantic issues of the
underlying implementation.
- 2022-08: `@lgarron` [drafted a new
implementation](https://github.com/github/secure_headers/pull/498) that
semantically parses and compares source expressions based on the
specification for source expressions.
- This implementation already proved to have some value in early
testing, as its stricter validation caught an issue in `github.com`'s
CSP. However, it would take additional work to make this implementation
fully aware of CSP syntax (e.g. not allowing URL source expressions in a
source directive when only special keywords are allowed, and
vice-versa), and it relies on a new regex-based implementation of source
expression parsing that may very well lead to more subtle bugs.

In effect, this is a half feature whose maintenance cost has outweighed
its functionality:

- The relevant code has suffered from continued bugs, described as
above.
- Deduplication is purely a "nice-to-have" — it is not necessary for the
security or correct functionality of `secure_headers`.
- It was [introduced by `@oreoshake` (the then-maintainer) without
explanation in
2015](32bb3f51e8),
never "officially" documented. We have no concrete data on whether it
has any performance impact on any real apps — for all we know, uncached
deduplication calculations might even cost more than the saved header
bytes.
- Further, in response to the first relevant bug, `@oreoshake` himself
[said](https://github.com/github/secure_headers/issues/317#issuecomment-283431124):

> I've never been a fan of the deduplication based on `*` anyways. Maybe
we should just rip that out.

> Like people trying to save a few bytes can optimize elsewhere.

So this PR completely removes the functionality. If we learn of a use
case where this was very important (and the app somehow can't preprocess
the list before passing it to `secure_headers`), we can always resume
consideration of one of:

- https://github.com/github/secure_headers/pull/490
- https://github.com/github/secure_headers/pull/498
2022-10-24 12:03:34 -07:00
Lucas Garron a488b4d5ec
CI changes: run on push, drop Ruby 2.5 (#500)
Ruby 2.5 has been failing on CI since
https://github.com/github/secure_headers/pull/499 and is no longer
supported.
2022-10-24 12:01:54 -07:00
Lucas Garron cd73b02188 Update tests. 2022-10-24 11:01:01 -07:00
Lucas Garron cdb40e5b85 Remove `dedup_source_list` and replace with a "best-effort" `.uniq` call. 2022-10-24 11:01:01 -07:00
Lucas Garron af92ce6f09 Add a regression test for a current bug. 2022-10-24 11:01:01 -07:00
Lucas Garron 53f2eac675 Remove Ruby 2.5 from CI.
Ruby 2.5 has trouble connecting to `coveralls.io`.
2022-10-19 13:00:27 -07:00
Lucas Garron 388b8faf74 Run CI on push.
CI doesn't have access to any secrets (like a RubyGems auth token) or production data, so it's fairly safe to run on every push.
2022-10-19 13:00:20 -07:00
Lucas Garron c8e58c3f0b
Merge pull request #495 from github/lgarron/trusted-types-quoted-script
Trusted types: Use single-quoted `'script'`.
2022-08-12 12:38:34 -07:00
Kevin Jones 5500622e28
Set license code in metadata to MIT 2022-08-10 18:13:21 -04:00
Ewoud Kohl van Wijngaarden 02d65f10d7
Set license code in metadata to MIT
In 5638cb0334 the gem was relicensed to
MIT, but it was incomplete.  86c762aea4 at
least fixed the README, but the gemspec itself was still forgotten.

Fixes: 5638cb0334
2022-08-10 23:39:06 +02:00
Kevin Jones dcf9040d23
Use SPDX license code and swap summary & description 2022-08-10 16:52:35 -04:00
Lucas Garron 0e8f4999dd Trusted types: Use single-quoted `'script'`.
Contrary to e.g. `require-sri-for` (which our previous implementation was for), it turns out the `require-trusted-types-for` directive uses:

- Single-quoted `'script'` and `'none'` sources (in addition to `'allow-duplicates'`).
- Unquoted policies in addition to those.

See:

- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/require-sri-for
- https://w3c.github.io/webappsec-trusted-types/dist/spec/#require-trusted-types-for-csp-directive

Right now we are flexible about both quoted and unquoted sources, but this PR starts by using the values used for the directive per spec / browser implementations.
2022-08-09 20:03:14 -07:00
Kylie Stradley 084f517482
update version and changelog (#494)
* update version and changelog

* add PR link to changelog
2022-08-02 15:41:52 -04:00
Kylie Stradley 494b75ff92
Merge pull request #486 from github/kyfast-add-trusted-types
Add trusted-types and require-trusted-types-for CSP Directive
2022-08-02 09:51:13 -04:00
Ewoud Kohl van Wijngaarden 6a3b75d122
Use SPDX license code and swap summary & description
Using an SPDX code makes automatic processing easier. The summary should be
shorter than the description.
2022-07-26 16:36:18 +02:00
Kylie Stradley f40910c4fe add test for 'none' trusted type 2022-06-28 13:38:40 +00:00
Kylie Stradley 071c580fe6 fix whitespace 2022-06-28 13:29:06 +00:00
Kylie Stradley 98674532f9 Apply suggestions from code review
Co-authored-by: Lucas Garron <lgarron@chromium.org>
2022-06-28 13:29:06 +00:00
Kylie Stradley ba3cf0288d make test match others and add tesfor allow-duplicates 2022-06-28 13:29:06 +00:00
Kylie Stradley f10a4a4dd0 remove debugging in file 2022-06-28 13:29:06 +00:00
Kylie Stradley f2cc4c9f81 move trusted types validate config to appropriate test file 2022-06-28 13:29:06 +00:00
Kylie Stradley 79a2b5dce2 remove unused function 2022-06-28 13:29:06 +00:00
Kylie Stradley 21b2f46cab fix test syntax 2022-06-28 13:29:06 +00:00
Kylie Stradley e78ae24e25 just enough to get the trusted types directive into the csp, I think 2022-06-28 13:29:06 +00:00
Jack McCracken 65c917240e Add trusted types directive 2022-06-28 13:29:06 +00:00
Kylie Stradley 5f91c40ee9
Merge pull request #489 from petergoldstein/feature/add_ruby_3_1
Add Ruby 3.1 to the CI configuration
2022-06-28 09:28:02 -04:00
Peter Goldstein 57d8995e6d Add Ruby 3.1 to the CI configuration
Also made several formatting changes to get Rubocop to be green.
2022-06-27 16:23:27 -07:00
Lucas Garron e6db1f848d Add a workflow to automatically relase version tags. 2022-06-27 15:58:47 -07:00
Lucas Garron 6b5242889b
Merge pull request #487 from github/release-v6.3.4
Update changelog and version for v6.3.4.
2022-06-27 15:55:53 -07:00
Lucas Garron fac659e54d Update changelog and version for v6.3.4. 2022-06-22 11:52:18 -07:00
Jack McCracken 0dc7feed39
Merge pull request #478 from keithamus/do-not-dedupe-alternate-schema-source-expresions
do not dedupe alternate schema source expresions
2022-06-15 11:03:00 -04:00
Lucas Garron 034c8b60b3
Update one more `README.md` reference to HTTPS. 2022-05-05 14:43:26 -07:00
Lucas Garron b3dfa2c11a
Merge pull request #483 from akashhansda/patch-1
Update README.md
2022-05-05 14:41:36 -07:00
akashhansda daa0662111
Update README.md
Use https
2022-04-07 08:37:50 -07:00
Keith Cirkel 78cb949f8f
fix test to properly fail without scheme pattern match 2022-04-01 14:59:23 +01:00
Keith Cirkel 7e8d967684
precompute schemes map before any loop 2022-04-01 14:59:01 +01:00
Keith Cirkel 1bd1e4c010
do not dedupe alternate schema source expresions 2022-04-01 11:58:36 +01:00
Neil Matatall 7f89df2daf don't limit rubocop version 2021-11-15 06:06:24 +00:00
Neil Matatall e4a198c0f4
bump to 6.3.3 2021-09-07 12:12:56 -10:00
Neil Matatall e4caeb0c33
Merge pull request #472 from rahearn/generate-hashes-trailing-whitespace
Fix hash generation for indented helper methods
2021-09-07 12:11:37 -10:00
Ryan Ahearn a0072e096e Fix hash generation for indented helper methods
The helper outputs the closing </script> or </style> unindented
if it is on its own line. Needed to remove any extra whitespace
the regex captures on that last line.
2021-08-27 16:41:32 -04:00
Neil Matatall 8e28012493
Add https://github.com/TypeError/secure to list of similar libraries
cc @cak
2021-05-06 10:30:21 -10:00
Neil Matatall 159bbdb0b6
Update per_action_configuration.md 2021-04-28 07:17:16 -10:00
Neil Matatall ce2ad13964
Merge pull request #467 from sapientpants/fix-clear-site-data-example
Fix ClearSiteData example
2021-03-09 10:18:08 -10:00
Neil Matatall c32e49f276
Delete sync.yml 2021-03-09 10:15:36 -10:00
Neil Matatall 607a8cd628
Merge pull request #468 from github/oreoshake-patch-1
Update ruby build scripts and bump test matrix versions
2021-03-09 10:10:47 -10:00
Neil Matatall bba850a4fb
Update ruby build scripts and bump test matrix versions 2021-03-09 09:57:50 -10:00