/*
 * Copyright (c) 2018, 2026, Oracle and/or its affiliates.
 * Licensed under The Universal Permissive License (UPL), Version 1.0
 * as shown at https://oss.oracle.com/licenses/upl/
 */
const RULE_NAME="csp-html-style-unsafe-inline";const LONG_DESCRIPT="<b>CSP-1030:</b><br>"+"Embedding styles into HTML using &lt;style&gt; tags is a CSP violation.<br>"+"For example, the following implementation will be blocked:<p>"+"<b>&lt;style&gt;<br>"+" &nbsp; &nbsp; #inline-style { background: red }<br>"+"&lt;/style&gt;</b><p>"+"The general solution is to extract the styles into a style sheet and reference it in the HTML using <b>&lt;link href=\". . .\"&gt;</b>"+"<b><p>CSP-1031:</b><br>"+"Setting a style attribute directly on element, e.g.<b>&lt;div style=\". . .\"&gt;</b> is a CSP violation.<p>"+"The general solution is to set properties directly on the element's style property, e.g.<br><b>element.style.display = \"none\"</b><p>"+"Alternatively, styles can be added by changing to a class and including the class in the HTML element.";const SHORT_DESCRIPT=LONG_DESCRIPT;function getName(){return RULE_NAME};function getShortDescription(){return SHORT_DESCRIPT};function getDescription(){return LONG_DESCRIPT};function register(){return{"tag":_fnTag,"ojtag":_fnTag}};function _fnTag(context,tag){var attrs,attr,nonce,issue;if(tag==="style"){attrs=context.tagNode.attribs;if(attrs){for(attr in attrs){if(attr==="nonce"){nonce=true;break}}}if(!nonce){issue=new context.Issue("inline <style> element : 'nonce' not specified - CSP violation");issue.setMsgKey(context.ruleName+"_1");context.reporter.addIssue(issue,context)}}_checkAttrs(context,tag);if(attrs){for(attr in attrs){if(attr==="nonce"){nonce=true;break}}}}function _checkAttrs(context,tag){var attrs,attr,issue,attrPos;attrs=context.tagNode.attribs;if(attrs){for(attr in attrs){if(attr==="style"){issue=new context.Issue("inline 'style' attribute on <"+tag+">  - CSP violation");attrPos=context.utils.DomUtils.getAttribPosition(context.data,context.node,attr);issue.setPosition(attrPos.row,attrPos.col,attrPos.start,attrPos.end);issue.setMsgKey(context.ruleName+"_2");context.reporter.addIssue(issue,context)}}}};module.exports={getName,getDescription,getShortDescription,register};