refactor(misc): Harden request handling, tighten defaults, and pin CI deps (#2878)
* refactor(misc): Harden request handling, tighten defaults, and pin CI dependencies * feat(auth): normalize usernames for login rate limiting * refactor(epub): fix XML document builder creation * feat(http): enhance image download with redirect handling and DNS rebinding protection * chore: upgrade Node.js version to 24 and add frontend dependency audit step * feat(auth): refactor username normalization for login rate limiting and enhance image download security * fix(metadata): simplify JAXB validation event handling by using direct import * chore(pipeline): remove unnecessary --force flag from npm ci and format audit step * chore(pipeline): streamline frontend dependency audits and add validation step * fix(image): improve error handling for image processing and download, enforce pixel limits * test(image): update tests * fix(icon): update DOMPurify import and replace deprecated theme package * fix(imports): update theme package imports and format code for consistency * fix(cors): update allowed origins configuration to support wildcard and trim whitespace
This commit is contained in:
Generated
+335
-415
File diff suppressed because it is too large
Load Diff
@@ -24,7 +24,7 @@
|
||||
"@angular/service-worker": "^21.1.5",
|
||||
"@iharbeck/ngx-virtual-scroller": "^20.0.0",
|
||||
"@jsverse/transloco": "^8.2.1",
|
||||
"@primeng/themes": "^21.0.3",
|
||||
"@primeuix/themes": "^2.0.3",
|
||||
"@stomp/rx-stomp": "^2.3.0",
|
||||
"@stomp/stompjs": "^7.3.0",
|
||||
"@tweenjs/tween.js": "^25.0.0",
|
||||
@@ -33,6 +33,7 @@
|
||||
"chartjs-chart-matrix": "^3.0.0",
|
||||
"chartjs-plugin-datalabels": "^2.2.0",
|
||||
"date-fns": "^4.1.0",
|
||||
"dompurify": "^3.3.1",
|
||||
"jwt-decode": "^4.0.0",
|
||||
"ng-lazyload-image": "^9.1.3",
|
||||
"ng2-charts": "^8.0.0",
|
||||
@@ -44,25 +45,32 @@
|
||||
"rxjs": "^7.8.2",
|
||||
"showdown": "^2.1.0",
|
||||
"tslib": "^2.8.1",
|
||||
"uuid": "^13.0.0",
|
||||
"uuid": "^11.0.0",
|
||||
"ws": "^8.19.0",
|
||||
"zone.js": "^0.16.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@analogjs/vite-plugin-angular": "^2.2.3",
|
||||
"@analogjs/vitest-angular": "^2.2.3",
|
||||
"@angular/build": "^21.1.4",
|
||||
"@angular/cli": "^21.1.4",
|
||||
"@angular/build": "^21.1.5",
|
||||
"@angular/cli": "^21.1.5",
|
||||
"@angular/compiler-cli": "^21.1.5",
|
||||
"@types/dompurify": "^3.0.5",
|
||||
"@types/node": "^25.3.0",
|
||||
"@types/showdown": "^2.0.6",
|
||||
"@types/uuid": "^11.0.0",
|
||||
"@vitest/coverage-v8": "^4.0.17",
|
||||
"angular-eslint": "^21.2.0",
|
||||
"eslint": "^10.0.0",
|
||||
"eslint": "^9.39.3",
|
||||
"jsdom": "^28.1.0",
|
||||
"typescript": "~5.9.3",
|
||||
"typescript-eslint": "^8.56.0",
|
||||
"typescript-eslint": "^8.56.1",
|
||||
"vitest": "^4.0.17"
|
||||
},
|
||||
"overrides": {
|
||||
"minimatch": "^10.2.1",
|
||||
"ajv": "^8.18.0",
|
||||
"eslint": {
|
||||
"ajv": "^6.14.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import Aura from '@primeng/themes/aura';
|
||||
import Aura from '@primeuix/themes/aura';
|
||||
|
||||
type ColorPalette = Record<string, string>;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {DOCUMENT, isPlatformBrowser} from '@angular/common';
|
||||
import {effect, inject, Injectable, PLATFORM_ID, signal} from '@angular/core';
|
||||
import {$t, updatePreset, updateSurfacePalette} from '@primeng/themes';
|
||||
import Aura from '@primeng/themes/aura';
|
||||
import {AppState} from '../model/app-state.model';
|
||||
import { DOCUMENT, isPlatformBrowser } from '@angular/common';
|
||||
import { effect, inject, Injectable, PLATFORM_ID, signal } from '@angular/core';
|
||||
import { $t, updatePreset, updateSurfacePalette } from '@primeuix/themes';
|
||||
import Aura from '@primeuix/themes/aura';
|
||||
import { AppState } from '../model/app-state.model';
|
||||
|
||||
type ColorPalette = Record<string, string>;
|
||||
|
||||
@@ -332,7 +332,7 @@ export class AppConfigService {
|
||||
|
||||
constructor() {
|
||||
const initialState = this.loadAppState();
|
||||
this.appState.set({...initialState});
|
||||
this.appState.set({ ...initialState });
|
||||
this.document.documentElement.classList.add('p-dark');
|
||||
|
||||
if (isPlatformBrowser(this.platformId)) {
|
||||
@@ -383,7 +383,7 @@ export class AppConfigService {
|
||||
if (primaryName === 'noir') {
|
||||
return {
|
||||
semantic: {
|
||||
primary: {...surfacePalette},
|
||||
primary: { ...surfacePalette },
|
||||
colorScheme: {
|
||||
dark: {
|
||||
primary: {
|
||||
@@ -430,6 +430,6 @@ export class AppConfigService {
|
||||
onPresetChange(): void {
|
||||
const surfacePalette = this.getSurfacePalette(this.appState().surface ?? 'neutral');
|
||||
const preset = this.getPresetExt();
|
||||
$t().preset(Aura).preset(preset).surfacePalette(surfacePalette).use({useDefaultOptions: true});
|
||||
$t().preset(Aura).preset(preset).surfacePalette(surfacePalette).use({ useDefaultOptions: true });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Observable, of} from 'rxjs';
|
||||
import {finalize, map, shareReplay, tap} from 'rxjs/operators';
|
||||
import {API_CONFIG} from '../../core/config/api-config';
|
||||
import {IconCacheService} from './icon-cache.service';
|
||||
import {DomSanitizer, SafeHtml} from '@angular/platform-browser';
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { finalize, map, shareReplay, tap } from 'rxjs/operators';
|
||||
import { API_CONFIG } from '../../core/config/api-config';
|
||||
import { IconCacheService } from './icon-cache.service';
|
||||
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
|
||||
import DOMPurify from 'dompurify';
|
||||
|
||||
interface SvgIconData {
|
||||
svgName: string;
|
||||
@@ -25,7 +26,6 @@ interface SvgIconBatchResponse {
|
||||
}
|
||||
|
||||
type IconContentMap = Record<string, string>;
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@@ -39,6 +39,16 @@ export class IconService {
|
||||
private iconCache = inject(IconCacheService);
|
||||
private sanitizer = inject(DomSanitizer);
|
||||
|
||||
/**
|
||||
* Sanitizes SVG content using DOMPurify.
|
||||
*/
|
||||
private sanitizeSvgContent(content: string): string {
|
||||
return DOMPurify.sanitize(content, {
|
||||
USE_PROFILES: { svg: true },
|
||||
FORBID_TAGS: ['script', 'style', 'foreignObject']
|
||||
});
|
||||
}
|
||||
|
||||
preloadAllIcons(): Observable<void> {
|
||||
if (this.preloadCache$) {
|
||||
return this.preloadCache$;
|
||||
@@ -47,12 +57,12 @@ export class IconService {
|
||||
this.preloadCache$ = this.http.get<IconContentMap>(`${this.baseUrl}/all/content`).pipe(
|
||||
tap((iconsMap) => {
|
||||
Object.entries(iconsMap).forEach(([iconName, content]) => {
|
||||
const sanitized = this.sanitizer.bypassSecurityTrustHtml(content);
|
||||
const sanitized = this.sanitizer.bypassSecurityTrustHtml(this.sanitizeSvgContent(content));
|
||||
this.iconCache.cacheIcon(iconName, content, sanitized);
|
||||
});
|
||||
}),
|
||||
map(() => void 0),
|
||||
shareReplay({bufferSize: 1, refCount: false}),
|
||||
shareReplay({ bufferSize: 1, refCount: false }),
|
||||
finalize(() => this.preloadCache$ = null)
|
||||
);
|
||||
|
||||
@@ -70,10 +80,10 @@ export class IconService {
|
||||
responseType: 'text'
|
||||
}).pipe(
|
||||
tap(content => {
|
||||
const sanitized = this.sanitizer.bypassSecurityTrustHtml(content);
|
||||
const sanitized = this.sanitizer.bypassSecurityTrustHtml(this.sanitizeSvgContent(content));
|
||||
this.iconCache.cacheIcon(iconName, content, sanitized);
|
||||
}),
|
||||
shareReplay({bufferSize: 1, refCount: true}),
|
||||
shareReplay({ bufferSize: 1, refCount: true }),
|
||||
finalize(() => this.requestCache.delete(iconName))
|
||||
);
|
||||
|
||||
@@ -113,13 +123,13 @@ export class IconService {
|
||||
}
|
||||
|
||||
saveBatchSvgIcons(icons: SvgIconData[]): Observable<SvgIconBatchResponse> {
|
||||
return this.http.post<SvgIconBatchResponse>(`${this.baseUrl}/batch`, {icons}).pipe(
|
||||
return this.http.post<SvgIconBatchResponse>(`${this.baseUrl}/batch`, { icons }).pipe(
|
||||
tap((response) => {
|
||||
response.results.forEach(result => {
|
||||
if (result.success) {
|
||||
const iconData = icons.find(icon => icon.svgName === result.iconName);
|
||||
if (iconData) {
|
||||
const sanitized = this.sanitizer.bypassSecurityTrustHtml(iconData.svgData);
|
||||
const sanitized = this.sanitizer.bypassSecurityTrustHtml(this.sanitizeSvgContent(iconData.svgData));
|
||||
this.iconCache.cacheIcon(iconData.svgName, iconData.svgData, sanitized);
|
||||
}
|
||||
}
|
||||
|
||||
+24
-24
@@ -1,28 +1,28 @@
|
||||
import {provideHttpClient, withInterceptors} from '@angular/common/http';
|
||||
import {DialogService} from 'primeng/dynamicdialog';
|
||||
import {ConfirmationService, MessageService} from 'primeng/api';
|
||||
import {RxStompService} from './app/shared/websocket/rx-stomp.service';
|
||||
import {rxStompServiceFactory} from './app/shared/websocket/rx-stomp-service-factory';
|
||||
import {provideRouter, RouteReuseStrategy} from '@angular/router';
|
||||
import {CustomReuseStrategy} from './app/core/custom-reuse-strategy';
|
||||
import {provideAnimationsAsync} from '@angular/platform-browser/animations/async';
|
||||
import {providePrimeNG} from 'primeng/config';
|
||||
import {bootstrapApplication} from '@angular/platform-browser';
|
||||
import {AppComponent} from './app/app.component';
|
||||
import Aura from '@primeng/themes/aura';
|
||||
import {routes} from './app/app.routes';
|
||||
import {AuthInterceptorService} from './app/core/security/auth-interceptor.service';
|
||||
import {AuthService, websocketInitializer} from './app/shared/service/auth.service';
|
||||
import {OAuthStorage, provideOAuthClient} from 'angular-oauth2-oidc';
|
||||
import {inject, isDevMode, provideAppInitializer, provideZoneChangeDetection} from '@angular/core';
|
||||
import {initializeAuthFactory} from './app/core/security/auth-initializer';
|
||||
import {StartupService} from './app/shared/service/startup.service';
|
||||
import {provideCharts, withDefaultRegisterables} from 'ng2-charts';
|
||||
import { provideHttpClient, withInterceptors } from '@angular/common/http';
|
||||
import { DialogService } from 'primeng/dynamicdialog';
|
||||
import { ConfirmationService, MessageService } from 'primeng/api';
|
||||
import { RxStompService } from './app/shared/websocket/rx-stomp.service';
|
||||
import { rxStompServiceFactory } from './app/shared/websocket/rx-stomp-service-factory';
|
||||
import { provideRouter, RouteReuseStrategy } from '@angular/router';
|
||||
import { CustomReuseStrategy } from './app/core/custom-reuse-strategy';
|
||||
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
||||
import { providePrimeNG } from 'primeng/config';
|
||||
import { bootstrapApplication } from '@angular/platform-browser';
|
||||
import { AppComponent } from './app/app.component';
|
||||
import Aura from '@primeuix/themes/aura';
|
||||
import { routes } from './app/app.routes';
|
||||
import { AuthInterceptorService } from './app/core/security/auth-interceptor.service';
|
||||
import { AuthService, websocketInitializer } from './app/shared/service/auth.service';
|
||||
import { OAuthStorage, provideOAuthClient } from 'angular-oauth2-oidc';
|
||||
import { inject, isDevMode, provideAppInitializer, provideZoneChangeDetection } from '@angular/core';
|
||||
import { initializeAuthFactory } from './app/core/security/auth-initializer';
|
||||
import { StartupService } from './app/shared/service/startup.service';
|
||||
import { provideCharts, withDefaultRegisterables } from 'ng2-charts';
|
||||
import ChartDataLabels from 'chartjs-plugin-datalabels';
|
||||
import {provideServiceWorker} from '@angular/service-worker';
|
||||
import {provideTransloco} from '@jsverse/transloco';
|
||||
import {AVAILABLE_LANGS, TranslocoInlineLoader} from './app/core/config/transloco-loader';
|
||||
import {initializeLanguage} from './app/core/config/language-initializer';
|
||||
import { provideServiceWorker } from '@angular/service-worker';
|
||||
import { provideTransloco } from '@jsverse/transloco';
|
||||
import { AVAILABLE_LANGS, TranslocoInlineLoader } from './app/core/config/transloco-loader';
|
||||
import { initializeLanguage } from './app/core/config/language-initializer';
|
||||
|
||||
export function storageFactory(): OAuthStorage {
|
||||
return localStorage;
|
||||
|
||||
Reference in New Issue
Block a user