expectCt.tsx 3.2 KB

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