expectCt.tsx 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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(
  43. t('Certificate Transparency (Expect-CT)'),
  44. projectId!,
  45. false
  46. )}
  47. />
  48. <SettingsPageHeader title={t('Certificate Transparency')} />
  49. <PreviewFeature />
  50. <ReportUri keyList={keyList} orgId={organization.slug} projectId={projectId!} />
  51. <Panel>
  52. <PanelHeader>{t('About')}</PanelHeader>
  53. <PanelBody withPadding>
  54. <p>
  55. {tct(
  56. `[link:Certificate Transparency]
  57. (CT) is a security standard which helps track and identify valid certificates, allowing identification of maliciously issued certificates`,
  58. {
  59. link: (
  60. <ExternalLink href="https://en.wikipedia.org/wiki/Certificate_Transparency" />
  61. ),
  62. }
  63. )}
  64. </p>
  65. <p>
  66. {tct(
  67. "To configure reports in Sentry, you'll need to configure the [header] a header from your server:",
  68. {
  69. header: <code>Expect-CT</code>,
  70. }
  71. )}
  72. </p>
  73. <pre>{getInstructions(keyList)}</pre>
  74. <p>
  75. {tct('For more information, see [link:the article on MDN].', {
  76. link: (
  77. <ExternalLink href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Expect-CT" />
  78. ),
  79. })}
  80. </p>
  81. </PanelBody>
  82. </Panel>
  83. </div>
  84. );
  85. }
  86. export default ProjectExpectCtReports;