DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

dnnjsinclude gives script src integrity check

 9 Replies
 2 Subscribed to this topic
 21 Subscribed to this forum
Sort:
Author
Messages
New Around Here
Posts: 8
New Around Here

 

I am using DontnetNuke 7.4, Visual Studio 2013 and .net framework 4.0

I am referencing typekit.js in dnnjsinclude.

 

<dnn:dnnjsinclude filepath="https://use.typekit.net/xie1khe.js" id="someID" runat="server">

After a PCI scan, we are having a script src integrity check issue. I checked online and saw adding an integrity property with value as a key generated using https://www.srihash.org/ . However I think the integrity property here isn't recognized and all the interface gets messed up. Is there any way to set it ? Kindly let me know if my question is not clear. Thank you for your time in advance.

Thanks

Advanced Member
Posts: 159
Advanced Member
MVP
MVP
You're an MVP!

There is, in fact, a little known method for adding attributes to these script tags.  The <code>DnnJsInclude</code> control has a <code>HtmlAttributesAsString</code> property which can be used to add attributes.  In your example, that would look like this:

<code>
&lt;&#37;@ Register TagPrefix="dnn" Namespace="DotNetNuke.Web.Client.ClientResourceManagement" Assembly="DotNetNuke.Web.Client" %>

&lt;dnn:DnnJsInclude &#114;&#117;nat=&quot;server&quot; FilePath=&quot;https://use.typekit.net/xie1khe.js&quot; HtmlAttributesAsString=&quot;integrity:sha384-cVzjI50ULMD2q5gObcDlRz+PX+kfeUHv+/Wv4WSV5DDVwYC2fOWGbkdUeaAFgcln,crossorigin:anonymous&quot; /&gt;
</code>

At one point I had found that setting multiple attributes this was wasn't working, and there was a fix in DNN 9.2 which addressed that; however, testing just now, this did work on my DNN 7.4.2 site, so hopefully this works for you. One caveat is that you do need to use the <code>DnnJsInclude</code> class from <code>DotNetNuke.Web.Client.ClientResourceManagement</code> (see the <code>&lt;&#37;@ Register … %></code> directive above), rather than the skin/theme object by the same name.

New Around Here
Posts: 8
New Around Here

Hi Brian,

Thank you so much for your reply. I had tried adding the HtmlAttributesAsString in my website before. So my complete code was something as follows :

<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.Web.Client.ClientResourceManagement" Assembly="DotNetNuke.Web.Client" %>    (at the top of the page)

then 

 

<dnn:dnnjsinclude filepath="https://use.typekit.net/xie1khe.js" htmlattributesasstring="crossorigin:'anonymous',integrity:'sha384-cVzjI50ULMD2q5gObcDlRz+PX+kfeUHv+/Wv4WSV5DDVwYC2fOWGbkdUeaAFgcln'" id="SomeID" runat="server">

But when I right click and inspect element and check the console, it gives me the following error :

Error parsing 'integrity' attribute (''sha384-cVzjI50ULMD2q5gObcDlRz+PX+kfeUHv+/Wv4WSV5DDVwYC2fOWGbkdUeaAFgcln''). The specified hash algorithm must be one of 'sha256', 'sha384', or 'sha512' .

Am I doing something wrong ? Is there any way to test if the added integrity constraint is working correctly ?

KIndly let me know if I am not clear.

Thanks !

Advanced Member
Posts: 159
Advanced Member
MVP
MVP
You're an MVP!

It looks like the newer versions allow you to wrap the attribute values in single quotes, but the version in DNN 7.4.2 does not. If you remove the single quotes it should work.

New Around Here
Posts: 8
New Around Here

It worked !!! :)  

Thank you very much for helping me

Veteran Member
Posts: 349
Veteran Member
3 Helpful Replier
Helpful Replier
Thanks for being such a helpful replier!
MVP
MVP
You're an MVP!
Engaged Reader
Engaged Reader
You are an engaged reader!
Avid Reader
Avid Reader
Avid Reader art thou!
Hmm, interesting, I did not know about this. Is that supported as a SPA token too ?
Advanced Member
Posts: 159
Advanced Member
MVP
MVP
You're an MVP!
Nope, the SPA token only supports six properties https://github.com/dnnsof...iptPropertyAccess.cs
Veteran Member
Posts: 349
Veteran Member
3 Helpful Replier
Helpful Replier
Thanks for being such a helpful replier!
MVP
MVP
You're an MVP!
Engaged Reader
Engaged Reader
You are an engaged reader!
Avid Reader
Avid Reader
Avid Reader art thou!
Thanks for the link, I was wondering what code the tokens fired :)
Veteran Member
Posts: 349
Veteran Member
3 Helpful Replier
Helpful Replier
Thanks for being such a helpful replier!
MVP
MVP
You're an MVP!
Engaged Reader
Engaged Reader
You are an engaged reader!
Avid Reader
Avid Reader
Avid Reader art thou!
Am I correct in assuming a module could extend this to use custom tokens by implementing IPropertyAccess or something like that ?
Advanced Member
Posts: 159
Advanced Member
MVP
MVP
You're an MVP!

SPA modules have an extension mechanism, but typically the <code>TokenReplace</code> type will have a hard-coded list of <code>IPropertyAccess</code> implementations, see e.g. <code>HtmlTokenReplace</code> (which is the base class for the SPA module token replace, but also used for the HTML module).

For a SPA module, the module's business controller class can implement <code>ICustomTokenProvider</code> (here's where that's found and called).

These Forums are for the discussion of the open source CMS DNN platform and ecosystem.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
  2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
  3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  5. No Flaming or Trolling.
  6. No Profanity, Racism, or Prejudice.
  7. Site Moderators have the final word on approving / removing a thread or post or comment.
  8. English language posting only, please.

Would you like to help us?

Awesome! Simply post in the forums using the link below and we'll get you started.

Get Involved