Skip to content

Created 3 new instance scan checks (Table Check) & Updated the README.md document. #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ Tickets from tables such as Incident, Change Request, Problem, and other task-re
### Check Inactive Business Rules over 90 days
Inactive Business Rules which are not updated for more than 90 days and not created by glide.maint and not updated by admin should be identified to remove unnecessary overhead.

### Always keep code/snippet in functions - Business Rules
In general, an advanced busiess rule will wrap your code in a function, and it is important that this guideline is followed. When code is not enclosed in a function, variable and other objects are avilable to all other server-side scripts. This availability can lead to unexpected consequences that are difficult to troubleshoot.

### Update set In Progress/Completed previously Ignored
Usually, developers mark an updatesets as Ignore if the work done is not required to be promoted or incorrect or irrelavent or due to any other reasons.
However, at times, some of the developers may use the ignored set for any active work instead of creating new one by updating the state from Ignore to In-Progress. It is not a good practice to do the same. It may case the deployment issues and also makes the troubleshooting process cumbersome.
It may also impact the deployment and cause issues in case if the state is changed to In-Progress/Completed for the potential ignored sets.


## Category: Upgradability

### Call GlideRecord using new
Expand Down Expand Up @@ -332,6 +341,9 @@ Unpublished knowledge articles may contain sensitive information that should not
### Scripts in ACLs should be cleared when Advanced is not checked
Scripts in ACLs ARE executed regardless of whether or not the Advanced checked box is checked off. As such, unnecessary scripts should be cleared from the field OR the Advanced checkbox should be checked in cases where scripts are required to provide better visibility to admins for troubleshooting purposes.

### Catalog Client script with GlideRecord API calls
Catalog Client script should be using GlideAjax if you need to make asyc calls to Server to get data from Server. GlideRecord() API shouldn't be used to avoid performance issues.

## Category: User Experience

### Added a Number Prefix which already exists
Expand Down
2 changes: 1 addition & 1 deletion ca8467c41b9abc10ce0f62c3b24bcbaa/checksum.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2GkIkYTRLHBrnaK0BLk-XjxdsvdTIZ9jJdpNRMX35K_6xuWTi5y1Ry99K-DOjlG11wqAiWwvl7aCdE4ZWrSiATbI0lxnUdQ9WxlKwYNvs1x4VCYSXFOyYvTvKT3kiAZAzCrckOa4Em4EIaQWsrb_I8Hs0bgKv33rj-ePUrlm_eyaKJ2rnW23umP3MLy86FEu-J5jxkDLisX7iqlAtjOoRsUQBweQsMoxupOYvfpdE9hb2_IVDL9CoKdTg80_4ggyJ8PNBz0-61EPdmnU7cRKcwrgivmxrwlsMZRJ1uYb2HSI-uveGE4A7AF1o6mBZIz6ssbtFd7EiA0adaGXD5P15jiG014hPjkYP4HKiiA0_Yjt6wL60LGi3OSCJ9gd8YGeijcceUhadJ8o7-_9kKB87bMrCZLimt0eMOU9IP8roKLd8mrCC7yROA1N93b861zaMf9Rya_aFIMJAxF42hodGemepQf6byCLRA_-rQf6UZS9gCn3BUKuaXq3SQ-zJZRa8abRZPslmATdHB_qc3qD-zHdKaau-2U4IjCX5uN8_zJWyiHrskGbzNbjghd7A0IyCLH5cWiIxHZp41YeMQQhXX0ZQyhH8rnFFviKVQkfU9MEVdpqhBTLKe5B0bM5sXYhejFEzKJayrE0FcpgYQhxsN3AyPQpH5w62LMaCkTbugU
O2Z77o9EFursYt1K07qAJxi1q3toSYYu845IcvgRCRP4mg_d8i7G2DvNCJKO6ugMMGVksnwGH69Ehft-qk2O8iHVVDabTYaW9VKCNnoQcWSVwgxYRcCDy7HuepXLHyPfWsKqfatmB3M2GgXO7DTcACLGNuHcf9vLnMSYe168U5lIa7Tt-_3hiWXYwRNRESs10QXHznJ5kkeQjwbZa7ux3ttV15daavjwyejh6wImpTbsAxPwapNgC-klYerXPNmzqoeb7-QLAZnoQ7pvMywmGKjCdFd-3rX4Bnq3O9IdTdKW5hYgdOpj1rlJBYSLiJ6UyOpE3-OURcENQJjo_AV9wSrubWgIfakHA3jkEPUqb256GiDV0aMOXdWxu2wF3gmxVOZLHYGc3c1orSE8WhdDkTatOBiXSsAcwk4SX25-1g0S5rqD5Hq598i8WJGpUzTEcF5rCZ0LPzsgcaWIlVTKJozgTLPvKEbtfXnXzqtGWeKBTCgU2ewKZpwUJkEw3D4wHvg83WstSNngYClZ9cM3PSi-KhlJLq-nJvCdyRm9o7SBZrwufXwmB72lcC3CaJsvL8ll5qPBfyg0MQUySD8q9az-BkOnqjdYAjBJHwdsN6rtqPGtv8sRQU5iPEQi8rWKrmGGLG404fT-Z9SkAl-iIjX34j3INxlYsgBwJQiQo_w
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?><record_update table="scan_table_check">
<scan_table_check action="INSERT_OR_UPDATE">
<active>true</active>
<advanced>true</advanced>
<category>manageability</category>
<conditions table="sys_update_set">state=in progress^ORstate=complete^EQ<item display_value="In progress" endquery="false" field="state" goto="false" newquery="false" operator="=" or="false" value="in progress"/>
<item display_value="Complete" endquery="false" field="state" goto="false" newquery="false" operator="=" or="true" value="complete"/>
<item endquery="true" field="" goto="false" newquery="false" operator="=" or="false" value=""/>
</conditions>
<description>Usually, developers mark an updatesets as Ignore if the work done is not required to be promoted or incorrect or irrelavent or due to any other reasons. &#13;
However, at times, some of the developers may use the ignored set for any active work instead of creating new one by updating the state from Ignore to In-Progress. It is not a good practice to do the same. It may case the deployment issues and also makes the troubleshooting process cumbersome.&#13;
It may also impact the deployment and cause issues in case if the state is changed to In-Progress/Completed for the potential ignored sets.</description>
<documentation_url/>
<finding_type>scan_finding</finding_type>
<name>Update set In Progress/Completed previously Ignored</name>
<priority>3</priority>
<resolution_details>It is always good and recommended to create a new updateset instead of using already Ignored updatesets by changing the state from Ignore to In-Progress/Completed.</resolution_details>
<run_condition/>
<score_max>100</score_max>
<score_min>0</score_min>
<score_scale>1</score_scale>
<script><![CDATA[(function (finding, current) {

var usSysId = current.getUniqueValue();
var audit = new GlideRecord('sys_audit');
audit.addEncodedQuery('fieldname=state^tablename=sys_update_set^oldvalue=ignore^newvalue=in progress^ORnewvalue=complete');
audit.addQuery('documentkey', usSysId);
audit.setLimit(1);
audit.query();

if(audit.hasNext()){
finding.increment();
}

})(finding, current);]]></script>
<short_description>Already Ignored Update Set shouldn't be set back to In Pogress/Completed.</short_description>
<sys_class_name>scan_table_check</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2024-10-30 19:28:34</sys_created_on>
<sys_id>01c1c08ec3a19610afa6fc84e401310d</sys_id>
<sys_mod_count>0</sys_mod_count>
<sys_name>Update set In Progress/Completed previously Ignored</sys_name>
<sys_package display_value="Example Instance Checks" source="x_appe_exa_checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_package>
<sys_policy/>
<sys_scope display_value="Example Instance Checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_scope>
<sys_update_name>scan_table_check_01c1c08ec3a19610afa6fc84e401310d</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2024-10-30 19:28:34</sys_updated_on>
<table>sys_update_set</table>
<use_manifest>false</use_manifest>
</scan_table_check>
</record_update>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not validate whether the code is enclosed in a function. This looks for the text function. I could write a comment such as:

// I hope this code functions as expected

and it would match the value. I recommend removing this one so we can accept this PR, and then submitting a separate one that users a linter check to validate this behaviour

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?><record_update table="scan_table_check">
<scan_table_check action="INSERT_OR_UPDATE">
<active>true</active>
<advanced>false</advanced>
<category>manageability</category>
<conditions table="sys_script">scriptNOT LIKEfunction^EQ<item endquery="false" field="script" goto="false" newquery="false" operator="NOT LIKE" or="false" value="function"/>
<item endquery="true" field="" goto="false" newquery="false" operator="=" or="false" value=""/>
</conditions>
<description>In general, an advanced busiess rule will wrap your code in a function, and it is important that this guideline is followed. When code is not enclosed in a function, variable and other objects are avilable to all other server-side scripts. This availability can lead to unexpected consequences that are difficult to troubleshoot.</description>
<documentation_url/>
<finding_type>scan_finding</finding_type>
<name>Always keep code/snippet in functions - Business Rules</name>
<priority>2</priority>
<resolution_details>If you have already written code without function in any business rule, move the code by having the function. &#13;
If you create any new business rule, please ensure to write code inside of a function rather writing it directly in script field.</resolution_details>
<run_condition/>
<score_max>100</score_max>
<score_min>0</score_min>
<score_scale>1</score_scale>
<script><![CDATA[(function (engine) {

// Add your code here

})(engine);]]></script>
<short_description>Keep code in functions - Business Rules</short_description>
<sys_class_name>scan_table_check</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2024-10-30 18:42:01</sys_created_on>
<sys_id>03173371c3a19610afa6fc84e40131af</sys_id>
<sys_mod_count>1</sys_mod_count>
<sys_name>Always keep code/snippet in functions - Business Rules</sys_name>
<sys_package display_value="Example Instance Checks" source="x_appe_exa_checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_package>
<sys_policy/>
<sys_scope display_value="Example Instance Checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_scope>
<sys_update_name>scan_table_check_03173371c3a19610afa6fc84e40131af</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2024-10-30 18:48:42</sys_updated_on>
<table>sys_script</table>
<use_manifest>false</use_manifest>
</scan_table_check>
</record_update>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not validate whether the GlideRecord object is used. This looks for the text GlideRecord. I could write a comment such as:

// Using GlideAjax instead of GlideRecord as requested

and it would match the value. I recommend removing this one so we can accept this PR, and then submitting a separate one that users a linter check to validate this behaviour

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?><record_update table="scan_table_check">
<scan_table_check action="INSERT_OR_UPDATE">
<active>true</active>
<advanced>false</advanced>
<category>performance</category>
<conditions table="catalog_script_client">scriptLIKEGlideRecord^EQ<item endquery="false" field="script" goto="false" newquery="false" operator="LIKE" or="false" value="GlideRecord"/>
<item endquery="true" field="" goto="false" newquery="false" operator="=" or="false" value=""/>
</conditions>
<description>Catalog Client script should be using GlideAjax if you need to make asyc calls to Server to get data from Server. GlideRecord() API shouldn't be used to avoid performance issues.</description>
<documentation_url/>
<finding_type>scan_finding</finding_type>
<name>DO NOT USE GlideRecord API in catalog client script</name>
<priority>2</priority>
<resolution_details>Catalog Client scripts run on browser and they uses either data available on the form or data retrieved from the database.&#13;
Use client data as much as possible to eliminate the need for time-consuming server lookups i.e. GlideRecord.&#13;
The best ways to get data into form/browser from the database are g_scratchpad, and asynchronous GlideAjax lookup</resolution_details>
<run_condition/>
<score_max>100</score_max>
<score_min>0</score_min>
<score_scale>1</score_scale>
<script><![CDATA[(function (engine) {

// Add your code here

})(engine);]]></script>
<short_description>Catalog Client script with GlideRecord API calls</short_description>
<sys_class_name>scan_table_check</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2024-10-30 18:23:17</sys_created_on>
<sys_id>a8d2377dc3619610afa6fc84e4013135</sys_id>
<sys_mod_count>0</sys_mod_count>
<sys_name>DO NOT USE GlideRecord API in catalog client script</sys_name>
<sys_package display_value="Example Instance Checks" source="x_appe_exa_checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_package>
<sys_policy/>
<sys_scope display_value="Example Instance Checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_scope>
<sys_update_name>scan_table_check_a8d2377dc3619610afa6fc84e4013135</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2024-10-30 18:23:17</sys_updated_on>
<table>catalog_script_client</table>
<use_manifest>false</use_manifest>
</scan_table_check>
</record_update>
Loading