Skip to content

Commit

Permalink
Added check "CodeSanity - Client-side logging".
Browse files Browse the repository at this point in the history
  • Loading branch information
admin committed Feb 2, 2023
1 parent 85901f0 commit 29e1c9b
Show file tree
Hide file tree
Showing 8 changed files with 275 additions and 9 deletions.
2 changes: 1 addition & 1 deletion 8ed42c23dbad0510bcced03cd39619ce/checksum.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
zYZER2oZT68ltp1MHWZfZDhPdiUKTS-7KxPx9m6jVPMNBVxpfGwdqwVUzJPelJK_duRE6XVO4DsGW--zKXJo6DpJYF84QJQCB8BgtJH3OW4XG64p9ksLOuCb6OfWCbz24_MIeS0-DykBD2aJ9j2c2CwRPIjiUuRXX1vvTPdqttB3ptyGcfPnLD1rpegzPqKltpdknPDGDOyi0Ryi5_KJP5GPns6Cs-sXpdbgYOHGQ2XrYBKlT_UTnQDD0YwJeu3ZZ0avQT0-5zTmyIjFVCW7Hyf9asD6UaZJY5KS3n82GC3v1JI9ujOld-zVhNoMOGd1eEAur_WuZ0ETsyN7lU9GSK2o4Qt6-pjuNRNHEx7a3ecZSghiFNXu7ZDbqs-pR7izMjhySA8ffqpTZwAc5ayQp5bgsV80eft1LEramXiMRQzYeILg42XaszCL50xk0CLq7oirU9wo0_gQDMPgp9hcLR9PXFZCuGTm37agmz357F0jrQ6I_5d0rByHnA3gW1rYggOPuF4Ja3aGLZMjKMp_4YKxo0P37T_rtTMX0KBUAqS-PGqhHNhRItqoV0YUEgXRKw4ODVtAzXUj8iDHBpXNsUuqZfF8kseA0ViWefe06iN1w3rWFlb6z9j8QY4rfU1d5FRtEtTnRhgSNomAnk3etQCYyMvYBtiPfkCdV6lbuHo
4TBnAVWcTvr1mocCsj3Hnshxjhd1x6IYXraDKPmvxP1go3MGsQnjEM_-JJHpZkYjmCLxMEUb61k-gk42QtWINTlL7SDIf26RX1QDrLN_8lE06OSUvnPC-QOM-ZBfxcokd45-RNGTWXhU1pd1fQT-G-heto9y1Efz9E-B5f6hEEKCI0NvUAcn_byeFU8A91GF0dwgbawODOoknfgmeu7X_wo2DJNZ3ipmVHYI75KAPCnSfI5hjRTu17imaO1UajFPHkzoEk446U2epTVbZnN7cXo3b32Q3QxnF7M3TZq_S22RP1CK4_z9ZcIITEMVggZjO6NnCxNU7GU77rOs8R_fvBKXzNLSmwNjOxhEr4wFc5pwRug3XAbcreIkLKlNPYYyaBIjsVBV4uOd_tYNMXzPpl8X8hJL7FWeUFODdfSb_7rl9v6a4T9q-bLTpjHKKKduoMirVs50RxWF_MRP2Pk63SjT1Bvd27PjbPnFM6PLOq-0MH2Jx1rQpEeDe5EZe5qfvHq54Jvt92E9riwehCePWWLDkYyqGP5df2gAoj4OJyvVg_JkjWAqqOlQsqrsv5CphoYSw8DJvYSU-lT8nlMWV_npBvH7t4cL32Gi1UFdrilViMWLNptRXaKy_puFhX10EcGQJfnTCMvSNdSYZnkM_LfjedbFr8vItcxRQjl5zSU
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?><record_update table="scan_check_suite_check">
<scan_check_suite_check action="INSERT_OR_UPDATE">
<check display_value="CodeSanity - Client-side logging">89c69b85dbf425106a03dad1f3961980</check>
<score_weight>1</score_weight>
<suite display_value="CodeSanity">4fcb181bdb4a8510bcced03cd39619eb</suite>
<sys_class_name>scan_check_suite_check</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2023-02-02 13:09:20</sys_created_on>
<sys_id>f8d7d7c5dbf425106a03dad1f396193c</sys_id>
<sys_mod_count>0</sys_mod_count>
<sys_name/>
<sys_package display_value="CodeSanity WORK IN PROGRESS" source="x_snc_codesanity">8ed42c23dbad0510bcced03cd39619ce</sys_package>
<sys_policy/>
<sys_scope display_value="CodeSanity WORK IN PROGRESS">8ed42c23dbad0510bcced03cd39619ce</sys_scope>
<sys_update_name>scan_check_suite_check_f8d7d7c5dbf425106a03dad1f396193c</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2023-02-02 13:09:20</sys_updated_on>
</scan_check_suite_check>
</record_update>
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?><record_update table="scan_linter_check">
<scan_linter_check action="INSERT_OR_UPDATE">
<active>true</active>
<category>code_sanity</category>
<description>Any use of "jslog()" or "console.log()" (or any other console-based logging methods) lead to output on the console of the user's browser. Such output never makes it into a server log where administrators or developers can review it. Such output should be considered as debug output which should be avoided in production. </description>
<documentation_url/>
<finding_type>scan_finding</finding_type>
<name>CodeSanity - Client-side logging</name>
<priority>1</priority>
<resolution_details>Remove all console.log(), console.warn(), console.error() and jslog() statements.</resolution_details>
<run_condition/>
<score_max>100</score_max>
<score_min>0</score_min>
<score_scale>1</score_scale>
<script><![CDATA[(function(engine) {
if (x_snc_codesanity.IsCheckApplicableToRecord())
{
engine.rootNode.visit(function(node)
{
//console.*
if (node.getTypeName() === 'GETPROP')
{
var bConsole = false;
var bMethod = false;
node.visit(function(childnode)
{
if (childnode.getTypeName() != 'NAME')
{
return;
}
if (childnode.getNameIdentifier() === 'log')
{
bMethod = true;
return;
}
if (childnode.getNameIdentifier() === 'warn')
{
bMethod = true;
return;
}
if (childnode.getNameIdentifier() === 'error')
{
bMethod = true;
return;
}
if (childnode.getNameIdentifier() === 'console')
{
bConsole = true;
return;
}
});
//Create scan finding
if (bConsole && bMethod) {
engine.finding.incrementWithNode(node);
}
}
//jslog
var parentnode = node.getParent();
if (node.getNameIdentifier()
&& node.getTypeName() === 'NAME'
&& node.getNameIdentifier() === 'jslog'
&& parentnode.getTypeName() === 'CALL')
{
engine.finding.incrementWithNode(node);
}
});
}
})(engine);]]></script>
<short_description>Avoid client-side logging</short_description>
<sys_class_name>scan_linter_check</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2023-02-02 13:09:20</sys_created_on>
<sys_id>89c69b85dbf425106a03dad1f3961980</sys_id>
<sys_mod_count>1</sys_mod_count>
<sys_name>CodeSanity - Client-side logging</sys_name>
<sys_package display_value="CodeSanity WORK IN PROGRESS" source="x_snc_codesanity">8ed42c23dbad0510bcced03cd39619ce</sys_package>
<sys_policy/>
<sys_scope display_value="CodeSanity WORK IN PROGRESS">8ed42c23dbad0510bcced03cd39619ce</sys_scope>
<sys_update_name>scan_linter_check_89c69b85dbf425106a03dad1f3961980</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2023-02-02 13:12:48</sys_updated_on>
</scan_linter_check>
</record_update>
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
<sys_created_by>admin</sys_created_by>
<sys_created_on>2022-11-30 16:06:07</sys_created_on>
<sys_id>218ade641babd1105b76777d8b4bcb0c</sys_id>
<sys_mod_count>2</sys_mod_count>
<sys_mod_count>3</sys_mod_count>
<sys_name>Run Server Side Script</sys_name>
<sys_package display_value="CodeSanity WORK IN PROGRESS" source="x_snc_codesanity">8ed42c23dbad0510bcced03cd39619ce</sys_package>
<sys_policy/>
<sys_scope display_value="CodeSanity WORK IN PROGRESS">8ed42c23dbad0510bcced03cd39619ce</sys_scope>
<sys_update_name>sys_atf_step_218ade641babd1105b76777d8b4bcb0c</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2022-11-30 16:07:52</sys_updated_on>
<sys_updated_on>2023-02-02 13:16:47</sys_updated_on>
<table/>
<test display_value="CodeSanity - UI Script description">4a7a5e641babd1105b76777d8b4bcb56</test>
<timeout/>
Expand Down Expand Up @@ -50,9 +50,9 @@
<sys_created_by>admin</sys_created_by>
<sys_created_on>2022-11-30 16:06:07</sys_created_on>
<sys_id>e28ade641babd1105b76777d8b4bcb55</sys_id>
<sys_mod_count>2</sys_mod_count>
<sys_mod_count>3</sys_mod_count>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2022-11-30 16:07:52</sys_updated_on>
<sys_updated_on>2023-02-02 13:16:47</sys_updated_on>
<value>(function(outputs, steps, stepResult, assertEqual)&#13;
{&#13;
var test = new x_snc_devtools.TestAPI(outputs, steps, stepResult, assertEqual);&#13;
Expand All @@ -61,8 +61,6 @@
&#13;
var strCheck = '6c2ad6641babd1105b76777d8b4bcb51';&#13;
&#13;
var testdata = new x_snc_devtools.TestDataAPI('_ATF_CODESANITY_');&#13;
&#13;
// no description is a fail&#13;
var grRecord = new GlideRecord('sys_ui_script');&#13;
grRecord.initialize();&#13;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?><record_update table="sys_atf_step">
<sys_atf_step action="INSERT_OR_UPDATE">
<active>true</active>
<copied_from/>
<description>Run Server Side Validation Script</description>
<display_name>Run Server Side Script</display_name>
<inputs/>
<mugshots_cache_json/>
<notes/>
<order>1</order>
<snapshot/>
<step_config display_value="Run Server Side Script">41de4a935332120028bc29cac2dc349a</step_config>
<sys_class_name>sys_atf_step</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2023-02-02 13:15:49</sys_created_on>
<sys_id>aa495349dbf425106a03dad1f396198a</sys_id>
<sys_mod_count>1</sys_mod_count>
<sys_name>Run Server Side Script</sys_name>
<sys_package display_value="CodeSanity WORK IN PROGRESS" source="x_snc_codesanity">8ed42c23dbad0510bcced03cd39619ce</sys_package>
<sys_policy/>
<sys_scope display_value="CodeSanity WORK IN PROGRESS">8ed42c23dbad0510bcced03cd39619ce</sys_scope>
<sys_update_name>sys_atf_step_aa495349dbf425106a03dad1f396198a</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2023-02-02 13:19:26</sys_updated_on>
<table/>
<test display_value="CodeSanity - Client-side logging">7e195f09dbf425106a03dad1f3961947</test>
<timeout/>
<warning_message/>
</sys_atf_step>
<sys_variable_value action="delete_multiple" query="document_key=aa495349dbf425106a03dad1f396198a"/>
<sys_variable_value action="INSERT_OR_UPDATE">
<document>sys_atf_step</document>
<document_key>aa495349dbf425106a03dad1f396198a</document_key>
<order>100</order>
<sys_class_name>sys_variable_value</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2023-02-02 13:15:50</sys_created_on>
<sys_id>7f491349dbf425106a03dad1f396196f</sys_id>
<sys_mod_count>0</sys_mod_count>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2023-02-02 13:15:50</sys_updated_on>
<value>3.1</value>
<variable display_value="Jasmine version">42f2564b73031300440211d8faf6a777</variable>
</sys_variable_value>
<sys_variable_value action="INSERT_OR_UPDATE">
<document>sys_atf_step</document>
<document_key>aa495349dbf425106a03dad1f396198a</document_key>
<order>200</order>
<sys_class_name>sys_variable_value</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2023-02-02 13:15:50</sys_created_on>
<sys_id>bb495349dbf425106a03dad1f39619cc</sys_id>
<sys_mod_count>1</sys_mod_count>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2023-02-02 13:19:26</sys_updated_on>
<value>(function(outputs, steps, stepResult, assertEqual)&#13;
{&#13;
var test = new x_snc_devtools.TestAPI(outputs, steps, stepResult, assertEqual);&#13;
&#13;
test.SetResult(true);&#13;
&#13;
var strCheck = '89c69b85dbf425106a03dad1f3961980';&#13;
&#13;
// No client side logging&#13;
var grRecord = new GlideRecord('sys_ui_script');&#13;
grRecord.initialize();&#13;
grRecord.name = 'Test1';&#13;
grRecord.script = 'function Test1() {}';&#13;
var strRecordSysId = x_snc_devtools.GlideRecordInsert(grRecord);&#13;
test.TestCase_InstanceScanCheck(strCheck,'sys_ui_script',strRecordSysId,false);&#13;
&#13;
// jslog&#13;
var grRecord = new GlideRecord('sys_ui_script');&#13;
grRecord.initialize();&#13;
grRecord.name = 'Test10';&#13;
grRecord.script = 'function Test10() { jslog("Hello!"); }';&#13;
var strRecordSysId = x_snc_devtools.GlideRecordInsert(grRecord);&#13;
test.TestCase_InstanceScanCheck(strCheck,'sys_ui_script',strRecordSysId,true);&#13;
&#13;
// console.log&#13;
var grRecord = new GlideRecord('sys_ui_script');&#13;
grRecord.initialize();&#13;
grRecord.name = 'Test11';&#13;
grRecord.script = 'function Test11() { console.log("Hello!"); }';&#13;
var strRecordSysId = x_snc_devtools.GlideRecordInsert(grRecord);&#13;
test.TestCase_InstanceScanCheck(strCheck,'sys_ui_script',strRecordSysId,true);&#13;
&#13;
// console.warn&#13;
var grRecord = new GlideRecord('sys_ui_script');&#13;
grRecord.initialize();&#13;
grRecord.name = 'Test12';&#13;
grRecord.script = 'function Test12() { console.warn("Hello!"); }';&#13;
var strRecordSysId = x_snc_devtools.GlideRecordInsert(grRecord);&#13;
test.TestCase_InstanceScanCheck(strCheck,'sys_ui_script',strRecordSysId,true);&#13;
&#13;
// console.error&#13;
var grRecord = new GlideRecord('sys_ui_script');&#13;
grRecord.initialize();&#13;
grRecord.name = 'Test13';&#13;
grRecord.script = 'function Test13() { console.error("Hello!"); }';&#13;
var strRecordSysId = x_snc_devtools.GlideRecordInsert(grRecord);&#13;
test.TestCase_InstanceScanCheck(strCheck,'sys_ui_script',strRecordSysId,true);&#13;
&#13;
&#13;
&#13;
return test.GetResult();&#13;
&#13;
})(outputs, steps, stepResult, assertEqual);</value>
<variable display_value="Test script">989d9e235324220002c6435723dc3484</variable>
</sys_variable_value>
</record_update>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?><record_update table="sys_atf_test">
<sys_atf_test action="INSERT_OR_UPDATE">
<active>true</active>
<copied_from/>
<description/>
<enable_parameterized_testing>false</enable_parameterized_testing>
<name>CodeSanity - Client-side logging</name>
<parameters/>
<remember/>
<sys_class_name>sys_atf_test</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2023-02-02 13:14:56</sys_created_on>
<sys_id>7e195f09dbf425106a03dad1f3961947</sys_id>
<sys_mod_count>1</sys_mod_count>
<sys_name>CodeSanity - Client-side logging</sys_name>
<sys_package display_value="CodeSanity WORK IN PROGRESS" source="x_snc_codesanity">8ed42c23dbad0510bcced03cd39619ce</sys_package>
<sys_policy/>
<sys_scope display_value="CodeSanity WORK IN PROGRESS">8ed42c23dbad0510bcced03cd39619ce</sys_scope>
<sys_update_name>sys_atf_test_7e195f09dbf425106a03dad1f3961947</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2023-02-02 13:15:37</sys_updated_on>
</sys_atf_test>
<sys_variable_value action="delete_multiple" query="document_key=7e195f09dbf425106a03dad1f3961947"/>
</record_update>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?><record_update table="sys_atf_test_suite_test">
<sys_atf_test_suite_test action="INSERT_OR_UPDATE">
<abort_on_failure>false</abort_on_failure>
<order>100</order>
<sys_class_name>sys_atf_test_suite_test</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2023-02-02 13:14:57</sys_created_on>
<sys_id>3e195f09dbf425106a03dad1f396194b</sys_id>
<sys_mod_count>1</sys_mod_count>
<sys_name>7e195f09dbf425106a03dad1f3961947</sys_name>
<sys_package display_value="CodeSanity WORK IN PROGRESS" source="x_snc_codesanity">8ed42c23dbad0510bcced03cd39619ce</sys_package>
<sys_policy/>
<sys_scope display_value="CodeSanity WORK IN PROGRESS">8ed42c23dbad0510bcced03cd39619ce</sys_scope>
<sys_update_name>sys_atf_test_suite_test_3e195f09dbf425106a03dad1f396194b</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2023-02-02 13:16:05</sys_updated_on>
<test display_value="CodeSanity - Client-side logging">7e195f09dbf425106a03dad1f3961947</test>
<test_suite display_value="CodeSanity">2c6758d3db4a8510bcced03cd396191d</test_suite>
</sys_atf_test_suite_test>
</record_update>
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
&lt;ol&gt;&#13;
&lt;li&gt;DevTools 1.55.0 is now required.&lt;/li&gt;&#13;
&lt;li&gt;Added check "CodeSanity - AppInstall".&lt;/li&gt;&#13;
&lt;li&gt;Added check "CodeSanity - Client-side logging".&lt;/li&gt;&#13;
&lt;li&gt;The check "CodeSanity - Avoid "Copy of"" no longer scans sys_complex_object records.&lt;/li&gt;&#13;
&lt;/ol&gt; &#13;
&#13;
Expand Down Expand Up @@ -376,13 +377,13 @@
<sys_created_by>admin</sys_created_by>
<sys_created_on>2022-03-10 09:51:04</sys_created_on>
<sys_id>ec6718d3db4a8510bcced03cd39619ff</sys_id>
<sys_mod_count>226</sys_mod_count>
<sys_mod_count>227</sys_mod_count>
<sys_name>manual</sys_name>
<sys_package display_value="CodeSanity WORK IN PROGRESS" source="x_snc_codesanity">8ed42c23dbad0510bcced03cd39619ce</sys_package>
<sys_policy/>
<sys_scope display_value="CodeSanity WORK IN PROGRESS">8ed42c23dbad0510bcced03cd39619ce</sys_scope>
<sys_update_name>sys_ui_page_ec6718d3db4a8510bcced03cd39619ff</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2023-02-01 20:22:43</sys_updated_on>
<sys_updated_on>2023-02-02 13:20:35</sys_updated_on>
</sys_ui_page>
</record_update>

0 comments on commit 29e1c9b

Please sign in to comment.