projectSecurityAndPrivacyGroups.tsx 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. import type {JsonFormObject} from 'sentry/components/forms/types';
  2. import Link from 'sentry/components/links/link';
  3. import {t, tct} from 'sentry/locale';
  4. import {convertMultilineFieldValue, extractMultilineFields} from 'sentry/utils';
  5. import {
  6. formatStoreCrashReports,
  7. getStoreCrashReportsValues,
  8. SettingScope,
  9. } from 'sentry/utils/crashReports';
  10. // Export route to make these forms searchable by label/help
  11. export const route = '/settings/:orgId/projects/:projectId/security-and-privacy/';
  12. const ORG_DISABLED_REASON = t(
  13. "This option is enforced by your organization's settings and cannot be customized per-project."
  14. );
  15. // Check if a field has been set AND IS TRUTHY at the organization level.
  16. const hasOrgOverride = ({organization, name}) => organization[name];
  17. const formGroups: JsonFormObject[] = [
  18. {
  19. title: t('Security & Privacy'),
  20. fields: [
  21. {
  22. name: 'storeCrashReports',
  23. type: 'select',
  24. label: t('Store Native Crash Reports'),
  25. help: ({organization}) =>
  26. tct(
  27. 'Store native crash reports such as Minidumps for improved processing and download in issue details. Overrides [organizationSettingsLink: organization settings].',
  28. {
  29. organizationSettingsLink: (
  30. <Link to={`/settings/${organization.slug}/security-and-privacy/`} />
  31. ),
  32. }
  33. ),
  34. visible: ({features}) => features.has('event-attachments'),
  35. placeholder: ({organization, value}) => {
  36. // empty value means that this project should inherit organization settings
  37. if (value === '') {
  38. return tct('Inherit organization settings ([organizationValue])', {
  39. organizationValue: formatStoreCrashReports(organization.storeCrashReports),
  40. });
  41. }
  42. // HACK: some organization can have limit of stored crash reports a number that's not in the options (legacy reasons),
  43. // we therefore display it in a placeholder
  44. return formatStoreCrashReports(value);
  45. },
  46. choices: ({organization}) =>
  47. getStoreCrashReportsValues(SettingScope.PROJECT).map(value => [
  48. value,
  49. formatStoreCrashReports(value, organization.storeCrashReports),
  50. ]),
  51. },
  52. ],
  53. },
  54. {
  55. title: t('Data Scrubbing'),
  56. fields: [
  57. {
  58. name: 'dataScrubber',
  59. type: 'boolean',
  60. label: t('Data Scrubber'),
  61. disabled: hasOrgOverride,
  62. disabledReason: ORG_DISABLED_REASON,
  63. help: t('Enable server-side data scrubbing'),
  64. 'aria-label': t('Enable server-side data scrubbing'),
  65. // `props` are the props given to FormField
  66. setValue: (val, props) => props.organization?.[props.name] || val,
  67. confirm: {
  68. false: t('Are you sure you want to disable server-side data scrubbing?'),
  69. },
  70. },
  71. {
  72. name: 'dataScrubberDefaults',
  73. type: 'boolean',
  74. disabled: hasOrgOverride,
  75. disabledReason: ORG_DISABLED_REASON,
  76. label: t('Use Default Scrubbers'),
  77. help: t(
  78. 'Apply default scrubbers to prevent things like passwords and credit cards from being stored'
  79. ),
  80. 'aria-label': t(
  81. 'Enable to apply default scrubbers to prevent things like passwords and credit cards from being stored'
  82. ),
  83. // `props` are the props given to FormField
  84. setValue: (val, props) => props.organization?.[props.name] || val,
  85. confirm: {
  86. false: t('Are you sure you want to disable using default scrubbers?'),
  87. },
  88. },
  89. {
  90. name: 'scrubIPAddresses',
  91. type: 'boolean',
  92. disabled: hasOrgOverride,
  93. disabledReason: ORG_DISABLED_REASON,
  94. // `props` are the props given to FormField
  95. setValue: (val, props) => props.organization?.[props.name] || val,
  96. label: t('Prevent Storing of IP Addresses'),
  97. help: t('Preventing IP addresses from being stored for new events'),
  98. 'aria-label': t(
  99. 'Enable to prevent IP addresses from being stored for new events'
  100. ),
  101. confirm: {
  102. false: t('Are you sure you want to disable scrubbing IP addresses?'),
  103. },
  104. },
  105. {
  106. name: 'sensitiveFields',
  107. type: 'string',
  108. multiline: true,
  109. autosize: true,
  110. maxRows: 10,
  111. rows: 1,
  112. placeholder: t('email'),
  113. label: t('Additional Sensitive Fields'),
  114. help: t(
  115. 'Additional field names to match against when scrubbing data. Separate multiple entries with a newline'
  116. ),
  117. 'aria-label': t(
  118. 'Enter additional field names to match against when scrubbing data. Separate multiple entries with a newline'
  119. ),
  120. getValue: val => extractMultilineFields(val),
  121. setValue: val => convertMultilineFieldValue(val),
  122. },
  123. {
  124. name: 'safeFields',
  125. type: 'string',
  126. multiline: true,
  127. autosize: true,
  128. maxRows: 10,
  129. rows: 1,
  130. placeholder: t('business-email'),
  131. label: t('Safe Fields'),
  132. help: t(
  133. 'Field names which data scrubbers should ignore. Separate multiple entries with a newline'
  134. ),
  135. 'aria-label': t(
  136. 'Enter field names which data scrubbers should ignore. Separate multiple entries with a newline'
  137. ),
  138. getValue: val => extractMultilineFields(val),
  139. setValue: val => convertMultilineFieldValue(val),
  140. },
  141. ],
  142. },
  143. ];
  144. export default formGroups;