projectSecurityAndPrivacyGroups.tsx 5.5 KB

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