Skip to content

Commit

Permalink
Replace ffi-napi and ref-napi with forks
Browse files Browse the repository at this point in the history
Electron 21 enabled V8 sandboxed pointers, following Chrome's decision to do the same in Chrome 103. This has some implications for native modules, namely ArrayBuffers which point to external ("off-heap") memory are no longer allowed. This breaks our `win-ca.ts` implementation. We're opting to use these forks as a short-term fix to allow us to upgrade to the latest version of electron as we evaluate a long-term fix.

See the following links for more details:
- https://www.electronjs.org/blog/v8-memory-cage
- node-ffi-napi/node-ffi-napi#238

Signed-off-by: Phillip Rak <rak.phillip@gmail.com>
  • Loading branch information
rak-phillip committed Sep 29, 2023
1 parent 3ca7c48 commit 3c851d3
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 28 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"dompurify": "3.0.1",
"electron-updater": "^5.3.0",
"express": "4.18.1",
"ffi-napi": "4.0.3",
"@lwahonen/ffi-napi": "4.0.12",
"fs-extra": "11.1.1",
"http-proxy-agent": "5.0.0",
"http-proxy-middleware": "2.0.6",
Expand All @@ -80,7 +80,7 @@
"node-forge": "1.3.1",
"os-browserify": "^0.3.0",
"rancher-icons": "rancher/icons#v2.0.19",
"ref-napi": "3.0.3",
"@lwahonen/ref-napi": "4.0.8",
"ref-struct-di": "1.1.1",
"semver": "7.5.4",
"socks-proxy-agent": "8.0.2",
Expand Down
4 changes: 2 additions & 2 deletions pkg/rancher-desktop/main/networking/win-ca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* This module iterates through system certificates on Windows.
*/

import ffi from 'ffi-napi';
import ffi from '@lwahonen/ffi-napi';
import ref from '@lwahonen/ref-napi';
import _ from 'lodash';
import ref from 'ref-napi';
import refStructDi from 'ref-struct-di';

import Logging from '@pkg/utils/logging';
Expand Down
12 changes: 12 additions & 0 deletions pkg/rancher-desktop/typings/linux-ca.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,15 @@ declare module 'linux-ca' {
export function certToPem(cert: forge.pki.Certificate): string;
export function defaultFilter(cert: forge.pki.Certificate, subject: string): boolean;
}

declare module '@lwahonen/ffi-napi' {
import ffi from 'ffi-napi';

export default ffi;
}

declare module '@lwahonen/ref-napi' {
import ref from 'ref-napi';

export default ref;
}
53 changes: 29 additions & 24 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1894,6 +1894,28 @@
resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz#b2ac626d6cb9c8718ab459166d4bb405b8ffa78b"
integrity sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A==

"@lwahonen/ffi-napi@4.0.12":
version "4.0.12"
resolved "https://registry.yarnpkg.com/@lwahonen/ffi-napi/-/ffi-napi-4.0.12.tgz#9936ec24e99823c79621e2322cf7238773d054d4"
integrity sha512-SYEu6IEEUAc+RQYul6rXtDjAJwK9NhWrSV8Wc2xN68YbUpqWVV8bomGX2MEnxwgRNXkTSJOKKYdj1cLr+KEO8A==
dependencies:
"@lwahonen/ref-napi" "^4.0.8"
debug "^4.1.1"
get-uv-event-loop-napi-h "^1.0.5"
node-addon-api "^3.2.1"
node-gyp-build "^4.5.0"
ref-struct-di "^1.1.0"

"@lwahonen/ref-napi@4.0.8", "@lwahonen/ref-napi@^4.0.8":
version "4.0.8"
resolved "https://registry.yarnpkg.com/@lwahonen/ref-napi/-/ref-napi-4.0.8.tgz#350cf4becafdeafe4e96fa58e096aa45b369934b"
integrity sha512-NYPHEELDNtWqPugI6kkxvp2M5NvvVgfAWZO7E07emDg2BtILcTTgXeWPT49/iyOr0J+xR9U3ONNHZg/cWeJ/qA==
dependencies:
debug "^4.3.4"
get-symbol-from-current-process-h "^1.0.2"
node-addon-api "^3.2.1"
node-gyp-build "^4.5.0"

"@malept/cross-spawn-promise@^1.1.0":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@malept/cross-spawn-promise/-/cross-spawn-promise-1.1.1.tgz#504af200af6b98e198bce768bc1730c6936ae01d"
Expand Down Expand Up @@ -7254,18 +7276,6 @@ fd-slicer@~1.1.0:
dependencies:
pend "~1.2.0"

ffi-napi@4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/ffi-napi/-/ffi-napi-4.0.3.tgz#27a8d42a8ea938457154895c59761fbf1a10f441"
integrity sha512-PMdLCIvDY9mS32RxZ0XGb95sonPRal8aqRhLbeEtWKZTe2A87qRFG9HjOhvG8EX2UmQw5XNRMIOT+1MYlWmdeg==
dependencies:
debug "^4.1.1"
get-uv-event-loop-napi-h "^1.0.5"
node-addon-api "^3.0.0"
node-gyp-build "^4.2.1"
ref-napi "^2.0.1 || ^3.0.2"
ref-struct-di "^1.1.0"

figures@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962"
Expand Down Expand Up @@ -10404,7 +10414,7 @@ node-addon-api@^1.6.3, node-addon-api@^1.7.1:
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-1.7.2.tgz#3df30b95720b53c24e59948b49532b662444f54d"
integrity sha512-ibPK3iA+vaY1eEjESkQkM0BbCqFOaZMiXRTtdB0u7b4djtY6JnsjvPdUHVMg6xQt3B8fpTTWHI9A+ADjM9frzg==

node-addon-api@^3.0.0:
node-addon-api@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.2.1.tgz#81325e0a2117789c0128dab65e7e38f07ceba161"
integrity sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==
Expand Down Expand Up @@ -10441,11 +10451,16 @@ node-forge@^0.10.0:
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.10.0.tgz#32dea2afb3e9926f02ee5ce8794902691a676bf3"
integrity sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA==

node-gyp-build@4, node-gyp-build@^4.2.1, node-gyp-build@^4.3.0:
node-gyp-build@4, node-gyp-build@^4.3.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.6.0.tgz#0c52e4cbf54bbd28b709820ef7b6a3c2d6209055"
integrity sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ==

node-gyp-build@^4.5.0:
version "4.6.1"
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.6.1.tgz#24b6d075e5e391b8d5539d98c7fc5c210cac8a3e"
integrity sha512-24vnklJmyRS8ViBNI8KbtK/r/DmXQMRiOMXTNz2nrTnAYUwjmEEbnnpB/+kt+yWRv73bPsSPRFddrcIbAxSiMQ==

node-int64@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
Expand Down Expand Up @@ -11619,16 +11634,6 @@ readdirp@~3.6.0:
dependencies:
picomatch "^2.2.1"

ref-napi@3.0.3, "ref-napi@^2.0.1 || ^3.0.2":
version "3.0.3"
resolved "https://registry.yarnpkg.com/ref-napi/-/ref-napi-3.0.3.tgz#e259bfc2bbafb3e169e8cd9ba49037dd00396b22"
integrity sha512-LiMq/XDGcgodTYOMppikEtJelWsKQERbLQsYm0IOOnzhwE9xYZC7x8txNnFC9wJNOkPferQI4vD4ZkC0mDyrOA==
dependencies:
debug "^4.1.1"
get-symbol-from-current-process-h "^1.0.2"
node-addon-api "^3.0.0"
node-gyp-build "^4.2.1"

ref-struct-di@1.1.1, ref-struct-di@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/ref-struct-di/-/ref-struct-di-1.1.1.tgz#5827b1d3b32372058f177547093db1fe1602dc10"
Expand Down

0 comments on commit 3c851d3

Please sign in to comment.