Rule Definition
Another form of browser sniffing; unreliable and obsolete.
Remediation
Use feature detection (e.g., checking if a method exists) or standards-based behavior; avoid IE-only branches.
Violation Code Sample
if (navigator.appName === "Microsoft Internet Explorer") {
enableIEWorkaround();
}
Fixed Code Sample
if (!("addEventListener" in window)) {
enableLegacyWorkaround();
}
Reference
– MDN – Navigator.appName (deprecated): https://developer.mozilla.org/en-US/docs/Web/API/Navigator/appName
– MDN – Browser detection is discouraged: https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent
– WHATWG – Navigator object (legacy compatibility): https://html.spec.whatwg.org/multipage/system-state.html#the-navigator-object
Related Technologies
Technical Criterion
CWE-710 - Improper Adherence to Coding Standards [Pillar]
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.