SSWConsulting / SSW.CodeAuditor

SSW Code Auditor V2
6 stars 6 forks source link

✨ Custom Rule - favicon must be added to a website #853

Closed tombui99 closed 5 months ago

tombui99 commented 6 months ago

Cc: @adamcogan @william-liebenberg @tiagov8

Pain

As per my conversation with @tiagov8 , we need to add a new custom rule that checks if a website has favicon.

See SSW Rule https://www.ssw.com.au/rules/favicon/

Tasks

Thanks!

tombui99 commented 6 months ago

Cc: @adamcogan @william-liebenberg @tiagov8

Implement the new rule

Done - I have added a new custom rule to CodeAuditor that checks for website without favicon. CodeAuditor scans for any website without rel="icon

Image

Figure: New custom rule on CodeAuditor page https://codeauditor.com/rules

Image

Figure: Custom rule logic

Image

Figure: All custom rules unit tests which have all passed

tiagov8 commented 6 months ago

Hi @tombui99

One question:

  1. Does the logic say the rel="icon should be inside the <head> ?

Before you close this Issue, we need some testing:

tombui99 commented 5 months ago

cc @william-liebenberg @adamcogan

Hi @tiagov8

From my testing, it is not technically possible to implement this custom rule due to how the HTML engine works. The engine checks each HTML element individually and reports if it finds a problem within that element. For example, within a head, there might be multiple link tags without the text icon, and the engine will report all of these tags, even if there's one correct tag with icon. Therefore, I'm disabling the custom rule and closing this issue. Let me know if there's anything.

tombui99 commented 5 months ago

Fix custom rule so it checks for rel=icon is used at least once in the head

Done - As approved by @william-liebenberg , we have implemented the custom rule with the workaround.

Also, as per my Teams conversation with @tiagov8 , I have also ran a test scan on https://kontofurniture.ca/collections/office-chairs and CodeAuditor was able to catch the error.

See https://codeauditor.com/htmlhint/9def4cbb-38ad-460b-9602-cc2b0a33d8fd