SCRAPE-20: Implement credential redaction in scraper log calls #24

Merged
stephen merged 1 commits from scraper/log-audit into dev 2026-02-06 23:00:09 -07:00
Showing only changes of commit ba09cdf8ec - Show all commits

View File

@ -1156,8 +1156,12 @@ const {
getNextScheduledRun getNextScheduledRun
} = require('../jobs/scraperJob'); } = require('../jobs/scraperJob');
const { runScrape } = require('../services/scraperService'); const { runScrape } = require('../services/scraperService');
const { createLogger } = require('../services/scraperLogger');
const scraperConfig = require('../config/scraper'); const scraperConfig = require('../config/scraper');
// Logger for scraper admin routes
const scraperRouteLogger = createLogger('scraper-admin');
/** /**
* POST /api/admin/scraper/run * POST /api/admin/scraper/run
* Trigger a manual scrape * Trigger a manual scrape
@ -1190,7 +1194,10 @@ router.post('/scraper/run', async (req, res) => {
// Start scrape asynchronously (do not await - return 202 immediately) // Start scrape asynchronously (do not await - return 202 immediately)
runScrape(db, { trigger: 'manual', jobId, dryRun, htmlContent }) runScrape(db, { trigger: 'manual', jobId, dryRun, htmlContent })
.catch((error) => { .catch((error) => {
console.error('Async scrape failed:', error.message); scraperRouteLogger.error('Async scrape failed', {
errorType: error.name,
errorMessage: error.message
});
}) })
.finally(() => releaseLock()); .finally(() => releaseLock());
@ -1205,7 +1212,10 @@ router.post('/scraper/run', async (req, res) => {
}); });
} catch (error) { } catch (error) {
console.error('Error triggering scrape:', error); scraperRouteLogger.error('Error triggering scrape', {
errorType: error.name,
errorMessage: error.message
});
res.status(500).json({ error: 'Failed to start scrape job' }); res.status(500).json({ error: 'Failed to start scrape job' });
} }
}); });
@ -1245,7 +1255,10 @@ router.get('/scraper/status', async (req, res) => {
}); });
} catch (error) { } catch (error) {
console.error('Error fetching scraper status:', error); scraperRouteLogger.error('Error fetching scraper status', {
errorType: error.name,
errorMessage: error.message
});
res.status(503).json({ error: 'Service temporarily unavailable' }); res.status(503).json({ error: 'Service temporarily unavailable' });
} }
}); });
@ -1295,7 +1308,10 @@ router.get('/scraper/history', async (req, res) => {
res.json({ data: history }); res.json({ data: history });
} catch (error) { } catch (error) {
console.error('Error fetching scraper history:', error); scraperRouteLogger.error('Error fetching scraper history', {
errorType: error.name,
errorMessage: error.message
});
res.status(503).json({ error: 'Service temporarily unavailable' }); res.status(503).json({ error: 'Service temporarily unavailable' });
} }
}); });