Tobias Nießen
e673c03629
policy: use tamper-proof integrity check function
...
Using the JavaScript Hash class is unsafe because its internals can be
tampered with. In particular, an application can cause
Hash.prototype.digest() to return arbitrary values, thus allowing to
circumvent the integrity verification that policies are supposed to
guarantee.
Add and use a new C++ binding internalVerifyIntegrity() that (hopefully)
cannot be tampered with from JavaScript.
PR-URL: https://github.com/nodejs-private/node-private/pull/462
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
CVE-ID: CVE-2023-38552
2023-10-13 18:03:19 -03:00
Moshe Atlow
9658d84ddd
tools: fix jsdoc lint
...
PR-URL: https://github.com/nodejs/node/pull/47789
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Mestery <mestery@protonmail.com >
2023-05-02 00:48:20 +00:00
Antoine du Hamel
cbcefdf253
lib: enforce use of trailing commas in more files
...
Some part of the codebase already use trailing commas, this commit is
adding a lint rule to ensure it stays this way.
This commit also adds the rule for a few files that were missing only
one or two trailing commas.
PR-URL: https://github.com/nodejs/node/pull/46655
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
2023-02-16 18:47:24 +01:00
Antoine du Hamel
fe514bf960
lib: enforce use of trailing commas for functions
...
PR-URL: https://github.com/nodejs/node/pull/46629
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
2023-02-14 18:45:16 +01:00
Jordan Harband
757c104147
tools: add prefer-proto rule
...
fixup: add support for `Object.create(null)`
fixup: extend to any 1-argument Object.create call
fixup: add tests
PR-URL: https://github.com/nodejs/node/pull/46083
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2023-01-10 05:38:36 +00:00
Joyee Cheung
be525d7d04
src: consolidate exit codes in the code base
...
Add an ExitCode enum class and use it throughout the code base
instead of hard-coding the exit codes everywhere. At the moment,
the exit codes used in many places do not actually conform to
what the documentation describes. With the new enums (which
are also available to the JS land as constants in an internal
binding) we could migrate to a more consistent usage of the
codes, and eventually expose the constants to the user land
when they are stable enough.
PR-URL: https://github.com/nodejs/node/pull/44746
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
2022-10-06 12:41:16 +00:00
Antoine du Hamel
a055337a02
lib: refactor to avoid unsafe regex primordials
...
PR-URL: https://github.com/nodejs/node/pull/43475
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
2022-06-27 17:16:06 +02:00
Antoine du Hamel
06d8606960
lib: use null-prototype objects for property descriptors
...
Refs: https://github.com/nodejs/node/pull/42921
PR-URL: https://github.com/nodejs/node/pull/43270
Reviewed-By: Paolo Insogna <paolo@cowtech.it >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com >
2022-06-03 09:23:58 +01:00
ceadb473e6
esm: support https remotely and http locally under flag
...
Co-authored-by: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com >
Co-authored-by: James M Snell <jasnell@gmail.com >
Co-authored-by: Jordan Harband <ljharb@gmail.com >
Co-authored-by: James Sumners <james@sumners.email >
PR-URL: https://github.com/nodejs/node/pull/36328
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
2022-02-09 19:47:12 -08:00
Rich Trott
a02099b9f2
policy: revise manifest.js to avoid empty blocks
...
PR-URL: https://github.com/nodejs/node/pull/41831
Refs: https://eslint.org/docs/rules/no-empty
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-02-05 12:58:31 +00:00
Rich Trott
78a2cd8624
lib: add comments to empty catch statements
...
PR-URL: https://github.com/nodejs/node/pull/41831
Refs: https://eslint.org/docs/rules/no-empty
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-02-05 12:58:30 +00:00
Rich Trott
0bc642202f
policy: check for null instead of falsy in loop
...
This prepares the code for the no-cond-assign ESLint rule.
PR-URL: https://github.com/nodejs/node/pull/41614
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2022-01-22 19:38:07 -08:00
Mohammed Keyvanzadeh
a1f827a859
policy: replace entries with keys
...
Replaced the entries with keys since the values of the entries are not
used, and changed loop style to avoid mangled `Symbol.iterator`s and
to keep consistency.
PR-URL: https://github.com/nodejs/node/pull/41482
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2022-01-17 22:56:11 +00:00
Rich Trott
73d2d90122
policy: add missing JSDoc @param entry
...
PR-URL: https://github.com/nodejs/node/pull/41239
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2021-12-21 17:53:39 +00:00
Rich Trott
070b54a4ac
policy: fix message for invalid manifest specifier
...
Add test for invalid manifest specifier and fix the error message
which is missing a space ("singletrailing" instead of
"single trailing").
PR-URL: https://github.com/nodejs/node/pull/40574
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Voltrex <mohammadkeyvanzade94@gmail.com >
2021-10-24 22:41:28 -07:00
90e2e78763
policy: canonicalize before resolving specifiers
...
PR-URL: https://github.com/nodejs/node/pull/37863
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com >
Co-authored-by: James M Snell <jasnell@gmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
2021-08-19 12:43:21 -05:00
Tobias Nießen
fdce138e1d
policy: fix integrity when DEFAULT_ENCODING is set
...
PR-URL: https://github.com/nodejs/node/pull/39750
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-08-15 11:10:12 -07:00
Antoine du Hamel
f34d8de65a
lib: remove use of array destructuring
...
PR-URL: https://github.com/nodejs/node/pull/36818
Reviewed-By: Rich Trott <rtrott@gmail.com >
2021-03-03 19:53:24 +01:00
Bradley Farias and James M Snell
f24e70736f
policy: fix cascade getting scope
...
PR-URL: https://github.com/nodejs/node/pull/37298
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Co-authored-by: James M Snell <jasnell@gmail.com >
2021-02-15 16:04:58 -06:00
Antoine du Hamel
b4c2ff5a3b
policy: refactor to use more primordials
...
PR-URL: https://github.com/nodejs/node/pull/36210
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
2020-11-27 17:19:30 +00:00
Bradley Farias
4234904232
policy: implement scopes field
...
PR-URL: https://github.com/nodejs/node/pull/34552
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-08-26 14:35:34 -05:00
Bradley Farias
e155d96014
policy: support conditions for redirects
...
PR-URL: https://github.com/nodejs/node/pull/34414
Reviewed-By: Jan Krems <jan.krems@gmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
2020-08-13 13:17:40 -05:00
sapics
50bc7adcf7
lib: simplify assignment
...
PR-URL: https://github.com/nodejs/node/pull/33718
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2020-07-20 18:22:12 +02:00
Bradley Farias
66810a0d47
policy: add startup benchmark and make SRI lazier
...
PR-URL: https://github.com/nodejs/node/pull/29527
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-07-14 13:03:04 -05:00
Brian White
c24b74a7ab
lib: improve debuglog() performance
...
PR-URL: https://github.com/nodejs/node/pull/32260
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-05-30 17:24:43 -04:00
Luigi Pinca
b533fb3508
tools: enable no-else-return lint rule
...
Refs: https://github.com/nodejs/node/pull/32644
Refs: https://github.com/nodejs/node/pull/32662
PR-URL: https://github.com/nodejs/node/pull/32667
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2020-05-16 06:42:16 +02:00
Sebastien Ahkrin
a494d12723
lib: add RegExp primordials
...
PR-URL: https://github.com/nodejs/node/pull/31208
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2020-01-07 19:26:15 -08:00
Michaël Zasso
141a6e34ee
lib: enforce use of Array from primordials
...
PR-URL: https://github.com/nodejs/node/pull/30635
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2019-11-27 19:29:01 +01:00
Michaël Zasso
0646eda4fc
lib: flatten access to primordials
...
Store all primordials as properties of the primordials object.
Static functions are prefixed by the constructor's name and prototype
methods are prefixed by the constructor's name followed by "Prototype".
For example: primordials.Object.keys becomes primordials.ObjectKeys.
PR-URL: https://github.com/nodejs/node/pull/30610
Refs: https://github.com/nodejs/node/issues/29766
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2019-11-25 10:28:15 +01:00
Semir Ajruli
dfbdfb4d32
lib: use let instead of var
...
use let instead of var for lib/internal/policy/manifest.js
PR-URL: https://github.com/nodejs/node/pull/30424
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2019-11-25 11:41:29 +05:30
Bradley Farias
6ce87c027d
policy: minor perf opts and cleanup
...
PR-URL: https://github.com/nodejs/node/pull/29322
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-09-03 11:12:05 -05:00
Bradley Farias
7e8ad9bad8
policy: add dependencies map for resources
...
Adds a "dependencies" field to resources in policy manifest files.
In order to ease development and testing while using manifests,
wildcard values for both "dependencies" and "integrity" have been
added using the boolean value "true" in the policy manifest.
PR-URL: https://github.com/nodejs/node/pull/28767
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Jan Krems <jan.krems@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2019-07-26 15:13:53 -05:00
Michaël Zasso
112cc7c275
lib: use safe methods from primordials
...
This changes the primordials to expose built-in prototypes with their
methods already uncurried.
The uncurryThis function is therefore moved to the primordials.
All uses of uncurryThis on built-ins are changed to import the relevant
prototypes from primordials.
All uses of Function.call.bind are also changed to use primordials.
PR-URL: https://github.com/nodejs/node/pull/27096
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2019-04-08 11:23:09 +02:00
Jesse Katsumata
afdadbcff5
policy: reduce internal usage of public util for manifest.js
...
PR-URL: https://github.com/nodejs/node/pull/26833
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Masashi Hirano <shisama07@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2019-03-23 13:25:42 +08:00
Joyee Cheung
b44131ab92
lib: use internal/options to query --abort-on-uncaught-exception
...
Instead of using
`internalBinding('config').shouldAbortOnUncaughtException`.
Also removes that property from the binding.
PR-URL: https://github.com/nodejs/node/pull/25862
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2019-02-08 08:09:56 +08:00
Joyee Cheung
39d922123c
lib: save primordials during bootstrap and use it in builtins
...
This patches changes the `safe_globals` internal module into a
script that gets run during bootstrap and saves JavaScript builtins
(primordials) into an object that is available for all other builtin
modules to access lexically later.
PR-URL: https://github.com/nodejs/node/pull/25816
Refs: https://github.com/nodejs/node/issues/18795
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Gus Caplan <me@gus.host >
2019-02-02 05:40:47 +08:00
Anna Henningsen
0f5c14c43e
lib: refactor policy code for readability
...
Simplify a few particularly quirky bits of code, and add
whitespace for readability.
PR-URL: https://github.com/nodejs/node/pull/25629
Reviewed-By: Denys Otrishko <shishugi@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com >
2019-01-25 07:24:22 +01:00
Bradley Farias
9d5fbeb55f
policy: manifest with subresource integrity checks
...
This enables code loaded via the module system to be checked for
integrity to ensure the code loaded matches expectations.
PR-URL: https://github.com/nodejs/node/pull/23834
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2019-01-17 09:43:42 -06:00