feat(libSceNKWebKit): implement WebCore::SecurityOrigin and SecurityOriginData origin queries #22751

Merged
opxdelwin merged 2 commits from upstream-pr/22751 into main 2026-11-18 08:06:30 +00:00
opxdelwin commented 2026-11-18 07:02:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by opxdelwin on 2026-11-18T07:02:44Z.


What

Implements 11 libSceNKWebKit exports for WebKit's origin model, ported from the pinned PS5 WebKit source neonmodder123/PS5-WebKit-11.x@80f77e94c63e (SecurityOrigin.cpp/.h, SecurityOriginData.cpp/.h, OriginAccessEntry.cpp, and URL::hasSpecialScheme from WTF/wtf/URL.cpp):

  • WebCore::SecurityOrigin::create(const URL&), toString, toRawString, isolatedCopy, equal, isSameOriginAs, domainForCachePartition, isMatchingRegistrableDomainSuffix
  • WebCore::SecurityOriginData::toString, databaseIdentifier, securityOrigin

Changes:

  • src/SecurityOriginAbi.hpp (new) models the release-build layout of SecurityOrigin (64 bytes) and SecurityOriginData (32 bytes, a std::variant of tuple and opaque data), taken from the pinned SecurityOrigin.h, SecurityOriginData.h and ProcessQualified.h. static_asserts pin every offset and both sizes.
  • include/SecurityOriginExports.hpp holds the typed declarations. The stubs are removed from Export.cpp, and the declarations from InventoryExports.hpp.
  • src/Mime.cpp gets two small accessors over the existing no-access and cache-partitioned scheme registries.
  • src/WtfString.cpp exposes the existing URL port helper.

Paths that still throw NotImplemented_nid_no_patch, all recorded in the debt fragment:

  • create(URL) for blob: URLs, because there is no blob origin cache;
  • SecurityOriginData::securityOrigin for local schemes other than file, because there is no URL parser.

The fragment also records the layout assumption that libc++'s std::variant index is 32 bits.

Known nit, left for review: raw URL bit masks could be a named helper.

Note on overlap: tools/pr_overlap.py --branch reports a textual conflict with #19636 in src/Mime.cpp (L711-712 on main). Both PRs append new code at the end of the file, so the conflict is trivial to resolve and neither PR changes the other's code. The tool could not compare 29 other PRs (#13515, #14138, #14164, #14259, #14860, #16510, #17550, #17569, #17695, #17771, #17793, #17805, #17922, #17927, #17933, #18395, #18797, #18802, #19105, #19823, #20304, #20314, #20327, #21957, #22454, #22555, #22556, #22557, #22674), because each conflicts with main. They share only Export.cpp / InventoryExports.hpp with this PR. I checked their diffs by hand: none adds, edits or removes any of the exports this PR implements.

Tested

Not tested with a title or homebrew. Unit tests only, on Linux (Docker, Ubuntu image).

The build targets were libSceNKWebKit nkwebkit_securityorigin_tests nkwebkit_forwarding_tests nkwebkit_symbolset_tests, run with ctest -R '^(nkwebkit_securityorigin|nkwebkit_forwarding|nkwebkit_symbolset|public_headers.*)$':

  • GCC, on this commit rebased onto main 64da1641bd: 68 of 68 tests pass.
  • Clang, on the same change before that rebase: nkwebkit_securityorigin, nkwebkit_forwarding and nkwebkit_symbolset pass. Four tests fail: public_headers_compile_1/16/29/39, on -Winvalid-offsetof for Region in RegionExports.hpp, a file this PR does not touch. Unmodified main (324cc9554d) built with Clang fails the same four tests (4 of 67), so they fail before this PR too.

New tests cover:

  • tuple, opaque and file origins;
  • default-port stripping and 16-bit strings;
  • equal, isSameOriginAs and document.domain handling;
  • isolatedCopy (deep string copies, every flag, refcounts);
  • domainForCachePartition, including a registered scheme;
  • isMatchingRegistrableDomainSuffix (public suffixes, IP address vs domain);
  • SecurityOriginData::toString, databaseIdentifier and securityOrigin;
  • the NotImplemented paths, a valueless variant and null-pointer throws.

A scratch program built with both g++ and clang++ checked the layout offsets against the static_asserts.

Also passed: tools/check_conventions.py --base upstream/main and tools/debt_fold.py --check.

Not run: the Windows (MSYS2) build, and the Clang tests after the rebase. None of the commits the rebase took in touch libSceNKWebKit.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5371474390 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22751). Originally posted by [opxdelwin](https://github.com/opxdelwin) on 2026-11-18T07:02:44Z. --- ### What Implements 11 `libSceNKWebKit` exports for WebKit's origin model, ported from the pinned PS5 WebKit source [neonmodder123/PS5-WebKit-11.x@80f77e94c63e](https://github.com/neonmodder123/PS5-WebKit-11.x/tree/80f77e94c63ee7202eec3d4b5b1a021dd89011ba) (`SecurityOrigin.cpp/.h`, `SecurityOriginData.cpp/.h`, `OriginAccessEntry.cpp`, and `URL::hasSpecialScheme` from `WTF/wtf/URL.cpp`): - `WebCore::SecurityOrigin::create(const URL&)`, `toString`, `toRawString`, `isolatedCopy`, `equal`, `isSameOriginAs`, `domainForCachePartition`, `isMatchingRegistrableDomainSuffix` - `WebCore::SecurityOriginData::toString`, `databaseIdentifier`, `securityOrigin` Changes: - `src/SecurityOriginAbi.hpp` (new) models the release-build layout of `SecurityOrigin` (64 bytes) and `SecurityOriginData` (32 bytes, a `std::variant` of tuple and opaque data), taken from the pinned `SecurityOrigin.h`, `SecurityOriginData.h` and `ProcessQualified.h`. `static_assert`s pin every offset and both sizes. - `include/SecurityOriginExports.hpp` holds the typed declarations. The stubs are removed from `Export.cpp`, and the declarations from `InventoryExports.hpp`. - `src/Mime.cpp` gets two small accessors over the existing no-access and cache-partitioned scheme registries. - `src/WtfString.cpp` exposes the existing URL port helper. Paths that still throw `NotImplemented_nid_no_patch`, all recorded in the debt fragment: - `create(URL)` for `blob:` URLs, because there is no blob origin cache; - `SecurityOriginData::securityOrigin` for local schemes other than `file`, because there is no URL parser. The fragment also records the layout assumption that libc++'s `std::variant` index is 32 bits. Known nit, left for review: raw URL bit masks could be a named helper. Note on overlap: `tools/pr_overlap.py --branch` reports a textual conflict with #19636 in `src/Mime.cpp` (L711-712 on main). Both PRs append new code at the end of the file, so the conflict is trivial to resolve and neither PR changes the other's code. The tool could not compare 29 other PRs (#13515, #14138, #14164, #14259, #14860, #16510, #17550, #17569, #17695, #17771, #17793, #17805, #17922, #17927, #17933, #18395, #18797, #18802, #19105, #19823, #20304, #20314, #20327, #21957, #22454, #22555, #22556, #22557, #22674), because each conflicts with `main`. They share only `Export.cpp` / `InventoryExports.hpp` with this PR. I checked their diffs by hand: none adds, edits or removes any of the exports this PR implements. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Not tested with a title or homebrew. Unit tests only, on Linux (Docker, Ubuntu image). The build targets were `libSceNKWebKit nkwebkit_securityorigin_tests nkwebkit_forwarding_tests nkwebkit_symbolset_tests`, run with `ctest -R '^(nkwebkit_securityorigin|nkwebkit_forwarding|nkwebkit_symbolset|public_headers.*)$'`: - GCC, on this commit rebased onto main 64da1641bd: 68 of 68 tests pass. - Clang, on the same change before that rebase: `nkwebkit_securityorigin`, `nkwebkit_forwarding` and `nkwebkit_symbolset` pass. Four tests fail: `public_headers_compile_1/16/29/39`, on `-Winvalid-offsetof` for `Region` in `RegionExports.hpp`, a file this PR does not touch. Unmodified `main` (324cc9554da1) built with Clang fails the same four tests (4 of 67), so they fail before this PR too. New tests cover: - tuple, opaque and `file` origins; - default-port stripping and 16-bit strings; - `equal`, `isSameOriginAs` and `document.domain` handling; - `isolatedCopy` (deep string copies, every flag, refcounts); - `domainForCachePartition`, including a registered scheme; - `isMatchingRegistrableDomainSuffix` (public suffixes, IP address vs domain); - `SecurityOriginData::toString`, `databaseIdentifier` and `securityOrigin`; - the `NotImplemented` paths, a valueless variant and null-pointer throws. A scratch program built with both g++ and clang++ checked the layout offsets against the `static_assert`s. Also passed: `tools/check_conventions.py --base upstream/main` and `tools/debt_fold.py --check`. Not run: the Windows (MSYS2) build, and the Clang tests after the rebase. None of the commits the rebase took in touch `libSceNKWebKit`. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-18 07:12:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-18T07:12:09Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against b4446230cf:

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_securityorigin_tests built cleanly.
  • CTest (nkwebkit_securityorigin):
    1/1 Test #4545: nkwebkit_securityorigin ..........   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp, core/libs/prx/libSceNKWebKit/include/SecurityOriginExports.hpp, core/libs/prx/libSceNKWebKit/src/Mime.cpp, core/libs/prx/libSceNKWebKit/src/SecurityOrigin.cpp, core/libs/prx/libSceNKWebKit/src/WtfString.cpp, core/libs/prx/libSceNKWebKit/src/WtfStringAbi.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • SecurityOriginAbi.hpp: verified struct alignments, sizes (64B for SecurityOrigin, 32B for SecurityOriginData), and offset static_asserts against WebKit release layout and libc++ variant layout
    • SecurityOrigin.cpp: verified null pointer checks using Checked() for self, other, and url across all exported WebCore::SecurityOrigin and WebCore::SecurityOriginData functions
    • SecurityOrigin.cpp: verified fastMalloc/fastFree and atomic refCount memory management in PendingOrigin, CreateFromURL, CreateFromData, and SecurityOrigin::deref
    • SecurityOrigin.cpp: checked string concatenation and length limits in Concatenate, ensuring protection against integer overflow (> std::numeric_limits<int32_t>::max())
    • SecurityOrigin.cpp: checked origin comparisons (equal, isSameOriginAs) for correct handling of opaque identifiers and domainWasSetInDOM semantics
    • docs/dev/debt/changes/feat-libscenkwebkit-security-origin.md: verified debt fragment records all unimplemented paths (blob URLs, non-file local schemes in CreateFromData, etc.) per AGENTS.md rules

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5952168575 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22751#pullrequestreview-5952168575). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-18T07:12:09Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `b4446230cf`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_securityorigin_tests` built cleanly. - **CTest** (`nkwebkit_securityorigin`): ``` 1/1 Test #4545: nkwebkit_securityorigin .......... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp`, `core/libs/prx/libSceNKWebKit/include/SecurityOriginExports.hpp`, `core/libs/prx/libSceNKWebKit/src/Mime.cpp`, `core/libs/prx/libSceNKWebKit/src/SecurityOrigin.cpp`, `core/libs/prx/libSceNKWebKit/src/WtfString.cpp`, `core/libs/prx/libSceNKWebKit/src/WtfStringAbi.hpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - SecurityOriginAbi.hpp: verified struct alignments, sizes (64B for SecurityOrigin, 32B for SecurityOriginData), and offset static_asserts against WebKit release layout and libc++ variant layout - SecurityOrigin.cpp: verified null pointer checks using Checked() for self, other, and url across all exported WebCore::SecurityOrigin and WebCore::SecurityOriginData functions - SecurityOrigin.cpp: verified fastMalloc/fastFree and atomic refCount memory management in PendingOrigin, CreateFromURL, CreateFromData, and SecurityOrigin::deref - SecurityOrigin.cpp: checked string concatenation and length limits in Concatenate, ensuring protection against integer overflow (> std::numeric_limits<int32_t>::max()) - SecurityOrigin.cpp: checked origin comparisons (equal, isSameOriginAs) for correct handling of opaque identifiers and domainWasSetInDOM semantics - docs/dev/debt/changes/feat-libscenkwebkit-security-origin.md: verified debt fragment records all unimplemented paths (blob URLs, non-file local schemes in CreateFromData, etc.) per AGENTS.md rules Looks Good To Me
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!22751
No description provided.