/*
 * Copyright (c) 2018, 2025, 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-ts-style-unsafe-inline";const LONG_DESCRIPT="Styles applied in JavaScript by setting the style attribute directly using setAttribute() are a CSP violation. "+"Style properties that are set directly on an element's style property permit safe style manipulation in JavaScript. e.g. in place of<p>"+" &nbsp; &nbsp; elem<b>.setAttribute</b>('style', 'background-color : red;')<p>"+"use<p>"+" &nbsp; &nbsp; elem<b>.style</b>.backgroundColor = 'red';";const SHORT_DESCRIPT=LONG_DESCRIPT;var _scopes;function getName(){return RULE_NAME};function getShortDescription(){return SHORT_DESCRIPT};function getDescription(){return LONG_DESCRIPT};function register(){return{CallExpression:_fnCall}};function _fnCall(ruleCtx,node){var callee,meth,args,arg,issue;callee=node.callee;if(callee.property&&callee.property.type==="Identifier"){meth=callee.property.name;if(meth==="setAttribute"||meth==="attr"){args=node.arguments;if(meth==="attr"&&args.length<2){return}arg=args[0];if(arg.value==="style"){if(arg.type==="Literal"){if(meth==="setAttribute"||_isKO(node)){issue=true}}}if(issue){issue=new ruleCtx.Issue("setAttribute('style') - CSP violation");ruleCtx.reporter.addIssue(issue,ruleCtx)}}}};function _isKO(node){var callee=node.callee;var o=callee.object;return o&&o.callee&&o.callee.type==="Identifier"&&o.callee.name==="$"};module.exports={getName,getDescription,getShortDescription,register};