@profullstack/threatcrush 0.13.6 → 0.13.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -12672,12 +12672,21 @@ function initialState(now = Date.now()) {
12672
12672
  notice: null,
12673
12673
  busy: false,
12674
12674
  moduleIndex: 0,
12675
- moduleFilter: null
12675
+ moduleFilter: null,
12676
+ showNoise: false
12676
12677
  };
12677
12678
  }
12679
+ function isNoise(event) {
12680
+ return (event.severity === "low" || event.severity === "info") && /^Client error 4\d\d:/.test(event.message);
12681
+ }
12678
12682
  function visibleEvents(state) {
12679
- if (!state.moduleFilter) return state.events;
12680
- return state.events.filter((e) => e.module === state.moduleFilter);
12683
+ return state.events.filter(
12684
+ (e) => (!state.moduleFilter || e.module === state.moduleFilter) && (state.showNoise || !isNoise(e))
12685
+ );
12686
+ }
12687
+ function hiddenNoise(state) {
12688
+ if (state.showNoise) return 0;
12689
+ return state.events.filter((e) => (!state.moduleFilter || e.module === state.moduleFilter) && isNoise(e)).length;
12681
12690
  }
12682
12691
  function isBanned(state, ip) {
12683
12692
  return state.bans.some((b) => b.ip === ip);
@@ -12814,6 +12823,8 @@ function reducer(state, action) {
12814
12823
  }
12815
12824
  case "clear_module_filter":
12816
12825
  return { ...state, moduleFilter: null, scrollBack: 0 };
12826
+ case "toggle_noise":
12827
+ return { ...state, showNoise: !state.showNoise, scrollBack: 0 };
12817
12828
  case "counters":
12818
12829
  return {
12819
12830
  ...state,
@@ -12847,7 +12858,8 @@ function reducer(state, action) {
12847
12858
  firewall: state.firewall,
12848
12859
  focus: state.focus,
12849
12860
  moduleFilter: state.moduleFilter,
12850
- moduleIndex: state.moduleIndex
12861
+ moduleIndex: state.moduleIndex,
12862
+ showNoise: state.showNoise
12851
12863
  };
12852
12864
  }
12853
12865
  }
@@ -13142,6 +13154,10 @@ function severityPanel(parent, state, theme) {
13142
13154
  }
13143
13155
  );
13144
13156
  }
13157
+ function noiseNote(state) {
13158
+ const hidden = hiddenNoise(state);
13159
+ return hidden > 0 ? `${hidden} routine 4xx hidden \xB7 n shows` : void 0;
13160
+ }
13145
13161
  function feedPanel(parent, state, theme, options) {
13146
13162
  const following = state.scrollBack === 0;
13147
13163
  const shown = visibleEvents(state);
@@ -13153,7 +13169,7 @@ function feedPanel(parent, state, theme, options) {
13153
13169
  border: "rounded",
13154
13170
  borderColor: state.connection === "live" ? theme.borderFocused : theme.border,
13155
13171
  titleColor: theme.primary,
13156
- subtitle: filtered ? `${shown.length}/${state.events.length} \xB7 esc clears filter` : following ? void 0 : `\u2191 ${state.scrollBack} back \xB7 end to follow`,
13172
+ subtitle: filtered ? `${shown.length}/${state.events.length} \xB7 esc clears filter` : following ? noiseNote(state) : `\u2191 ${state.scrollBack} back \xB7 end to follow`,
13157
13173
  subtitleColor: filtered ? theme.primary : severityColors.medium,
13158
13174
  padding: [0, 1]
13159
13175
  },
@@ -13165,6 +13181,13 @@ function feedPanel(parent, state, theme, options) {
13165
13181
  panel.label("esc shows everything again", { fg: theme.muted, align: "center" });
13166
13182
  return;
13167
13183
  }
13184
+ if (!filtered && shown.length === 0 && state.events.length > 0) {
13185
+ panel.spacer(1);
13186
+ panel.text("Nothing but routine 4xx client errors so far.", { fg: theme.muted, align: "center" });
13187
+ panel.spacer(1);
13188
+ panel.label("n shows them", { fg: theme.muted, align: "center" });
13189
+ return;
13190
+ }
13168
13191
  if (state.events.length === 0) {
13169
13192
  panel.spacer(1);
13170
13193
  if (state.connection === "live") {
@@ -13368,7 +13391,8 @@ function footer(ui, state, theme) {
13368
13391
  { key: "\u2191\u2193", label: onFeed ? "scroll" : "select" },
13369
13392
  ...state.focus === "modules" ? [{ key: "\u23CE", label: state.moduleFilter ? "unfilter" : "filter" }] : [{ key: "b", label: "ban" }, { key: "u", label: "unban" }],
13370
13393
  { key: "p", label: state.paused ? "resume" : "pause" },
13371
- { key: "r", label: "reset" }
13394
+ { key: "r", label: "reset" },
13395
+ { key: "n", label: state.showNoise ? "hide 4xx" : "show 4xx" }
13372
13396
  ],
13373
13397
  right: [
13374
13398
  // The notice is the answer to "did my keypress do anything", so it takes
@@ -13631,6 +13655,9 @@ async function startDashboard(options = {}) {
13631
13655
  case "r":
13632
13656
  dispatch({ type: "reset" });
13633
13657
  break;
13658
+ case "n":
13659
+ dispatch({ type: "toggle_noise" });
13660
+ break;
13634
13661
  case "tab":
13635
13662
  dispatch({ type: "focus_next" });
13636
13663
  break;