|
2 | 2 | /// <reference types="@actions/github-script" /> |
3 | 3 |
|
4 | 4 | const { resolveExecutionOwnerRepo } = require("./repo_helpers.cjs"); |
| 5 | +const { sanitizeContent } = require("./sanitize_content.cjs"); |
5 | 6 |
|
6 | 7 | const TARGET_LABEL = "agentic-workflows"; |
| 8 | +// Keep a conservative, explicit upper bound for comment sanitization. |
| 9 | +const MAX_COMMENT_BODY_LENGTH = 65536; |
7 | 10 | const NO_REPRO_MESSAGE = `Closing as no repro. |
8 | 11 |
|
9 | 12 | If this is still reproducible, please open a new issue with clear reproduction steps.`; |
@@ -31,6 +34,23 @@ async function closeIssueAsNotPlanned(issueId) { |
31 | 34 | }); |
32 | 35 | } |
33 | 36 |
|
| 37 | +/** |
| 38 | + * Build the close-comment body with SEC-004 sanitization guarantees. |
| 39 | + * |
| 40 | + * @param {(content: string, options?: { maxLength?: number }) => string} [sanitize=sanitizeContent] |
| 41 | + * @returns {string} |
| 42 | + */ |
| 43 | +function getNoReproCommentBody(sanitize = sanitizeContent) { |
| 44 | + const body = sanitize(NO_REPRO_MESSAGE, { maxLength: MAX_COMMENT_BODY_LENGTH }); |
| 45 | + if (typeof body !== "string") { |
| 46 | + throw new Error("Close comment body sanitization must return a string"); |
| 47 | + } |
| 48 | + if (body.trim().length === 0) { |
| 49 | + throw new Error("Close comment body is empty after sanitization"); |
| 50 | + } |
| 51 | + return body; |
| 52 | +} |
| 53 | + |
34 | 54 | /** |
35 | 55 | * Close all open issues with the "agentic-workflows" label. |
36 | 56 | * @returns {Promise<void>} |
@@ -63,11 +83,11 @@ async function main() { |
63 | 83 | owner, |
64 | 84 | repo, |
65 | 85 | issue_number: issue.number, |
66 | | - body: NO_REPRO_MESSAGE, |
| 86 | + body: getNoReproCommentBody(), |
67 | 87 | }); |
68 | 88 |
|
69 | 89 | await closeIssueAsNotPlanned(issue.node_id); |
70 | 90 | } |
71 | 91 | } |
72 | 92 |
|
73 | | -module.exports = { main, closeIssueAsNotPlanned, CLOSE_ISSUE_MUTATION, NO_REPRO_MESSAGE }; |
| 93 | +module.exports = { main, closeIssueAsNotPlanned, CLOSE_ISSUE_MUTATION, NO_REPRO_MESSAGE, MAX_COMMENT_BODY_LENGTH, getNoReproCommentBody }; |
0 commit comments