Skip to content

Commit 0dde6ed

Browse files
committed
v2.15.2: Remove tokens from JSON output.
1 parent 5cfbbb7 commit 0dde6ed

6 files changed

Lines changed: 38 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [2.15.2] - 2024-12-01
5+
### Fixed
6+
- Prevents `githubToken` and `personalToken` from be included in the JSON output.
7+
48
## [2.15.1] - 2024-07-19
59
### Changes
610
- Fix on "Build with" link.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pull-request-stats",
3-
"version": "2.15.1",
3+
"version": "2.15.2",
44
"description": "Github action to print relevant stats about Pull Request reviewers",
55
"main": "dist/index.js",
66
"type": "commonjs",

src/execute.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const {
1111
postComment,
1212
getReviewers,
1313
buildComment,
14+
buildJsonOutput,
1415
setUpReviewers,
1516
checkSponsorship,
1617
alreadyPublished,
@@ -72,12 +73,13 @@ const run = async (params) => {
7273
core.debug(`Commit content built successfully: ${content}`);
7374

7475
const whParams = { ...params, core, reviewers };
76+
const jsonOutput = buildJsonOutput({ ...params, reviewers });
7577
await postWebhook(whParams);
7678
await postSlackMessage({ ...whParams, pullRequest });
7779
await postTeamsMessage({ ...whParams, pullRequest });
7880
await postSummary({ core, content });
7981
await core.setOutput('resultsMd', content);
80-
await core.setOutput('resultsJson', whParams);
82+
await core.setOutput('resultsJson', jsonOutput);
8183

8284
if (pullRequestId) {
8385
await postComment({
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const buildJsonOutput = require('../buildJsonOutput');
2+
3+
describe('Interactors | .alreadyPublished', () => {
4+
const params = {
5+
githubToken: 'GITHUB_TOKEN',
6+
personalToken: 'PERSONAL_TOKEN',
7+
reviewers: 'REVIEWERS',
8+
foo: 'BAR',
9+
};
10+
11+
it('removes tokens', () => {
12+
const results = buildJsonOutput(params);
13+
expect(results).not.toHaveProperty('githubToken');
14+
expect(results).not.toHaveProperty('personalToken');
15+
});
16+
17+
it('keeps the other properties', () => {
18+
const results = buildJsonOutput(params);
19+
const { githubToken, personalToken, ...other } = params;
20+
expect(results).toEqual(expect.objectContaining({
21+
...other,
22+
}));
23+
});
24+
});

src/interactors/buildJsonOutput.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = (params) => {
2+
const { githubToken, personalToken, ...other } = params;
3+
return other;
4+
};

src/interactors/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const alreadyPublished = require('./alreadyPublished');
22
const buildTable = require('./buildTable');
33
const buildComment = require('./buildComment');
4+
const buildJsonOutput = require('./buildJsonOutput');
45
const checkSponsorship = require('./checkSponsorship');
56
const getPulls = require('./getPulls');
67
const getReviewers = require('./getReviewers');
@@ -15,6 +16,7 @@ module.exports = {
1516
alreadyPublished,
1617
buildTable,
1718
buildComment,
19+
buildJsonOutput,
1820
checkSponsorship,
1921
getPulls,
2022
getReviewers,

0 commit comments

Comments
 (0)