From 5abbd109444b0455e820213acb65dd6c9ace6176 Mon Sep 17 00:00:00 2001 From: "sonarqube-agent[bot]" <210722872+sonarqube-agent[bot]@users.noreply.github.com> Date: Mon, 25 May 2026 01:02:59 +0000 Subject: [PATCH] fix: Address 5 SonarQube issues Fixed issues: - AZWU-tC6YJSZqVQVbSbn for typescript:S4138 rule - AZWU-tkZYJSZqVQVbSkC for typescript:S6594 rule - AZWU-teOYJSZqVQVbShY for typescript:S6594 rule - AZWU-s-ZYJSZqVQVbSbY for typescript:S101 rule - AZWU-s_NYJSZqVQVbSbb for typescript:S101 rule Generated by SonarQube Agent (task: 1f5035c4-bc1c-4331-8b3a-9872039a2a8e) --- frontend/src/app/Services/code-fixes.service.ts | 4 ++-- frontend/src/app/Services/vuln-lines.service.ts | 4 ++-- frontend/src/app/code-snippet/code-snippet.component.ts | 4 ++-- frontend/src/app/oauth/oauth.component.ts | 4 ++-- lib/codingChallenges.ts | 2 +- test/cypress/support/commands.ts | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/frontend/src/app/Services/code-fixes.service.ts b/frontend/src/app/Services/code-fixes.service.ts index 9d92c26ef1e..91f87cf7603 100644 --- a/frontend/src/app/Services/code-fixes.service.ts +++ b/frontend/src/app/Services/code-fixes.service.ts @@ -4,7 +4,7 @@ import { HttpClient } from '@angular/common/http' import { catchError, map } from 'rxjs/operators' import { type Observable } from 'rxjs' -export interface result { +export interface Result { verdict: boolean } @@ -33,6 +33,6 @@ export class CodeFixesService { return this.http.post(this.host, { key, selectedFix - }).pipe(map((response: result) => response), catchError((error: any) => { throw error })) + }).pipe(map((response: Result) => response), catchError((error: any) => { throw error })) } } diff --git a/frontend/src/app/Services/vuln-lines.service.ts b/frontend/src/app/Services/vuln-lines.service.ts index 1531150c546..3d11fade3e9 100644 --- a/frontend/src/app/Services/vuln-lines.service.ts +++ b/frontend/src/app/Services/vuln-lines.service.ts @@ -3,7 +3,7 @@ import { environment } from '../../environments/environment' import { HttpClient } from '@angular/common/http' import { catchError, map } from 'rxjs/operators' -export interface result { +export interface Result { verdict: boolean hint: string } @@ -21,6 +21,6 @@ export class VulnLinesService { return this.http.post(this.host, { key, selectedLines - }).pipe(map((response: result) => response), catchError((error: any) => { throw error })) + }).pipe(map((response: Result) => response), catchError((error: any) => { throw error })) } } diff --git a/frontend/src/app/code-snippet/code-snippet.component.ts b/frontend/src/app/code-snippet/code-snippet.component.ts index 54e175e1280..0979c152ff3 100644 --- a/frontend/src/app/code-snippet/code-snippet.component.ts +++ b/frontend/src/app/code-snippet/code-snippet.component.ts @@ -7,7 +7,7 @@ import { CodeSnippetService, type CodeSnippet } from '../Services/code-snippet.s import { CodeFixesService } from '../Services/code-fixes.service' import { CookieService } from 'ngx-cookie' import { ChallengeService } from '../Services/challenge.service' -import { VulnLinesService, type result } from '../Services/vuln-lines.service' +import { VulnLinesService, type Result } from '../Services/vuln-lines.service' import { Component, Inject, type OnInit } from '@angular/core' import { MAT_DIALOG_DATA } from '@angular/material/dialog' @@ -112,7 +112,7 @@ export class CodeSnippetComponent implements OnInit { } checkLines = () => { - this.vulnLinesService.check(this.dialogData.key, this.selectedLines).subscribe((verdict: result) => { + this.vulnLinesService.check(this.dialogData.key, this.selectedLines).subscribe((verdict: Result) => { this.setVerdict(verdict.verdict) this.hint = verdict.hint }) diff --git a/frontend/src/app/oauth/oauth.component.ts b/frontend/src/app/oauth/oauth.component.ts index d6ace480026..12d71a79575 100644 --- a/frontend/src/app/oauth/oauth.component.ts +++ b/frontend/src/app/oauth/oauth.component.ts @@ -54,8 +54,8 @@ export class OAuthComponent implements OnInit { const hash = this.route.snapshot.data.params.substr(1) const splitted = hash.split('&') const params: any = {} - for (let i = 0; i < splitted.length; i++) { - const param: string = splitted[i].split('=') + for (const item of splitted) { + const param: string = item.split('=') const key: string = param[0] params[key] = param[1] } diff --git a/lib/codingChallenges.ts b/lib/codingChallenges.ts index 7650cc28999..617e01c280b 100644 --- a/lib/codingChallenges.ts +++ b/lib/codingChallenges.ts @@ -56,7 +56,7 @@ function getCodeChallengesFromFile (file: FileMatch) { } function getCodingChallengeFromFileContent (source: string, challengeKey: string) { - const snippets = source.match(`[/#]{0,2} vuln-code-snippet start.*${challengeKey}([^])*vuln-code-snippet end.*${challengeKey}`) + const snippets = new RegExp(`[/#]{0,2} vuln-code-snippet start.*${challengeKey}([^])*vuln-code-snippet end.*${challengeKey}`).exec(source) if (snippets == null) { throw new BrokenBoundary('Broken code snippet boundaries for: ' + challengeKey) } diff --git a/test/cypress/support/commands.ts b/test/cypress/support/commands.ts index 9c865d551a4..b2eb143bc9d 100644 --- a/test/cypress/support/commands.ts +++ b/test/cypress/support/commands.ts @@ -33,7 +33,7 @@ Cypress.Commands.add( 'login', (context: { email: string, password: string, totpSecret?: string }) => { cy.visit('/#/login') - if (context.email.match(/\S+@\S+\.\S+/) != null) { + if (/\S+@\S+\.\S+/.exec(context.email) != null) { cy.get('#email').type(context.email) } else { cy.task('GetFromConfig', 'application.domain').then(