Skip to content

Commit

Permalink
v2.15.2: Remove tokens from JSON output.
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelmhtr committed Dec 1, 2024
1 parent 5cfbbb7 commit 0dde6ed
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.

## [2.15.2] - 2024-12-01
### Fixed
- Prevents `githubToken` and `personalToken` from be included in the JSON output.

## [2.15.1] - 2024-07-19
### Changes
- Fix on "Build with" link.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pull-request-stats",
"version": "2.15.1",
"version": "2.15.2",
"description": "Github action to print relevant stats about Pull Request reviewers",
"main": "dist/index.js",
"type": "commonjs",
Expand Down
4 changes: 3 additions & 1 deletion src/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
postComment,
getReviewers,
buildComment,
buildJsonOutput,
setUpReviewers,
checkSponsorship,
alreadyPublished,
Expand Down Expand Up @@ -72,12 +73,13 @@ const run = async (params) => {
core.debug(`Commit content built successfully: ${content}`);

const whParams = { ...params, core, reviewers };
const jsonOutput = buildJsonOutput({ ...params, reviewers });
await postWebhook(whParams);
await postSlackMessage({ ...whParams, pullRequest });
await postTeamsMessage({ ...whParams, pullRequest });
await postSummary({ core, content });
await core.setOutput('resultsMd', content);
await core.setOutput('resultsJson', whParams);
await core.setOutput('resultsJson', jsonOutput);

if (pullRequestId) {
await postComment({
Expand Down
24 changes: 24 additions & 0 deletions src/interactors/__tests__/buildJsonOutput.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const buildJsonOutput = require('../buildJsonOutput');

describe('Interactors | .alreadyPublished', () => {
const params = {
githubToken: 'GITHUB_TOKEN',
personalToken: 'PERSONAL_TOKEN',
reviewers: 'REVIEWERS',
foo: 'BAR',
};

it('removes tokens', () => {
const results = buildJsonOutput(params);
expect(results).not.toHaveProperty('githubToken');
expect(results).not.toHaveProperty('personalToken');
});

it('keeps the other properties', () => {
const results = buildJsonOutput(params);
const { githubToken, personalToken, ...other } = params;
expect(results).toEqual(expect.objectContaining({
...other,
}));
});
});
4 changes: 4 additions & 0 deletions src/interactors/buildJsonOutput.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = (params) => {
const { githubToken, personalToken, ...other } = params;
return other;
};
2 changes: 2 additions & 0 deletions src/interactors/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const alreadyPublished = require('./alreadyPublished');
const buildTable = require('./buildTable');
const buildComment = require('./buildComment');
const buildJsonOutput = require('./buildJsonOutput');
const checkSponsorship = require('./checkSponsorship');
const getPulls = require('./getPulls');
const getReviewers = require('./getReviewers');
Expand All @@ -15,6 +16,7 @@ module.exports = {
alreadyPublished,
buildTable,
buildComment,
buildJsonOutput,
checkSponsorship,
getPulls,
getReviewers,
Expand Down

0 comments on commit 0dde6ed

Please sign in to comment.