Skip to content

Commit

Permalink
Merge pull request #59
Browse files Browse the repository at this point in the history
fix(regex): fix regex call
  • Loading branch information
rubenvitt authored Oct 29, 2024
2 parents ec484ee + 85fd252 commit 3a8047e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions backend/src/fahrzeuge/fahrzeuge.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import { Prisma } from '@prisma/client';
export class FahrzeugeService {
private readonly logger = new Logger(FahrzeugeService.name);

constructor(private readonly prismaService: PrismaService) {
}
constructor(private readonly prismaService: PrismaService) {}

findAll(filter?: Prisma.FahrzeugWhereInput) {
return this.prismaService.fahrzeug.findMany({
Expand Down Expand Up @@ -179,7 +178,7 @@ export class FahrzeugeService {
const regex = /\(([^)]+)\)/;
const match = regex.exec(fahrzeug.funkrufname);

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data High

This
regular expression
that depends on
a user-provided value
may run slow on strings starting with '(' and with many repetitions of '(('.
This
regular expression
that depends on
a user-provided value
may run slow on strings starting with '(' and with many repetitions of '(('.
const maybeLabel = funkrufnameParts.some((part) => isNaN(Number(part)))
? (match ? match[1] || fahrzeug.funkrufname)
? match?.[1] || fahrzeug.funkrufname
: this.extractFunkrufnameLabel(funkrufnameParts)();
return { optaOrt, optaFunktion, optaOrdnung, maybeLabel };
}
Expand All @@ -195,7 +194,7 @@ export class FahrzeugeService {
}

private extractFunkrufnameLabel(funkrufnameParts: string[]) {
return function() {
return function () {
const part = funkrufnameParts[funkrufnameParts.length - 1];
if (part.includes(' ')) {
const regex = /\(([^)]+)\)/;
Expand Down

0 comments on commit 3a8047e

Please sign in to comment.