mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-09-13 01:51:51 +00:00
* feat: introduce optional content protection seam * feat: enforce source-aware content filters * feat: complete source-aware content enforcement * test: activate skill file-text fail-close fixtures * fix: harden source-aware content filters * fix: harden model-bound content filtering * fix: preserve legacy filters and generated files * fix: inspect shared scalar metadata * test: align mocks with current dev dependencies * feat: add persisted content filter safeguards * feat: complete source-aware content filter enforcement * fix: move resume content preflight into TypeScript * fix: close content inspection edge cases * fix: harden content protection boundaries * fix: complete content protection safeguards * test: align persisted memory filter coverage * fix: reconcile content protection with current dev * fix: reconcile content protection with latest dev * fix: close content protection review gaps * fix: enforce source-aware provider boundaries * fix: preserve legacy PII preflight semantics * test: stabilize stored branch preflight fixture * fix: defer agent writes until protected model admission * perf: harden source-aware model-bound filtering * fix: canonicalize provider lineage before validation * fix: satisfy model-bound callback type checks * perf: Bound content protection filtering work * fix: Bound submission array traversal * fix: Stabilize bounded content snapshots * fix: Scope model-bound traversal overflows * fix: Preserve scoped content inspection * fix: Accumulate aggregate traversal scopes * fix: centralize content policy boundaries * test: align deferred tool policy context * test: align controller policy mocks * style: normalize content protection imports * fix: close content policy review gaps * fix: narrow active skill policy config * fix: address content protection review boundaries * fix: retain exact provenance overflow sentinel * fix: preserve literal and scoped provenance updates * fix: narrow persisted edit provenance * fix: isolate exact overflow attribution * fix: centralize stored prompt protection * fix: fail closed on incomplete transcript evidence * fix: align canonical transcript routing * refactor: centralize content policy preflights * fix: isolate upload policy error typing * style: sort policy preflight imports * refactor: centralize content policy boundaries
92 lines
2.8 KiB
JavaScript
92 lines
2.8 KiB
JavaScript
const mockLogger = {
|
|
debug: jest.fn(),
|
|
info: jest.fn(),
|
|
warn: jest.fn(),
|
|
error: jest.fn(),
|
|
};
|
|
const mockCreate = jest.fn();
|
|
const mockGetOpenAIClient = jest.fn();
|
|
const mockUpdateAssistantDoc = jest.fn();
|
|
|
|
jest.mock('@librechat/data-schemas', () => ({ logger: mockLogger }));
|
|
jest.mock('@librechat/api', () => ({}));
|
|
jest.mock('librechat-data-provider', () => ({
|
|
FileContext: { avatar: 'avatar' },
|
|
ToolCallTypes: {},
|
|
}));
|
|
jest.mock('~/models', () => ({
|
|
deleteFileByFilter: jest.fn(),
|
|
updateAssistantDoc: mockUpdateAssistantDoc,
|
|
getAssistants: jest.fn(),
|
|
}));
|
|
jest.mock('~/server/services/Files/process', () => ({
|
|
uploadImageBuffer: jest.fn(),
|
|
filterFile: jest.fn(),
|
|
}));
|
|
jest.mock('~/server/middleware/assistants/validateAuthor', () => jest.fn());
|
|
jest.mock('~/server/services/Files/strategies', () => ({
|
|
getStrategyFunctions: jest.fn(),
|
|
}));
|
|
jest.mock('~/server/services/ActionService', () => ({
|
|
deleteAssistantActions: jest.fn(),
|
|
validateAndUpdateTool: jest.fn(),
|
|
}));
|
|
jest.mock('~/server/controllers/assistants/helpers', () => ({
|
|
getOpenAIClient: mockGetOpenAIClient,
|
|
fetchAssistants: jest.fn(),
|
|
}));
|
|
jest.mock('~/server/services/Config', () => ({
|
|
getCachedTools: jest.fn().mockResolvedValue({}),
|
|
}));
|
|
jest.mock('~/server/services/MCP', () => ({
|
|
healMcpToolNames: jest.fn(({ tools }) => tools),
|
|
getAssistantToolDefinitions: jest.fn().mockResolvedValue({}),
|
|
toProviderToolDefinition: jest.fn((tool) => tool),
|
|
}));
|
|
jest.mock('~/app/clients/tools', () => ({
|
|
manifestToolMap: {},
|
|
isAgentsOnlyTool: jest.fn((tool) => typeof tool === 'object'),
|
|
}));
|
|
|
|
const controllers = [require('./v1').createAssistant, require('./v2').createAssistant];
|
|
|
|
describe.each(controllers)('assistant create logging', (createAssistant) => {
|
|
beforeEach(() => {
|
|
jest.clearAllMocks();
|
|
mockCreate.mockImplementation(async (data) => ({ id: 'assistant-1', ...data }));
|
|
mockGetOpenAIClient.mockResolvedValue({
|
|
openai: {
|
|
locals: {},
|
|
beta: { assistants: { create: mockCreate } },
|
|
},
|
|
});
|
|
mockUpdateAssistantDoc.mockResolvedValue({
|
|
conversation_starters: ['PRIVATE-SENTINEL'],
|
|
});
|
|
});
|
|
|
|
it('does not log submitted assistant content or tool names', async () => {
|
|
const res = {
|
|
status: jest.fn().mockReturnThis(),
|
|
json: jest.fn(),
|
|
};
|
|
await createAssistant(
|
|
{
|
|
user: { id: 'user-1' },
|
|
body: {
|
|
endpoint: 'assistants',
|
|
name: 'PRIVATE-SENTINEL',
|
|
instructions: 'PRIVATE-SENTINEL',
|
|
conversation_starters: ['PRIVATE-SENTINEL'],
|
|
tools: [{ type: 'function', function: { name: 'PRIVATE-SENTINEL' } }],
|
|
},
|
|
},
|
|
res,
|
|
);
|
|
|
|
expect(res.status).toHaveBeenCalledWith(201);
|
|
expect(
|
|
JSON.stringify([...mockLogger.warn.mock.calls, ...mockLogger.debug.mock.calls]),
|
|
).not.toContain('PRIVATE-SENTINEL');
|
|
});
|
|
});
|