Skip to content

A Fix Script to Scan and check for the log statements #160

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
2 changes: 1 addition & 1 deletion ca8467c41b9abc10ce0f62c3b24bcbaa/checksum.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BgiovevC1ze9ekbSNu313pR_3YPr9xUl8hAleZQ_Rnfiowfr5T_DAmii6h_xnZewjTA5kJDPZ8x14S0gIPG4eStZ_r0uGIAEaMA2i5ojlbIKORDDapgOMutOHKJaSSwf5uZ0VkEcLzooGIDWB0v16daIWWmH_U_tcnLaTE7bj5lyq4EtAk53xdL2hPu7eGFz949_eZIJg4np37S0xRegM9y_dmXRrQ8sLopLNT_af4u_BCPeNIg9Gwq5Wjn9Qj-xbi8bazd-3t7Koe2HKHH2vqOryT-dhuZufc9zUI_l55ev-4cGovoOeBX2wc13EwKh1HIMaW9kwiWljZ-0An9_loh6WU6FYCcnEV9xS2xDXUbHOoWeuOdg76lvyor5qfEN3jOQ46xXIoW5vidkXaoBVtMSLMcBFbrFBZuJWI0Zq4lZU6TiRvzbveuo1rDeAv126QIJhGCuE0SDcvzuV96dbttSOQ-ZgAUumexHi91tJ_97V2MDP9q5Ms-5Y0Mg9r0PNqCibJqaPEnkxgYPIYePZZZdYPYWbOtM4eTteRkWZxAXO_lRTEq7Bon9z0cpiIRBaZLIg7LiMeLZk8F2gHservOdv1_Y1D_rFznoMifC65doHeUJMmIqw6u6vCAM7C9B8YpsXDLWfL6sPrSqTQwVK1WHG_lmjTI_4U6Qb1fAgFg
rJLf1AAbFV5OE_dPDo2VP8-l8MV3ExKZUxo9R7aB416ndfQD0tQ1_cF14Qj4Ok9A9LvkHmb6rlQDxvq_CHedxSDw7EhbBUDTsNooyiRl4IOCw1tH2TTAqmIJn14tRyDgKyznlboIqhJu1RSqd_c95cB7wqcQpE-Qu1q1rMFrp6wxJlpujSDe6RoRuuLINet8T893EjjT00zLbpWFSoio-gPtWGYuCZ9r-SrJllBTNIv1XR22kMPzJeDtNo47GzEs4c7KZwU911yqSpzjgvOcAMfrPShDKvxaUeqidyNwSS9KXR8BB1jdvJaLkQxxDxJQPPP9CbTHQiTKyvr6TNJMriHPOtidllo_b5eExLLyqfLV3Jfwm5nzPJEPgs5O25my5uZuJvGH4AK5xlcTYRujDlX41YLevqwQJrzvFxMr6gufeB-KSzcw4B1flvJiXmGAQzZGcYgFm0fKsipTcukW0NaR8wtrQbgsWPSyMk0614LTwpNXDahR8rxD6dK1kewISM02sBux3wFbR5z8X46LImaHV7_kvCdni-8JDd-pfIdjicv5HVObrfbPKi0LiveZs7RQLbxDQgan_qIz-YmbfPEGq_Qhx24auoceP7yy9RGQ3fBaUVsoDpLStjbJblbjl1UiPzdaWkRsSqoxPbD5p_kQ7mB6-TOILSPI8oujpLw
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?><record_update table="sys_script_fix">
<sys_script_fix action="INSERT_OR_UPDATE">
<before>false</before>
<description>This utility script helps in finding the various log statements which are against the bad practices such as gs.log,gs.info,console.log etc should bot be used in production environment. The script returns the line numbers where such statements are used which can help identify such statements.</description>
<name>Scan for log statements</name>
<record_for_rollback>true</record_for_rollback>
<script><![CDATA[var tableName = 'sys_script';
var sysId = '3b59c70d47441210788164f2e16d4386';
var gr = new GlideRecord(tableName);
gr.addQuery('sys_id',sysId);
gr.query();
var script = "";
if(gr.next()){
script = gr.getValue('script');
}
var logStatements = ['gs.log', 'gs.info', 'gs.debug', 'console.log', 'gs.print'];
// Split the script into lines
var lines = script.split("\n");
// Array to store line numbers where log statements are found
var logLineNumbers = [];
// Iterate over each line and check for log statements
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
// Check if the line contains any of the log statements
for (var j = 0; j < logStatements.length; j++) {
if (line.includes(logStatements[j])) {
logLineNumbers.push(i + 1); // Line numbers are 1-based, so we add 1
break; // No need to check further for this line
}
}
}
// Output the line numbers with log statements
gs.print('Log statements found at line numbers: ' + logLineNumbers.join(', '));
]]></script>
<sys_class_name>sys_script_fix</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2024-10-21 13:49:57</sys_created_on>
<sys_id>5c5dd84747d95210788164f2e16d43b8</sys_id>
<sys_mod_count>0</sys_mod_count>
<sys_name>Scan for log statements</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>sys_script_fix_5c5dd84747d95210788164f2e16d43b8</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2024-10-21 13:49:57</sys_updated_on>
<unloadable>false</unloadable>
</sys_script_fix>
<sys_es_latest_script action="INSERT_OR_UPDATE">
<id>5c5dd84747d95210788164f2e16d43b8</id>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2024-10-21 13:49:56</sys_created_on>
<sys_id>3cfd1c4747d95210788164f2e16d434f</sys_id>
<sys_mod_count>0</sys_mod_count>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2024-10-21 13:49:56</sys_updated_on>
<table>sys_script_fix</table>
<use_es_latest>true</use_es_latest>
</sys_es_latest_script>
</record_update>
Loading