Skip to content

Commit e9511be

Browse files
author
Julien Bouquillon
authored
feat(testssl): add expiration warning (#87)
* feat(testssl): add expiration warning * fix: test
1 parent 52d579c commit e9511be

7 files changed

Lines changed: 228 additions & 143 deletions

File tree

report/src/summary/__snapshots__/index.test.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Object {
2222
"lighthouse_pwaGrade": "D",
2323
"lighthouse_seo": 0.9,
2424
"lighthouse_seoGrade": "A",
25+
"testsslExpireDate": "2021-11-30T19:40:00.000Z",
26+
"testsslExpireSoon": false,
2527
"testsslGrade": "A+",
2628
"trackersCount": 0,
2729
"trackersGrade": "A",

report/src/summary/testssl.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,35 @@ const summary = (report) => {
66
report.find &&
77
report.find((entry) => entry.id === "overall_grade");
88
const value = overallGrade && overallGrade.finding;
9+
10+
const notAfterNode = report.find((r) => r.id === "cert_notAfter");
11+
const notAfterIntermediateNode = report.find(
12+
(r) => r.id === "intermediate_cert_notAfter <#1>"
13+
);
14+
15+
// warn a month before
16+
const warningDelay = 30 * 24 * 60 * 60 * 1000;
17+
let expirationDate = null;
18+
if (notAfterNode) {
19+
if (notAfterIntermediateNode) {
20+
const closest = Math.min(
21+
new Date(notAfterNode.finding).getTime(),
22+
new Date(notAfterIntermediateNode.finding).getTime()
23+
);
24+
expirationDate = closest;
25+
} else {
26+
expirationDate = new Date(notAfterNode.finding).getTime();
27+
}
28+
}
29+
30+
const expiresSoon =
31+
expirationDate && new Date().getTime() + warningDelay > expirationDate;
32+
933
if (value) {
1034
return {
35+
testsslExpireSoon: expiresSoon,
36+
testsslExpireDate:
37+
expirationDate && new Date(expirationDate).toISOString(),
1138
testsslGrade: value,
1239
};
1340
}

report/www/src/__tests__/__snapshots__/Url.test.js.snap

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,7 @@ Array [
662662
className="fr-col"
663663
>
664664
<h3>
665-
Scan Summary :
666-
665+
Scan Summary :
667666
<button
668667
className=""
669668
onClick={[Function]}
@@ -672,6 +671,10 @@ Array [
672671
A+
673672
</button>
674673
</h3>
674+
<h4>
675+
Expiration :
676+
30/11/2021
677+
</h4>
675678
</div>
676679
</div>
677680
</div>
@@ -2502,8 +2505,7 @@ Array [
25022505
className="fr-col"
25032506
>
25042507
<h3>
2505-
Scan Summary :
2506-
2508+
Scan Summary :
25072509
<button
25082510
className=""
25092511
onClick={[Function]}
@@ -2512,6 +2514,10 @@ Array [
25122514
A+
25132515
</button>
25142516
</h3>
2517+
<h4>
2518+
Expiration :
2519+
30/11/2021
2520+
</h4>
25152521
</div>
25162522
</div>
25172523
</div>

0 commit comments

Comments
 (0)