Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/api/challenges/challenges.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
uniqBy,
} from 'lodash';
import { ConflictException, Injectable } from '@nestjs/common';
import { isUUID } from 'class-validator';
import { ENV_CONFIG } from 'src/config';
import { Logger } from 'src/shared/global';
import {
Expand Down Expand Up @@ -61,6 +62,10 @@ export class ChallengesService {
) {}

async getChallenge(challengeId: string) {
if (!isUUID(challengeId)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The isUUID function should be verified to ensure it correctly validates UUIDs according to the expected version (e.g., v4). If isUUID is a custom implementation, consider using a well-tested library function to avoid potential errors in UUID validation.

throw new BadRequestException('Invalid challengeId provided! Uuid expected!');
}

// Use the URL constructor to avoid path traversal/SSRF risks.
const baseUrl = TC_API_BASE.endsWith('/') ? TC_API_BASE.slice(0, -1) : TC_API_BASE;
const requestUrl = new URL(`/challenges/${challengeId}`, baseUrl).toString();
Expand Down