Skip to content

Fix/types chart tooltip order - #1870

Closed
jaya6400 wants to merge 83 commits into
GreedyBear-Project:mainfrom
jaya6400:fix/types-chart-tooltip-order
Closed

jaya6400 wants to merge 83 commits into
GreedyBear-Project:mainfrom
jaya6400:fix/types-chart-tooltip-order

Conversation

@jaya6400

Copy link
Copy Markdown

Description

Fixes the hover tooltip order on the Feeds: Types chart.

The API returns honeypots sorted alphabetically, and Recharts stacks the first one at the bottom of the bar. But the tooltip (default itemSorter: 'name' in Recharts 3.10.1) lists the same honeypot first, at the top. So the bar and the tooltip were in opposite orders.

I added an optional reverseStackOrder prop to ChartSkeleton (default false) and only FeedsTypesChart turns it on. Now the bar reads top to bottom in the same order as the tooltip rows. The other charts are not affected.

Things to know:

  • The fix relies on the backend's alphabetical order and the tooltip's alphabetical order agreeing, which is true for the current honeypot names.
  • The segment colours change between page loads because getRandomColorsArray is random, so the colours in the two screenshots differ. That's not part of this change.

Before: (tooltip order is the reverse of the bar)

Screenshot (169)

After: (bar and tooltip read in the same order)

Screenshot (171)(1)

Frontend tests (charts.test.jsx):

charts-test-terminal

I also ran the full frontend suite once. Everything passed except Feeds.test.jsx, which timed out at 5s while the whole suite ran. It passes when run on its own, and it doesn't touch the charts.

Related issues

Closes #1830

AI disclosure

I used Claude (chat) to help set up the project locally and to work out the root cause. Claude suggested the code change and the tests, and I applied them, tested them locally in the browser and with Vitest, and reviewed the final diff. I wrote this description myself based on that.

Type of change

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).
  • Chore (refactoring, dependency updates, CI/CD changes, code cleanup, docs-only changes).

rainnj and others added 30 commits September 24, 2026 14:10
…yBear-Project#1584 (GreedyBear-Project#1623)

* Move Tanner attack types to IOC.http_attack_types field. Closes GreedyBear-Project#1584

* Add http_attack_types to SimpleFeedResponseSerializer

* Truncate attack type values in data migration

* Set attack types before add_ioc and remove bulk_add_http_attack_types

* Renumber migrations after merging develop

* Add tests asserting http_attack_types reaches the API
…yBear-Project#1571)

* build(deps-dev): bump vitest from 4.1.11 to 5.0.1 in /frontend

Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 4.1.11 to 5.0.1.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Changelog](https://github.com/vitest-dev/vitest/blob/main/docs/releases.md)
- [Commits](https://github.com/vitest-dev/vitest/commits/v5.0.1/packages/vitest)

---
updated-dependencies:
- dependency-name: vitest
  dependency-version: 5.0.0
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* bump vitest/coverage-v8

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: tim <46972822+regulartim@users.noreply.github.com>
…reedyBear-Project#1622 (GreedyBear-Project#1629)

* Isolate malformed src_ip before bulk prefetch in extraction. Closes GreedyBear-Project#1622

* Extract hit grouping and validation per review
GreedyBear-Project#1515 (GreedyBear-Project#1621)

* feat(api): support date range filtering in cowrie session endpoint

* test(api): Add tests for cowrie-session date filter
…ear-Project#1636 (GreedyBear-Project#1638)

* Widen Credential.protocol to match the event fields. Closes GreedyBear-Project#1636

EventSerializer.protocol and RawEvent.protocol both allow 50 characters
while Credential.protocol only held 32, so an event with a protocol longer
than 32 was accepted with a 202, stored fine, and then raised a DataError
inside the atomic block in process_incoming_event(). That rolled back every
IOC in the batch, and since _claim_batch() treats FAILED as claimable the
same failure replayed on every redelivery.

Widening the column to 50 lines the three widths up so an accepted event can
always be persisted. The migration is a single ALTER COLUMN TYPE, which
Postgres does as a metadata change, so no table rewrite and the unique
constraint and indexes are untouched.

* Address review: drop the field comment and hoist the test import

The comment on Credential.protocol explained a decision rather than the
code, and left one field annotated while the rest of the model is bare.
The reasoning is already in the PR and in GreedyBear-Project#1636.

EventSerializer is imported at module level now; nothing in that chain
imports back into the tests, so it does not need to be deferred.
…r-Project#1651)

* add new dependencies

* add ty config

* merge dependency groups

* refactor ty config

* clear ty type errors across the application

* clear ty type errors in tests

* adapt dockerfile to new dependency groups

* replace deprecated utcnow calls in migration files

* add badge to readme

* add pre-commit hook

* add ty workflow

* pin ty version

* fix comment
…r-Project#1656)

Bumps [nanoid](https://github.com/ai/nanoid) from 3.3.19 to 6.0.1.
- [Release notes](https://github.com/ai/nanoid/releases)
- [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md)
- [Commits](ai/nanoid@3.3.19...6.0.1)

---
updated-dependencies:
- dependency-name: nanoid
  dependency-version: 6.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ear-Project#1657)

Bumps [date-fns](https://github.com/date-fns/date-fns) from 2.30.0 to 4.4.0.
- [Release notes](https://github.com/date-fns/date-fns/releases)
- [Commits](date-fns/date-fns@v2.30.0...v4.4.0)

---
updated-dependencies:
- dependency-name: date-fns
  dependency-version: 4.4.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…eedyBear-Project#1639 (GreedyBear-Project#1664)

nginx used to add the real client IP to the end of whatever
X-Forwarded-For header the client sent. Django uses that header for
rate limiting and for the request statistics, so anyone could put a
fake IP in it and get around the login and feed rate limits, or pad
the source counts on the dashboard.

Now nginx sets the header to $remote_addr, so the client's value is
thrown away and Django only ever sees the real IP. I made the same
change in django_server.conf so the local setup matches production.
Closes GreedyBear-Project#1596 (GreedyBear-Project#1592)

* fix(api): return 400 Bad Request on malformed range parameter in statistics view

* fix(api): lower log level and add statistics sources overflow tests. Closes GreedyBear-Project#1596
…t#1500)

* add separate ssl config file

* rewrite config files

* mount ssl.conf

* create ssl.conf template file

* add ssl_password_file to template

* adjust client_max_body_size

* add /hc endpoint to django_server.conf

* add gzip_vary to feeds API

* add comments

* polish

* add guard function to gbctl
GreedyBear-Project#1653)

* Migrate DataTable to TanStack Table v9. Closes GreedyBear-Project#1648

Signed-off-by: ABHIGYA0205 <abhigyasachdeva2005@gmail.com>

* Fix ESLint prefer-destructuring in Feeds test

Signed-off-by: ABHIGYA0205 <abhigyasachdeva2005@gmail.com>

* Key DataTable memos on stable inputs (v9 returns a fresh table per render)

Signed-off-by: ABHIGYA0205 <abhigyasachdeva2005@gmail.com>

* Re-lock frontend with npm 24 and drop unrelated date-fns/nanoid bumps

Signed-off-by: ABHIGYA0205 <abhigyasachdeva2005@gmail.com>

* Restore package files from develop and re-lock with npm 24

Signed-off-by: ABHIGYA0205 <abhigyasachdeva2005@gmail.com>

---------

Signed-off-by: ABHIGYA0205 <abhigyasachdeva2005@gmail.com>
…loses GreedyBear-Project#1640 (GreedyBear-Project#1641)

* fix(extraction): prevent CommandSequence.last_seen regression when merging sessions

* refactor(extraction): remove isinstance checks and strengthen cleanup regression test
…rites. Closes GreedyBear-Project#1649 (GreedyBear-Project#1652)

* Invalidate feed cache on enrichment, scoring, cleanup and ingestion writes. Closes GreedyBear-Project#1649

* Fix test boundary absorbed by invalidation test

* Address review: drop redundant bump, document score_only contract, fix test mocks

* Address review: use invalidate_ioc_cache() in pipeline, drop absent-code comments
…reedyBear-Project#1666 (GreedyBear-Project#1667)

* create copy of command sequence when session is spanning runs

* add regression test
…tPayload. Closes GreedyBear-Project#1568 (GreedyBear-Project#1644)

* refactor: extend PayloadRepository with full CRUD methods for HoneypotPayload. Closes GreedyBear-Project#1568

* refactor: pass HoneypotPayload instances to upserts, persist updates, add return type hints
…ct#1676 (GreedyBear-Project#1687)

* Remove deprecated onlyActive query parameter. Closes GreedyBear-Project#1676

* Flatten single-case honeypot view tests
…edyBear-Project#1659)

Bumps [django-test-migrations](https://github.com/wemake-services/django-test-migrations) from 1.6.0 to 1.7.0.
- [Release notes](https://github.com/wemake-services/django-test-migrations/releases)
- [Changelog](https://github.com/wemake-services/django-test-migrations/blob/master/CHANGELOG.md)
- [Commits](wemake-services/django-test-migrations@1.6.0...1.7.0)

---
updated-dependencies:
- dependency-name: django-test-migrations
  dependency-version: 1.7.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…Project#1672 (GreedyBear-Project#1678)

* Include the full end day in feeds end_date filter. Closes GreedyBear-Project#1672

* Drop redundant api-cache clears; CustomTestCase.setUp already clears per test
Aditya Amol Kuchekar and others added 27 commits October 28, 2026 10:46
…reedyBear-Project#1668 (GreedyBear-Project#1780)

* Reject over long hostnames before the insert

parse_url_hostname moves from the Cowrie strategy into utils and now
returns None for anything longer than a valid DNS name, so an attacker
URL with a 300 character host no longer reaches varchar(256) and raises.
Tanner used urlparse directly and bypassed the helper; it now shares it.

A hostname rejected here is still a dropped record, so the three call
sites count it in skipped, which the guard used to do when the insert
raised.

* Reject over long related URLs instead of letting the column cut them

Django casts related_urls explicitly, and an explicit cast truncates
rather than raising, so a URL over 900 characters was stored cut in half
with nothing logged. fits_field reads the width off the field, the same
way clamp_to_field does, so the limit cannot drift from the schema.

The hostname is the identifying part and is stored separately, so a URL
that does not fit costs the URL and not the record: the IOC is still
saved, with related_urls empty.

Covers all four sites that write a URL there: both Cowrie sites and
Tanner through related_urls_for on the base strategy, and the event
collector path in _process_related_urls.

* Keep a test for the real database error

You asked to keep at least one test that causes a real DataError.
The guards now reject the long hostname before the insert, so nothing
reached Postgres any more and the recovery in base.py was not covered.

The new test puts the old parse_url_hostname back for one run so the
long host gets to the insert. It checks the log really says DataError,
then that the five records behind it still went through and only one
was skipped. A mocked exception would not test this because the point
is the savepoint rollback after Postgres aborts the transaction.

Also fixed the assertion you asked about. It reads the width off the
field now instead of comparing against 256.
…t#1752 (GreedyBear-Project#1753)

* Fix GreedyBear-Project#1752: reserve feed-type date key

* Fix GreedyBear-Project#1752: group feed statistics by honeypot

* Keep existing statistics cache namespace
…Project#1765 (GreedyBear-Project#1781)

* Fix duplicate IOC metrics in ASN feed

* Address ASN aggregation review feedback

* Fix duplicate ASN re-query block

---------

Co-authored-by: tim <46972822+regulartim@users.noreply.github.com>
…-Project#1705 (GreedyBear-Project#1778)

* Enforce CSRF for cookie-authenticated API requests. Closes GreedyBear-Project#1705

* Silence ty false positives for the unused CSRFCheck arguments

* Drop unneeded LogoutView/APIAccessTokenView subclasses

* Set CSRF cookie for non-superusers on page load and login
…eedyBear-Project#1787 (GreedyBear-Project#1808)

end_date=9999-12-31 overflowed when the filter added a day to it, so it
is now treated as no upper bound. max_age gets an upper limit of 36500
days, so values reaching back before year 1 return 400 instead of 500.
GreedyBear-Project#1729 (GreedyBear-Project#1811)

The cluster expansion in the Cowrie session view deliberately ignores
start_date and end_date, but nothing said so. The help text for
include_similar now states it, and both date fields point back at the
exception, so it is visible from either side of the API docs.

Because commands, sources and credentials are aggregated after the
expansion, out-of-window data reaches them too, even without
include_session_data. The help text says that as well.

Three tests pin the behaviour, which the suite did not cover before:
the expansion crossing the window, the aggregated fields crossing it,
and an empty window staying empty because the expansion has no
in-window session to take its clusters from.

No behaviour change.
… (GreedyBear-Project#1810)

* Fix cross-user share-token ownership

* Fix share-token type-check errors

* Move share-token salt helper and update tests

* Move salt generation to models.py

---------

Co-authored-by: tim <46972822+regulartim@users.noreply.github.com>
…ar-Project#1751 (GreedyBear-Project#1833)

* Move Spamhaus Drop tagging to its own enrichment job. Closes GreedyBear-Project#1751

* Share blocklist tagging between FireHol and Spamhaus DROP jobs.
…ear-Project#1683 (GreedyBear-Project#1735)

* Normalize IPv6 addresses on read and write operations. Closes GreedyBear-Project#1683

* Normalize IPs on write path and fix BaseEnrichmentJob._match_iocs normalization

* Lint: apply ruff formatting fixes (spacing, blank lines, trailing newlines)

* Add test case

* Normalize FireHOL keys in get_entries_by_ip instead of _match_iocs

---------

Co-authored-by: tim <46972822+regulartim@users.noreply.github.com>
…ar-Project#1794 (GreedyBear-Project#1843)

The active honeypot filter ran after the early return for aggregated views, so the ASN feed counted IOCs that only inactive honeypots had seen. Apply it before the return. aggregate_iocs_by_asn re-queries by pk, so the join does not double-count.
…r-Project#1814 (GreedyBear-Project#1840)

iocs_from_hits now collects the distinct days of all hit timestamps
and _merge_iocs merges them into the stored days_seen. Before, only
the date of the latest event was recorded, so batches that span
several days (or late uploads) lost days.
…ject#1789 (GreedyBear-Project#1844)

* Fix trending feed cache across hour boundaries

* Add return type to trending window property

* Add return type to trending window property

* Fix import formatting
…edyBear-Project#1837)

* fix: enforce JSON-only rendering for ASN feed

* test: add regression test for application/x-ndjson accept header

* style: fix test spacing for ruff formatting
…Closes GreedyBear-Project#1812 (GreedyBear-Project#1834)

* Clamp attacker-controlled event fields instead of rejecting the batch. Closes GreedyBear-Project#1812

InjectionSerializer validates a batch as one unit, so a single event that
fails validation rejects the whole request and nothing is staged. Several
EventSerializer fields hold strings the attacker types at the honeypot
rather than values the operator's agent picks, so one over long username
or one malformed download URL discarded up to 10,000 valid events.

Clamp username, password, session_id and protocol to the width of their
column, the way normalize_credential_field already does on the T-Pot path,
and drop an unusable related_url to an empty string. _process_related_urls
already drops an over long URL rather than storing it, and
_normalize_raw_event_to_hit re-checks is_valid_url before the value is
used, so dropping it here loses nothing that would have been kept.

LenientURLField subclasses CharField rather than URLField because
URLField's URLValidator lives in self.validators and runs after
to_internal_value, so a dropped value would fail as an empty string.

This reverses a deliberate decision from GreedyBear-Project#1707: sanitize_text returned a
clean over long value whole so that it still failed validation. Its
docstring and the test that pinned it are updated accordingly.

* Drop related_url values Postgres can't store. Refs GreedyBear-Project#1812

A related_url with a NUL or a lone surrogate passes URLValidator, so
LenientURLField returned it unchanged. The model's validators then reject
it and the whole batch fails - the same thing the clamp was meant to avoid.

Screen for those characters in to_internal_value and drop the URL to an
empty string, like any other unusable value, and cover both through the
batch tests. Lift the shared _post_mixed/_assert_batch_saved helpers into a
BatchSanitizationTestCase base so the two batch test classes don't repeat them.
…ear-Project#1815 (GreedyBear-Project#1852)

* End Django admin session on logout

* revoke other Django sessions along with auth tokens
- Add optional reverseStackOrder prop to ChartSkeleton (defaults to false)
- Enable reverseStackOrder in FeedsTypesChart so bars read top-to-bottom
- Expose prop in ComposedChart mock and add unit tests
@jaya6400 jaya6400 closed this Nov 18, 2026
@jaya6400 jaya6400 reopened this Nov 18, 2026
@jaya6400 jaya6400 closed this Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feeds: Types chart: hover tooltip lists honeypots in reverse order of the stacked bar