Skip to content

Refactor: Secure sessionStorageService and update cookie attributes#80

Open
Anurag-elitx wants to merge 1 commit into
PSMRI:mainfrom
Anurag-elitx:refactor/session-storage-security
Open

Refactor: Secure sessionStorageService and update cookie attributes#80
Anurag-elitx wants to merge 1 commit into
PSMRI:mainfrom
Anurag-elitx:refactor/session-storage-security

Conversation

@Anurag-elitx

Copy link
Copy Markdown

📋 Description

JIRA ID: #131

This PR audits and secures the sessionStorageService by addressing several security and robustness flaws identified during the audit.

Key Changes:

  1. Added Object Serialization: Implemented JSON.stringify before encryption and JSON.parse after decryption in setItem and getItem. Previously, passing an object resulted in "[object Object]" being stored.
  2. Fallback Encryption Key: Added a fallback key check to ensure that if environment.encKey is empty (as it currently is in environment.ts), the service uses a fallback instead of failing or storing with an empty key.
  3. Cookie Security: Updated the setCookie method to include the ; SameSite=Lax attribute to provide CSRF protection.
  4. Code Cleanup: Removed unused legacy RxJS operator imports (map, catch) to clean up the file.

✅ Type of Change

  • 🐞 Bug fix (non-breaking change which resolves 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)
  • 🛠 Refactor (change that is neither a fix nor a new feature)
  • ⚙️ Config change (configuration file or build script updates)
  • 📚 Documentation (updates to docs or readme)
  • 🧪 Tests (adding new or updating existing tests)
  • 🎨 UI/UX (changes that affect the user interface)
  • 🚀 Performance (improves performance)
  • 🧹 Chore (miscellaneous changes that don't modify src or test files)

ℹ️ Additional Information

  • The getItem method includes a try-catch block around JSON.parse to ensure backward compatibility with plain string values that might already be in the storage.

@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Anurag-elitx has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 36 minutes and 21 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 84db74b8-d7fe-41dc-995a-9d0f77a6d492

📥 Commits

Reviewing files that changed from the base of the PR and between df5db19 and 7415e1b.

📒 Files selected for processing (1)
  • src/app/services/sessionStorageService/session-storage.service.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

1 participant