projectSecurityAndPrivacyGroups.tsx 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. name: 'recapServerUrl',
  54. type: 'string',
  55. placeholder: t('URL'),
  56. label: t('Recap Server URL'),
  57. help: t('URL to the Recap Server events should be polled from'),
  58. visible: ({features}) => features.has('recap-server'),
  59. },
  60. {
  61. name: 'recapServerToken',
  62. type: 'string',
  63. placeholder: t('Token'),
  64. label: t('Recap Server Token'),
  65. help: t('Auth Token to the configured Recap Server'),
  66. visible: ({features}) => features.has('recap-server'),
  67. },
  68. ],
  69. },
  70. {
  71. title: t('Data Scrubbing'),
  72. fields: [
  73. {
  74. name: 'dataScrubber',
  75. type: 'boolean',
  76. label: t('Data Scrubber'),
  77. disabled: hasOrgOverride,
  78. disabledReason: ORG_DISABLED_REASON,
  79. help: t('Enable server-side data scrubbing'),
  80. 'aria-label': t('Enable server-side data scrubbing'),
  81. // `props` are the props given to FormField
  82. setValue: (val, props) => props.organization?.[props.name] || val,
  83. confirm: {
  84. false: t('Are you sure you want to disable server-side data scrubbing?'),
  85. },
  86. },
  87. {
  88. name: 'dataScrubberDefaults',
  89. type: 'boolean',
  90. disabled: hasOrgOverride,
  91. disabledReason: ORG_DISABLED_REASON,
  92. label: t('Use Default Scrubbers'),
  93. help: t(
  94. 'Apply default scrubbers to prevent things like passwords and credit cards from being stored'
  95. ),
  96. 'aria-label': t(
  97. 'Enable to apply default scrubbers to prevent things like passwords and credit cards from being stored'
  98. ),
  99. // `props` are the props given to FormField
  100. setValue: (val, props) => props.organization?.[props.name] || val,
  101. confirm: {
  102. false: t('Are you sure you want to disable using default scrubbers?'),
  103. },
  104. },
  105. {
  106. name: 'scrubIPAddresses',
  107. type: 'boolean',
  108. disabled: hasOrgOverride,
  109. disabledReason: ORG_DISABLED_REASON,
  110. // `props` are the props given to FormField
  111. setValue: (val, props) => props.organization?.[props.name] || val,
  112. label: t('Prevent Storing of IP Addresses'),
  113. help: t('Preventing IP addresses from being stored for new events'),
  114. 'aria-label': t(
  115. 'Enable to prevent IP addresses from being stored for new events'
  116. ),
  117. confirm: {
  118. false: t('Are you sure you want to disable scrubbing IP addresses?'),
  119. },
  120. },
  121. {
  122. name: 'sensitiveFields',
  123. type: 'string',
  124. multiline: true,
  125. autosize: true,
  126. maxRows: 10,
  127. rows: 1,
  128. placeholder: t('email'),
  129. label: t('Additional Sensitive Fields'),
  130. help: t(
  131. 'Additional field names to match against when scrubbing data. Separate multiple entries with a newline'
  132. ),
  133. 'aria-label': t(
  134. 'Enter additional field names to match against when scrubbing data. Separate multiple entries with a newline'
  135. ),
  136. getValue: val => extractMultilineFields(val),
  137. setValue: val => convertMultilineFieldValue(val),
  138. },
  139. {
  140. name: 'safeFields',
  141. type: 'string',
  142. multiline: true,
  143. autosize: true,
  144. maxRows: 10,
  145. rows: 1,
  146. placeholder: t('business-email'),
  147. label: t('Safe Fields'),
  148. help: t(
  149. 'Field names which data scrubbers should ignore. Separate multiple entries with a newline'
  150. ),
  151. 'aria-label': t(
  152. 'Enter field names which data scrubbers should ignore. Separate multiple entries with a newline'
  153. ),
  154. getValue: val => extractMultilineFields(val),
  155. setValue: val => convertMultilineFieldValue(val),
  156. },
  157. ],
  158. },
  159. ];
  160. export default formGroups;