Shun Miyazawa 3 лет назад
Родитель
Сommit
8f6ebd0b24

+ 0 - 5
packages/app/src/interfaces/rehype.ts

@@ -4,8 +4,3 @@ export const RehypeSanitizeOption = {
 } as const;
 } as const;
 
 
 export type RehypeSanitizeOption = typeof RehypeSanitizeOption[keyof typeof RehypeSanitizeOption];
 export type RehypeSanitizeOption = typeof RehypeSanitizeOption[keyof typeof RehypeSanitizeOption];
-
-export type RehypeSanitizeOptionConfig = {
-  isEnabledXssPrevention: boolean,
-  // Todo add types for custom sanitize option at https://redmine.weseek.co.jp/issues/109763
-}

+ 1 - 4
packages/app/src/interfaces/services/renderer.ts

@@ -1,8 +1,5 @@
 import { XssOptionConfig } from '~/services/xss/xssOption';
 import { XssOptionConfig } from '~/services/xss/xssOption';
 
 
-import { RehypeSanitizeOptionConfig } from '../rehype';
-
-
 export type RendererConfig = {
 export type RendererConfig = {
   isEnabledLinebreaks: boolean,
   isEnabledLinebreaks: boolean,
   isEnabledLinebreaksInComments: boolean,
   isEnabledLinebreaksInComments: boolean,
@@ -12,4 +9,4 @@ export type RendererConfig = {
 
 
   plantumlUri: string | null,
   plantumlUri: string | null,
   blockdiagUri: string | null,
   blockdiagUri: string | null,
-} & XssOptionConfig & RehypeSanitizeOptionConfig;
+} & XssOptionConfig;

+ 9 - 4
packages/app/src/services/xss/xssOption.ts

@@ -1,16 +1,21 @@
+import { defaultSchema } from 'rehype-sanitize';
+
+type RehypeSanitizeTags = typeof defaultSchema.tagNames;
+type RehypeSanitizeAttributes = typeof defaultSchema.attributes;
+
 export type XssOptionConfig = {
 export type XssOptionConfig = {
   isEnabledXssPrevention: boolean,
   isEnabledXssPrevention: boolean,
-  tagWhiteList: any[],
-  attrWhiteList: any[],
+  tagWhiteList: RehypeSanitizeTags
+  attrWhiteList: RehypeSanitizeAttributes,
 }
 }
 
 
 export default class XssOption {
 export default class XssOption {
 
 
   isEnabledXssPrevention: boolean;
   isEnabledXssPrevention: boolean;
 
 
-  tagWhiteList: any[];
+  tagWhiteList: RehypeSanitizeAttributes;
 
 
-  attrWhiteList: any[];
+  attrWhiteList: RehypeSanitizeTags;
 
 
   constructor(config: XssOptionConfig) {
   constructor(config: XssOptionConfig) {
     const recommendedWhitelist = require('~/services/xss/recommended-whitelist');
     const recommendedWhitelist = require('~/services/xss/recommended-whitelist');