Skip to content
Open
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
11 changes: 10 additions & 1 deletion src/oracle/middleware/oracle-key-validation.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,20 @@ export class OracleKeyValidationMiddleware implements NestMiddleware {
key = pathKey;
}

// Trim whitespace and reject empty or whitespace‑only keys
if (key !== undefined) {
key = key.trim();
if (key.length === 0) {
this.logger.warn('Rejected empty or whitespace‑only oracle key');
throw new BadRequestException('Invalid oracle key format. Expected ' + ORACLE_KEY_FORMAT_DESCRIPTION + '.');
}
}

if (!key) {
return next();
}

if (!isValidOracleKeyFormat(key)) {
if (key !== undefined && !isValidOracleKeyFormat(key)) {
this.logger.warn(`Rejected malformed oracle key: ${key}`);
throw new BadRequestException(
`Invalid oracle key format. Expected ${ORACLE_KEY_FORMAT_DESCRIPTION}.`,
Expand Down