@backstage/core-components 0.12.4-next.1 → 0.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @backstage/core-components
2
2
 
3
+ ## 0.12.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 68ce7d0417: Added aria labels on the support button and sidebar
8
+ - 5637ebed92: Added a global override for `window.open` that helps prevent security vulnerabilities.
9
+ - 910015f5b7: The Button component has been deprecated in favor of the LinkButton component
10
+ - 20840b36b4: Adds new type, TableOptions, extending Material Table Options.
11
+ - e81a6e0ab5: Updated Link URL validation to be more strict.
12
+ - 85b04f659a: Internal refactor to not use deprecated `substr`
13
+ - 66e2aab4c4: Navigation items in mobile sidebar now have aria label.
14
+ - Updated dependencies
15
+ - @backstage/theme@0.2.17
16
+ - @backstage/core-plugin-api@1.4.0
17
+ - @backstage/config@1.0.6
18
+ - @backstage/errors@1.1.4
19
+ - @backstage/version-bridge@1.0.3
20
+
3
21
  ## 0.12.4-next.1
4
22
 
5
23
  ### Patch Changes
package/dist/index.esm.js CHANGED
@@ -278,6 +278,24 @@ const useStyles$R = makeStyles(
278
278
  { name: "Link" }
279
279
  );
280
280
  const isExternalUri = (uri) => /^([a-z+.-]+):/.test(uri);
281
+ const scriptProtocolPattern = (
282
+ // eslint-disable-next-line no-control-regex
283
+ /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i
284
+ );
285
+ const originalWindowOpen = window.open;
286
+ if (originalWindowOpen && !originalWindowOpen.__backstage) {
287
+ const newOpen = function open(...args) {
288
+ const url = String(args[0]);
289
+ if (scriptProtocolPattern.test(url)) {
290
+ throw new Error(
291
+ "Rejected window.open() with a javascript: URL as a security precaution"
292
+ );
293
+ }
294
+ return originalWindowOpen.apply(this, args);
295
+ };
296
+ newOpen.__backstage = true;
297
+ window.open = newOpen;
298
+ }
281
299
  const useBaseUrl = () => {
282
300
  try {
283
301
  const config = useApi(configApiRef);
@@ -324,6 +342,11 @@ const Link = React.forwardRef(
324
342
  const linkText = getNodeText(props.children) || to;
325
343
  const external = isExternalUri(to);
326
344
  const newWindow = external && !!/^https?:/.exec(to);
345
+ if (scriptProtocolPattern.test(to)) {
346
+ throw new Error(
347
+ "Link component rejected javascript: URL as a security precaution"
348
+ );
349
+ }
327
350
  const handleClick = (event) => {
328
351
  onClick == null ? void 0 : onClick(event);
329
352
  if (!noTrack) {
@@ -3336,14 +3359,15 @@ function SupportButton(props) {
3336
3359
  color: "primary",
3337
3360
  size: "small",
3338
3361
  onClick: onClickHandler,
3339
- "data-testid": "support-button"
3362
+ "data-testid": "support-button",
3363
+ "aria-label": "Support"
3340
3364
  },
3341
3365
  /* @__PURE__ */ React.createElement(HelpIcon, null)
3342
3366
  ) : /* @__PURE__ */ React.createElement(
3343
3367
  Button$1,
3344
3368
  {
3345
3369
  "data-testid": "support-button",
3346
- "aria-label": "support",
3370
+ "aria-label": "Support",
3347
3371
  color: "primary",
3348
3372
  onClick: onClickHandler,
3349
3373
  startIcon: /* @__PURE__ */ React.createElement(HelpIcon, null)
@@ -3366,7 +3390,15 @@ function SupportButton(props) {
3366
3390
  onClose: popoverCloseHandler
3367
3391
  },
3368
3392
  /* @__PURE__ */ React.createElement(List, { className: classes.popoverList }, title && /* @__PURE__ */ React.createElement(ListItem, { alignItems: "flex-start" }, /* @__PURE__ */ React.createElement(Typography, { variant: "subtitle1" }, title)), React.Children.map(children, (child, i) => /* @__PURE__ */ React.createElement(ListItem, { alignItems: "flex-start", key: `child-${i}` }, child)), (items != null ? items : configItems).map((item, i) => /* @__PURE__ */ React.createElement(SupportListItem, { item, key: `item-${i}` }))),
3369
- /* @__PURE__ */ React.createElement(DialogActions, null, /* @__PURE__ */ React.createElement(Button$1, { color: "primary", onClick: popoverCloseHandler }, "Close"))
3393
+ /* @__PURE__ */ React.createElement(DialogActions, null, /* @__PURE__ */ React.createElement(
3394
+ Button$1,
3395
+ {
3396
+ color: "primary",
3397
+ onClick: popoverCloseHandler,
3398
+ "aria-label": "Close"
3399
+ },
3400
+ "Close"
3401
+ ))
3370
3402
  ));
3371
3403
  }
3372
3404