added hardening on documents link

This commit is contained in:
2021-11-16 19:12:03 +00:00
parent c6d4743f73
commit 831f0497c5
6 changed files with 101 additions and 160 deletions
+14 -14
View File
@@ -105,12 +105,9 @@ const DocumentDetails = (props) => {
>
<dd className="govuk-summary-list__value govuk-!-font-size-16 ">
<a
href={
"/api/proxy/documents/download/" +
encryptDocReference(
detailsObj.pinswg_isharedocumentreference
)
}
href={encryptDocReference(
detailsObj.pinswg_isharedocumentreference
)}
>
<span className="results-visually-hidden">
{t(
@@ -194,15 +191,18 @@ const DocumentDetails = (props) => {
);
};
const encryptDocReference = (documentRef) => {
var encrypted = encodeURIComponent(
CryptoJS.AES.encrypt(
documentRef,
process.env.NEXT_PUBLIC_ISHARESECRETPHRASE
)
);
const WORDKEY = process.env.NEXT_PUBLIC_HASHKEY;
return encrypted;
const encryptDocReference = (documentRef) => {
var hashlink = CryptoJS.HmacSHA256(
"/api/proxy/documents/download/" + documentRef,
CryptoJS.enc.Hex.parse(WORDKEY)
);
hashlink = hashlink.toString();
return (
"/api/proxy/documents/download/" + documentRef + "&hash=" + hashlink
);
};
useEffect(() => {
+13 -1
View File
@@ -263,7 +263,19 @@ const Pinswg_dnsid = (props) => {
detailsObj.pinswg_webaddress +
'")].value_cy'
)
: detailsObj.pinswg_webaddress ||
: (
<a
target="_blank"
rel="noopener"
href={
detailsObj.pinswg_webaddress
}
>
{
detailsObj.pinswg_webaddress
}
</a>
) ||
t(
"case:summary-no-date-entered-label"
)}
+1 -1
View File
@@ -268,7 +268,7 @@ const DNSSearchResults = (props) => {
//console.log("getting details", data);
return getSearchDetailsPaged(data).then((data) => {
setSearchDetails(data);
setShowSpinnerState(false);
//setShowSpinnerState(false);
});
});
};