utils.tsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. import {t} from 'app/locale';
  2. import {MethodType, RuleType, SourceSuggestion, SourceSuggestionType} from './types';
  3. function getRuleLabel(type: RuleType) {
  4. switch (type) {
  5. case RuleType.ANYTHING:
  6. return t('Anything');
  7. case RuleType.IMEI:
  8. return t('IMEI numbers');
  9. case RuleType.MAC:
  10. return t('MAC addresses');
  11. case RuleType.EMAIL:
  12. return t('Email addresses');
  13. case RuleType.PEMKEY:
  14. return t('PEM keys');
  15. case RuleType.URLAUTH:
  16. return t('Auth in URLs');
  17. case RuleType.USSSN:
  18. return t('US social security numbers');
  19. case RuleType.USER_PATH:
  20. return t('Usernames in filepaths');
  21. case RuleType.UUID:
  22. return t('UUIDs');
  23. case RuleType.CREDITCARD:
  24. return t('Credit card numbers');
  25. case RuleType.PASSWORD:
  26. return t('Password fields');
  27. case RuleType.IP:
  28. return t('IP addresses');
  29. case RuleType.PATTERN:
  30. return t('Regex matches');
  31. default:
  32. return '';
  33. }
  34. }
  35. function getMethodLabel(type: MethodType) {
  36. switch (type) {
  37. case MethodType.MASK:
  38. return {
  39. label: t('Mask'),
  40. description: t('Replace with ****'),
  41. };
  42. case MethodType.HASH:
  43. return {
  44. label: t('Hash'),
  45. description: t('Replace with DEADBEEF'),
  46. };
  47. case MethodType.REMOVE:
  48. return {
  49. label: t('Remove'),
  50. description: t('Replace with null'),
  51. };
  52. case MethodType.REPLACE:
  53. return {
  54. label: t('Replace'),
  55. description: t('Replace with Placeholder'),
  56. };
  57. default:
  58. return {
  59. label: '',
  60. };
  61. }
  62. }
  63. const binarySuggestions: Array<SourceSuggestion> = [
  64. {
  65. type: SourceSuggestionType.BINARY,
  66. value: '&&',
  67. },
  68. {
  69. type: SourceSuggestionType.BINARY,
  70. value: '||',
  71. },
  72. ];
  73. const unarySuggestions: Array<SourceSuggestion> = [
  74. {
  75. type: SourceSuggestionType.UNARY,
  76. value: '!',
  77. },
  78. ];
  79. const valueSuggestions: Array<SourceSuggestion> = [
  80. {type: SourceSuggestionType.VALUE, value: '**', description: t('everywhere')},
  81. {
  82. type: SourceSuggestionType.VALUE,
  83. value: 'password',
  84. description: t('attributes named "password"'),
  85. },
  86. {
  87. type: SourceSuggestionType.VALUE,
  88. value: '$error.value',
  89. description: t('the exception value'),
  90. },
  91. {
  92. type: SourceSuggestionType.VALUE,
  93. value: '$message',
  94. description: t('the log message'),
  95. },
  96. {
  97. type: SourceSuggestionType.VALUE,
  98. value: 'extra.MyValue',
  99. description: t('the key "MyValue" in "Additional Data"'),
  100. },
  101. {
  102. type: SourceSuggestionType.VALUE,
  103. value: 'extra.**',
  104. description: t('everything in "Additional Data"'),
  105. },
  106. {
  107. type: SourceSuggestionType.VALUE,
  108. value: '$http.headers.x-custom-token',
  109. description: t('the X-Custom-Token HTTP header'),
  110. },
  111. {
  112. type: SourceSuggestionType.VALUE,
  113. value: '$user.ip_address',
  114. description: t('the user IP address'),
  115. },
  116. {
  117. type: SourceSuggestionType.VALUE,
  118. value: '$frame.vars.foo',
  119. description: t('the local variable "foo"'),
  120. },
  121. {
  122. type: SourceSuggestionType.VALUE,
  123. value: 'contexts.device.timezone',
  124. description: t('the timezone in the device context'),
  125. },
  126. {
  127. type: SourceSuggestionType.VALUE,
  128. value: 'tags.server_name',
  129. description: t('the tag "server_name"'),
  130. },
  131. {
  132. type: SourceSuggestionType.VALUE,
  133. value: '$attachments.**',
  134. description: t('all attachments'),
  135. },
  136. {
  137. type: SourceSuggestionType.VALUE,
  138. value: "$attachments.'logfile.txt'",
  139. description: t('all attachments named "logfile.txt"'),
  140. },
  141. {
  142. type: SourceSuggestionType.VALUE,
  143. value: '$minidump',
  144. description: t('the entire minidump of a native crash report'),
  145. },
  146. {
  147. type: SourceSuggestionType.VALUE,
  148. value: '$minidump.heap_memory',
  149. description: t('the heap memory region in a native crash report'),
  150. },
  151. {
  152. type: SourceSuggestionType.VALUE,
  153. value: 'code_file',
  154. description: t('the pathname of a code module in a native crash report'),
  155. },
  156. {
  157. type: SourceSuggestionType.VALUE,
  158. value: 'debug_file',
  159. description: t('the pathname of a debug module in a native crash report'),
  160. },
  161. ];
  162. export {
  163. binarySuggestions,
  164. getMethodLabel,
  165. getRuleLabel,
  166. unarySuggestions,
  167. valueSuggestions,
  168. };