Skip to content

Commit 07b0da6

Browse files
authored
Merge pull request #3000 from modernweb-dev/fix/glob-promise
fix(storybook-builder): fix glob-promise security finding
2 parents 8df5564 + 0dd56f2 commit 07b0da6

File tree

4 files changed

+146
-34
lines changed

4 files changed

+146
-34
lines changed

.changeset/curvy-ducks-destroy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@web/storybook-builder': patch
3+
---
4+
5+
replace glob-promise with glob due to security findings

package-lock.json

Lines changed: 129 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/storybook-builder/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"cjs-module-lexer": "^1.2.3",
6464
"es-module-lexer": "^1.2.1",
6565
"esbuild": "^0.25.0",
66-
"glob-promise": "^6.0.3",
66+
"glob": "^12.0.0",
6767
"lodash-es": "^4.17.21",
6868
"path-browserify": "^1.0.1",
6969
"rehype-external-links": "^3.0.0",

packages/storybook-builder/src/list-stories.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
import { normalizeStories } from '@storybook/core-common';
44
import type { Options } from '@storybook/types';
5-
import { promise as glob } from 'glob-promise';
5+
import { glob } from 'glob';
66
import { isAbsolute, join } from 'node:path';
77

8+
const excludeNodeModulesGlobOptions = (glob: string) =>
9+
/node_modules/.test(glob) ? {} : { ignore: ['**/node_modules/**'] };
10+
811
export async function listStories(options: Options) {
912
const slash = (await import('slash')).default; // for CJS compatibility
1013

@@ -17,8 +20,13 @@ export async function listStories(options: Options) {
1720
const pattern = join(directory, files);
1821
const absolutePattern = isAbsolute(pattern) ? pattern : join(options.configDir, pattern);
1922

20-
return glob(slash(absolutePattern), { follow: true });
23+
return glob(slash(absolutePattern), {
24+
...excludeNodeModulesGlobOptions(absolutePattern),
25+
follow: true,
26+
});
2127
}),
2228
)
23-
).reduce((carry, stories) => carry.concat(stories), []);
29+
)
30+
.reduce((carry, stories) => carry.concat(stories.map(slash)), [])
31+
.sort();
2432
}

0 commit comments

Comments
 (0)