Skip to content

Commit fca2104

Browse files
committed
Avoid unsafe regex
In 321c465 (misc-helper: start implementing the Pipeline side of the new strategy, 2018-12-19), I introduced a regular expression that could potentially be used to DoS the GitGitGadget Pipelines runner, via a crafted (and most likely invalid) slash command. The saving grace here is that only users who are already allowed to use GitGitGadget will even come as far with such a crafted command as to hit that parser. Nevertheless, it's better to be safe than to be sorry. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent fd54c52 commit fca2104

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/ci-helper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,13 +541,13 @@ export class CIHelper {
541541
}
542542
}
543543

544-
const match = comment.body.match(/^\s*(\/[-a-z]+)(\s+(.*?))?\s*$/);
544+
const match = comment.body.trim().match(/^(\/[-a-z]+)\s*(.*)$/);
545545
if (!match) {
546546
console.log(`Not a command; doing nothing: '${comment.body}'`);
547547
return; /* nothing to do */
548548
}
549549
const command = match[1];
550-
const argument = match[3];
550+
const argument = match[2].trim();
551551
const prKey = {
552552
owner: repositoryOwner,
553553
repo: this.config.repo.name,

0 commit comments

Comments
 (0)