Skip to content

Commit 333987a

Browse files
committed
release bug fix
1 parent 679e9b4 commit 333987a

4 files changed

Lines changed: 24 additions & 8 deletions

File tree

src/main/preload.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
9393
testModelConnection: (model: any) => ipcRenderer.invoke('test-model-connection', model),
9494
executeRedTeamAttack: (model: any, attack: any) => ipcRenderer.invoke('execute-red-team-attack', model, attack),
9595
executeBenchmarkTest: (model: any, benchmark: any, payload: any) => ipcRenderer.invoke('execute-benchmark-test', model, benchmark, payload),
96+
getAttackPayloads: () => ipcRenderer.invoke('get-attack-payloads'),
9697
})
9798

9899
// Type declaration for the exposed API
@@ -124,6 +125,7 @@ declare global {
124125
testModelConnection: (model: any) => Promise<any>
125126
executeRedTeamAttack: (model: any, attack: any) => Promise<any>
126127
executeBenchmarkTest: (model: any, benchmark: any, payload: any) => Promise<any>
128+
getAttackPayloads: () => Promise<AttackPayload[]>
127129
}
128130
}
129131
}

src/main/services/attack-engine.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ import { AIRequest } from '../../types';
88
// Import attack payloads with proper path resolution for packaged apps
99
const getPayloadsPath = () => {
1010
if (app.isPackaged) {
11-
// In packaged app, use the resources directory
12-
return path.join(process.resourcesPath, 'app.asar', 'public/assets/payloads/all-attack-payloads.json')
11+
// In packaged app, use the asar path
12+
return path.join(process.resourcesPath, 'app.asar', 'public', 'assets', 'payloads', 'all-attack-payloads.json');
1313
} else {
1414
// In development, use the normal path
15-
return path.join(__dirname, '../../../public/assets/payloads/all-attack-payloads.json')
15+
return path.join(__dirname, '../../../public/assets/payloads/all-attack-payloads.json');
1616
}
1717
}
1818

19-
const payloadsPath = getPayloadsPath()
20-
const attackPayloads = JSON.parse(fs.readFileSync(payloadsPath, 'utf8'))
19+
const payloadsPath = getPayloadsPath();
20+
console.log('Payloads path:', payloadsPath);
21+
console.log('Exists:', fs.existsSync(payloadsPath));
22+
const attackPayloads = JSON.parse(fs.readFileSync(payloadsPath, 'utf8'));
2123

2224
export interface AttackPayload {
2325
id: string
@@ -293,5 +295,9 @@ export class AttackEngine extends EventEmitter {
293295
ipcMain.handle('get-test', (_event, testId: string) => {
294296
return this.tests.get(testId)
295297
})
298+
299+
ipcMain.handle('get-attack-payloads', async () => {
300+
return attackPayloads;
301+
});
296302
}
297303
}

src/services/payload-manager.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,16 @@ export class PayloadManager {
382382
public async loadAllPayloads(): Promise<AttackPayload[]> {
383383
const allPayloads: AttackPayload[] = []
384384
try {
385-
const response = await fetch(this.sources[0])
386-
if (!response.ok) throw new Error('Failed to load all-attack-payloads.json')
387-
const payloads = await response.json()
385+
let payloads: AttackPayload[] = [];
386+
if (window.electronAPI && typeof window.electronAPI.getAttackPayloads === 'function') {
387+
// Electron production: use IPC
388+
payloads = await window.electronAPI.getAttackPayloads();
389+
} else {
390+
// Dev mode: use fetch
391+
const response = await fetch(this.sources[0])
392+
if (!response.ok) throw new Error('Failed to load all-attack-payloads.json')
393+
payloads = await response.json()
394+
}
388395
allPayloads.push(...payloads)
389396
// Index payloads by ID
390397
allPayloads.forEach(payload => {

vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import path from 'path'
44

55
// https://vitejs.dev/config/
66
export default defineConfig({
7+
base: './',
78
plugins: [react()],
89
resolve: {
910
alias: {

0 commit comments

Comments
 (0)