forked from saschawildgrube/servicenow-codesanity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added check "CodeSanity - Client-side logging".
- Loading branch information
admin
committed
Feb 2, 2023
1 parent
85901f0
commit 29e1c9b
Showing
8 changed files
with
275 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
19 changes: 19 additions & 0 deletions
19
...ad0510bcced03cd39619ce/update/scan_check_suite_check_f8d7d7c5dbf425106a03dad1f396193c.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
93 changes: 93 additions & 0 deletions
93
...c23dbad0510bcced03cd39619ce/update/scan_linter_check_89c69b85dbf425106a03dad1f3961980.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
8ed42c23dbad0510bcced03cd39619ce/update/sys_atf_step_aa495349dbf425106a03dad1f396198a.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
{ | ||
var test = new x_snc_devtools.TestAPI(outputs, steps, stepResult, assertEqual); | ||
| ||
test.SetResult(true); | ||
| ||
var strCheck = '89c69b85dbf425106a03dad1f3961980'; | ||
| ||
// No client side logging | ||
var grRecord = new GlideRecord('sys_ui_script'); | ||
grRecord.initialize(); | ||
grRecord.name = 'Test1'; | ||
grRecord.script = 'function Test1() {}'; | ||
var strRecordSysId = x_snc_devtools.GlideRecordInsert(grRecord); | ||
test.TestCase_InstanceScanCheck(strCheck,'sys_ui_script',strRecordSysId,false); | ||
| ||
// jslog | ||
var grRecord = new GlideRecord('sys_ui_script'); | ||
grRecord.initialize(); | ||
grRecord.name = 'Test10'; | ||
grRecord.script = 'function Test10() { jslog("Hello!"); }'; | ||
var strRecordSysId = x_snc_devtools.GlideRecordInsert(grRecord); | ||
test.TestCase_InstanceScanCheck(strCheck,'sys_ui_script',strRecordSysId,true); | ||
| ||
// console.log | ||
var grRecord = new GlideRecord('sys_ui_script'); | ||
grRecord.initialize(); | ||
grRecord.name = 'Test11'; | ||
grRecord.script = 'function Test11() { console.log("Hello!"); }'; | ||
var strRecordSysId = x_snc_devtools.GlideRecordInsert(grRecord); | ||
test.TestCase_InstanceScanCheck(strCheck,'sys_ui_script',strRecordSysId,true); | ||
| ||
// console.warn | ||
var grRecord = new GlideRecord('sys_ui_script'); | ||
grRecord.initialize(); | ||
grRecord.name = 'Test12'; | ||
grRecord.script = 'function Test12() { console.warn("Hello!"); }'; | ||
var strRecordSysId = x_snc_devtools.GlideRecordInsert(grRecord); | ||
test.TestCase_InstanceScanCheck(strCheck,'sys_ui_script',strRecordSysId,true); | ||
| ||
// console.error | ||
var grRecord = new GlideRecord('sys_ui_script'); | ||
grRecord.initialize(); | ||
grRecord.name = 'Test13'; | ||
grRecord.script = 'function Test13() { console.error("Hello!"); }'; | ||
var strRecordSysId = x_snc_devtools.GlideRecordInsert(grRecord); | ||
test.TestCase_InstanceScanCheck(strCheck,'sys_ui_script',strRecordSysId,true); | ||
| ||
| ||
| ||
return test.GetResult(); | ||
| ||
})(outputs, steps, stepResult, assertEqual);</value> | ||
<variable display_value="Test script">989d9e235324220002c6435723dc3484</variable> | ||
</sys_variable_value> | ||
</record_update> |
24 changes: 24 additions & 0 deletions
24
8ed42c23dbad0510bcced03cd39619ce/update/sys_atf_test_7e195f09dbf425106a03dad1f3961947.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
20 changes: 20 additions & 0 deletions
20
...d0510bcced03cd39619ce/update/sys_atf_test_suite_test_3e195f09dbf425106a03dad1f396194b.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters