expectCt.tsx 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import {RouteComponentProps} from 'react-router';
  2. import ExternalLink from 'sentry/components/links/externalLink';
  3. import {Panel, PanelBody, PanelHeader} from 'sentry/components/panels';
  4. import PreviewFeature from 'sentry/components/previewFeature';
  5. import {t, tct} from 'sentry/locale';
  6. import {ProjectKey} from 'sentry/types';
  7. import routeTitleGen from 'sentry/utils/routeTitle';
  8. import AsyncView from 'sentry/views/asyncView';
  9. import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';
  10. import ReportUri, {
  11. getSecurityDsn,
  12. } from 'sentry/views/settings/projectSecurityHeaders/reportUri';
  13. type Props = RouteComponentProps<{orgId: string; projectId: string}, {}>;
  14. type State = {
  15. keyList: null | ProjectKey[];
  16. } & AsyncView['state'];
  17. export default class ProjectExpectCtReports extends AsyncView<Props, State> {
  18. getEndpoints(): ReturnType<AsyncView['getEndpoints']> {
  19. const {orgId, projectId} = this.props.params;
  20. return [['keyList', `/projects/${orgId}/${projectId}/keys/`]];
  21. }
  22. getTitle() {
  23. const {projectId} = this.props.params;
  24. return routeTitleGen(t('Certificate Transparency (Expect-CT)'), projectId, false);
  25. }
  26. getInstructions(keyList: ProjectKey[]) {
  27. return `Expect-CT: report-uri="${getSecurityDsn(keyList)}"`;
  28. }
  29. renderBody() {
  30. const {params} = this.props;
  31. const {keyList} = this.state;
  32. if (!keyList) {
  33. return null;
  34. }
  35. return (
  36. <div>
  37. <SettingsPageHeader title={t('Certificate Transparency')} />
  38. <PreviewFeature />
  39. <ReportUri keyList={keyList} orgId={params.orgId} projectId={params.orgId} />
  40. <Panel>
  41. <PanelHeader>{'About'}</PanelHeader>
  42. <PanelBody withPadding>
  43. <p>
  44. {tct(
  45. `[link:Certificate Transparency]
  46. (CT) is a security standard which helps track and identify valid certificates, allowing identification of maliciously issued certificates`,
  47. {
  48. link: (
  49. <ExternalLink href="https://en.wikipedia.org/wiki/Certificate_Transparency" />
  50. ),
  51. }
  52. )}
  53. </p>
  54. <p>
  55. {tct(
  56. "To configure reports in Sentry, you'll need to configure the [header] a header from your server:",
  57. {
  58. header: <code>Expect-CT</code>,
  59. }
  60. )}
  61. </p>
  62. <pre>{this.getInstructions(keyList)}</pre>
  63. <p>
  64. {tct('For more information, see [link:the article on MDN].', {
  65. link: (
  66. <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Expect-CT" />
  67. ),
  68. })}
  69. </p>
  70. </PanelBody>
  71. </Panel>
  72. </div>
  73. );
  74. }
  75. }