Skip to content

security(demo): archive default-credential demo users in spp_mis_demo_v2/spp_grm_demo/spp_drims_sl(_demo)#356

Draft
gonzalesedwin1123 wants to merge 2 commits into
19.0from
security-demo-default-creds-other-bundles
Draft

security(demo): archive default-credential demo users in spp_mis_demo_v2/spp_grm_demo/spp_drims_sl(_demo)#356
gonzalesedwin1123 wants to merge 2 commits into
19.0from
security-demo-default-creds-other-bundles

Conversation

@gonzalesedwin1123

Copy link
Copy Markdown
Member

Closes #345. Follow-up from #341 (which fixed the same class in spp_demo + spp_farmer_registry_demo), extended to the remaining demo bundles.

Problem

Four modules ship res.users records with the well-known password demo in their data/demo_users.xml, listed under the manifest data section — so they are created on every install, including a production database installed without demo data, where the well-known credentials are a live login vector. spp_drims_sl's user_admin_dmc (admin.dmc@drims.gov.lk) even holds base.group_system.

Module Default-cred users (password demo)
spp_mis_demo_v2 7 (demo_local_registrardemo_cycle_approver)
spp_grm_demo 2 (demo_grm_manager, demo_grm_officer)
spp_drims_sl 14 (incl. user_admin_dmcbase.group_system)
spp_drims_sl_demo 6 (kumari, rajitha, silva, perera, fernando, secretary)

Fix (same pattern as #341)

Each module gains a post_init_hook that archives (active=False) its default-credential users when the database has no demo data (ir.module.module.demo is False), and leaves them active on demo/evaluation instances. Odoo runs post_init_hook on install, and these user records carry no demo-gated active toggle, so the hook is the mechanism that neutralizes them on a production-style install.

Self-contained helpers (no dependency on #341). The spp_demo helper #341 adds does not exist on 19.0 yet, so reusing it would couple this PR to #341. Instead each module carries its own small archive helper; spp_drims_sl_demo reuses spp_drims_sl's via its existing dependency. spp_mis_demo_v2's hook composes the archiving with its existing demo-variable activation (the manifest keeps a single post_init_hook).

spp_mis_demo_v2 and spp_grm_demo also drop Production/StableAlpha (they are demo-only bundles); spp_drims_sl(_demo) were already Alpha. Each demo_users.xml gains a security header comment. Deliberately not doing a datademo restructure — the demo generators need these users to exist on eval DBs, matching #341's rationale.

Tests

New test_demo_user_safety.py per module (archived when demo disabled; active when enabled; demo_data_enabled matches the module flag; manifest wires the hook; spp_drims_sl additionally asserts user_admin_dmc is in the set and holds base.group_system).

One pre-existing test, spp_mis_demo_v2's test_change_request_workflow_states, drives the demo CR generator's tiered approval — which only the designated demo validators can perform (admin is not a tier approver). Since the hook archives those validators on the (demo-less) test DB, its setUpClass now reactivates them; running the generator is an explicit demo action. Generator runtime and the security hook are unchanged — no real install re-enables the default-credential users.

Suites green locally: spp_mis_demo_v2 279, spp_grm_demo 36, spp_drims_sl 9, spp_drims_sl_demo 13. README/index regeneration left to CI's pinned oca-gen (fragments changed).

Merge-web note

Disjoint from the 18 open security PRs and from #341/#336. spp_mis_demo_v2 also appears in the held reland #282 (which is stale on this module: it bumps to 19.0.2.1.0 while base is 19.0.2.1.3); this PR bumps to 19.0.2.1.4. Whichever lands second re-merges metadata.

Draft — awaiting human security review before undraft/merge.

…nstall

spp_mis_demo_v2, spp_grm_demo, spp_drims_sl and spp_drims_sl_demo each ship
res.users with the well-known password "demo" in their data section, so they
are created on every install — including a production database without demo
data, where the credentials are a login vector (spp_drims_sl's user_admin_dmc
even holds base.group_system). Same class as #341, extended to these bundles.

Each module gains a post_init_hook that archives its default-credential users
when the database has no demo data, leaving them active on demo/eval instances.
The helper is self-contained per module (no dependency on the unmerged #341
spp_demo helper); spp_drims_sl_demo reuses spp_drims_sl's helper via its
existing dependency. spp_mis_demo_v2's hook composes the archiving with its
existing demo-variable activation. spp_mis_demo_v2 and spp_grm_demo drop
Production/Stable (demo-only bundles).

test_change_request_workflow_states drives the demo CR generator's tiered
approval, which requires the designated demo validators; its setUpClass now
reactivates them (running the generator is an explicit demo action). Generator
runtime and the security hook are unchanged.

Refs #345
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.22%. Comparing base (1caf794) to head (59a93b3).
⚠️ Report is 3 commits behind head on 19.0.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             19.0     #356      +/-   ##
==========================================
- Coverage   74.28%   69.22%   -5.06%     
==========================================
  Files         372      119     -253     
  Lines       25385    11810   -13575     
==========================================
- Hits        18857     8176   -10681     
+ Misses       6528     3634    -2894     
Flag Coverage Δ
spp_analytics ?
spp_api_v2_cycles ?
spp_api_v2_entitlements ?
spp_api_v2_gis ?
spp_api_v2_programs ?
spp_api_v2_simulation ?
spp_audit_programs ?
spp_base_common 91.07% <ø> (+0.80%) ⬆️
spp_case_demo ?
spp_case_entitlements ?
spp_case_programs ?
spp_cr_type_assign_program ?
spp_dci_compliance ?
spp_dci_demo 94.28% <ø> (+0.88%) ⬆️
spp_dci_server_social ?
spp_demo ?
spp_demo_phl_luzon ?
spp_drims ?
spp_drims_sl 100.00% <100.00%> (+100.00%) ⬆️
spp_drims_sl_demo 69.18% <100.00%> (+0.84%) ⬆️
spp_farmer_registry_demo ?
spp_gis_report ?
spp_grm_demo 81.34% <100.00%> (+1.47%) ⬆️
spp_indicator ?
spp_indicator_studio ?
spp_metric_service ?
spp_mis_demo_v2 71.25% <100.00%> (+0.29%) ⬆️
spp_programs 65.27% <ø> (+<0.01%) ⬆️
spp_registry 86.94% <ø> (+0.10%) ⬆️
spp_security 69.56% <ø> (+2.89%) ⬆️
spp_simulation ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
spp_drims_sl/__init__.py 100.00% <100.00%> (ø)
spp_drims_sl_demo/__init__.py 100.00% <100.00%> (ø)
spp_grm_demo/__init__.py 100.00% <100.00%> (ø)
spp_mis_demo_v2/__init__.py 100.00% <100.00%> (ø)

... and 255 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gonzalesedwin1123

Copy link
Copy Markdown
Member Author

CI status note. All module test jobs pass (incl. test (spp_mis_demo_v2)), and this PR's four modules are lint-clean. The pre-commit check is red only due to repo-wide linter version drift tracked in #361 (~200 pre-existing translation-required across ~22 unrelated modules + eslint findings in ~6 JS modules; the same base commit 0dc69f08 passed pre-commit on 2026-07-14 and fails now with identical code). The one part of the pre-commit failure attributable to this PR — the oca-gen README regeneration — has been applied from CI's diff and pushed. No unrelated modules were touched here per PR-scope discipline.

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.

security(demo): default-credential users unguarded in spp_mis_demo_v2/spp_grm_demo/spp_drims_sl(_demo); + data->demo restructure [Severity: Medium]

1 participant