Commit graph

46 commits

Author SHA1 Message Date
Sebastian C
27c8a899ea
Replace hsts preload list hashmap with an FST (#37015)
This reduces the memory used by the preload list to just 1.9MB. The
total memory savings in HSTS from
pre-103cbed928
is now 62MB, or 96%. And in terms of total resident memory is a 7.5%
reduction. The DAFSA/DAWG used by Firefox is 1.1MB so there could be
additional gains available but this seems like the best option based on
maintained libraries available (I could not find a good maintained
library for DAFSAs in Rust).

The main trick is this: the FST map API is currently designed to map
byte sequences to u64 values. Because we only need to determine if a
preloaded domain has the `includeSubdomains` flag set, we encode that
into the lowest bit of the ids in the map. This way finding an entry in
the map directly provides us with the `includeSubdomains` flag and we
don't need to keep another mapping in memory or on disk.

Updated the `./mach update-hsts-preload` command to generate the new FST
map file. (Not sure if I need to update any dev-dependencies anywhere
for this change)

This change also replaces the use of "mozilla.org" with "example.com" in
the HSTS unit tests to make sure that entries in the preload list do not
influence the tests (since example.com should not ever end up on the
preload list)

Testing: Updated unit tests
Fixes: #25929

---------

Signed-off-by: Sebastian C <sebsebmc@gmail.com>
2025-05-20 04:26:55 +00:00
Sebastian C
103cbed928
HSTS list memory reduction and fixes (#37000)
Combines the 2 time values in the HSTS entry with a single timestamp for
expiration. (9MB savings per list)

The previous time representations were based on system boot time which
meant that the `hsts_list.json` round trip across boots resulted in
completely erroneous expiration times.

The preload list is now initialized separately from the public and
private lists and shared by both, cutting memory use in half.

Overall takes memory use from 64MB for HSTS to 24MB.

Expired HSTS entries are now removed from the list when updating an
entry and subdomains can be added to a list if the superdomain does not
already include them.

Testing: New unit tests added
Related to #25929 but the next step would be to attempt to use
https://github.com/BurntSushi/fst Which will be explored in a follow-up.

---------

Signed-off-by: Sebastian C <sebsebmc@gmail.com>
2025-05-15 04:06:57 +00:00
Josh Matthews
f16f625c9b
net: Measure HSTS memory usage. (#36558)
Records the memory usage of the HSTS lists in the network thread.

Testing: Verified the presence of the new reports for servo.org.
Fixes: #35059

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-04-16 13:11:44 +00:00
Simon Wülker
3d320fa96a
Update rustfmt to the 2024 style edition (#35764)
* Use 2024 style edition

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Reformat all code

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-03-03 11:26:53 +00:00
Martin Robinson
0e616e0c5d
api: Flatten and simplify Servo preferences (#34966)
Flatten and simplify Servo's preferences code. In addition, have both
preferences and options passed in as arguments to `Servo::new()` and
make sure not to use the globally set preferences in `servoshell` (as
much as possible now).

Instead of a complex procedural macro to generate preferences, just
expose a very simple derive macro that adds string based getters and
setters.

- All command-line parsing is moved to servoshell.
- There is no longer the concept of a missing preference.
- Preferences no longer have to be part of the resources bundle because
  they now have reasonable default values.
- servoshell specific preferences are no longer part of the preferences
  exposed by the Servo API.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-01-14 13:54:06 +00:00
Ngo Iok Ui (Wu Yu Wei)
b58cee48ce
doc(resources): Preferences, HstsPreloadList, RippyPNG (#33775)
* Set to default if Preferences and HstsPreloadList are empty

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>

* Add documentation of Preferences, HstsPreloadList, RippyPNG

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>

* Add warn log when setting prefs to default

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>

* Add error log instead

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>

* Add error log to HSTS preload list

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>

* Apply suggestions from code review

Address a couple wording nits

Signed-off-by: Martin Robinson <mrobinson@igalia.com>

---------

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-10-10 18:19:41 +00:00
Simon Wülker
7df30f3788
Replace .map_or(false with Option::is_some_and (#33468)
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2024-09-16 10:03:52 +00:00
Martin Robinson
bc8d8b62c3
Stop using time@0.1 in Servo (#33394)
This removes the last few uses of `time@0.1` in Servo. There are still
dependencies from `style` and `webrender`, but they will be removed soon
as well. The uses of this version of `time` are replaced with
`std::time` types and `time@0.3` when negative `Duration` is necessary.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-09-11 07:09:56 +00:00
eri
67b277c992
clippy: fix warnings in components/net (#31564)
* clippy: fix some warnings in components/net

* fix: review comments

* fix: tidy
2024-03-10 15:34:16 +00:00
Martin Robinson
5c1723c983
rustdoc: Fix many rustdoc errors (#31147)
This fixes many rustdoc errors that occur due to raw URLs in rustdoc
comments as well as unescaped Rust code that should be in backticks.
2024-01-22 13:13:48 +00:00
Martin Robinson
8e5f28839c
Revert "Replace time with std::time in components/net (#31079)" (#31120)
This reverts commit 580062228b.
2024-01-18 15:10:48 +00:00
Taym Haddadi
580062228b
Replace time with std::time in components/net (#31079)
* Replace time with std::time in components/net

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Fix cookie::test_sort_order test

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

---------

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>
2024-01-17 14:18:20 +00:00
Samson
aad2dccc9c
Strict import formatting (grouping and granularity) (#30325)
* strict imports formatting

* Reformat all imports
2023-09-11 19:16:54 +00:00
Samson
711dbbd4af
remove extern crate (#30311)
* remove extern crate

* Update components/script_plugins/lib.rs

Co-authored-by: Martin Robinson <mrobinson@igalia.com>

---------

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2023-09-08 12:11:31 +00:00
shanehandley
00241e84bc
Remove customised implementation of hsts headers. (#30046)
This looks to have originally been implemented due to missing functionality in the headers crate, which has since been added and released.
2023-07-31 08:53:53 +00:00
Jan Andre Ikenmeyer
68ebecb775
Fix HSTS 2020-01-07 16:07:12 +01:00
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +01:00
Simon Sapin
9f977c5287 Remove useless use crate_name; imports.
A `crate_name::foo` path always works in 2018
2018-11-08 09:29:52 +01:00
Pyfisch
9e92eb205a Reorder imports 2018-11-06 22:35:07 +01:00
Pyfisch
2481ad25f8 Rustfmt net crate 2018-11-03 15:29:01 +01:00
Alan Jeffrey
05391e27cd Add lots of derived Debug impls 2018-10-29 09:21:37 -05:00
Paul Rouget
9fb5795f37 delegate resource reading to embedder 2018-04-27 15:34:52 +08:00
coalman
fc34b9a14d Fix indentation errors in servo rust code that tidy now finds. 2017-04-18 14:56:13 -04:00
Anthony Ramine
fb86bfebf4 Introduce HstsList::switch_known_hsts_host_domain_url_to_https 2017-04-05 14:42:59 +02:00
Anthony Ramine
170bcfc03e Kill hsts::secure_url 2017-04-05 14:42:49 +02:00
Anthony Ramine
fd9cd33892 Use serde_json to persist cookies in the net crate 2017-02-22 12:33:10 +01:00
Raghav
6a14349eb1 Refactor HSTSList to use HashMap
Refactored HSTSList to use HashMap, where the key of HashMap is the base
domain. Every time when we check if a host is secure, we find the base
domain of the host and get a vector of HSTS entries associated with the
base domain.

While this will not give O(1) look up time, we would have a smaller list
to iterate for every lookup. I have added one unit test to validate
HashMap changes.
2016-12-30 22:00:03 +05:30
Alan Jeffrey
9be4fd56ce Removed util. 2016-12-14 18:04:37 -06:00
Cullen Rhodes
40acd24e8f Report use statements that use {} with only one entry 2016-05-27 10:18:44 +01:00
Simon Sapin
7932ab6ac2 Upgrade to rust-url 1.0 and hyper 0.9 2016-04-23 20:27:58 +02:00
Corey Farwell
08fc002f41 Rename 'HSTS*' structures to 'Hsts*'.
"In CamelCase, acronyms count as one word: use Uuid rather than UUID."

-- https://doc.rust-lang.org/style/style/naming/README.html
2016-04-17 14:12:28 -04:00
Corey Farwell
faa3d8724b Refactor Servo HSTS file loading, hard-fail if can't load.
Use constructor pattern instead of separate utility function.

Instead of allowing the Servo HSTS file loading to silently fail, we
should expect that file to always exist and be formatted correctly.
2016-04-17 14:12:07 -04:00
Corey Farwell
d3b8b6472b Move UTF8 bytes handling into generic constructor.
Separate from Servo specific logic.
2016-04-17 12:39:50 -04:00
Corey Farwell
52b3226d54 Rename constructor to match convention, add doc comment. 2016-04-17 12:38:29 -04:00
Corey Farwell
c37ab1facd Make read_resource_file param simpler and more idiomatic.
`<P: AsRef<Path>>` is also what `File::open` uses as a generic type for
the parameter.
2016-04-16 23:06:59 -04:00
Simon Sapin
45ec900745 Remove dependency on regex_macros
This reduces the amount of code using unstable features that we depend on.
The hand-written IP address parser is probably just as fast.
2015-11-24 22:07:14 +01:00
Ravi Shankar
889eec364b sorted the extern crate, mod & use declarations 2015-09-24 02:12:45 +05:30
Maciej Skrzypkowski
88815d21ba Add plugins for compositing and net crates #7699
Changed to_string calls to to_owned calls
where was a need.
2015-09-22 13:51:21 +02:00
Brandon Fairchild
de3547e401 Fix reported test-tidy errors for unmerged import blocks
This merges import blocks that were reported by tidy as unmerged.
2015-09-19 12:50:14 -04:00
Johann Tuffe
ec07178b6f sort all uses 2015-08-20 20:47:12 +08:00
James Graham
f52276d2cc Use hosts-replaced URL only when loading resources 2015-08-05 10:34:20 +01:00
Sam Gibson
118122da38 Uses the approach suggested by @SimonSapin for changing Url scheme
servo/rust-url#61
2015-07-22 11:49:10 +12:00
Sam Gibson
bae979137a Moves HSTS includeSubdomains enum to net_traits 2015-07-22 11:49:09 +12:00
Sam Gibson
11f5be6d85 Responds to more code review feedback
* Use regex from resource task
* Don't have an option of an HSTS list, default to empty
2015-07-22 11:49:08 +12:00
Sam Gibson
f2148f06b1 Moves the HSTS replacement code to http_loader
This respects STS for redirects as well.
2015-07-22 11:49:08 +12:00
Sam Gibson
826f56bdf3 Moves HSTS code to it's own module 2015-07-22 11:49:07 +12:00