Skip to content

Absorb MUIO v5.5 changes#422

Merged
SeaCelo merged 12 commits intomainfrom
feature/v55-ui-sync
Apr 8, 2026
Merged

Absorb MUIO v5.5 changes#422
SeaCelo merged 12 commits intomainfrom
feature/v55-ui-sync

Conversation

@SeaCelo
Copy link
Copy Markdown
Collaborator

@SeaCelo SeaCelo commented Apr 7, 2026

Closes #388, closes #389, closes #390, closes #391, closes #392

Summary

  • Syncs MUIOGO with upstream MUIO v5.5, following upstream by default and patching only where MUIOGO needs to preserve runtime safety, security, or cross-platform correctness.
  • Adds a smoke test harness and sync checklist (UPSTREAM_SYNC.md) so future upstream pulls have repeatable guardrails.
  • Adds runtime logging infrastructure with file rotation and a fallback to temp dir when .runtime/ isn't writable.
  • Ports the v5.5 diagnostics UI: DataFile model/log viewer, standalone ModelFile page with MathJax equation rendering, scenario toggle-all.
  • Takes upstream v5.5 result metadata, unit rules, and pivot updates (Variables.json, Parameters.json, DataModelResult.Class.js, Const.Class.js, Pivot.js).
  • Backend files that carry MUIOGO-specific fixes (path validation, session guards, solver resolution, subprocess safety) are kept on the MUIOGO version — not replaced with upstream.

What changed

What was intentionally not taken from upstream v5.5

  • Home.js, Base.Class.js, CaseRoute.py — upstream didn't change these; MUIOGO's fixes stay as-is
  • UploadRoute.py — upstream change is trivial (unused import); MUIOGO's path traversal protection stays
  • FileClass.py, OsemosysClass.py — MUIOGO's refactored versions kept; upstream changes are subsumed
  • app.config.js — upstream sets SA_IGNORE_CSS = true which is a broad layout toggle; not taken
  • osy.pro.css, osy.prov2.css, osemosys.gif, .vscode/launch.json, FileClassCompressed.py, WebAPP/app.log — passive upstream assets not wired into the app

Known residuals

  • RYC unit display is blank in results view — upstream v5.5 metadata gap, intentionally left unpatched
  • pandas FutureWarning during CBC postprocessing — pre-existing, not from this work

Test plan

  • ./scripts/setup.sh --check
  • ./scripts/smoke.sh — 5 tests pass
  • git ls-files -u — no unmerged paths
  • git diff --check — no whitespace errors
  • DataFile page loads, model/log buttons present and working
  • /#/ModelFile renders equations (MathJax typeset when available, readable fallback when not)
  • Scenario toggle-all works, SC_0 stays locked
  • CBC demo run end-to-end
  • Results/pivot screens load with correct data
  • Manual browser validation pass

@github-actions github-actions Bot added the needs-intake-fix PR intake structure needs maintainer follow-up label Apr 7, 2026
@SeaCelo SeaCelo added Priority: High and removed needs-intake-fix PR intake structure needs maintainer follow-up labels Apr 7, 2026
Copy link
Copy Markdown

@github-advanced-security github-advanced-security AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@SeaCelo SeaCelo marked this pull request as draft April 7, 2026 21:06
@github-actions github-actions Bot added the needs-intake-fix PR intake structure needs maintainer follow-up label Apr 8, 2026
@SeaCelo SeaCelo removed the needs-intake-fix PR intake structure needs maintainer follow-up label Apr 8, 2026
@SeaCelo SeaCelo marked this pull request as ready for review April 8, 2026 02:22
@github-actions github-actions Bot added the needs-intake-fix PR intake structure needs maintainer follow-up label Apr 8, 2026
@SeaCelo SeaCelo marked this pull request as draft April 8, 2026 02:24
@parthdagia05
Copy link
Copy Markdown

Hi @SeaCelo ,

I noticed the CodeQL check is flagging 72 high-severity alerts for "Uncontrolled data used in path expression" in API/Classes/Base/FileClass.py and API/Classes/Case/DataFileClass.py. These are path traversal warnings file paths built from user input without sanitization.

Let me know if you'd like me to open a PR against your branch with the fixes, or if you'd prefer to handle it yourself.

@SeaCelo
Copy link
Copy Markdown
Collaborator Author

SeaCelo commented Apr 8, 2026

This PR syncs MUIOGO with upstream MUIO v5.5 and adds path traversal protection.

What changed upstream in v5.5

MUIO v5.5 reworked the diagnostics UI (the "DataFile" page), added a new "ModelFile" page for viewing/editing the model text file, simplified how results metadata works (fewer hardcoded parameters/variables), and cleaned up the backend routing and app startup.

We took all of it. The only places we held back were where upstream's changes would undo MUIOGO-specific fixes — cross-platform path handling, the Python version guard, and _muiogo_handler (our custom error handler that replaces MUIO's inline path logic with Config.DATA_STORAGE).

Path traversal guards (new)

CodeQL flagged 72 py/path-injection alerts. The core problem: several routes take a case name or filename from the user and plug it straight into a file path. A malicious user could send ../../etc/passwd instead of a real case name and read or delete files outside the data folder.

The fix has two parts:

  1. OsemosysClass constructor — one validate_path call at the top. Every case operation flows through Osemosys(case) or its child DataFile(case), so this single check covers all ~55 alerts in DataFileClass.py.

  2. DataFileRoute download/delete routes — five routes build paths from multiple user-supplied pieces (case + run + filename) without going through the constructor. Each gets its own validate_path call before any file access.

validate_path (in Config.py) resolves the full path and checks it stays inside DATA_STORAGE. If not, it raises PermissionError and the request gets a 400.

The 72 CodeQL alerts are false positives. CodeQL tracks user input from source to sink and flags any path that uses it in a file operation. It can't recognise custom sanitizer functions — only built-in ones. We explored adding a CodeQL model file to declare validate_path as a sanitizer barrier, but the YAML-based model approach doesn't resolve local project modules, only installed packages. The alerts remain open, but the runtime protection is real and tested.

To guard against future changes to validate_path weakening the protection without anyone noticing, we added 8 unit tests that verify it blocks the main attack patterns: ../ traversal, absolute paths, encoded traversal, null bytes, and None input.

Also included

  • UPSTREAM_SYNC.md documenting what we changed and why
  • Smoke tests (tests/test_app_smoke.py) covering the path traversal guards and basic route health
  • Shell/batch scripts for running smoke tests on any platform

@SeaCelo SeaCelo marked this pull request as ready for review April 8, 2026 03:01
@SeaCelo
Copy link
Copy Markdown
Collaborator Author

SeaCelo commented Apr 8, 2026

Hi @SeaCelo ,

I noticed the CodeQL check is flagging 72 high-severity alerts for "Uncontrolled data used in path expression" in API/Classes/Base/FileClass.py and API/Classes/Case/DataFileClass.py. These are path traversal warnings file paths built from user input without sanitization.

Let me know if you'd like me to open a PR against your branch with the fixes, or if you'd prefer to handle it yourself.

@parthdagia05 yes, I'm fixed the traversal by sanitizing, but CodeQL doesn't recognize it for other reasons. I documented and we will dismiss the alert as a false positive.

Comment thread API/Classes/Case/DataFileClass.py Dismissed
Comment thread API/Classes/Case/DataFileClass.py Dismissed
Comment thread API/Classes/Case/DataFileClass.py Dismissed
Comment thread API/Classes/Case/DataFileClass.py Dismissed
Comment thread API/Classes/Case/DataFileClass.py Dismissed
Comment thread API/Classes/Case/DataFileClass.py Dismissed
Comment thread API/Classes/Case/DataFileClass.py Dismissed
Comment thread API/Classes/Case/DataFileClass.py Dismissed
Comment thread API/Classes/Case/DataFileClass.py Dismissed
Comment thread API/Classes/Case/DataFileClass.py Dismissed
@SeaCelo SeaCelo merged commit 7fd0404 into main Apr 8, 2026
5 checks passed
@SeaCelo SeaCelo deleted the feature/v55-ui-sync branch April 8, 2026 03:21
@brightyorcerf
Copy link
Copy Markdown
Contributor

brightyorcerf commented Apr 8, 2026

This is a massive lift, @SeaCelo!

Stabilizing the v5.5 baseline with a formal UPSTREAM_SYNC playbook is a huge win for the repo’s long-term health.

I'll take a look at the RYC metadata gap and those CBC FutureWarnings. I've already prototyped a lightweight way to fill those specific blanks without diverging from the new upstream baseline, so I'll follow up with a targeted patch to clear the residuals.

Update: #433

parthdagia05 added a commit to parthdagia05/MUIOGO that referenced this pull request Apr 13, 2026
Removes 25 active console.log debug calls across 20 files in
WebAPP/App/Controller/ and WebAPP/App/Model/. These fired during
normal user actions (page loads, cell edits, case selection) and
in some cases dumped entire model objects to the browser console.

Scope notes:
- Preserves console.error (intentional error logging) and
  commented-out // console.log(...) lines (out of scope).
- Skips WebAPP/Classes/*.js since those are upstream-overlap
  surface per docs/UPSTREAM_SYNC.md and would risk merge
  conflicts at the next MUIO sync.

Follows the cleanup precedent from EAPD-DRB#422, which removed similar
debug logs from Pivot.js, DataModelResult.Class.js, and
Const.Class.js during the v5.5 sync.

Fixes EAPD-DRB#436
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-intake-fix PR intake structure needs maintainer follow-up Priority: High

Projects

None yet

4 participants