projectSecurityAndPrivacyGroups.tsx 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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) =>
  83. (props.organization && props.organization[props.name]) || val,
  84. confirm: {
  85. false: t('Are you sure you want to disable server-side data scrubbing?'),
  86. },
  87. },
  88. {
  89. name: 'dataScrubberDefaults',
  90. type: 'boolean',
  91. disabled: hasOrgOverride,
  92. disabledReason: ORG_DISABLED_REASON,
  93. label: t('Use Default Scrubbers'),
  94. help: t(
  95. 'Apply default scrubbers to prevent things like passwords and credit cards from being stored'
  96. ),
  97. 'aria-label': t(
  98. 'Enable to apply default scrubbers to prevent things like passwords and credit cards from being stored'
  99. ),
  100. // `props` are the props given to FormField
  101. setValue: (val, props) =>
  102. (props.organization && props.organization[props.name]) || val,
  103. confirm: {
  104. false: t('Are you sure you want to disable using default scrubbers?'),
  105. },
  106. },
  107. {
  108. name: 'scrubIPAddresses',
  109. type: 'boolean',
  110. disabled: hasOrgOverride,
  111. disabledReason: ORG_DISABLED_REASON,
  112. // `props` are the props given to FormField
  113. setValue: (val, props) =>
  114. (props.organization && props.organization[props.name]) || val,
  115. label: t('Prevent Storing of IP Addresses'),
  116. help: t('Preventing IP addresses from being stored for new events'),
  117. 'aria-label': t(
  118. 'Enable to prevent IP addresses from being stored for new events'
  119. ),
  120. confirm: {
  121. false: t('Are you sure you want to disable scrubbing IP addresses?'),
  122. },
  123. },
  124. {
  125. name: 'sensitiveFields',
  126. type: 'string',
  127. multiline: true,
  128. autosize: true,
  129. maxRows: 10,
  130. rows: 1,
  131. placeholder: t('email'),
  132. label: t('Additional Sensitive Fields'),
  133. help: t(
  134. 'Additional field names to match against when scrubbing data. Separate multiple entries with a newline'
  135. ),
  136. 'aria-label': t(
  137. 'Enter additional field names to match against when scrubbing data. Separate multiple entries with a newline'
  138. ),
  139. getValue: val => extractMultilineFields(val),
  140. setValue: val => convertMultilineFieldValue(val),
  141. },
  142. {
  143. name: 'safeFields',
  144. type: 'string',
  145. multiline: true,
  146. autosize: true,
  147. maxRows: 10,
  148. rows: 1,
  149. placeholder: t('business-email'),
  150. label: t('Safe Fields'),
  151. help: t(
  152. 'Field names which data scrubbers should ignore. Separate multiple entries with a newline'
  153. ),
  154. 'aria-label': t(
  155. 'Enter field names which data scrubbers should ignore. Separate multiple entries with a newline'
  156. ),
  157. getValue: val => extractMultilineFields(val),
  158. setValue: val => convertMultilineFieldValue(val),
  159. },
  160. ],
  161. },
  162. ];
  163. export default formGroups;