Fix remaining typescript errors (#2741)

This commit is contained in:
Zane
2025-05-30 12:06:49 -07:00
committed by GitHub
parent 2c0cda7bec
commit 0c042010ff
109 changed files with 1873 additions and 1438 deletions
+40 -2
View File
@@ -4,6 +4,24 @@ import Electron from 'electron';
import log from './logger';
export const getBinaryPath = (app: Electron.App, binaryName: string): string => {
// Security validation: Ensure binaryName doesn't contain suspicious characters
if (
!binaryName ||
typeof binaryName !== 'string' ||
binaryName.includes('..') ||
binaryName.includes('/') ||
binaryName.includes('\\') ||
binaryName.includes(';') ||
binaryName.includes('|') ||
binaryName.includes('&') ||
binaryName.includes('`') ||
binaryName.includes('$') ||
binaryName.length > 50
) {
// Reasonable length limit
throw new Error(`Invalid binary name: ${binaryName}`);
}
const isWindows = process.platform === 'win32';
const possiblePaths: string[] = [];
@@ -16,8 +34,28 @@ export const getBinaryPath = (app: Electron.App, binaryName: string): string =>
for (const binPath of possiblePaths) {
try {
if (fs.existsSync(binPath)) {
return binPath;
// Security: Resolve the path and validate it's within expected directories
const resolvedPath = path.resolve(binPath);
// Ensure the resolved path doesn't contain suspicious sequences
if (
resolvedPath.includes('..') ||
resolvedPath.includes(';') ||
resolvedPath.includes('|') ||
resolvedPath.includes('&')
) {
log.error(`Suspicious path detected, skipping: ${resolvedPath}`);
continue;
}
if (fs.existsSync(resolvedPath)) {
// Additional security check: ensure it's a regular file
const stats = fs.statSync(resolvedPath);
if (stats.isFile()) {
return resolvedPath;
} else {
log.error(`Path exists but is not a regular file: ${resolvedPath}`);
}
}
} catch (error) {
log.error(`Error checking path ${binPath}:`, error);
+1 -1
View File
@@ -139,7 +139,7 @@ export const initializeSystem = async (
// Get recipeConfig directly here
const recipeConfig = window.appConfig?.get?.('recipeConfig');
const botPrompt = recipeConfig?.instructions;
const botPrompt = (recipeConfig as { instructions?: string })?.instructions;
// Extend the system prompt with desktop-specific information
const response = await fetch(getApiUrl('/agent/prompt'), {
method: 'POST',
+5 -5
View File
@@ -1,4 +1,4 @@
import { app } from 'electron';
import { app, MenuItem } from 'electron';
import fs from 'fs';
import path from 'path';
@@ -70,9 +70,9 @@ export function createEnvironmentMenu(
return [
{
label: 'Enable Memory Mode',
type: 'checkbox',
type: 'checkbox' as const,
checked: envToggles.GOOSE_SERVER__MEMORY,
click: (menuItem: { checked: boolean }) => {
click: (menuItem: MenuItem) => {
const newToggles = {
...envToggles,
GOOSE_SERVER__MEMORY: menuItem.checked,
@@ -82,9 +82,9 @@ export function createEnvironmentMenu(
},
{
label: 'Enable Computer Controller Mode',
type: 'checkbox',
type: 'checkbox' as const,
checked: envToggles.GOOSE_SERVER__COMPUTER_CONTROLLER,
click: (menuItem: { checked: boolean }) => {
click: (menuItem: MenuItem) => {
const newToggles = {
...envToggles,
GOOSE_SERVER__COMPUTER_CONTROLLER: menuItem.checked,
+1 -1
View File
@@ -53,7 +53,7 @@ export function extractUrls(content: string, previousUrls: string[] = []): strin
const normalizedCurrentUrls = eligibleUrls.map(normalizeUrl);
// Filter out duplicates from previous URLs
const uniqueUrls = eligibleUrls.filter((url, index) => {
const uniqueUrls = eligibleUrls.filter((_url, index) => {
const normalized = normalizedCurrentUrls[index];
const isDuplicate = normalizedPreviousUrls.some(
(prevUrl) => normalizeUrl(prevUrl) === normalized