-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release/v3.32.0 #3761
base: release/v3.31.2
Are you sure you want to change the base?
Release/v3.32.0 #3761
Conversation
…inks and metadata
…DOUT_MAX_SIZE error for wide csvs
|
||
if (window.location.origin.startsWith('http://localhost')) { | ||
// If we are running on localhost, we want to use the local server for authentication | ||
sessionStorage.setItem(this.user.username, this.user.password); |
Check failure
Code scanning / CodeQL
Clear text storage of sensitive information High
an access to password
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 11 days ago
To fix the problem, we need to ensure that the password is encrypted before storing it in sessionStorage
. We can use the Web Crypto API to encrypt the password. This will involve generating a key, encrypting the password, and then storing the encrypted password in sessionStorage
.
-
Copy modified lines R41-R42 -
Copy modified lines R54-R73
@@ -40,3 +40,4 @@ | ||
// If we are running on localhost, we want to use the local server for authentication | ||
sessionStorage.setItem(this.user.username, this.user.password); | ||
const encryptedPassword = await this.encryptPassword(this.user.password); | ||
sessionStorage.setItem(this.user.username, encryptedPassword); | ||
this.router.navigate([this.returnUrl]); | ||
@@ -52,2 +53,22 @@ | ||
} | ||
|
||
async encryptPassword(password: string): Promise<string> { | ||
const encoder = new TextEncoder(); | ||
const data = encoder.encode(password); | ||
const key = await crypto.subtle.generateKey( | ||
{ name: "AES-GCM", length: 256 }, | ||
true, | ||
["encrypt", "decrypt"] | ||
); | ||
const iv = crypto.getRandomValues(new Uint8Array(12)); | ||
const encrypted = await crypto.subtle.encrypt( | ||
{ name: "AES-GCM", iv: iv }, | ||
key, | ||
data | ||
); | ||
const encryptedArray = new Uint8Array(encrypted); | ||
const ivArray = Array.from(iv); | ||
const encryptedPassword = ivArray.concat(Array.from(encryptedArray)); | ||
return btoa(String.fromCharCode(...encryptedPassword)); | ||
} | ||
|
Description
[What is the business, user experience or technical problem? What is the motivation or context? Any Dependencies required for the change? e.g
tangy-forms
version etc][List the issues fixed and any other relevant issues]
Type of Change
[Please delete irrelevant options]
Proposed Solution
[Please give a description of the solution proposed in the PR]
Limitations and Trade-offs
[Optional. What are the limitations of the proposed solution? What are the potential edge cases that one should be aware of? What are some of the tradeoffs? What are some of the approaches considered and not used? Why were they not used? ]
Security considerations
Screenshots/Videos
[Optional. Post screenshots or videos to explain this change visually.]
Tests
[How you tested (or have not tested) this PR and what where those steps.]
Notices, Regressions, Breaking Changes
[Optional. Impacts to developers, project or structure that is required to be communicated.]
TODOS/enhancements
[Optional. List out the remaining tasks that would complete this pull request.]