Skip to content

Commit 6fc9ce9

Browse files
authored
Refactor CI for forked repositories - Remove reportPaths by reports (#119)
1 parent afb871e commit 6fc9ce9

File tree

10 files changed

+13
-14
lines changed

10 files changed

+13
-14
lines changed

.github/actions/reports-group/codacy-uploader-action/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ runs:
6767
const {METADATA} = process.env;
6868
6969
const metadata = JSON.parse(METADATA);
70-
core.setOutput('coverage-reports', metadata.reportPaths); // Trusted path as it comes from trusted metadata (=from `reports-group/load-metadata`)
70+
core.setOutput('coverage-reports', metadata.reports); // Trusted path as it comes from trusted metadata (=from `reports-group/load-metadata`)
7171
7272
- name: Ensure at least one report to upload
7373
if: ${{ '' == steps.build-uploader-options.outputs.coverage-reports }}

.github/actions/reports-group/codecov-uploader-action/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ runs:
106106
107107
const metadata = JSON.parse(METADATA);
108108
core.setOutput('name', metadata.name);
109-
core.setOutput('files', metadata.reportPaths); // Trusted path as it comes from trusted metadata (=from `reports-group/load-metadata`)
109+
core.setOutput('files', metadata.reports); // Trusted path as it comes from trusted metadata (=from `reports-group/load-metadata`)
110110
if (metadata.flags.length > 0) {
111111
core.setOutput('flags', metadata.flags);
112112
}

.github/actions/reports-group/create-action/dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/actions/reports-group/create-action/dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/actions/reports-group/find-action/dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/actions/reports-group/find-action/dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/actions/reports-group/load-metadata-action/dist/index.js

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

.github/actions/reports-group/load-metadata-action/dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/actions/reports-group/load-metadata-action/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ async function run() {
5353
reports: formatList('reports'),
5454
flags: formatList('flags'),
5555
path: formatScalar('path'),
56-
reportPaths: formatList('reportPaths')
5756
};
5857
}
5958

.github/actions/reports-group/node-sdk/src/path.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function trustFrom(workspacePath) {
6363
},
6464
/**
6565
* @param {string} untrustedGroupPath
66-
* @returns {{name: string, format: string, reports: string[], flags: string[], path: string, reportPaths: string[]}}
66+
* @returns {{name: string, format: string, reports: string[], flags: string[], path: string}}
6767
*/
6868
trustedMetadataUnder: (untrustedGroupPath) => {
6969
const trustedPath = helpers.trust(path.join(untrustedGroupPath, METADATA_FILENAME));
@@ -72,15 +72,15 @@ function trustFrom(workspacePath) {
7272

7373
const untrustedMetadata = JSON.parse(content);
7474
const trustedGroupPath = path.dirname(trustedPath);
75-
const trustedReportPaths = untrustedMetadata.reports.map(r => helpers.trust(r));
75+
// Ensure `reports` hasn't been tampered with ! (may lead to files outside the directory)
76+
const trustedReportPathsConverter = trustFrom(trustedGroupPath);
7677

7778
return {
7879
name: untrustedMetadata.name,
7980
format: untrustedMetadata.format,
80-
reports: trustedReportPaths,
81+
reports: untrustedMetadata.reports.map(r => trustedReportPathsConverter.trust(path.join(trustedGroupPath, r))),
8182
flags: untrustedMetadata.flags,
8283
path: withTrailingSeparator(trustedGroupPath),
83-
reportPaths: trustedReportPaths.map(trustedFp => path.join(trustedGroupPath, trustedFp)),
8484
};
8585
}
8686
};

0 commit comments

Comments
 (0)