expectCt.tsx 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import ExternalLink from 'sentry/components/links/externalLink';
  2. import LoadingError from 'sentry/components/loadingError';
  3. import LoadingIndicator from 'sentry/components/loadingIndicator';
  4. import Panel from 'sentry/components/panels/panel';
  5. import PanelBody from 'sentry/components/panels/panelBody';
  6. import PanelHeader from 'sentry/components/panels/panelHeader';
  7. import PreviewFeature from 'sentry/components/previewFeature';
  8. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  9. import {t, tct} from 'sentry/locale';
  10. import type {ProjectKey} from 'sentry/types/project';
  11. import {useApiQuery} from 'sentry/utils/queryClient';
  12. import routeTitleGen from 'sentry/utils/routeTitle';
  13. import useOrganization from 'sentry/utils/useOrganization';
  14. import {useParams} from 'sentry/utils/useParams';
  15. import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';
  16. import ReportUri, {
  17. getSecurityDsn,
  18. } from 'sentry/views/settings/projectSecurityHeaders/reportUri';
  19. function getInstructions(keyList: ProjectKey[]) {
  20. return `Expect-CT: report-uri="${getSecurityDsn(keyList)}"`;
  21. }
  22. function ProjectExpectCtReports() {
  23. const organization = useOrganization();
  24. const {projectId} = useParams();
  25. const {
  26. data: keyList,
  27. isPending,
  28. isError,
  29. refetch,
  30. } = useApiQuery<ProjectKey[]>([`/projects/${organization.slug}/${projectId}/keys/`], {
  31. staleTime: 0,
  32. });
  33. if (isPending) {
  34. return <LoadingIndicator />;
  35. }
  36. if (isError) {
  37. return <LoadingError onRetry={refetch} />;
  38. }
  39. return (
  40. <div>
  41. <SentryDocumentTitle
  42. title={routeTitleGen(t('Certificate Transparency (Expect-CT)'), projectId, false)}
  43. />
  44. <SettingsPageHeader title={t('Certificate Transparency')} />
  45. <PreviewFeature />
  46. <ReportUri keyList={keyList} orgId={organization.slug} projectId={projectId} />
  47. <Panel>
  48. <PanelHeader>{t('About')}</PanelHeader>
  49. <PanelBody withPadding>
  50. <p>
  51. {tct(
  52. `[link:Certificate Transparency]
  53. (CT) is a security standard which helps track and identify valid certificates, allowing identification of maliciously issued certificates`,
  54. {
  55. link: (
  56. <ExternalLink href="https://en.wikipedia.org/wiki/Certificate_Transparency" />
  57. ),
  58. }
  59. )}
  60. </p>
  61. <p>
  62. {tct(
  63. "To configure reports in Sentry, you'll need to configure the [header] a header from your server:",
  64. {
  65. header: <code>Expect-CT</code>,
  66. }
  67. )}
  68. </p>
  69. <pre>{getInstructions(keyList)}</pre>
  70. <p>
  71. {tct('For more information, see [link:the article on MDN].', {
  72. link: (
  73. <ExternalLink href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Expect-CT" />
  74. ),
  75. })}
  76. </p>
  77. </PanelBody>
  78. </Panel>
  79. </div>
  80. );
  81. }
  82. export default ProjectExpectCtReports;