Skip to content

Commit 806784b

Browse files
author
CI Bot
committed
fix: clamp limit internally in getArticleHistory
Defense-in-depth: clamp the caller-provided limit to [1, HISTORY_WALK_LIMIT] inside the service method itself so future direct callers (CLI, tests) can't trigger unbounded ancestry walks.
1 parent c086e0c commit 806784b

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/lib/CmsService.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ export default class CmsService {
352352
* @returns {Promise<Array<{ sha: string, title: string, status: string, author: string, date: string }>>}
353353
*/
354354
async getArticleHistory({ slug, limit = 50 }) {
355+
const effectiveLimit = Math.max(1, Math.min(limit, HISTORY_WALK_LIMIT));
355356
const canonicalSlug = canonicalizeSlug(slug);
356357
const draftRef = this._refFor(canonicalSlug, 'articles');
357358
const pubRef = this._refFor(canonicalSlug, 'published');
@@ -367,7 +368,7 @@ export default class CmsService {
367368
const versions = [];
368369
let current = sha;
369370

370-
while (current && versions.length < limit) {
371+
while (current && versions.length < effectiveLimit) {
371372
const [info, message] = await Promise.all([
372373
this.graph.getNodeInfo(current),
373374
this.graph.showNode(current),

0 commit comments

Comments
 (0)