mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-08-28 12:44:28 +00:00
🧼 fix: Prevent Shared Link Caching and Strengthen Log Redaction (#13561)
* fix: tighten share caching and log redaction * fix: sort changed imports * fix: redact splat log arguments * fix: avoid mutating log metadata during redaction * fix: redact error and api_key log values * fix: preserve error log context during redaction * fix: cover remaining log redaction paths * fix: bound log redaction work * fix: align redaction scan cap with log config
This commit is contained in:
parent
265d660076
commit
4b871a11ad
6 changed files with 601 additions and 47 deletions
|
|
@ -66,7 +66,12 @@ jest.mock('~/server/middleware/requireJwtAuth', () => (req, res, next) => next()
|
|||
const { RetentionMode } = require('librechat-data-provider');
|
||||
const { createTempChatExpirationDate, logger } = require('@librechat/data-schemas');
|
||||
const { deleteSharedLinkWithCleanup } = require('@librechat/api');
|
||||
const { createSharedLink, updateSharedLink, getRoleByName } = require('~/models');
|
||||
const {
|
||||
getSharedMessages,
|
||||
createSharedLink,
|
||||
updateSharedLink,
|
||||
getRoleByName,
|
||||
} = require('~/models');
|
||||
const shareRouter = require('../share');
|
||||
|
||||
const activeExpiration = new Date('2030-01-01T00:00:00.000Z');
|
||||
|
|
@ -101,6 +106,15 @@ describe('share routes retention', () => {
|
|||
mockGrantCreationPermissions.mockResolvedValue(undefined);
|
||||
});
|
||||
|
||||
it('prevents successful shared message responses from being cached', async () => {
|
||||
getSharedMessages.mockResolvedValue({ shareId: 'share-123', messages: [] });
|
||||
|
||||
const response = await request(buildApp()).get('/api/share/share-123');
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.headers['cache-control']).toBe('private, no-store');
|
||||
});
|
||||
|
||||
it('expires new shares for retained non-temporary conversations', async () => {
|
||||
mockGetSharedLinkExpiration.mockResolvedValue(activeExpiration);
|
||||
createSharedLink.mockResolvedValue({ _id: 'link-123', shareId: 'share-123' });
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ if (allowSharedLinks) {
|
|||
try {
|
||||
const share = await getSharedMessages(req.params.shareId, req.shareResourceId);
|
||||
if (share) {
|
||||
res.set('Cache-Control', 'private, no-store');
|
||||
res.status(200).json(share);
|
||||
} else {
|
||||
res.status(404).end();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue