Skip to content

Commit 8509891

Browse files
authored
Merge branch 'master' into dependabot/npm_and_yarn/aws-sdk/client-ecs-3.731.1
2 parents f9f1056 + dd2c04c commit 8509891

File tree

4 files changed

+73
-16
lines changed

4 files changed

+73
-16
lines changed

.github/workflows/notifications.yml

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,44 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16+
- uses: actions/github-script@v7
17+
id: sanitize-title
18+
with:
19+
script: |
20+
const isPR = !!context.payload.pull_request;
21+
const isIssue = !!context.payload.issue;
22+
const item = isPR ? context.payload.pull_request : isIssue ? context.payload.issue : context.payload.issue_comment.issue;
23+
24+
// Sanitization functions
25+
const sanitizeTitle = (title) => {
26+
return title
27+
// Remove potential markdown formatting
28+
.replace(/[*_~`]/g, '')
29+
// Remove potential HTML tags
30+
.replace(/<[^>]*>/g, '')
31+
// Remove multiple spaces
32+
.replace(/\s{2,}/g, ' ')
33+
// Trim whitespace
34+
.trim()
35+
// Enforce max length of 100
36+
.substring(0, 100);
37+
};
38+
39+
// Escape special characters for Slack
40+
const escapeForSlack = (text) => {
41+
return text
42+
.replace(/"/g, '&quot;')
43+
.replace(/&/g, '&amp;')
44+
.replace(/</g, '&lt;')
45+
.replace(/[@]/g, '\\@')
46+
.replace(/>/g, '&gt;')
47+
.replace(/&amp;lt;/g, '&lt;')
48+
.replace(/&amp;gt;/g, '&gt;');
49+
};
50+
51+
const sanitizedTitle = escapeForSlack(sanitizeTitle(item.title));
52+
console.log('Sanitized Title: ', sanitizedTitle);
53+
core.setOutput('safe-title', sanitizedTitle);
1654
- name: Send notifications on Pull Request
1755
if: ${{ github.event_name == 'pull_request'}}
1856
id: slack_PR
@@ -23,7 +61,7 @@ jobs:
2361
"Notification Type": "Pull Request",
2462
"Notification URL":"${{ github.event.pull_request.html_url }}",
2563
"GitHub Repo": "${{ github.repository }}",
26-
"Notification Title": "${{ github.event.pull_request.title }}"
64+
"Notification Title": "${{ steps.sanitize-title.outputs.safe-title }}"
2765
}
2866
env:
2967
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
@@ -37,7 +75,7 @@ jobs:
3775
"Notification Type": "Issue",
3876
"Notification URL":"${{ github.event.issue.html_url }}",
3977
"GitHub Repo": "${{ github.repository }}",
40-
"Notification Title": "${{ github.event.issue.title }}"
78+
"Notification Title": "${{ steps.sanitize-title.outputs.safe-title }}"
4179
}
4280
env:
4381
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
@@ -51,7 +89,7 @@ jobs:
5189
"Notification Type": "Issue comment",
5290
"Notification URL":"${{ github.event.comment.html_url }}",
5391
"GitHub Repo": "${{ github.repository }}",
54-
"Notification Title": "${{ github.event.issue_comment.issue.title }}"
92+
"Notification Title": "${{ steps.sanitize-title.outputs.safe-title }}"
5593
}
5694
env:
5795
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

dist/index.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91071,6 +91071,14 @@ const { isUint8Array, isArrayBuffer } = __nccwpck_require__(98253)
9107191071
const { File: UndiciFile } = __nccwpck_require__(63041)
9107291072
const { parseMIMEType, serializeAMimeType } = __nccwpck_require__(94322)
9107391073

91074+
let random
91075+
try {
91076+
const crypto = __nccwpck_require__(77598)
91077+
random = (max) => crypto.randomInt(0, max)
91078+
} catch {
91079+
random = (max) => Math.floor(Math.random(max))
91080+
}
91081+
9107491082
let ReadableStream = globalThis.ReadableStream
9107591083

9107691084
/** @type {globalThis['File']} */
@@ -91156,7 +91164,7 @@ function extractBody (object, keepalive = false) {
9115691164
// Set source to a copy of the bytes held by object.
9115791165
source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength))
9115891166
} else if (util.isFormDataLike(object)) {
91159-
const boundary = `----formdata-undici-0${`${Math.floor(Math.random() * 1e11)}`.padStart(11, '0')}`
91167+
const boundary = `----formdata-undici-0${`${random(1e11)}`.padStart(11, '0')}`
9116091168
const prefix = `--${boundary}\r\nContent-Disposition: form-data`
9116191169

9116291170
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
@@ -105972,6 +105980,14 @@ module.exports = require("node:buffer");
105972105980

105973105981
/***/ }),
105974105982

105983+
/***/ 77598:
105984+
/***/ ((module) => {
105985+
105986+
"use strict";
105987+
module.exports = require("node:crypto");
105988+
105989+
/***/ }),
105990+
105975105991
/***/ 78474:
105976105992
/***/ ((module) => {
105977105993

package-lock.json

Lines changed: 14 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"devDependencies": {
3434
"@eslint/js": "^9.18.0",
3535
"@vercel/ncc": "^0.38.3",
36-
"eslint": "^9.18.0",
36+
"eslint": "^9.19.0",
3737
"globals": "^15.14.0",
3838
"jest": "^29.7.0"
3939
},

0 commit comments

Comments
 (0)