DumbAssets icon indicating copy to clipboard operation
DumbAssets copied to clipboard

add multiple user and multiple language and fix cve

Open burghy86 opened this issue 6 months ago โ€ข 1 comments

Security (CVE / Path Traversal)

  • deleteAssetFileAsync: Added a path.resolve() check against DATA_DIR to prevent path traversal vulnerabilities.
  • /api/delete-file: Implemented the same protection; now returns a 403 Forbidden status code if the resolved path falls outside of DATA_DIR.

Internationalization (i18n)

  • public/i18n/translations.js: Created a complete EN/IT translation module exposing window.i18n and window.t().
  • HTML Integration: Included the script in index.html and login.html ensuring it loads before config.js.
  • DOM Elements: Added data-i18n and data-i18n-placeholder attributes to key elements.
  • UI Updates: Added a "Language" tab in the settings menu with ๐Ÿ‡ฌ๐Ÿ‡ง English / ๐Ÿ‡ฎ๐Ÿ‡น Italiano toggle buttons.
  • Styling: Added dedicated CSS rules for language selectors (.lang-btn, .language-options).

Multi-user Support

  • /api/users: Endpoint added to fetch the user list (public, unauthenticated).
  • /api/whoami: Endpoint added to return the current session user (authenticated).
  • /verify-pin: Refactored to handle both single-user and multi-user modes (requiring username + PIN).
  • /pin-length: Updated to return multiUser: true when active.
  • Login Flow: Completely rewrote login.html to support a new multi-step flow: User Selection โ†’ PIN Input โ†’ Back Button.
  • Styling: Added custom CSS for .user-btn, .user-list, and .back-btn.
  • Routing: Updated publicPaths to allow access to /api/users and /i18n/.
  • UI Updates: The logged-in user's badge is now displayed in the footer when multi-user mode is active.

Bug Fixes

  • Search Reset: Fixed an issue where search queries were cleared; loadAssets() now caches the search term before fetching and reapplies it afterward.
  • CSV Export Quantity: Added the missing Quantity column to both CSV generators (full and simple exports).

High-level PR Summary

This PR introduces multi-user authentication support with username selection and individual PIN verification, adds internationalization (i18n) with English and Italian translations, and fixes a path traversal security vulnerability (CVE) in file deletion endpoints. The changes include a new translation module with data-i18n attributes throughout the UI, a completely rewritten multi-step login flow that handles both single-user and multi-user modes, security enhancements using path.resolve() checks to prevent directory traversal attacks, and several bug fixes including missing Quantity column in CSV exports and search query persistence issues.

โฑ๏ธ Estimated Review Time: 30-90 minutes

๐Ÿ’ก Review Order Suggestion
Order File Path
1 server.js
2 public/i18n/translations.js
3 public/login.html
4 public/index.html
5 public/config.js
6 public/script.js
7 public/managers/settings.js
8 public/styles.css
9 package-lock.json
10 .replit
โš ๏ธ Inconsistent Changes Detected
File Path Warning
.replit Adding Replit-specific deployment configuration appears unrelated to the main PR objectives of multi-user support, i18n, and security fixes. This is infrastructure/deployment configuration that doesn't align with the stated feature additions.

Need help? Join our Discord

Summary by CodeRabbit

  • New Features

    • Added internationalization support with English and Italian language options
    • Introduced multi-user PIN authentication with user selection on login
    • Added language selector in the settings interface
    • Added user identification display showing logged-in user information
    • Added Quantity column to CSV export functionality
  • Bug Fixes

    • Search queries are now preserved when refreshing the asset list
    • Enhanced security for file deletion operations

Review Change Stack

burghy86 avatar May 25 '26 13:05 burghy86

Walkthrough

This PR implements internationalization (English/Italian), multi-user PIN authentication, dashboard language switching, server-side user verification with IP lockout, path traversal protection for file deletion, and includes CSS styling, CSV export improvements, search persistence, and Replit configuration.

Changes

Multi-user authentication and internationalization infrastructure

Layer / File(s) Summary
i18n translation engine and DOM integration
public/i18n/translations.js, public/config.js
Introduces TRANSLATIONS catalog for English and Italian, detects active language from localStorage or browser, exposes window.i18n API with t(), setLanguage(), getLanguage(), applyTranslations(), and wires DOM translation on DOMContentLoaded using data-i18n attributes.
Login page multi-user and single-user flows
public/login.html
Refactors login to detect single vs. multi-user mode via /pin-length endpoint, renders conditional UI for user selection or direct PIN entry, implements buildPinInputs helper for digit input management, verifies via verify-pin with {username, pin} or {pin}, handles lockout/redirect messages with i18n labels.
Server multi-user authentication endpoints and middleware
server.js
Parses DUMBASSETS_USERS into USERS array, adds /api/users and /api/whoami endpoints, refactors authMiddleware to handle multi-user sessions, extends pin-length/verify-pin to validate {username, pin} with IP-based brute-force lockout (429), and preserves single-user behavior when multi-user is disabled.

Dashboard UI integration, styling, and hardening

Layer / File(s) Summary
Dashboard language support and settings tab
public/index.html
Loads translations.js, applies i18n to sidebar search, "Add Asset" button, and Settings modal tabs, introduces Language/Lingua tab with language buttons, and internationalizes Save/Cancel/Test action buttons.
User badge and language sync
public/index.html (script section)
Adds hidden user badge element, wires language button clicks to setLanguage(), syncs active button with current language, listens for languageChanged events, and fetches /api/whoami to display logged-in username.
Login and dashboard UI styling
public/styles.css
Adds CSS for language selector buttons (.language-options, .lang-btn), multi-user user list (.user-list, .user-btn), and back button (.back-btn) with hover/active state styling.
File deletion security and minor features
server.js (path checks), public/managers/settings.js, public/script.js
Hardens asset file deletion and /api/delete-file with path traversal boundary checks. Extends CSV exports to include Quantity field with 1 as default. Updates loadAssets() to preserve active search query on re-render.
Replit environment configuration
.replit
Defines Replit environment with Node.js modules, expertMode agent settings, Nix stable-25_05 channel, server startup workflow (port 5000), port mappings, and VM deployment run command.

๐ŸŒ๐Ÿ” Multi-users now log in with their own PINs,
While languages dance between English and Italian spins,
Path traversal blocked with security gains,
Dashboard glows with i18n's refrains,
CSV counts quantities as the flow begins. ๐ŸŽฏ


๐ŸŽฏ 3 (Moderate) | โฑ๏ธ ~25 minutes

๐Ÿšฅ Pre-merge checks | โœ… 3 | โŒ 2

โŒ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage โš ๏ธ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check โ“ Inconclusive The PR title mentions the main features added (multiple users, multiple languages) but is vague about the CVE fix and lacks specificity about what changes were made. Consider being more specific, such as: 'Add multi-user and i18n support with path traversal security fix' to better convey the scope and main objectives.
โœ… Passed checks (3 passed)
Check name Status Explanation
Description Check โœ… Passed Check skipped - CodeRabbitโ€™s high-level summary is enabled.
Linked Issues check โœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check โœ… Passed Check skipped because no linked issues were found for this pull request.

โœ๏ธ Tip: You can configure your own custom pre-merge checks in the settings.

โœจ Finishing Touches
๐Ÿงช Generate unit tests (beta)
  • [ ] Create PR with unit tests

[!WARNING] There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

๐Ÿ”ง ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

โค๏ธ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar May 25 '26 13:05 coderabbitai[bot]