fix(security): remediate audit vulnerabilities SEC-001 through SEC-023
This commit is contained in:
1 parent
dc88677169
commit
bd49fbc4a0
31 files changed
+867
-114
No files matched your search
@@ -38,10 +38,7 @@ export class RolesGuard implements CanActivate {
|
||||
// If request originates from an API key, verify it has admin scope for admin-guarded routes
|
||||
if (user.isApiKey) {
|
||||
const scopes = Array.isArray(user.scopes) ? user.scopes : [];
|
||||
const hasAdminScope =
|
||||
scopes.includes('*') ||
|
||||
scopes.includes('admin') ||
|
||||
scopes.includes('all');
|
||||
const hasAdminScope = scopes.includes('admin');
|
||||
if (!hasAdminScope) {
|
||||
throw new ForbiddenException(
|
||||
'کلید API ارائهشده فاقد اسکوپ مدیریتی لازم برای این عملیات است',
|
||||
|
||||
@@ -13,9 +13,15 @@ export class RevalidationService {
|
||||
}
|
||||
|
||||
private get secret(): string {
|
||||
return (
|
||||
process.env.REVALIDATION_SECRET || 'canina_revalidation_secret_key_2026'
|
||||
);
|
||||
const secret = process.env.REVALIDATION_SECRET;
|
||||
if (!secret) {
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
throw new Error('REVALIDATION_SECRET is required in production environment.');
|
||||
}
|
||||
this.logger.warn('REVALIDATION_SECRET is not defined in environment variables.');
|
||||
return '';
|
||||
}
|
||||
return secret;
|
||||
}
|
||||
|
||||
async revalidateTag(tag: string): Promise<boolean> {
|
||||
|
||||
Reference in new issue
Block a user