Skip to content

Commit 6ef1c07

Browse files
authored
Merge pull request #33981 from storybookjs/version-non-patch-from-10.3.0-alpha.13
Release: Prerelease 10.3.0-alpha.14
2 parents c61b4e2 + 8f6f950 commit 6ef1c07

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1212
-161
lines changed

.github/workflows/copilot-setup-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ jobs:
3333
install-code-deps: true
3434

3535
- name: Compile
36-
run: yarn nx run-many --targets compile
36+
run: yarn nx run-many --targets compile --no-cloud

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 10.2.14
2+
3+
- CLI: Set STORYBOOK environment variable - [#33938](https://github.com/storybookjs/storybook/pull/33938), thanks @yannbf!
4+
- UI: Prevent crash when tag filters contain undefined entries - [#33931](https://github.com/storybookjs/storybook/pull/33931), thanks @abhaysinh1000!
5+
16
## 10.2.13
27

38
- Addon Pseudo-states: Process all nested css rules - [#33605](https://github.com/storybookjs/storybook/pull/33605), thanks @hpohlmeyer!

CHANGELOG.prerelease.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 10.3.0-alpha.14
2+
3+
- CSF-Factories: Fix ConfigFile parser false warning on `definePreview({...}).type<T>()` export default - [#33885](https://github.com/storybookjs/storybook/pull/33885), thanks @copilot-swe-agent!
4+
- Core: Add host/origin validation to requests and websocket connections - [#33835](https://github.com/storybookjs/storybook/pull/33835), thanks @ghengeveld!
5+
- Core: Storybook failed to load iframe.html when publishing - [#33896](https://github.com/storybookjs/storybook/pull/33896), thanks @danielalanbates!
6+
- Core: Zoom tool refinements - Hide reset button when value is initial - [#33635](https://github.com/storybookjs/storybook/pull/33635), thanks @superLipbalm!
7+
- Docs: Edit JSON button is now accessible at 320x256 viewport (WCAG 2.1 Reflow test) - [#33707](https://github.com/storybookjs/storybook/pull/33707), thanks @TheSeydiCharyyev!
8+
- Manager-API: Update refs sequentially in experimental_setFilter - [#33958](https://github.com/storybookjs/storybook/pull/33958), thanks @ia319!
9+
- UI: Allow direct kb/mouse actions on zoom tool button - [#33496](https://github.com/storybookjs/storybook/pull/33496), thanks @Sidnioulz!
10+
111
## 10.3.0-alpha.13
212

313
- A11y: Add ScrollArea prop focusable for when it has static children - [#33876](https://github.com/storybookjs/storybook/pull/33876), thanks @Sidnioulz!

SECURITY.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
## Supported Versions
44

5-
We release patches for fixing security vulnerabilities, primarily focusing on the latest release only.
5+
We release patches for security vulnerabilities, primarily focusing on the latest major version.
66

7-
In the event of a high-risk vulnerability, we may backport the security fixes to the minor versions of the software, starting from the latest minor version up to the latest major release. The decision to backport security fixes to older versions will be made based on a risk assessment and the feasibility of implementing the patch in those versions.
7+
Security fixes are backported to the previous two major versions only for vulnerabilities with High or Critical CVSS scores (7.0+). The decision to backport is made based on severity assessment and the feasibility of implementing the patch in those versions.
8+
9+
- Latest major version: All security vulnerabilities
10+
- Previous two major versions: High or Critical CVSS scores only
11+
- Older versions: Not supported (Users should upgrade to a supported version)
812

913
## Reporting a Vulnerability
1014

code/addons/docs/src/blocks/controls/Object.stories.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,31 @@ export const ReadonlyAndUndefined: Story = {
112112
argType: { table: { readonly: true } },
113113
},
114114
};
115+
116+
export const ObjectSmallViewport: Story = {
117+
args: {
118+
value: {
119+
name: 'Michael',
120+
someDate: new Date('2022-10-30T12:31:11'),
121+
nested: { someBool: true, someNumber: 22 },
122+
},
123+
},
124+
parameters: {
125+
chromatic: { viewports: [320] },
126+
},
127+
};
128+
129+
export const ArraySmallViewport: Story = {
130+
args: {
131+
value: [
132+
'someString',
133+
22,
134+
true,
135+
new Date('2022-10-30T12:31:11'),
136+
{ someBool: true, someNumber: 22 },
137+
],
138+
},
139+
parameters: {
140+
chromatic: { viewports: [320] },
141+
},
142+
};

code/addons/docs/src/blocks/controls/Object.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
33

44
import { Button, Form, ToggleButton } from 'storybook/internal/components';
55

6-
import { AddIcon, SubtractIcon } from '@storybook/icons';
6+
import { AddIcon, EditIcon, SubtractIcon } from '@storybook/icons';
77

88
import { cloneDeep } from 'es-toolkit/object';
99
import { styled, useTheme } from 'storybook/theming';
@@ -18,8 +18,10 @@ const Wrapper = styled.div(({ theme }) => ({
1818
position: 'relative',
1919
display: 'flex',
2020
isolation: 'isolate',
21+
gap: 8,
2122

2223
'.rejt-tree': {
24+
flex: 1,
2325
marginLeft: '1rem',
2426
fontSize: '13px',
2527
listStyleType: 'none',
@@ -125,10 +127,9 @@ const Input = styled.input(({ theme, placeholder }) => ({
125127
}));
126128

127129
const RawButton = styled(ToggleButton)({
128-
position: 'absolute',
129-
zIndex: 2,
130-
top: 2,
131-
right: 2,
130+
alignSelf: 'flex-start',
131+
order: 2,
132+
marginRight: -10,
132133
});
133134

134135
const RawInput = styled(Form.Textarea)(({ theme }) => ({
@@ -188,7 +189,7 @@ export const ObjectControl: FC<ObjectProps> = ({ name, value, onChange, argType
188189
const onForceVisible = useCallback(() => {
189190
onChange({});
190191
setForceVisible(true);
191-
}, [setForceVisible]);
192+
}, [onChange, setForceVisible]);
192193

193194
const htmlElRef = useRef<HTMLTextAreaElement>(null);
194195
useEffect(() => {
@@ -240,13 +241,16 @@ export const ObjectControl: FC<ObjectProps> = ({ name, value, onChange, argType
240241
<RawButton
241242
disabled={readonly}
242243
pressed={showRaw}
243-
ariaLabel={`Edit the ${name} properties in JSON format`}
244+
ariaLabel={`Edit ${name} as JSON`}
244245
onClick={(e: SyntheticEvent) => {
245246
e.preventDefault();
246247
setShowRaw((isRaw) => !isRaw);
247248
}}
249+
variant="ghost"
250+
padding="small"
251+
size="small"
248252
>
249-
Edit JSON
253+
<EditIcon />
250254
</RawButton>
251255
)}
252256
{!showRaw ? (

code/builders/builder-vite/src/vite-server.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { logger } from 'storybook/internal/node-logger';
21
import type { Options } from 'storybook/internal/types';
32

43
import type { Server } from 'http';
5-
import { dedent } from 'ts-dedent';
64
import type { InlineConfig, ServerOptions } from 'vite';
75

86
import { createViteLogger } from './logger';
@@ -13,9 +11,12 @@ export async function createViteServer(options: Options, devServer: Server) {
1311

1412
const commonCfg = await commonConfig(options, 'development');
1513

14+
const { allowedHosts } = await presets.apply('core', {});
15+
1616
const config: InlineConfig & { server: ServerOptions } = {
1717
...commonCfg,
1818
server: {
19+
allowedHosts,
1920
middlewareMode: true,
2021
hmr: {
2122
port: options.port,
@@ -28,18 +29,12 @@ export async function createViteServer(options: Options, devServer: Server) {
2829
appType: 'custom' as const,
2930
};
3031

31-
// '0.0.0.0' binds to all interfaces, which is useful for Docker and other containerized environments.
32-
// but without server.allowedHosts set, requests from outside the container will be rejected.
33-
if (options.host === '0.0.0.0' && !config.server.allowedHosts) {
32+
// '0.0.0.0' binds to all interfaces, which is useful for Docker and other containerized environments
33+
if (
34+
options.host === '0.0.0.0' &&
35+
(!allowedHosts || (Array.isArray(allowedHosts) && allowedHosts.length === 0))
36+
) {
3437
config.server.allowedHosts = true;
35-
logger.warn(dedent`'host' is set to '0.0.0.0' but 'allowedHosts' is not defined.
36-
Defaulting 'allowedHosts' to true, which permits all hostnames.
37-
To restrict allowed hostnames, add the following to your 'viteFinal' config:
38-
Example: { server: { allowedHosts: ['mydomain.com'] } }
39-
See:
40-
- https://vite.dev/config/server-options.html#server-allowedhosts
41-
- https://storybook.js.org/docs/api/main-config/main-config-vite-final
42-
`);
4338
}
4439

4540
const finalConfig = await presets.apply('viteFinal', config, options);

code/core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@
320320
"get-npm-tarball-url": "^2.1.0",
321321
"glob": "^10.5.0",
322322
"globby": "^14.1.0",
323+
"host-validation-middleware": "^0.1.2",
323324
"jiti": "^2.6.1",
324325
"js-yaml": "^4.1.0",
325326
"jsdoc-type-pratt-parser": "^4.0.0",

code/core/src/core-server/build-dev.ts

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { join, relative, resolve } from 'pathe';
2323
import invariant from 'tiny-invariant';
2424
import { dedent } from 'ts-dedent';
2525

26+
import Channel from '../channels';
2627
import { detectPnp } from '../cli/detect';
2728
import { resolvePackageDir } from '../shared/utils/module';
2829
import { storybookDevServer } from './dev-server';
@@ -32,7 +33,7 @@ import { getManagerBuilder, getPreviewBuilder } from './utils/get-builders';
3233
import { getServerChannel } from './utils/get-server-channel';
3334
import { outputStartupInformation } from './utils/output-startup-information';
3435
import { outputStats } from './utils/output-stats';
35-
import { getServerChannelUrl, getServerPort } from './utils/server-address';
36+
import { getServerAddresses, getServerChannelUrl, getServerPort } from './utils/server-address';
3637
import { getServer } from './utils/server-init';
3738
import { stripCommentsAndStrings } from './utils/strip-comments-and-strings';
3839
import { updateCheck } from './utils/update-check';
@@ -91,13 +92,23 @@ export async function buildDevStandalone(
9192
outputDir = cacheOutputDir;
9293
}
9394

95+
invariant(port, 'expected options to have a port');
96+
const { address: localAddress, networkAddress } = getServerAddresses(
97+
port,
98+
options.host,
99+
options.https ? 'https' : 'http',
100+
options.initialPath
101+
);
102+
94103
options.port = port;
95104
options.versionCheck = versionCheck;
96105
options.configType = 'DEVELOPMENT';
97106
options.configDir = configDir;
98107
options.cacheKey = cacheKey;
99108
options.outputDir = outputDir;
100109
options.serverChannelUrl = getServerChannelUrl(port, options);
110+
options.localAddress = localAddress;
111+
options.networkAddress = networkAddress;
101112

102113
// TODO: Remove in SB11
103114
options.pnp = await detectPnp();
@@ -111,7 +122,7 @@ export async function buildDevStandalone(
111122
}
112123

113124
const config = await loadMainConfig(options);
114-
const { framework } = config;
125+
const { core, framework } = config;
115126
const corePresets = [];
116127

117128
let frameworkName = typeof framework === 'string' ? framework : framework?.name;
@@ -146,7 +157,6 @@ export async function buildDevStandalone(
146157
} catch (e) {}
147158

148159
const server = await getServer(options);
149-
const channel = getServerChannel(server, getWsToken());
150160

151161
// Load first pass: We need to determine the builder
152162
// We need to do this because builders might introduce 'overridePresets' which we need to take into account
@@ -158,10 +168,30 @@ export async function buildDevStandalone(
158168
],
159169
...options,
160170
isCritical: true,
161-
channel,
171+
channel: new Channel({
172+
transports: [
173+
{
174+
setHandler: () => () => console.error('CHANNEL IS NOT READY YET'),
175+
send: () => () => console.error('CHANNEL IS NOT READY YET'),
176+
},
177+
],
178+
}),
162179
});
163180

164-
const { renderer, builder, disableTelemetry } = await presets.apply('core', {});
181+
const { allowedHosts, renderer, builder, disableTelemetry } = await presets.apply('core', {});
182+
183+
// '0.0.0.0' binds to all interfaces, which is useful for Docker and other containerized environments.
184+
// By default we allow requests from all hosts in this case, but the user should be made aware of the risk.
185+
if (
186+
options.host === '0.0.0.0' &&
187+
(!allowedHosts || (allowedHosts !== true && allowedHosts.length === 0))
188+
) {
189+
logger.warn(dedent`
190+
--host is set to 0.0.0.0 but no allowedHosts are defined. Allowing all hosts.
191+
To restrict allowed hosts, set core.allowedHosts in your main Storybook config.
192+
See: https://storybook.js.org/docs/api/main-config/main-config-core
193+
`);
194+
}
165195

166196
if (!builder) {
167197
throw new MissingBuilderError();
@@ -202,6 +232,14 @@ export async function buildDevStandalone(
202232

203233
const resolvedRenderer = renderer && resolveAddonName(options.configDir, renderer, options);
204234

235+
const channel = getServerChannel(server, {
236+
token: getWsToken(),
237+
host: options.host,
238+
allowedHosts,
239+
localAddress,
240+
networkAddress,
241+
});
242+
205243
// Load second pass: all presets are applied in order
206244
presets = await loadAllPresets({
207245
corePresets: [
@@ -230,7 +268,7 @@ export async function buildDevStandalone(
230268
channel,
231269
};
232270

233-
const { address, networkAddress, managerResult, previewResult } = await buildOrThrow(async () =>
271+
const { managerResult, previewResult } = await buildOrThrow(async () =>
234272
storybookDevServer(fullOptions, server)
235273
);
236274

@@ -280,12 +318,13 @@ export async function buildDevStandalone(
280318
updateInfo: versionCheck,
281319
version: storybookVersion,
282320
name,
283-
address,
321+
address: localAddress,
284322
networkAddress,
323+
allowedHosts,
285324
managerTotalTime,
286325
previewTotalTime,
287326
});
288327
}
289328
}
290-
return { port, address, networkAddress };
329+
return { port, address: localAddress, networkAddress };
291330
}

0 commit comments

Comments
 (0)