fix: assign unique page_uid to custom-attribute tab/field ids - #1113
Open
Scharxi wants to merge 1 commit into
Open
fix: assign unique page_uid to custom-attribute tab/field ids#1113Scharxi wants to merge 1 commit into
Scharxi wants to merge 1 commit into
Conversation
page_uid namespaces the generated DOM ids for every custom-attribute tab/field (modal_attributes_tabs.html, modal_attributes_nav.html) but was never assigned anywhere in the codebase, so every render used the same unscoped ids (e.g. "1_investigation_metadata"). Bootstrap 4's data-toggle="pill" resolves its target pane via a document-global CSS id lookup while pill highlighting stays correctly scoped to the nav, so an id collision breaks tab switching without breaking which pill looks active - reproducing dfir-iris#1111 (case details: wrong tab highlighted by default, clicking tabs doesn't show their content). Adds a single generate_page_uid() helper in app/util.py and wires it into all 15 render_template() call sites that reach the shared attribute-tab partials, across case/asset/ioc/task/event/evidence and manage/case/customer/attribute-preview modals. No template changes - the templates already read {{page_uid}} correctly. Extends the test harness (tests/rest_api.py, tests/iris.py) with a raw-HTML fetch and a real cookie-session login helper, since every existing test only talks to the JSON API via API key and this bug is only observable in server-rendered HTML behind a real session (SESSION_COOKIE_SECURE=True means the session cookie never survives a plain-HTTP round trip, so the helper must go through nginx/HTTPS). Adds a regression test that renders two independent cases and asserts their custom-attribute tab ids differ.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1111. The case-details "Custom Attributes" tab didn't highlight or
switch correctly because
page_uid— used to namespace every generated attribute tab/field DOM id— was referenced in 12
templates but never assigned anywhere in the codebase, so every render
produced the same unscoped
ids and Bootstrap 4's global id-based tab lookup collided.
What changed
Adds one
generate_page_uid()helper (app/util.py) and wires it intoall 15
render_template()call sites that reach the shared attribute-tab partials, across
case/asset/ioc/task/event/evidence
and manage/case/customer/attribute-preview modals. Zero template changes —
modal_attributes_tabs.htmland
modal_attributes_nav.htmlalready read{{page_uid}}correctly,they just never received a value.
Also extends the test harness (
tests/rest_api.py,tests/iris.py) witha raw-HTML fetch and a real
cookie-session login helper — the existing suite only talks to the JSON
API via API key, which can't
reach this bug (only observable in server-rendered HTML behind a real
session). Adds a regression test
that renders two independent cases and asserts their attribute-tab ids
differ.
Validation
5/5pass (4 pre-existing + 1 new regression test) against afresh v2.4.29 stack running this
branch's code — zero regressions.
python -m py_compileclean on all 12 touched files.independently-rendered cases get
distinct
page_uids instead of both rendering1_investigation_metadata.docker-compose.dev.yml's from-source build could not be run in theauthoring sandbox (unrelated
Debian apt-signing/network issue, fails before any app code is copied
in) — substituted with the
published
v2.4.29images + this branch's source bind-mounted in; fulldetails in the notes below.
Notes for the reviewer
hotfix_v2.4.29, notdevelop—develophasmoved to a private
v3.0.0-beta submodule architecture (
iris-backend/iris-frontend)where this code no longer exists.
Redirect me if there's a different intended target for v2.4.x fixes.
SESSION_COOKIE_SECURE=True(configuration.py:294) meanssession-cookie auth only survives HTTPS —
the new test helper goes through nginx (
https://127.0.0.1, certverification off for the dev
self-signed cert), not the plain-HTTP port the existing API-key-based
tests use.
custom_attributesat creation (onlythe "Add case" modal
pre-fetches and echoes back defaults) — the regression test creates
cases first, then updates the
attribute definition, so
update_all_attributes()'s backfill path iswhat seeds them. Commented
inline in the test.
Linked
Fixes #1111
Ready for review.