Skip to content

Commit 2494db0

Browse files
authored
feat/#227-resolve-xss-vulnerabilities (#300)
Co-authored-by: Dmitry Baev <baev.dm@gmail.com> - Add `DOMPurify` as the main sanitizer library - Change HTML attachments to use `iframe` isolation instead of the risky `dangerouslySetInnerHTML` - Detach some `plugin-*` packages from the `web-commons` package that affects the build target
1 parent b689dba commit 2494db0

File tree

31 files changed

+244
-130
lines changed

31 files changed

+244
-130
lines changed

.pnp.cjs

Lines changed: 22 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
4.23 KB
Binary file not shown.
212 KB
Binary file not shown.

packages/core-api/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type * from "./model.js";
99
export type * from "./testCase.js";
1010
export type * from "./testPlan.js";
1111
export type * from "./config.js";
12+
export * from "./static.js";
1213
export * from "./utils/step.js";
1314
export type * from "./utils/tree.js";
1415
export * from "./utils/time.js";

packages/web-commons/src/static.ts renamed to packages/core-api/src/static.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,41 @@ export const createBaseUrlScript = () => {
2727
</script>
2828
`;
2929
};
30+
31+
export const createReportDataScript = (
32+
reportFiles: {
33+
name: string;
34+
value: string;
35+
}[] = [],
36+
) => {
37+
if (!reportFiles?.length) {
38+
return `
39+
<script async>
40+
window.allureReportDataReady = true;
41+
</script>
42+
`;
43+
}
44+
45+
const reportFilesDeclaration = reportFiles.map(({ name, value }) => `d('${name}','${value}')`).join(",");
46+
47+
return `
48+
<script async>
49+
window.allureReportDataReady = false;
50+
window.allureReportData = window.allureReportData || {};
51+
52+
function d(name, value){
53+
return new Promise(function (resolve) {
54+
window.allureReportData[name] = value;
55+
56+
return resolve(true);
57+
});
58+
}
59+
</script>
60+
<script defer>
61+
Promise.allSettled([${reportFilesDeclaration}])
62+
.then(function(){
63+
window.allureReportDataReady = true;
64+
})
65+
</script>
66+
`;
67+
};

packages/plugin-allure2/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"@allurereport/core-api": "workspace:*",
3434
"@allurereport/plugin-api": "workspace:*",
3535
"@allurereport/web-allure2": "workspace:*",
36-
"@allurereport/web-commons": "workspace:*",
3736
"handlebars": "^4.7.8"
3837
},
3938
"devDependencies": {

packages/plugin-allure2/src/generators.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import type { AttachmentLink, HistoryDataPoint, Statistic } from "@allurereport/core-api";
2-
import type { ReportFiles, ResultFile } from "@allurereport/plugin-api";
3-
import type { Allure2ReportOptions } from "@allurereport/web-allure2";
42
import {
53
createBaseUrlScript,
64
createFaviconLinkTag,
75
createReportDataScript,
86
createScriptTag,
97
createStylesLinkTag,
10-
} from "@allurereport/web-commons";
8+
} from "@allurereport/core-api";
9+
import type { ReportFiles, ResultFile } from "@allurereport/plugin-api";
10+
import type { Allure2ReportOptions } from "@allurereport/web-allure2";
1111
import Handlebars from "handlebars";
1212
import { readFile } from "node:fs/promises";
1313
import { createRequire } from "node:module";

packages/plugin-api/src/charts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type {
1414
TrendSlice,
1515
TrendSliceId,
1616
} from "@allurereport/core-api";
17-
import { ChartType, ChartDataType, ChartMode, getPieChartValues } from "@allurereport/core-api";
17+
import { ChartDataType, ChartMode, ChartType, getPieChartValues } from "@allurereport/core-api";
1818
import type { PluginContext } from "./plugin.js";
1919
import { severityTrendDataAccessor } from "./severityTrendAccessor.js";
2020
import { statusBySeverityBarDataAccessor } from "./statusBySeverityBarAccessor.js";

packages/plugin-awesome/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"@allurereport/core-api": "workspace:*",
3434
"@allurereport/plugin-api": "workspace:*",
3535
"@allurereport/web-awesome": "workspace:*",
36-
"@allurereport/web-commons": "workspace:*",
3736
"d3-shape": "^3.2.0",
3837
"handlebars": "^4.7.8"
3938
},

packages/plugin-awesome/src/generators.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import {
77
type TestResult,
88
type TreeData,
99
compareBy,
10+
createBaseUrlScript,
11+
createFontLinkTag,
12+
createReportDataScript,
13+
createScriptTag,
14+
createStylesLinkTag,
1015
getPieChartValues,
1116
incrementStatistic,
1217
nullsLast,
@@ -33,13 +38,6 @@ import type {
3338
AwesomeTreeGroup,
3439
AwesomeTreeLeaf,
3540
} from "@allurereport/web-awesome";
36-
import {
37-
createBaseUrlScript,
38-
createFontLinkTag,
39-
createReportDataScript,
40-
createScriptTag,
41-
createStylesLinkTag,
42-
} from "@allurereport/web-commons";
4341
import Handlebars from "handlebars";
4442
import { readFile } from "node:fs/promises";
4543
import { createRequire } from "node:module";

0 commit comments

Comments
 (0)