Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 71f18a2053 |
+9
-23
@@ -30,9 +30,7 @@ let activeConfig: SecurityConfig = { ...defaultConfig };
|
|||||||
* Configure security settings
|
* Configure security settings
|
||||||
* @param config Partial configuration to merge with defaults
|
* @param config Partial configuration to merge with defaults
|
||||||
*/
|
*/
|
||||||
export const configureSecuritySettings = (
|
export const configureSecuritySettings = (config: Partial<SecurityConfig>): void => {
|
||||||
config: Partial<SecurityConfig>
|
|
||||||
): void => {
|
|
||||||
activeConfig = { ...activeConfig, ...config };
|
activeConfig = { ...activeConfig, ...config };
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -320,13 +318,10 @@ export const appStateSchema = z
|
|||||||
.optional()
|
.optional()
|
||||||
.nullable(),
|
.nullable(),
|
||||||
currentItemRoundness: z
|
currentItemRoundness: z
|
||||||
.union([
|
.object({
|
||||||
z.enum(["sharp", "round"]),
|
|
||||||
z.object({
|
|
||||||
type: z.enum(["round", "sharp"]),
|
type: z.enum(["round", "sharp"]),
|
||||||
value: z.number().finite().min(0).max(1),
|
value: z.number().finite().min(0).max(1),
|
||||||
}),
|
})
|
||||||
])
|
|
||||||
.optional()
|
.optional()
|
||||||
.nullable(),
|
.nullable(),
|
||||||
currentItemFontSize: z
|
currentItemFontSize: z
|
||||||
@@ -432,19 +427,10 @@ export const sanitizeDrawingData = (data: {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Dangerous URL protocols to block entirely
|
// Dangerous URL protocols to block entirely
|
||||||
const dangerousProtocols = [
|
const dangerousProtocols = [/^javascript:/i, /^vbscript:/i, /^data:text\/html/i];
|
||||||
/^javascript:/i,
|
|
||||||
/^vbscript:/i,
|
|
||||||
/^data:text\/html/i,
|
|
||||||
];
|
|
||||||
|
|
||||||
// Suspicious patterns for security validation within data URLs
|
// Suspicious patterns for security validation within data URLs
|
||||||
const suspiciousPatterns = [
|
const suspiciousPatterns = [/<script/i, /javascript:/i, /on\w+\s*=/i, /<iframe/i];
|
||||||
/<script/i,
|
|
||||||
/javascript:/i,
|
|
||||||
/on\w+\s*=/i,
|
|
||||||
/<iframe/i,
|
|
||||||
];
|
|
||||||
|
|
||||||
// Maximum size for dataURL (configurable, default 10MB to prevent DoS)
|
// Maximum size for dataURL (configurable, default 10MB to prevent DoS)
|
||||||
const MAX_DATAURL_SIZE = activeConfig.maxDataUrlSize;
|
const MAX_DATAURL_SIZE = activeConfig.maxDataUrlSize;
|
||||||
@@ -462,8 +448,8 @@ export const sanitizeDrawingData = (data: {
|
|||||||
const normalizedValue = value.toLowerCase();
|
const normalizedValue = value.toLowerCase();
|
||||||
|
|
||||||
// First, check for dangerous protocols - block these entirely
|
// First, check for dangerous protocols - block these entirely
|
||||||
const hasDangerousProtocol = dangerousProtocols.some(
|
const hasDangerousProtocol = dangerousProtocols.some((pattern) =>
|
||||||
(pattern) => pattern.test(value)
|
pattern.test(value)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (hasDangerousProtocol) {
|
if (hasDangerousProtocol) {
|
||||||
@@ -479,8 +465,8 @@ export const sanitizeDrawingData = (data: {
|
|||||||
|
|
||||||
if (isSafeImageType) {
|
if (isSafeImageType) {
|
||||||
// Check for suspicious content and size limits
|
// Check for suspicious content and size limits
|
||||||
const hasSuspiciousContent = suspiciousPatterns.some(
|
const hasSuspiciousContent = suspiciousPatterns.some((pattern) =>
|
||||||
(pattern) => pattern.test(value)
|
pattern.test(value)
|
||||||
);
|
);
|
||||||
const isTooLarge = value.length > MAX_DATAURL_SIZE;
|
const isTooLarge = value.length > MAX_DATAURL_SIZE;
|
||||||
|
|
||||||
|
|||||||
@@ -301,7 +301,6 @@ export const Editor: React.FC = () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const persistableAppState = {
|
const persistableAppState = {
|
||||||
...appState,
|
|
||||||
viewBackgroundColor: appState?.viewBackgroundColor || '#ffffff',
|
viewBackgroundColor: appState?.viewBackgroundColor || '#ffffff',
|
||||||
gridSize: appState?.gridSize || null,
|
gridSize: appState?.gridSize || null,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user