homepage/src/widgets/npm/component.jsx
shamoon 52cce0ee21 Merge pull request from GHSA-24m5-7vjx-9x37
* Restrict emby endpoints and proxy segments

* Dont allow path traversal in segments

* Restrict qbittorrent proxy endpoints

* Restrict npm proxy endpoints

* Restrict flood proxy endpoints

* Restrict tdarr proxy endpoints

* Restrict xteve proxy endpoints

* Restrict transmission proxy endpoints

* disallow non-mapped endpoints

this change drops all requests that have un-mapped endpoint queries

allowedEndpoints is added as a method to pass proxy requests via a regex on the endpoint

most widgets with custom proxies use either no endpoint, or a static one

Co-Authored-By: Ben Phelps <ben@phelps.io>
2024-06-03 09:04:21 -07:00

36 lines
1019 B
JavaScript

import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import useWidgetAPI from "utils/proxy/use-widget-api";
export default function Component({ service }) {
const { widget } = service;
const { data: infoData, error: infoError } = useWidgetAPI(widget, "hosts");
if (infoError) {
return <Container service={service} error={infoError} />;
}
if (!infoData) {
return (
<Container service={service}>
<Block label="npm.enabled" />
<Block label="npm.disabled" />
<Block label="npm.total" />
</Container>
);
}
const enabled = infoData.filter((c) => c.enabled === 1).length;
const disabled = infoData.filter((c) => c.enabled === 0).length;
const total = infoData.length;
return (
<Container service={service}>
<Block label="npm.enabled" value={enabled} />
<Block label="npm.disabled" value={disabled} />
<Block label="npm.total" value={total} />
</Container>
);
}