|
| 1 | +<?xml version="1.0" encoding="UTF-8"?><record_update table="scan_column_type_check"> |
| 2 | + <scan_column_type_check action="INSERT_OR_UPDATE"> |
| 3 | + <active>true</active> |
| 4 | + <category>security</category> |
| 5 | + <column_type>script</column_type> |
| 6 | + <description>Variable declaration defines the scope of the variable, ensuring it's accessible only within the intended block. This prevents unintended variable pollution and conflicts. </description> |
| 7 | + <documentation_url>https://www.servicenow.com/community/developer-forum/why-declaration-of-variables-is-essential-in-servicenow/m-p/2379013</documentation_url> |
| 8 | + <finding_type>scan_finding</finding_type> |
| 9 | + <name>For loop iterators "i" should be declared</name> |
| 10 | + <priority>3</priority> |
| 11 | + <resolution_details>Rather than using a construction like "for (i=0; i<10; i++)," it's advisable to explicitly declare the iterator "i" within the for loop by using the "var" keyword, like this: "for (var i=0; i<10; i++)". This ensures proper variable scoping and avoids unintended issues in your code.</resolution_details> |
| 12 | + <run_condition/> |
| 13 | + <score_max>100</score_max> |
| 14 | + <score_min>0</score_min> |
| 15 | + <score_scale>1</score_scale> |
| 16 | + <script><![CDATA[(function(engine) { |
| 17 | + var search_regex = /for\s*\(\s*i\s*=\s*[^;]+/;//This regex detects for loops with an uninitialized i iterator. |
| 18 | + if (search_regex.test(engine.columnValue)) { |
| 19 | + engine.finding.increment(); |
| 20 | + } |
| 21 | +})(engine);]]></script> |
| 22 | + <short_description>Declare the iterator "i" in for loops to avoid variable pollution and conflicts</short_description> |
| 23 | + <sys_class_name>scan_column_type_check</sys_class_name> |
| 24 | + <sys_created_by>admin</sys_created_by> |
| 25 | + <sys_created_on>2023-10-14 09:00:00</sys_created_on> |
| 26 | + <sys_id>ee62ee7e97b131106c7cfed11153af4f</sys_id> |
| 27 | + <sys_mod_count>1</sys_mod_count> |
| 28 | + <sys_name>For loop iterators "i" should be declared</sys_name> |
| 29 | + <sys_package display_value="Example Instance Checks" source="x_appe_exa_checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_package> |
| 30 | + <sys_policy/> |
| 31 | + <sys_scope display_value="Example Instance Checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_scope> |
| 32 | + <sys_update_name>scan_column_type_check_ee62ee7e97b131106c7cfed11153af4f</sys_update_name> |
| 33 | + <sys_updated_by>admin</sys_updated_by> |
| 34 | + <sys_updated_on>2023-10-14 09:05:26</sys_updated_on> |
| 35 | + </scan_column_type_check> |
| 36 | + <sys_translated_text action="delete_multiple" query="documentkey=ee62ee7e97b131106c7cfed11153af4f"/> |
| 37 | +</record_update> |
0 commit comments