expectCt.tsx 3.0 KB

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