Disallow and suppress unsafe assignment (#19736)

This commit is contained in:
Christian Gunderman
2026-02-20 22:28:55 +00:00
committed by GitHub
parent 3e786a161e
commit 981e9a978e
71 changed files with 149 additions and 22 deletions
+5 -3
View File
@@ -5,10 +5,8 @@
*/
import { spawn } from 'node:child_process';
import type { HookConfig } from './types.js';
import { HookEventName, ConfigSource } from './types.js';
import type { Config } from '../config/config.js';
import type {
HookConfig,
HookInput,
HookOutput,
HookExecutionResult,
@@ -17,6 +15,8 @@ import type {
BeforeModelOutput,
BeforeToolInput,
} from './types.js';
import { HookEventName, ConfigSource } from './types.js';
import type { Config } from '../config/config.js';
import type { LLMRequest } from './hookTranslator.js';
import { debugLogger } from '../utils/debugLogger.js';
import { sanitizeEnvironment } from '../services/environmentSanitization.js';
@@ -356,8 +356,10 @@ export class HookRunner {
const textToParse = stdout.trim() || stderr.trim();
if (textToParse) {
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
let parsed = JSON.parse(textToParse);
if (typeof parsed === 'string') {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
parsed = JSON.parse(parsed);
}
if (parsed && typeof parsed === 'object') {
+1
View File
@@ -34,6 +34,7 @@ export class TrustedHooksManager {
try {
if (fs.existsSync(this.configPath)) {
const content = fs.readFileSync(this.configPath, 'utf-8');
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
this.trustedHooks = JSON.parse(content);
}
} catch (error) {