zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 1 | # Adding third_party Libraries |
| 2 | |
| 3 | [TOC] |
| 4 | |
| 5 | Using third party code can save time and is consistent with our values - no need |
| 6 | to reinvent the wheel! We put all code that isn't written by Chromium developers |
Rachael Newitt | cc7ede6 | 2025-05-09 00:36:32 | [diff] [blame] | 7 | into `//third_party`. We do this to make it easy to track license compliance, |
| 8 | security patches, and supply the right credit and attributions. It also makes it |
| 9 | a lot easier for other projects that embed our code to track what is Chromium |
| 10 | licensed and what is covered by other licenses. |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 11 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 12 | # Put the code in //third_party |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 13 | |
Lei Zhang | f1c7392 | 2024-05-13 19:17:44 | [diff] [blame] | 14 | By default, all third party code should be checked into |
Dirk Pranke | 53e12c3 | 2024-09-12 20:55:18 | [diff] [blame] | 15 | [//third_party](../third_party/), for the reasons given above. |
| 16 | |
| 17 | There is one primary exception to this, which is that if a third_party |
| 18 | dependency has its own dependencies *and* it can be built on its own (without |
| 19 | Chromium), you can check its dependencies into its third_party. For example, |
| 20 | Dawn is a project that is developed independently of Chromium, and |
| 21 | it has a dependency on GLFW (which Chromium does not have). Dawn |
| 22 | can check that dependency into its `//third_party/glfw`, and in a Chromium |
| 23 | checkout, that will show up at `//third_party/dawn/third_party/glfw`. |
| 24 | That is okay, but it'd be better if we could add GLFW to a Chromium |
| 25 | checkout (in chromium/src's `third_party/glfw`) and configure Dawn |
| 26 | to use that location when it is being built as part of Chromium. |
| 27 | |
| 28 | However, if that dependency is also needed by Chromium or another |
| 29 | of Chromium's dependencies, then it must be checked out into Chromium's |
| 30 | //third_party (i.e., now you have to use `//third_party/glfw`). This |
| 31 | prevents us from possibly needing to use two different versions of a |
| 32 | dependency. |
| 33 | |
| 34 | Apart from that, other locations are only appropriate in a few |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 35 | situations and need explicit approval; don't assume that because there's some |
| 36 | other directory with third_party in the name it's okay to put new things |
| 37 | there. |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 38 | |
Rachael Newitt | cc7ede6 | 2025-05-09 00:36:32 | [diff] [blame] | 39 | Regardless of where you add a third party dependency, you should use the |
| 40 | [recommended directory structure](#standard-dep-structure). |
| 41 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 42 | # Before you start |
Tim van der Lippe | 5870ac3 | 2019-10-18 11:46:54 | [diff] [blame] | 43 | |
| 44 | To make sure the inclusion of a new third_party project makes sense for the |
Alex Mineer | 5576433 | 2022-02-25 18:05:19 | [diff] [blame] | 45 | Chromium project, you should first obtain |
John Abd-El-Malek | 704bca0 | 2022-12-14 18:47:59 | [diff] [blame] | 46 | [Chrome ATL](../ATL_OWNERS) approval. Please include the following information in an |
John Abd-El-Malek | f44dc07b | 2023-02-07 02:39:11 | [diff] [blame] | 47 | email to [email protected]: |
Yaron Friedman | e3427139 | 2022-04-29 16:45:53 | [diff] [blame] | 48 | * Motivation of your project |
| 49 | * Design docs |
| 50 | * Additional checkout size |
John Abd-El-Malek | dde7f23 | 2022-12-14 23:41:50 | [diff] [blame] | 51 | * If the increase is significant (e.g., 20+ MB), can we consider limiting the |
| 52 | files to be checked in? |
Yaron Friedman | e3427139 | 2022-04-29 16:45:53 | [diff] [blame] | 53 | * Build time increase |
Erik Staab | 6e341e8 | 2024-08-26 15:13:35 | [diff] [blame] | 54 | * This refers to building `chrome` or test targets in the critical |
Erik Staab | 933b35e | 2025-03-01 02:29:54 | [diff] [blame] | 55 | development path. The [compile-size](speed/binary_size/compile_size_builder.md) |
| 56 | builder in CQ is a good proxy for the whether the delta is acceptable |
| 57 | (caveat that it measures just `chrome` on Linux). |
John Abd-El-Malek | dde7f23 | 2022-12-14 23:41:50 | [diff] [blame] | 58 | * If the increase is significant (e.g., 30+ seconds), can we consider making |
| 59 | this an optional build target? |
| 60 | * Binary size increase on Android ([official](https://www.chromium.org/developers/gn-build-configuration) builds) |
Lei Zhang | f1c7392 | 2024-05-13 19:17:44 | [diff] [blame] | 61 | * Any increase of 16 KB or more on Android is flagged on the build bots and |
John Abd-El-Malek | dde7f23 | 2022-12-14 23:41:50 | [diff] [blame] | 62 | justification is needed. |
Yaron Friedman | e3427139 | 2022-04-29 16:45:53 | [diff] [blame] | 63 | * Binary size increase on Windows |
John Abd-El-Malek | dde7f23 | 2022-12-14 23:41:50 | [diff] [blame] | 64 | * Is this library maintained on all platforms that we will use it on? |
| 65 | * If not, will the Chrome org be expected to maintain this for some or all |
| 66 | platforms? |
| 67 | * Does it have any performance / memory implications (esp. on Android)? Was the |
| 68 | library designed with intended use on Android? |
| 69 | * Do we really need the library? Is there any alternative such as an existing |
| 70 | library already in Chromium? If introducing a library with similar functionality |
| 71 | as existing, will it be easy for another developer to understand which should be |
| 72 | used where? Will you commit to consolidating uses in Chromium and remove the |
| 73 | alternative libraries? |
David Adrian | 254a437 | 2025-06-16 19:26:24 | [diff] [blame] | 74 | * Is the library memory safe? If not, is there an alternative library |
| 75 | available that is memory safe and meets Chromium's needs? |
| 76 | * You will be responsible for [owning the library](#add-owners), which |
| 77 | includes updating it for security and stability fixes. For C/C++, this is |
| 78 | your responsibility. For [Rust](#rust), minor version updates are regularly |
| 79 | handled by a rotation, so you are only responsible for major version updates |
| 80 | (and minor version updates which result in `gnrt` or Chromium CQ failures). |
John Abd-El-Malek | dde7f23 | 2022-12-14 23:41:50 | [diff] [blame] | 81 | * For desktop (Win/Mac/Linux/ChromeOS), does the dependency introduce closed |
| 82 | source components (e.g., binaries, WASM binaries, obfuscated code)? If yes, |
| 83 | please reach out to Chrome ATLs. |
| 84 | |
Yaron Friedman | e3427139 | 2022-04-29 16:45:53 | [diff] [blame] | 85 | |
John Abd-El-Malek | 704bca0 | 2022-12-14 18:47:59 | [diff] [blame] | 86 | Googlers can access [go/chrome-atls](https://goto.google.com/chrome-atls) and review |
| 87 | existing topics in g/chrome-atls, and can also come to office hours to ask |
Alex Mineer | 5576433 | 2022-02-25 18:05:19 | [diff] [blame] | 88 | questions. |
| 89 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 90 | ## Rust |
Scott Violet | 50a02e4 | 2022-11-29 20:02:34 | [diff] [blame] | 91 | |
David Adrian | d891869 | 2024-12-12 22:02:50 | [diff] [blame] | 92 | Rust is allowed for third party libraries. Unlike C++ libraries, Rust third |
| 93 | party libraries are [regularly rolled to updated versions by a |
| 94 | rotation](https://chromium.googlesource.com/chromium/src/tools/+/HEAD/crates/create_update_cl.md) |
| 95 | and can be audited for unsafety. The process for adding a Googler adding new Rust third-party |
| 96 | dependencies is documented at go/chrome-rust. External contributors adding a new |
| 97 | third party Rust dependency will be shepherded through the process as part of |
| 98 | their ATL review. |
Scott Violet | 50a02e4 | 2022-11-29 20:02:34 | [diff] [blame] | 99 | |
David Adrian | d891869 | 2024-12-12 22:02:50 | [diff] [blame] | 100 | Email [email protected] with any questions about the Rust toolchain. |
Scott Violet | 50a02e4 | 2022-11-29 20:02:34 | [diff] [blame] | 101 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 102 | ## A note on size constraints |
Yaron Friedman | e3427139 | 2022-04-29 16:45:53 | [diff] [blame] | 103 | |
| 104 | The size of Chromium derived executables can impact overall performance of those binaries as they |
| 105 | need to run on a wide range of devices including those with extremely limited RAM. Additionally, we |
| 106 | have experience from Windows of the binary size impacting successful patch rate of updates as well |
| 107 | as constraints from the Android Ecosystem where APKs included in the system image have hard |
| 108 | limits on their size due to allocation size of the system partition. For more details and |
| 109 | guidelines on size increases see |
Michael Cui | 5d51775 | 2022-11-01 14:11:32 | [diff] [blame] | 110 | [//docs/speed/binary_size/binary_size_explainer.md](speed/binary_size/binary_size_explainer.md) and Googlers can |
| 111 | additionally check [go/chrome-binary-size](https://goto.google.com/chrome-binary-size) |
Tim van der Lippe | 5870ac3 | 2019-10-18 11:46:54 | [diff] [blame] | 112 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 113 | ## Binaries, obfuscated or minified code |
Rachael Newitt | 1554699 | 2023-09-17 22:13:09 | [diff] [blame] | 114 | |
| 115 | The addition of third-party dependencies that contain binaries, obfuscated |
| 116 | code, or minified code is strongly discouraged. Code review is an important |
| 117 | part of reducing risk to Chromium and a reviewer asked to approve a change |
| 118 | that contains any of these has no way to determine the legitimacy of what |
| 119 | they are approving. Minification for performance optimization is |
| 120 | [usually not necessary](speed/binary_size/optimization_advice.md), and the |
| 121 | trade-off in terms of understandability and security is rarely worth |
| 122 | it. |
| 123 | |
| 124 | Where your dependency will form part of a release binary where size is a concern, |
| 125 | there are existing tools which handle [compression for distribution](speed/binary_size/optimization_advice.md). |
| 126 | |
| 127 | You should not check in any pre-built binaries where there is an alternate, |
| 128 | supported solution for getting them. If you need to compile from source, |
| 129 | consider using [CIPD](cipd_and_3pp.md) instead. |
| 130 | |
Dirk Pranke | 4038090a | 2024-05-09 01:51:37 | [diff] [blame] | 131 | This is accessible to Googlers only. Non-Googlers can email one of the people |
| 132 | in third_party/OWNERS for help. |
Rachael Newitt | 1554699 | 2023-09-17 22:13:09 | [diff] [blame] | 133 | |
| 134 | See [Chrome Code Policy](https://goto.google.com/chrome-code-policy) |
| 135 | |
| 136 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 137 | # Get the code |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 138 | |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 139 | There are two common ways to depend on third-party code: you can reference a |
Jason D. Clinton | b21e99b | 2021-09-30 19:19:58 | [diff] [blame] | 140 | Git repo directly (via entries in the DEPS file) or you can check in a |
| 141 | snapshot. The former is preferable in most cases: |
| 142 | |
| 143 | 1. If you are actively developing in the upstream repo, then having the DEPS |
Filipa Senra | 06109cce | 2025-05-29 09:19:02 | [diff] [blame] | 144 | file include the upstream (that's been mirrored to GoB, see [here](/docs/dependencies.md#adding-to-GoB)) |
| 145 | can be a way to include those changes into Chromium at a particular revision. |
| 146 | The DEPS file will be updated to a new revision when you are ready to "roll" |
| 147 | the new version into Chromium. This also avoids duplicate copies of the code |
Jason D. Clinton | b21e99b | 2021-09-30 19:19:58 | [diff] [blame] | 148 | showing up in multiple repos leading to contributor confusion. |
| 149 | 1. This interacts favorably with our upstream tracking automation. We |
| 150 | automatically consume the upstream Git hashes and match them against a |
| 151 | database of known upstreams to tracking drift between Chromium and upstream |
| 152 | sources. |
| 153 | 1. This makes adding deps that don't need local changes easier. E.g. some of |
| 154 | our automation automatically converts non-GN build rules into GN build rules |
| 155 | without any additional CLs. |
| 156 | |
| 157 | Checking in a snapshot is useful if this is effectively taking on maintenance |
| 158 | of an unmaintained project (e.g. an ancient library that we're going to GN-ify |
| 159 | that hasn't been updated in years). And, of course, if the code you need isn't |
| 160 | in a Git repo, then you have to snapshot. |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 161 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 162 | ## Node packages |
Tim van der Lippe | 5870ac3 | 2019-10-18 11:46:54 | [diff] [blame] | 163 | |
| 164 | To include a Node package, add the dependency to the |
| 165 | [Node package.json](../third_party/node/package.json). Make sure to update |
| 166 | the corresponding [`npm_exclude.txt`](../third_party/node/npm_exclude.txt) |
| 167 | and [`npm_include.txt`](../third_party/node/npm_include.txt) to make the code |
| 168 | available during checkout. |
| 169 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 170 | ## Pulling the code via DEPS |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 171 | |
Victor Hugo Vianna Silva | d1e1605 | 2025-05-23 16:33:18 | [diff] [blame] | 172 | See [here](/docs/dependencies.md#adding-dependencies). |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 173 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 174 | ## Checking in the code directly |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 175 | |
Rachael Newitt | cc7ede6 | 2025-05-09 00:36:32 | [diff] [blame] | 176 | If you are checking in a snapshot, you should follow the [standard directory structure](#standard-dep-structure). |
| 177 | For security reasons, please retrieve the code as securely as you can, using |
| 178 | HTTPS and GPG signatures if available. |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 179 | If retrieving a tarball, please do not check the tarball itself into the tree, |
| 180 | but do list the source and the SHA-512 hash (for verification) in the |
| 181 | README.chromium and Change List. The SHA-512 hash can be computed via |
| 182 | `sha512sum` or `openssl dgst -sha512`. If retrieving from a git |
Rachael Newitt | cc7ede6 | 2025-05-09 00:36:32 | [diff] [blame] | 183 | repository, please list the upstream URL and revision that the code was pulled |
| 184 | from. |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 185 | |
| 186 | If you are checking the files in directly, you do not need an entry in DEPS |
David Dorwin | 7fde299b | 2020-09-25 02:10:34 | [diff] [blame] | 187 | and do not need to modify `//third_party/.gitignore`. |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 188 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 189 | ## Checking in large files |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 190 | |
Dirk Pranke | 4038090a | 2024-05-09 01:51:37 | [diff] [blame] | 191 | This is accessible to Googlers only. Non-Googlers can email one of the people |
| 192 | in third_party/OWNERS for help. |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 193 | |
| 194 | See [Moving large files to Google Storage](https://goto.google.com/checking-in-large-files) |
| 195 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 196 | # Standard directory structure for dependencies {standard-dep-structure} |
Rachael Newitt | cc7ede6 | 2025-05-09 00:36:32 | [diff] [blame] | 197 | |
| 198 | Regardless of how you import a dependency, you should use the following |
| 199 | directory structure. This folder layout enforces separation between first and |
| 200 | third party code, making it easier to manage updates and dependency hygiene |
| 201 | long term. |
| 202 | |
| 203 | Any first party code or files you need for dependency management or |
| 204 | interoperability should be added to the top level dependency directory, and the |
| 205 | dependency source imported into the child src directory. |
| 206 | |
| 207 | **Recommended directory structure:** |
| 208 | ``` |
| 209 | ❯ //third_party/<dependency-name> |
| 210 | ├── BUILD.gn |
| 211 | ├── README.chromium |
| 212 | ├── OWNERS |
| 213 | ├── src <-- import third party code here |
| 214 | │ ├── LICENSE |
| 215 | │ ├── a.h |
| 216 | │ └── b.cc |
| 217 | ``` |
| 218 | |
| 219 | **What constitutes a dependency:** |
| 220 | |
| 221 | * A dependency should be sourced from a single upstream location. Putting code |
| 222 | from multiple upstream sources in a single `//third_party` directory makes it |
| 223 | difficult to reason about the origin of files and perform automated updates. |
| 224 | * If your dependency has its own vendored dependencies, it's not necessary to |
| 225 | split these into additional directories. |
| 226 | |
| 227 | **Formatting:** |
| 228 | |
| 229 | Do not reformat or apply Chromium-style formatting to any code within the |
| 230 | dependency `src` directory. Maintaining the original formatting is essential |
| 231 | for generating clean diffs against upstream versions. This simplifies |
| 232 | reviewing upstream changes, applying security patches, and performing updates. |
| 233 | |
| 234 | If you experience issues with submitting a CL due to Chromium formatting |
| 235 | requirements which need to be disabled, or you need to format first party code |
| 236 | in your top level dependency folder, you can add a language appropriate |
| 237 | formatting config (e.g [.clang-format-ignore](https://clang.llvm.org/docs/ClangFormat.html#clang-format-ignore)) |
| 238 | to your top level dependency directory. Ensure it does not format the third |
| 239 | party code. |
| 240 | |
| 241 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 242 | # Document the code's context |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 243 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 244 | ## Add OWNERS |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 245 | |
Dirk Pranke | 6d3bb8e | 2024-05-09 00:54:33 | [diff] [blame] | 246 | Your OWNERS file must either list the email addresses of two Chromium |
| 247 | committers on the first two lines or include a `file:` directive to an OWNERS |
| 248 | file within the `third_party` directory that itself conforms to this criterion. |
| 249 | This will ensure accountability for maintenance of the code over time. While |
| 250 | there isn't always an ideal or obvious set of people that should go in OWNERS, |
| 251 | this is critical for first-line triage of any issues that crop up in the code. |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 252 | |
| 253 | As an OWNER, you're expected to: |
| 254 | |
| 255 | * Remove the dependency when/if it is no longer needed |
| 256 | * Update the dependency when a security or stability bug is fixed upstream |
| 257 | * Help ensure the Chrome feature that uses the dependency continues to use the |
| 258 | dependency in the best way, as the feature and the dependency change over |
| 259 | time. |
| 260 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 261 | # README.chromium |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 262 | |
| 263 | You need a README.chromium file with information about the project from which |
| 264 | you're re-using code. See |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 265 | [//third_party/README.chromium.template](../third_party/README.chromium.template) |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 266 | for a list of fields to include. A presubmit check will check this has the right |
| 267 | format. |
| 268 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 269 | ## Security Critical {#security-critical} |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 270 | README.chromium files contain a field indicating whether the package is |
| 271 | security-critical or not. A package is security-critical if it is compiled |
| 272 | into the product and does any of the following: |
| 273 | |
| 274 | * Accepts untrustworthy inputs from the internet |
| 275 | * Parses or interprets complex input formats |
| 276 | * Sends data to internet servers |
| 277 | * Collects new data |
| 278 | * Influences or sets security-related policy (including the user experience) |
| 279 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 280 | ## Update Mechanism {#update-mechanism} |
Jordan | 9709bae | 2025-05-22 05:46:45 | [diff] [blame] | 281 | |
Jordan Brown | e55af57 | 2025-06-11 00:46:10 | [diff] [blame] | 282 | We aim to eventually autoroll as many dependencies as is feasible, and track those |
| 283 | that can't with an [exception](https://issues.chromium.org/issues/new?component=1801247&template=2135097). |
| 284 | |
| 285 | > We are currently only enforcing exceptions for **'Static'** dependencies. |
| 286 | > New dependencies pulled in via DEPS should be set to **'Manual'**. |
Jordan | 9709bae | 2025-05-22 05:46:45 | [diff] [blame] | 287 | |
| 288 | The `Update Mechanism:` field specifies how this dependency is kept |
| 289 | up-to-date. You will use one of the exact string formats listed below, |
| 290 | replacing `(crbug.com/BUG_ID)` with the actual bug link where required. |
| 291 | The format is `Primary[.SubsetSpecifier] (crbug.com/BUG_ID)`. |
| 292 | |
| 293 | **Accepted Values:** |
| 294 | * `Autoroll` |
| 295 | * `Manual (crbug.com/BUG_ID)` |
| 296 | * `Static (crbug.com/BUG_ID)` |
| 297 | * `Static.HardFork (crbug.com/BUG_ID)` |
| 298 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 299 | |||---||| 3,3,6 |
| 300 | ### Autoroll |
Jordan | 9709bae | 2025-05-22 05:46:45 | [diff] [blame] | 301 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 302 | Updated automatically by a service e.g. Skia Autoroller, Copybara. |
Jordan | 9709bae | 2025-05-22 05:46:45 | [diff] [blame] | 303 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 304 | No exception required. |
Jordan | 9709bae | 2025-05-22 05:46:45 | [diff] [blame] | 305 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 306 | ### Manual |
Jordan | 9709bae | 2025-05-22 05:46:45 | [diff] [blame] | 307 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 308 | Updated manually by OWNERS e.g., using `roll_deps`. |
Jordan | 9709bae | 2025-05-22 05:46:45 | [diff] [blame] | 309 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 310 | No exception required *yet*. |
| 311 | *** note |
| 312 | ### Static / Static.HardFork |
Jordan | 9709bae | 2025-05-22 05:46:45 | [diff] [blame] | 313 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 314 | An exception is required. |
| 315 | |
| 316 | *Changes are authored by Chromium Authors.* |
| 317 | |
| 318 | * **Static**: Origin is not a typical git repo or package manager, or package is |
| 319 | intentionally never updated. |
| 320 | * **Static.HardFork**: Origin is a git repo or package manager, but our version |
| 321 | has diverged from the upstream, and is no longer updatable. |
| 322 | *** |
| 323 | |||---||| |
| 324 | |
| 325 | > To maximise vulnerability scanning coverage, OWNERS should provide a |
| 326 | > revision/version/cpe which represents the closest point of divergence |
| 327 | > from the upstream. This may return some false positives but ensures |
| 328 | > coverage is optimal. |
| 329 | ### Autoroll Exceptions |
Jordan | 9709bae | 2025-05-22 05:46:45 | [diff] [blame] | 330 | |
| 331 | If a dependency can't be autorolled, it needs an exception. OWNERS |
| 332 | should file a bug using the template in |
| 333 | [`Chromium > ThirdParty > Autoroll Exceptions`](https://issues.chromium.org/issues/new?component=1801247&template=2135097). |
| 334 | This component has auto-assignment and will help you track the exception. |
| 335 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 336 | ### Transitive Dependencies |
| 337 | If a child dependency is rolled with a parent, it should specify an |
| 338 | Update Mechanism that is at _most_ as frequently/automated-ly |
| 339 | updated as the parent. |
| 340 | |
| 341 | * If the parent is `Autorolled`, then it could be `Autorolled`, `Manual` or `Static/Static.HardFork`. |
| 342 | * If the parent is `Manual`, then the child can only be `Manual` or `Static/Static.HardFork`. |
| 343 | * If the parent is `Static/Static.HardFork` then it must be `Static/Static.HardFork`. |
| 344 | |
| 345 | ## CPE Prefix |
Adrian Taylor | 0a06ec3 | 2020-03-03 05:00:07 | [diff] [blame] | 346 | One of the fields is CPEPrefix. This is used by Chromium and Google systems to |
| 347 | spot known upstream security vulnerabilities, and ensure we merge the fixes |
| 348 | into our third-party copy. These systems are not foolproof, so as the OWNER, |
| 349 | it's up to you to keep an eye out rather than solely relying on these |
| 350 | automated systems. But, adding CPEs decreases the chances of us missing |
| 351 | vulnerabilities, so they should always be added if possible. |
| 352 | |
| 353 | The CPE is a common format shared across the industry; you can look up the CPE |
Anne Redulla | 04f9197 | 2023-08-31 04:09:19 | [diff] [blame] | 354 | for your package [here](https://nvd.nist.gov/products/cpe/search). |
| 355 | * Use CPE format 2.3 (preferred) or CPE format 2.2 (supported). |
| 356 | * If the CPE uses the 2.3 URI binding or 2.2 format (i.e. starts with "cpe:/"), |
| 357 | and no version is explicitly specified within the `CPEPrefix`, the `Version` |
| 358 | in the `README.chromium` file will be appended to the `CPEPrefix`, if available. |
| 359 | * Note: if the `Version` field is set to a git hash value, version matching |
| 360 | for vulnerabilities will fail. |
| 361 | |
| 362 | When searching for a CPE, you may find that there is not yet a CPE for the |
| 363 | specific upstream version you're using. This is normal, as CPEs are typically |
| 364 | allocated only when a vulnerability is found. You should follow the version |
| 365 | number convention such that, when that does occur in future, we'll be notified. |
| 366 | If no CPE is available, please specify "unknown". |
Adrian Taylor | 0a06ec3 | 2020-03-03 05:00:07 | [diff] [blame] | 367 | |
Adrian Taylor | 8e0d3fd | 2020-04-17 20:14:25 | [diff] [blame] | 368 | If you're using a patched or modified version which is halfway between two |
| 369 | public versions, please "round downwards" to the lower of the public versions |
| 370 | (it's better for us to be notified of false-positive vulnerabilities than |
| 371 | false-negatives). |
Adrian Taylor | 0a06ec3 | 2020-03-03 05:00:07 | [diff] [blame] | 372 | |
Rachael Newitt | fc2e334 | 2023-07-04 23:07:31 | [diff] [blame] | 373 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 374 | ## Shipped |
Rachael Newitt | fc2e334 | 2023-07-04 23:07:31 | [diff] [blame] | 375 | Your README.chromium should also specify whether your third party dependency |
| 376 | will be shipped as part of a final binary. The "Shipped" field replaces the now |
| 377 | deprecated special value of "NOT_SHIPPED" which was previously allowed in the |
Rachael Newitt | f3531fd | 2024-09-26 03:37:41 | [diff] [blame] | 378 | "License File" field. This use is no longer supported and all third party |
| 379 | dependencies must include a valid license regardless of whether it is shipped |
| 380 | or not. |
Rachael Newitt | fc2e334 | 2023-07-04 23:07:31 | [diff] [blame] | 381 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 382 | ## License |
| 383 | #### Add a LICENSE file and run related checks |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 384 | |
| 385 | You need a LICENSE file. Example: |
Rachael Newitt | f3531fd | 2024-09-26 03:37:41 | [diff] [blame] | 386 | [//third_party/libjpeg/LICENSE](../third_party/libjpeg/LICENSE). Dependencies |
| 387 | should not be added without a license file and license type, even if they are |
| 388 | not shipped in a final product. Existing dependencies without a license file or |
| 389 | license type are currently being cleaned up as part of the metadata uplift |
| 390 | effort. If you are an OWNER of a dependency missing license fields, there will |
| 391 | soon be a bug filed to fix it. |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 392 | |
Andrew Mellen | 2be00b9 | 2022-11-11 16:38:42 | [diff] [blame] | 393 | Run `//tools/licenses/licenses.py scan`; this will complain about incomplete or missing |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 394 | data for third_party checkins. We use `licenses.py credits` to generate the |
| 395 | about:credits page in Google Chrome builds. |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 396 | |
| 397 | If the library will never be shipped as a part of Chrome (e.g. build-time tools, |
Rachael Newitt | fc2e334 | 2023-07-04 23:07:31 | [diff] [blame] | 398 | testing tools), make sure to set the "Shipped" field to "no" so that the license |
Rachael Newitt | 1554699 | 2023-09-17 22:13:09 | [diff] [blame] | 399 | is not included in about:credits page ([more on this below](#credits)). |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 400 | |
Jordan Brown | 77ce40f | 2024-12-10 00:31:13 | [diff] [blame] | 401 | When a dependency allows a choice of license, OWNERS should choose the least |
| 402 | restrictive license that meets Chromium's needs and document only the chosen |
| 403 | license(s) in the README.chromium file. |
| 404 | |
| 405 | Multiple licenses apply when there are dependencies bundled together, or |
| 406 | different parts have different restrictions, these are inherently 'and'. This is |
| 407 | very different to a project allowing multiple license options. |
| 408 | |
Jordan Brown | e9acbe7 | 2025-01-12 22:07:34 | [diff] [blame] | 409 | The `License:` field in README.chromium must use a _comma-separated list_ of licenses |
Jordan Brown | 77ce40f | 2024-12-10 00:31:13 | [diff] [blame] | 410 | that are actively in use. Complex license expressions are not allowed or |
| 411 | supported. |
| 412 | |
Jordan Brown | e9acbe7 | 2025-01-12 22:07:34 | [diff] [blame] | 413 | Use SPDX license identifiers (https://spdx.org/licenses/) when possible e.g. |
| 414 | ['Apache-2.0'](https://spdx.org/licenses/Apache-2.0.html). You can find the full |
| 415 | allowlist in |
| 416 | [depot_tools/+/main:metadata/fields/custom/license_allowlist.py](https://source.chromium.org/chromium/chromium/tools/depot_tools/+/main:metadata/fields/custom/license_allowlist.py). |
| 417 | If the dependency uses a license that is not in the allowlist, you will need to |
| 418 | add it to the |
| 419 | [allowlist](https://source.chromium.org/chromium/chromium/tools/depot_tools/+/main:metadata/fields/custom/license_allowlist.py). |
| 420 | This requires approval from the ATLs who will check that the license |
| 421 | classification is one of [unencumbered/permissive/notice/reciprocal]. If the |
| 422 | license is more restrictive than reciprocal, engage with the ATLs to determine |
| 423 | if the dependency is appropriate for Chromium. The license identifier will still |
| 424 | need to be added to the restricted list |
| 425 | ['WITH_PERMISSION_ONLY'](https://source.chromium.org/chromium/chromium/tools/depot_tools/+/main:metadata/fields/custom/license_allowlist.py). |
| 426 | Do not use a license on that list without approval from the ATLs. |
| 427 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 428 | ### License Classifications |
Jordan Brown | e9acbe7 | 2025-01-12 22:07:34 | [diff] [blame] | 429 | |
| 430 | Licenses used in our codebase fall into several categories of increasing |
| 431 | restrictiveness, with notice-level and less restrictive licenses being allowed |
| 432 | in all projects: |
| 433 | |
| 434 | * **Public Domain/Unencumbered/Permissive Licenses** - These licenses allow |
| 435 | you to do almost anything with the code, they may require attribution e.g.: |
| 436 | * [CC0-1.0](https://spdx.org/licenses/CC0-1.0.html). |
| 437 | * [Unlicense](https://spdx.org/licenses/Unlicense.html). |
| 438 | * **Notice Licenses** - (Most open source licenses fall into this category) |
| 439 | These licenses are similar to permissive but have additional notice |
| 440 | requirements e.g.: |
| 441 | * [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html): [`Any modified files |
| 442 | must carry prominent notices stating that you changed the |
| 443 | files`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/catapult/third_party/coverage/LICENSE.txt;l=98). |
| 444 | * [BSD-3-Clause](https://spdx.org/licenses/BSD-3-Clause): [`3. Neither the |
| 445 | name of the copyright holder nor the names of its contributors may be |
| 446 | used to endorse or promote products derived from this software without |
| 447 | specific prior written |
| 448 | permission.`](https://source.chromium.org/chromium/chromium/src/+/main:ios/third_party/fishhook/LICENSE;drc=1308ce89bbb959047a73145a0ca4a2f5f7dde894;l=10). |
| 449 | |
| 450 | Additionally, open source projects like Chromium are also allowed to use reciprocal licenses: |
| 451 | |
| 452 | * **Reciprocal Licenses** - These licenses require sharing modifications under |
| 453 | the same terms: |
| 454 | |
| 455 | * [MPL-1.1](https://spdx.org/licenses/MPL-1.1.html). |
| 456 | * [APSL-2.0](https://spdx.org/licenses/APSL-2.0.html). |
| 457 | |
| 458 | * **Restricted Licenses !Case-by-case Approval Required!** - These licenses |
| 459 | have stricter requirements but are allowed in some circumstances. These |
| 460 | licenses may require you to publish the code under the same terms and |
| 461 | conditions: |
| 462 | |
| 463 | * [LGPL-2.1](https://spdx.org/licenses/LGPL-2.1.html). |
| 464 | * [GPL-2.0](https://spdx.org/licenses/GPL-2.0.html). |
| 465 | |
| 466 | Make sure you understand the license terms before checking in a dependency, and |
| 467 | when making any local modifications or forks. |
| 468 | |
Jordan Brown | 09c138a | 2025-02-05 03:42:27 | [diff] [blame] | 469 | The following restricted licenses are allowed under the following circumstances |
| 470 | (this is not a definitive list): |
| 471 | |
| 472 | * GPL licenses are allowed for all non-shipped dependencies. |
| 473 | * LGPLv2.1 is always okay as long as it is part of the Chromium binary. |
| 474 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 475 | ## Multiple packages |
| 476 | Adding multiple packages in a single third party directory is not recommended, |
| 477 | because it does not follow the best practices for [third party dependency structure](#standard-dep-structure) |
| 478 | and complicates vulnerability scanning. |
| 479 | |
| 480 | Each dependency should have its own third party directory with a few very |
| 481 | limited exceptions: |
| 482 | * A package manager is used to manage dependencies in the directory via a lockfile. |
| 483 | * Your third party dependency has its own vendored transitive dependencies |
| 484 | |
| 485 | If your dependency is covered by one of the above exceptions and the information |
| 486 | for multiple packages must be placed in a single README.chromium, use the below |
| 487 | line to separate the data for each package: |
| 488 | ``` |
| 489 | -------------------- DEPENDENCY DIVIDER -------------------- |
| 490 | ``` |
| 491 | |
| 492 | # Get a review |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 493 | |
Aaron Gable | fc8cdad | 2018-01-16 21:02:40 | [diff] [blame] | 494 | All third party additions and substantive changes like re-licensing need the |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 495 | following sign-offs. Some of these are accessible to Googlers only. |
| 496 | Non-Googlers can email one of the people in |
| 497 | [//third_party/OWNERS](../third_party/OWNERS) for help. |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 498 | |
John Abd-El-Malek | 704bca0 | 2022-12-14 18:47:59 | [diff] [blame] | 499 | * Make sure you have the approval from Chrome ATLs as mentioned |
Tim van der Lippe | 8c749839 | 2019-10-28 12:21:04 | [diff] [blame] | 500 | [above](#before-you-start). |
Alex Rudenko | f712a7f | 2022-02-23 17:55:36 | [diff] [blame] | 501 | * Get [email protected] (or [email protected], Google-only) |
Jordan Brown | a376e32 | 2024-12-23 00:25:27 | [diff] [blame] | 502 | approval. Document all security considerations, concerns, and risks in the |
| 503 | `Description:` field of the README.chromium. Third party code is a hot spot |
| 504 | for security vulnerabilities. Help people make informed decisions about |
| 505 | relying on this package by highlighting security considerations. |
Dirk Pranke | 6fb90c0 | 2018-10-17 02:02:20 | [diff] [blame] | 506 | * Add [email protected] as a reviewer on your change. This |
Adam Langley | 88658b3 | 2018-11-20 22:12:47 | [diff] [blame] | 507 | will trigger an automatic round-robin assignment to a reviewer who will check |
| 508 | licensing matters. These reviewers may not be able to +1 a change so look for |
| 509 | verbal approval in the comments. (This list does not receive or deliver |
| 510 | email, so only use it as a reviewer, not for other communication. Internally, |
Michael Cui | 5d51775 | 2022-11-01 14:11:32 | [diff] [blame] | 511 | see [cl/221704656](http://cl/221704656) for details about how |
Dirk Pranke | f743281 | 2020-06-10 22:38:20 | [diff] [blame] | 512 | this is configured.). If you have questions about the third-party process, |
| 513 | ask one of the [//third_party/OWNERS](../third_party/OWNERS) instead. |
Adam Langley | 88658b3 | 2018-11-20 22:12:47 | [diff] [blame] | 514 | * Lastly, if all other steps are complete, get a positive code review from a |
| 515 | member of [//third_party/OWNERS](../third_party/OWNERS) to land the change. |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 516 | |
John Abd-El-Malek | 704bca0 | 2022-12-14 18:47:59 | [diff] [blame] | 517 | Please send separate emails to the ATLs and [email protected]. |
| 518 | You can skip the ATL review and [email protected] when you are only moving |
Kentaro Hara | cd32834 | 2022-02-25 08:25:44 | [diff] [blame] | 519 | existing directories in Chromium to //third_party/. |
jochen | 893d518 | 2017-01-31 22:01:49 | [diff] [blame] | 520 | |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 521 | Subsequent changes don't normally require third-party-owners or security |
| 522 | approval; you can modify the code as much as you want. When you update code, be |
| 523 | mindful of security-related mailing lists for the project and relevant CVE to |
| 524 | update your package. |
Dirk Pranke | bf4136b | 2018-09-20 22:48:43 | [diff] [blame] | 525 | |
Jordan Brown | 9a12a0d | 2025-06-12 08:07:49 | [diff] [blame] | 526 | # How we ensure that the right credits are displayed {#credits} |
Dirk Pranke | bf4136b | 2018-09-20 22:48:43 | [diff] [blame] | 527 | |
| 528 | As we said at the beginning, it is important that Chrome displays the |
| 529 | right credit and attributions for all of the third_party code we use. |
| 530 | |
| 531 | To view this in chrome, you can open chrome://credits. |
| 532 | |
| 533 | That page displays a resource embedded in the browser as part of the |
| 534 | [//components/resources/components_resources.grd](../components/resources/components_resource.grd) |
| 535 | GRIT file; the actual HTML text is generated in the |
| 536 | [//components/resources:about_credits](../components/resources/BUILD.gn) |
| 537 | build target using a template from the output of the |
Rachael Newitt | fc2e334 | 2023-07-04 23:07:31 | [diff] [blame] | 538 | [//tools/licenses/licenses.py](../tools/licenses/licenses.py) script. Assuming |
| 539 | you‘ve followed the rules above to ensure that you have the proper path to the |
| 540 | LICENSE file and set the Shipped value, if it passes the checks, it’ll be |
| 541 | included automatically. |