Skip to content

Commit 2e02421

Browse files
committed
Improve report title and version
- Use the product name only as title - Improve the application version and the update date displayed on the HTML report - Update dependencies
1 parent ef44a31 commit 2e02421

File tree

8 files changed

+686
-306
lines changed

8 files changed

+686
-306
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# .gitignore
33
#
44

5+
.idea/
6+
.vscode/
57
coverage/
68
node_modules/
79
tmp/

package-lock.json

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

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@
3333
"src/**/*.ejs"
3434
],
3535
"dependencies": {
36-
"axios": "^1.7.7",
36+
"axios": "^1.9.0",
3737
"ejs": "npm:neat-ejs@^3.1.10",
38-
"jsonpath-plus": "^10.0.3"
38+
"jsonpath-plus": "^10.3.0"
3939
},
4040
"devDependencies": {
41-
"@eslint/js": "^9.12.0",
42-
"c8": "^10.1.2",
43-
"eslint": "^9.12.0",
44-
"express": "^4.21.1",
45-
"globals": "^15.11.0",
46-
"mocha": "^10.7.3",
41+
"@eslint/js": "^9.25.1",
42+
"c8": "^10.1.3",
43+
"eslint": "^9.25.1",
44+
"express": "^4.21.2",
45+
"globals": "^15.15.0",
46+
"mocha": "^10.8.2",
4747
"mocha-junit-reporter": "^2.2.1"
4848
},
4949
"engines": {

src/defectdojo.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ export class DefectDojoApiClient {
4040
throw new Error("expected to find a single product");
4141
}
4242
const product = results[0];
43-
const d = product.description?.trim();
44-
product.title = d && d.length < 60 && !d.includes("\n") ? d : product.name;
43+
product.title = product.name;
4544
product.url = `${this.url}/product/${product.id}`;
4645
console.log(`[info] Product id = ${product.id}`);
4746
return product;

src/template.ejs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,13 @@
106106
<h2>
107107
<span><%= product.title %></span>
108108
<%_ if (product.engagements?.length > 0) { -%>
109-
<%_ if (product.engagements[0].version) { -%>
110-
<span class="tag" title="Application version"><%= product.engagements[0].version %></span>
109+
<%_ const engagement = product.engagements.reduce((last, cur) =>
110+
cur.updated?.localeCompare(last?.updated ?? "") > 0 ? cur : last) -%>
111+
<%_ if (engagement?.version) { -%>
112+
<span class="tag" title="Application version"><%= engagement.version %></span>
111113
<%_ } -%>
112-
<%_ if (product.engagements[0].updated) { -%>
113-
<span class="tag" title="Last security debt update"><%= product.engagements[0].updated.substring(0, 10) %></span>
114+
<%_ if (engagement?.updated) { -%>
115+
<span class="tag" title="Last security debt update"><%= engagement.updated.substring(0, 10) %></span>
114116
<%_ } -%>
115117
<%_ } -%>
116118
</h2>

test/defectdojo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe("DefectDojoApiClient", function () {
1010
let product;
1111
await assert.doesNotReject(async () => product = await client.getProduct("product"));
1212
assert.strictEqual(product.id, 1);
13-
assert.strictEqual(product.title, "Product description");
13+
assert.strictEqual(product.title, "product");
1414
assert.strictEqual(product.url, "http://localhost:8888/product/1");
1515
});
1616
it("should throw if the product doesn't exist", async function () {

test/e2e.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe("defectdojo-report", function () {
4141

4242
// Check the HTML report content
4343
assert.ok(html.match(/<h1>Security Debt<\/h1>/));
44-
assert.ok(html.match(/<span>Product description<\/span>/));
44+
assert.ok(html.match(/<span>product<\/span>/));
4545
[
4646
{ str: "#18aada", count: 2 }, // Custom primary color
4747
{ str: "320px-Defectdojologo.png", count: 1 }, // Custom logo

test/stub.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export async function mochaGlobalSetup() {
6464
await new Promise((resolve) => {
6565
server = app.listen(port, () => resolve())
6666
});
67-
};
67+
}
6868

6969
/**
7070
* Stop the HTTP server after running tests.

0 commit comments

Comments
 (0)