projectSecurityAndPrivacyGroups.tsx 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. // `props` are the props given to FormField
  65. setValue: (val, props) =>
  66. (props.organization && 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. // `props` are the props given to FormField
  81. setValue: (val, props) =>
  82. (props.organization && props.organization[props.name]) || val,
  83. confirm: {
  84. false: t('Are you sure you want to disable using default scrubbers?'),
  85. },
  86. },
  87. {
  88. name: 'scrubIPAddresses',
  89. type: 'boolean',
  90. disabled: hasOrgOverride,
  91. disabledReason: ORG_DISABLED_REASON,
  92. // `props` are the props given to FormField
  93. setValue: (val, props) =>
  94. (props.organization && props.organization[props.name]) || val,
  95. label: t('Prevent Storing of IP Addresses'),
  96. help: t('Preventing IP addresses from being stored for new events'),
  97. confirm: {
  98. false: t('Are you sure you want to disable scrubbing IP addresses?'),
  99. },
  100. },
  101. {
  102. name: 'sensitiveFields',
  103. type: 'string',
  104. multiline: true,
  105. autosize: true,
  106. maxRows: 10,
  107. rows: 1,
  108. placeholder: t('email'),
  109. label: t('Additional Sensitive Fields'),
  110. help: t(
  111. 'Additional field names to match against when scrubbing data. Separate multiple entries with a newline'
  112. ),
  113. getValue: val => extractMultilineFields(val),
  114. setValue: val => convertMultilineFieldValue(val),
  115. },
  116. {
  117. name: 'safeFields',
  118. type: 'string',
  119. multiline: true,
  120. autosize: true,
  121. maxRows: 10,
  122. rows: 1,
  123. placeholder: t('business-email'),
  124. label: t('Safe Fields'),
  125. help: t(
  126. 'Field names which data scrubbers should ignore. Separate multiple entries with a newline'
  127. ),
  128. getValue: val => extractMultilineFields(val),
  129. setValue: val => convertMultilineFieldValue(val),
  130. },
  131. ],
  132. },
  133. ] as JsonFormObject[];