Skip to content
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

Open
wants to merge 61 commits into
base: release/v3.31.2
Choose a base branch
from
Open

Release/v3.32.0 #3761

wants to merge 61 commits into from

Conversation

esurface
Copy link
Contributor

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]

  • Fixes #IssueNumber

Type of Change

[Please delete irrelevant options]

  • Bug fix (non-breaking change which fixes 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)
  • This change requires a documentation update

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.]

  • [Develop more tests for this PR.]
  • [Follow up on something else.]

esurface added 30 commits May 16, 2024 12:09
esurface added 24 commits June 12, 2024 13:29
@esurface esurface changed the base branch from main to release/v3.31.2 January 10, 2025 16:18

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

This stores sensitive data returned by
an access to password
as clear text.

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.

Suggested changeset 1
online-survey-app/src/app/core/auth/_components/login/login.component.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/online-survey-app/src/app/core/auth/_components/login/login.component.ts b/online-survey-app/src/app/core/auth/_components/login/login.component.ts
--- a/online-survey-app/src/app/core/auth/_components/login/login.component.ts
+++ b/online-survey-app/src/app/core/auth/_components/login/login.component.ts
@@ -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));
+  }
 
EOF
@@ -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));
}

Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
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