blob: 94b6f0160b652747c7124fdd4b9be0d82b8187a0 [file] [log] [blame] [view]
zpeng8d6f584a2016-12-16 20:50:281# Adding third_party Libraries
2
3[TOC]
4
5Using third party code can save time and is consistent with our values - no need
6to reinvent the wheel! We put all code that isn't written by Chromium developers
Dirk Pranke568e95c2018-11-01 23:41:507into `//third_party` (even if you end up modifying just a few functions). We do
zpeng8d6f584a2016-12-16 20:50:288this to make it easy to track license compliance, security patches, and supply
9the right credit and attributions. It also makes it a lot easier for other
10projects that embed our code to track what is Chromium licensed and what is
11covered by other licenses.
12
Dirk Pranke568e95c2018-11-01 23:41:5013## Put the code in //third_party
zpeng8d6f584a2016-12-16 20:50:2814
Dirk Pranke568e95c2018-11-01 23:41:5015By default, all code should be checked into [//third_party](../third_party/),
16for the reasons given above. Other locations are only appropriate in a few
17situations and need explicit approval; don't assume that because there's some
18other directory with third_party in the name it's okay to put new things
19there.
zpeng8d6f584a2016-12-16 20:50:2820
Tim van der Lippe5870ac32019-10-18 11:46:5421## Before you start
22
23To make sure the inclusion of a new third_party project makes sense for the
24Chromium project, you should first obtain Chrome Eng Review approval.
25Googlers should see go/chrome-eng-review and review existing topics in
26g/chrome-eng-review. Please include information about the additional checkout
John Abd-El-Malek988e2c02020-08-18 04:49:2427size, build times, and binary size increase of
28[official](https://www.chromium.org/developers/gn-build-configuration) builds
29on Android and one desktop platform. Please also make sure that the motivation
Tim van der Lippe5870ac32019-10-18 11:46:5430for your project is clear, e.g., a design doc has been circulated.
31
Dirk Pranke568e95c2018-11-01 23:41:5032## Get the code
zpeng8d6f584a2016-12-16 20:50:2833
Dirk Pranke568e95c2018-11-01 23:41:5034There are two common ways to depend on third-party code: you can reference a
35Git repo directly (via entries in the DEPS file), or you can check in a
36snapshot. The former is preferable if you are actively developing in it or need
37access to the history; the latter is better if you don't need the full history
38of the repo or don't need to pick up every single change. And, of course, if
39the code you need isn't in a Git repo, you have to do the latter.
zpeng8d6f584a2016-12-16 20:50:2840
Tim van der Lippe5870ac32019-10-18 11:46:5441### Node packages
42
43To include a Node package, add the dependency to the
44[Node package.json](../third_party/node/package.json). Make sure to update
45the corresponding [`npm_exclude.txt`](../third_party/node/npm_exclude.txt)
46and [`npm_include.txt`](../third_party/node/npm_include.txt) to make the code
47available during checkout.
48
Dirk Pranke568e95c2018-11-01 23:41:5049### Pulling the code via DEPS
50
51If the code is in a Git repo that you want to mirror, please file an [infra git
52ticket](https://bugs.chromium.org/p/chromium/issues/entry?template=Infra-Git)
53to get the repo mirrored onto chromium.googlesource.com; we don't allow direct
54dependencies on non-Google-hosted repositories, so that we can still build
55if an external repository goes down..
56
57Once the mirror is set up, add an entry to [//DEPS](../DEPS) so that gclient
58will pull it in. If the code is only needed on some platforms, add a condition
59to the deps entry so that developers on other platforms don't pull in things
60they don't need.
61
62As for specifying the path where the library is fetched, a path like
63`//third_party/<project_name>/src` is highly recommended so that you can put
64the file like OWNERS or README.chromium at `//third_party/<project_name>`. If
65you have a wrong path in DEPS and want to change the path of the existing
66library in DEPS, please ask the infrastructure team before committing the
67change.
68
69Lastly, add the new directory to Chromium's `//.gitignore`, so that it won't
70show up as untracked files when you run `git status` on the main repository.
71
72### Checking in the code directly
73
74If you are checking in a snapshot, please describe the source in the
75README.chromium file, described below. For security reasons, please retrieve
76the code as securely as you can, using HTTPS and GPG signatures if available.
77If retrieving a tarball, please do not check the tarball itself into the tree,
78but do list the source and the SHA-512 hash (for verification) in the
79README.chromium and Change List. The SHA-512 hash can be computed via
80`sha512sum` or `openssl dgst -sha512`. If retrieving from a git
81repository, please list the revision that the code was pulled from.
82
83If you are checking the files in directly, you do not need an entry in DEPS
84and do not need to modify `//.gitignore`.
85
86### Checking in large files
87
88_Accessible to Googlers only. Non-Googlers can email one of the people in
89third_party/OWNERS for help.
90
91See [Moving large files to Google Storage](https://goto.google.com/checking-in-large-files)
92
93## Document the code's context
zpeng8d6f584a2016-12-16 20:50:2894
95### Add OWNERS
96
Forrest Fleming80f70212020-07-01 00:13:5097Your OWNERS file must either list two Chromium developer accounts as the first
98two lines or include a `file:` directive to an OWNERS file within the
99`third_party` directory that itself conforms to this criterion. This will ensure
zpeng8d6f584a2016-12-16 20:50:28100accountability for maintenance of the code over time. While there isn't always
101an ideal or obvious set of people that should go in OWNERS, this is critical for
102first-line triage of any issues that crop up in the code.
103
104As an OWNER, you're expected to:
105
106* Remove the dependency when/if it is no longer needed
107* Update the dependency when a security or stability bug is fixed upstream
108* Help ensure the Chrome feature that uses the dependency continues to use the
109 dependency in the best way, as the feature and the dependency change over
110 time.
111
112### Add a README.chromium
113
114You need a README.chromium file with information about the project from which
115you're re-using code. See
Dirk Pranke568e95c2018-11-01 23:41:50116[//third_party/README.chromium.template](../third_party/README.chromium.template)
zpeng8d6f584a2016-12-16 20:50:28117for a list of fields to include. A presubmit check will check this has the right
118format.
119
Dirk Pranke568e95c2018-11-01 23:41:50120README.chromium files contain a field indicating whether the package is
121security-critical or not. A package is security-critical if it is compiled
122into the product and does any of the following:
123
124* Accepts untrustworthy inputs from the internet
125* Parses or interprets complex input formats
126* Sends data to internet servers
127* Collects new data
128* Influences or sets security-related policy (including the user experience)
129
Adrian Taylor0a06ec32020-03-03 05:00:07130One of the fields is CPEPrefix. This is used by Chromium and Google systems to
131spot known upstream security vulnerabilities, and ensure we merge the fixes
132into our third-party copy. These systems are not foolproof, so as the OWNER,
133it's up to you to keep an eye out rather than solely relying on these
134automated systems. But, adding CPEs decreases the chances of us missing
135vulnerabilities, so they should always be added if possible.
136
137The CPE is a common format shared across the industry; you can look up the CPE
138for your package [here](https://nvd.nist.gov/products/cpe/search). Please use
139CPE format 2.2. When searching for a CPE, you may find that there is not yet
140a CPE for the specific upstream version you're using. This is normal, as CPEs
141are typically allocated only when a vulnerability is found. You should follow
142the version number convention such that, when that does occur in future, we'll
143be notified. If no CPE is available, please specify "unknown".
144
Adrian Taylor8e0d3fd2020-04-17 20:14:25145If you're using a patched or modified version which is halfway between two
146public versions, please "round downwards" to the lower of the public versions
147(it's better for us to be notified of false-positive vulnerabilities than
148false-negatives).
Adrian Taylor0a06ec32020-03-03 05:00:07149
zpeng8d6f584a2016-12-16 20:50:28150### Add a LICENSE file and run related checks
151
152You need a LICENSE file. Example:
Dirk Pranke568e95c2018-11-01 23:41:50153[//third_party/libjpeg/LICENSE](../third_party/libjpeg/LICENSE).
zpeng8d6f584a2016-12-16 20:50:28154
Dirk Pranke568e95c2018-11-01 23:41:50155Run `//tools/licenses.py scan`; this will complain about incomplete or missing
156data for third_party checkins. We use `licenses.py credits` to generate the
157about:credits page in Google Chrome builds.
zpeng8d6f584a2016-12-16 20:50:28158
159If the library will never be shipped as a part of Chrome (e.g. build-time tools,
160testing tools), make sure to set "License File" as "NOT_SHIPPED" so that the
Dirk Prankebf4136b2018-09-20 22:48:43161license is not included in about:credits page ([more on this below](#credits)).
zpeng8d6f584a2016-12-16 20:50:28162
Dirk Pranke568e95c2018-11-01 23:41:50163## Get a review
zpeng8d6f584a2016-12-16 20:50:28164
Aaron Gablefc8cdad2018-01-16 21:02:40165All third party additions and substantive changes like re-licensing need the
Dirk Pranke568e95c2018-11-01 23:41:50166following sign-offs. Some of these are accessible to Googlers only.
167Non-Googlers can email one of the people in
168[//third_party/OWNERS](../third_party/OWNERS) for help.
zpeng8d6f584a2016-12-16 20:50:28169
Tim van der Lippe8c7498392019-10-28 12:21:04170* Make sure you have the approval from Chrome Eng Review as mentioned
171 [above](#before-you-start).
Aaron Gablefc8cdad2018-01-16 21:02:40172* Get security@chromium.org approval. Email the list with relevant details and
173 a link to the CL. Third party code is a hot spot for security vulnerabilities.
174 When adding a new package that could potentially carry security risk, make
175 sure to highlight risk to security@chromium.org. You may be asked to add
176 a README.security or, in dangerous cases, README.SECURITY.URGENTLY file.
Dirk Pranke6fb90c02018-10-17 02:02:20177* Add chromium-third-party@google.com as a reviewer on your change. This
Adam Langley88658b32018-11-20 22:12:47178 will trigger an automatic round-robin assignment to a reviewer who will check
179 licensing matters. These reviewers may not be able to +1 a change so look for
180 verbal approval in the comments. (This list does not receive or deliver
181 email, so only use it as a reviewer, not for other communication. Internally,
Dirk Prankef7432812020-06-10 22:38:20182 see [cl/221704656](https://cl/221704656) for details about how
183 this is configured.). If you have questions about the third-party process,
184 ask one of the [//third_party/OWNERS](../third_party/OWNERS) instead.
Adam Langley88658b32018-11-20 22:12:47185* Lastly, if all other steps are complete, get a positive code review from a
186 member of [//third_party/OWNERS](../third_party/OWNERS) to land the change.
zpeng8d6f584a2016-12-16 20:50:28187
Dirk Pranke6fb90c02018-10-17 02:02:20188Please send separate emails to the eng review and security lists.
jochen893d5182017-01-31 22:01:49189
Dirk Pranke568e95c2018-11-01 23:41:50190Subsequent changes don't normally require third-party-owners or security
191approval; you can modify the code as much as you want. When you update code, be
192mindful of security-related mailing lists for the project and relevant CVE to
193update your package.
Dirk Prankebf4136b2018-09-20 22:48:43194
195## How we ensure that the right credits are displayed {#credits}
196
197As we said at the beginning, it is important that Chrome displays the
198right credit and attributions for all of the third_party code we use.
199
200To view this in chrome, you can open chrome://credits.
201
202That page displays a resource embedded in the browser as part of the
203[//components/resources/components_resources.grd](../components/resources/components_resource.grd)
204GRIT file; the actual HTML text is generated in the
205[//components/resources:about_credits](../components/resources/BUILD.gn)
206build target using a template from the output of the
207[//tools/licenses.py](../tools/licenses.py) script. Assuming you've followed
208the rules above to ensure that you have the proper LICENSE file and it passes
209the checks, it'll be included automatically.