Skip to content

gs.info() instance check #141

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
wants to merge 11 commits into from
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
2 changes: 1 addition & 1 deletion ca8467c41b9abc10ce0f62c3b24bcbaa/checksum.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CuNEYHj5RbBsjVJxohTMD1xntLLtuzW06YrIQxv_dnuv66Z-CP9Yyz94aT1y6VMee62ueoZ-zoVm79qzmSN0EDnNTIajGUE-L9E8z-wSmPjpDRK6unp5pT-WyQru961HXU1NDT6tYoVYpmHPnC1pxK1hGqlJ5xCFlFjoYHaWTOMQ-jgr2lppwmOLGMGR7znGbC3ffVubbJzVWxZF2A54U5qoSwKmMb-Sl6nBVJvbZz8finGJvOBn8WzxH6DP_rUNqXJ4ZflVbC2EWzi2mlf_jhEvu35jXElgy6I7myTSoOJvWiK8J6arVkKEt1MNTtewGnDrFnAbFFZ53T08x7UafmirFgZuS4MbzwCYGQ_dX9IlcB-5OLXuB1JYApTLKEJnT364IFKOpAgwzZm5F9dhRAYQG6qVRonDCHrXl1ZJ1WFEMgDCksXtQpTcc53Fe-cH348-sbttOrFExqMtN8HmrJxdjJWFQB0WIPnb7BLMIc6qvc0QIfku9KZpHSlse1cttB-pn_l5UM07YLgjoWCB2wvGaLkZdjDOT0MZizytu7SaAs0SFgm4Q2g4p3xTJ9C78cM24TaT0oQ_gIehRDaf-ETeb4XCdMj1hpaRB4PR2JquoRXJvkfZ7bB6l0ahyfDeQvKqk2cmDf0Mt2CKXeALoAOwe3vhtLMTXKOL1NBAjm4
K1JwG_j7WZdRbR9E5RCgNlHV7ncqeRYgCBYlc1OVTjwKmAT0_sjhSeOl32ardd-NIi9UKNE48YlwCZEBxq4X8VM5NbKmdCN6QCAQnqOPk1iqkaEusiPol3BmiUsPcwHlQPWJbWN6WqSrrmAHNo231mWq9bAg0OcnzkIGg96BuvmlsjLy_okvq0TmANceDrQfxcrwyC0_rfFdxBauRWKKezEHHB8m8wmf7Ephd9WDzysQtwsr5YVZGBTMJzSt6emjvPHZRkGh909BiH_sL9cWHcWVIBfA35PbqQTGYWrs2ZqFEYly6H9zufI0Tn5elmxEPfA6JaFPFZVC38Xi9vIpyYFNShM7rnYuErb_GMYN_whb3NyOIB8DbU_VgjTaJDOoUPG4DDdA4gCVg7jz2cruK1HTjWnN3PVANnbTrG0L6qmB9Ev8RYB3mEvO5sbhO_3NmGzSHexRcC0GXRqrNvb0MuGDpNTmuym8gR2D_-Sm5m_pmmUo651rlDOp1WlXS1112fhC0OdBULo4xD0avthRAUPD16IYbXjTD3OzG7feLAHrTrRNkD4hL4Y7PFBUBgP7I1OXj57rfBNoiPHakm058FRXuGQeht6iXL-lI2BXXjc1M12eaduZ56wq8ifQMqN4y_hAFeKVjK4FtkNthU1o359ZerYmBhGU8zdoLS9TCxo
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?><record_update table="scan_script_only_check">
<scan_script_only_check action="INSERT_OR_UPDATE">
<active>true</active>
<category>manageability</category>
<description>In general, you should use the array literal notation when possible. It is easier to read, it gives the compiler a chance to optimize your code, and it's mostly faster too.</description>
<documentation_url/>
<finding_type>scan_finding</finding_type>
<name>Don't use new Array()</name>
<priority>3</priority>
<resolution_details>Validated new Array() pattern on Business rules, Client scripts and Script includes</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 grBr = new GlideRecord('sys_script'); //Business rule
grBr.addActiveQuery();
grBr.query();
while (grBr.next()) {
var scriptContent = grBr.getValue('script');
// Regular expression to check for 'new Array()'
var pattern = /new\s+Array\s*\(/;
if (pattern.test(scriptContent)) {
finding.increment();
}

}

var grCl = new GlideRecord('sys_script_client'); //Client script
grCl.addActiveQuery();
grCl.query();
while (grCl.next()) {
var scriptContent1 = grCl.getValue('script');
// Regular expression to check for 'new Array()'
var pattern1 = /new\s+Array\s*\(/;
if (pattern1.test(scriptContent1)) {
finding.increment();
}

}

var grSi = new GlideRecord('sys_script_include'); //Script Include
grSi.addActiveQuery();
grSi.query();
while (grSi.next()) {
var scriptContent2 = grSi.getValue('script');
// Regular expression to check for 'new Array()'
var pattern2 = /new\s+Array\s*\(/;
if (pattern2.test(scriptContent2)) {
finding.increment();
}

}



})(finding, current);]]></script>
<short_description>Don't use new Array()</short_description>
<sys_class_name>scan_script_only_check</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2024-10-14 18:14:56</sys_created_on>
<sys_id>7593193c5315521000b51901a0490ec5</sys_id>
<sys_mod_count>2</sys_mod_count>
<sys_name>Don't use new Array()</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_script_only_check_7593193c5315521000b51901a0490ec5</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2024-10-14 18:18:21</sys_updated_on>
</scan_script_only_check>
<sys_translated_text action="delete_multiple" query="documentkey=7593193c5315521000b51901a0490ec5"/>
<sys_es_latest_script action="INSERT_OR_UPDATE">
<id>7593193c5315521000b51901a0490ec5</id>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2024-10-14 18:14:55</sys_created_on>
<sys_id>86771d305355521000b51901a0490e92</sys_id>
<sys_mod_count>0</sys_mod_count>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2024-10-14 18:14:55</sys_updated_on>
<table>scan_script_only_check</table>
<use_es_latest>true</use_es_latest>
</sys_es_latest_script>
</record_update>
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?><record_update table="scan_script_only_check">
<scan_script_only_check action="INSERT_OR_UPDATE">
<active>true</active>
<category>manageability</category>
<description>The gs.info() statement can be used to write information to the system log. It is generally used when debugging. Using gs.info() statements will pollute the system log. Prior to promoting artifacts to a production instance, debugging statement should - in most cases - be removed</description>
<documentation_url/>
<finding_type>scan_finding</finding_type>
<name>Check gs.info in scripts</name>
<priority>2</priority>
<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 pattern = /gs\.info\((.*)\)/g;//gs.info() pattern

var grBr = new GlideRecord('sys_script'); //Business rule
grBr.addActiveQuery();
grBr.query();
while (grBr.next()) {
var scriptContent = grBr.getValue('script');
if (pattern.test(scriptContent)) {
finding.increment();
}

}

var grCl = new GlideRecord('sys_script_client'); //Client script
grCl.addActiveQuery();
grCl.query();
while (grCl.next()) {
var scriptContent1 = grCl.getValue('script');
if (pattern.test(scriptContent1)) {
finding.increment();
}

}

var grSi = new GlideRecord('sys_script_include'); //Script Include
grSi.addActiveQuery();
grSi.query();
while (grSi.next()) {
var scriptContent2 = grSi.getValue('script');
if (pattern.test(scriptContent2)) {
finding.increment();
}

}

})(finding, current);]]></script>
<short_description>Check gs.info in scripts</short_description>
<sys_class_name>scan_script_only_check</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2024-10-14 23:06:12</sys_created_on>
<sys_id>dcb996785399521000b51901a0490edb</sys_id>
<sys_mod_count>1</sys_mod_count>
<sys_name>Check gs.info in scripts</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_script_only_check_dcb996785399521000b51901a0490edb</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2024-10-15 17:25:45</sys_updated_on>
</scan_script_only_check>
<sys_translated_text action="delete_multiple" query="documentkey=dcb996785399521000b51901a0490edb"/>
<sys_es_latest_script action="INSERT_OR_UPDATE">
<id>dcb996785399521000b51901a0490edb</id>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2024-10-14 23:06:12</sys_created_on>
<sys_id>fc2a12b85399521000b51901a0490e9f</sys_id>
<sys_mod_count>0</sys_mod_count>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2024-10-14 23:06:12</sys_updated_on>
<table>scan_script_only_check</table>
<use_es_latest>true</use_es_latest>
</sys_es_latest_script>
</record_update>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?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>upgradability</category>
<conditions table="sys_properties">name=sn_atf.runner.enabled^value=false^EQ<item endquery="false" field="name" goto="false" newquery="false" operator="=" or="false" value="sn_atf.runner.enabled"/>
<item endquery="false" field="value" goto="false" newquery="false" operator="=" or="false" value="false"/>
<item endquery="true" field="" goto="false" newquery="false" operator="=" or="false" value=""/>
</conditions>
<description>Automate your testing with ServiceNow's Automated Test Framework to ensure functionality after updates and deployments Considering as instance scan best practices.</description>
<documentation_url/>
<finding_type>scan_finding</finding_type>
<name>Encourage ATFs</name>
<priority>2</priority>
<resolution_details>https://docs.servicenow.com/bundle/xanadu-application-development/page/administer/auto-test-framework/task/atf-enable-tests.html&#13;
&#13;
https://www.servicenow.com/community/developer-forum/how-to-get-type-of-instance-via-script/m-p/2029442</resolution_details>
<run_condition/>
<score_max>100</score_max>
<score_min>0</score_min>
<score_scale>1</score_scale>
<script><![CDATA[(function (finding, current) {
// Checks if we are in a non-production instance
if (gs.getProperty("glide.installation.production") === "false")
finding.increment();

})(finding, current);]]></script>
<short_description>Validate ATFs are enabled in sub production instances</short_description>
<sys_class_name>scan_table_check</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2024-10-14 16:09:20</sys_created_on>
<sys_id>357638f05391521000b51901a0490e6e</sys_id>
<sys_mod_count>5</sys_mod_count>
<sys_name>Encourage ATFs</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_357638f05391521000b51901a0490e6e</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2024-10-14 22:08:53</sys_updated_on>
<table>sys_properties</table>
<use_manifest>false</use_manifest>
</scan_table_check>
<sys_translated_text action="delete_multiple" query="documentkey=357638f05391521000b51901a0490e6e"/>
<sys_es_latest_script action="INSERT_OR_UPDATE">
<id>357638f05391521000b51901a0490e6e</id>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2024-10-14 16:09:19</sys_created_on>
<sys_id>96baf8785391521000b51901a0490e96</sys_id>
<sys_mod_count>0</sys_mod_count>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2024-10-14 16:09:19</sys_updated_on>
<table>scan_table_check</table>
<use_es_latest>true</use_es_latest>
</sys_es_latest_script>
</record_update>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?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_properties">name=sn_atf.runner.enabled^value=false^EQ<item endquery="false" field="name" goto="false" newquery="false" operator="=" or="false" value="sn_atf.runner.enabled"/>
<item endquery="false" field="value" goto="false" newquery="false" operator="=" or="false" value="false"/>
<item endquery="true" field="" goto="false" newquery="false" operator="=" or="false" value=""/>
</conditions>
<description>Automate your testing with ServiceNow's Automated Test Framework to ensure functionality after updates and deployments Considering as instance scan best practices.</description>
<documentation_url/>
<finding_type>scan_finding</finding_type>
<name>Encourage ATF</name>
<priority>2</priority>
<resolution_details>https://docs.servicenow.com/bundle/xanadu-application-development/page/administer/auto-test-framework/task/atf-enable-tests.html&#13;
&#13;
https://www.servicenow.com/community/developer-forum/how-to-get-type-of-instance-via-script/m-p/2029442</resolution_details>
<run_condition/>
<score_max>100</score_max>
<score_min>0</score_min>
<score_scale>1</score_scale>
<script><![CDATA[(function (finding, current) {
// Checks if we are in a non-production instance
if (gs.getProperty("glide.installation.production") === "false")
finding.increment();

})(finding, current);]]></script>
<short_description>Validate ATFs are enabled in sub production instances</short_description>
<sys_class_name>scan_table_check</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2024-10-14 22:19:17</sys_created_on>
<sys_id>6d0f0ab45359521000b51901a0490e96</sys_id>
<sys_mod_count>0</sys_mod_count>
<sys_name>Encourage ATF</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_6d0f0ab45359521000b51901a0490e96</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2024-10-14 22:19:17</sys_updated_on>
<table>sys_properties</table>
<use_manifest>false</use_manifest>
</scan_table_check>
<sys_translated_text action="delete_multiple" query="documentkey=6d0f0ab45359521000b51901a0490e96"/>
<sys_es_latest_script action="INSERT_OR_UPDATE">
<id>6d0f0ab45359521000b51901a0490e96</id>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2024-10-14 22:19:17</sys_created_on>
<sys_id>656fc6b45359521000b51901a0490ed1</sys_id>
<sys_mod_count>0</sys_mod_count>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2024-10-14 22:19:17</sys_updated_on>
<table>scan_table_check</table>
<use_es_latest>true</use_es_latest>
</sys_es_latest_script>
</record_update>
Loading