Coverity-CWE 922: Insecure Storage of Sensitive Information(localStorage write)
- Coverity fix for localStorage write issue: For storing datas
in browser localStorage so changed it to sessionStorage
Change-Id: I3fdce439b923e006b44a50a42fab19b7ffbcdec6
Signed-off-by: SANDHYA.JS <sandhya.j@tataelxsi.co.in>
diff --git a/src/app/login/LoginComponent.ts b/src/app/login/LoginComponent.ts
index db842d8..1ffa8c3 100644
--- a/src/app/login/LoginComponent.ts
+++ b/src/app/login/LoginComponent.ts
@@ -195,7 +195,7 @@
userName: ['', [Validators.required]],
password: ['', [Validators.required]]
});
- this.returnUrl = isNullOrUndefined(localStorage.getItem('returnUrl')) ? '/' : localStorage.getItem('returnUrl');
+ this.returnUrl = isNullOrUndefined(sessionStorage.getItem('returnUrl')) ? '/' : sessionStorage.getItem('returnUrl');
}
/**
@@ -227,15 +227,15 @@
this.router.navigate([this.returnUrl]).catch((): void => {
// Catch Navigation Error
});
- this.isAdminShow = localStorage.getItem('admin_show') === 'true' ? true : false;
- this.isUserShow = localStorage.getItem('user_show') === 'true' ? true : false;
+ this.isAdminShow = sessionStorage.getItem('admin_show') === 'true' ? true : false;
+ this.isUserShow = sessionStorage.getItem('user_show') === 'true' ? true : false;
setTimeout((): void => {
if (this.isAdminShow === true || this.isUserShow === true) {
this.generateData();
}
}, this.epochTime1000);
}
- localStorage.removeItem('returnUrl');
+ sessionStorage.removeItem('returnUrl');
}, (err: HttpErrorResponse): void => {
this.isLoadingResults = false;
this.restService.handleError(err, 'post');
@@ -244,7 +244,7 @@
/** Fetching the data from server to load it in toaster @public */
public generateData(): void {
- const userID: string = localStorage.getItem('user_id');
+ const userID: string = sessionStorage.getItem('user_id');
if (userID !== '') {
this.isLoadingResults = true;
this.restService.getResource(environment.USERS_URL + '/' + userID).subscribe((userDetails: UserDetail): void => {
@@ -267,8 +267,8 @@
this.accountExpireMessage = this.translateService.instant('PAGE.LOGIN.ACCOUNTEXPIRE');
this.passwordExpireMessage = this.translateService.instant('PAGE.LOGIN.PASSWORDEXPIRE');
this.daysMessage = this.translateService.instant('PAGE.LOGIN.DAYS');
- this.lastLogin = localStorage.getItem('last_login');
- this.failedAttempts = localStorage.getItem('failed_count');
+ this.lastLogin = sessionStorage.getItem('last_login');
+ this.failedAttempts = sessionStorage.getItem('failed_count');
if (this.accountNoOfDays !== '0' && this.passwordNoOfDays !== '0' &&
this.accountNoOfDays !== '1' && this.passwordNoOfDays !== '1') {
this.showToaster();