Skip to content

Commit ae8b485

Browse files
authored
Merge pull request #12 from markroethof/master
Contributing!
2 parents a4dc3ae + 08cd804 commit ae8b485

11 files changed

+500
-6
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ZOjLMA-C4RrIKNJc7i4svPHUEqPMY7c9JS9VarReiQPQ2sx2BGoBbm-1XwYKmazygymq8qa85ay0E9F21phcknYTmQ5Wla0JME5c2xmPQWV-x25CfLnK2a87yPJgQOQ7HTn2FiJm5bvBHXiX9fD_8MAwZF3EVUh1Vr6sJA_sKt_OCvResvBeRt1s9-eCyQOvcInU1hsSEm50eJNjRMTAVeWcMHNGPn1hNkcBouo0ZPJuSmgj8o67r6xIQXAX6o8smC17Tzo9UMoRr8p6MkfZuLs0-kikYzM9yE1gJuZqRSENu1oIYVxJsAfCaYllYyaf3B0NtRztaSaM8GuHrIiCMNky3KnxXs1otdzQOHzLVE15RHaLnnJxe3lRg20BuSitwNVbf4KZ4z0-1z5ncY2Oca9A3QLg7NNnW8zZWsAyl0THgnpTBVMqBMFelclDXoC9VUlPKFdMFiZ4T135v90kKcSEdLEn-wuIkzjXTTRnSB5AKasER_0ZB8QAA9ezvAzWBRgotzabgDT49UWcdj6D6nTaB8XbMCS2Ccj9YBGXS1W_gGVB8dFQL-NcHpRkG3TWdHSSNiKKSlM_S5N7aiw42W6wa8F_tHOsd28_hvYo1tdy2laSfCQ6kCHNzvrdQ_gnF6YzfcqLmVXTnD-yZhDPfIaek78TOoCqm5E82qgEmsc
1+
0x5JTGsuVftI6THFgd6j9kal0k6pwsnj87lodT9JdStqAayDcXdIdBk8dUx8rlf8_56U6lhRuZjOjMzr-8Bxhx9agM0G74E146s0Xejsu0kRSCW-gRwWm81jRtlvIeSfUAOc7KKbN8Yze_spJZd3xQ7KeA_eJT7XC35nPp2l3BtTSxbOJWAA3z__5StnoxHXag6QPhjIe9qvb872kl2ZksWp7PA0PUZ6S_VgFCRnzJVUy8EcuvDJLGzIZMtLhCQfftaWobqh96jpDGemEQtqxuefYrpgt8egIACDL3dgWSzd-MGaqx3ptqP9uyyAN_OWDu6sNpAJbjgxkvEx0vMMDIX6b9421p-LpoJDITTlI3yEsmXvAu7bOPvhbprXqOYC0w7BQ230UYBANBqgY15k6pttWnH6PyQU-mifsXPLg6OglVplGf884Y1Ak93-BANTOPNI1HwuQQIB_SWPyvL-_NLzMd7bNb9i-UtrjH4x4nZ1-DPVO6-iXSVm0IHdzHPxuM70OjDBZJN_v2tKekmwEGTgoD9bDIVnoODydrwjAsqZ1LxSNCKqkWN2VII0IEsSVrLAwzBl0SKWcQ4xo8pT2sssdxXOCd_eiXLVlYkSudrcK6DcmxugaXUajKumJkNt3rapqLTNsxXZ9jUHoRaVnUO5iGWi3ofqtw-ALdKOgS4

ca8467c41b9abc10ce0f62c3b24bcbaa/update/scan_linter_check_0b7623d41b1afc10ce0f62c3b24bcb24.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Care should be taken when setting system properties (sys_properties) using this
2929
return;
3030
}
3131
32-
if (childnode.getNameIdentifier() === "setProperty" || node.getNameIdentifier() === "cacheFlush") {
32+
if (childnode.getNameIdentifier() === "setProperty" || childnode.getNameIdentifier() === "cacheFlush") {
3333
method_found = true;
3434
return;
3535
}
@@ -45,21 +45,21 @@ Care should be taken when setting system properties (sys_properties) using this
4545
engine.finding.incrementWithNode(node);
4646
}
4747
}
48-
4948
});
49+
5050
})(engine);]]></script>
5151
<short_description>Cache flushed as part of scripts</short_description>
5252
<sys_class_name>scan_linter_check</sys_class_name>
5353
<sys_created_by>daniel.draes</sys_created_by>
5454
<sys_created_on>2021-08-27 07:18:40</sys_created_on>
5555
<sys_id>0b7623d41b1afc10ce0f62c3b24bcb24</sys_id>
56-
<sys_mod_count>8</sys_mod_count>
56+
<sys_mod_count>11</sys_mod_count>
5757
<sys_name>Cache flushed as part of scripts</sys_name>
5858
<sys_package display_value="Example Instance Checks" source="x_appe_exa_checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_package>
5959
<sys_policy/>
6060
<sys_scope display_value="Example Instance Checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_scope>
6161
<sys_update_name>scan_linter_check_0b7623d41b1afc10ce0f62c3b24bcb24</sys_update_name>
62-
<sys_updated_by>daniel.draes</sys_updated_by>
63-
<sys_updated_on>2021-08-27 08:12:47</sys_updated_on>
62+
<sys_updated_by>mark.roethof</sys_updated_by>
63+
<sys_updated_on>2021-10-03 16:55:38</sys_updated_on>
6464
</scan_linter_check>
6565
</record_update>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="UTF-8"?><record_update table="scan_linter_check">
2+
<scan_linter_check action="INSERT_OR_UPDATE">
3+
<active>true</active>
4+
<category>performance</category>
5+
<description>getXMLAnswer only retrieves the Answer which we are actually after. getXML retrieves the whole XML document. In most cases, we are not interested in the whole XML document, though only in the Answer.&#13;
6+
For the rare cases where you are interested in the whole XML document, simply mute the generated scan finding.</description>
7+
<documentation_url>https://community.servicenow.com/community?id=community_article&amp;sys_id=1c10a1fedbbd4890feb1a851ca961909</documentation_url>
8+
<finding_type>scan_finding</finding_type>
9+
<name>Consider using getXMLAnswer instead of getXML</name>
10+
<priority>3</priority>
11+
<resolution_details>Replace the usage of getXML by getXMLAnswer.</resolution_details>
12+
<run_condition/>
13+
<score_max>100</score_max>
14+
<score_min>0</score_min>
15+
<score_scale>1</score_scale>
16+
<script><![CDATA[(function (engine) {
17+
18+
// Perform Linter Check
19+
engine.rootNode.visit(function(node) {
20+
if(node.getTypeName() === "NAME" &&
21+
node.getNameIdentifier() === "getXML" &&
22+
node.getParent().getTypeName() === "GETPROP") {
23+
// Create scan finding
24+
engine.finding.incrementWithNode(node);
25+
}
26+
});
27+
28+
})(engine);]]></script>
29+
<short_description>Consider using getXMLAnswer instead of getXML</short_description>
30+
<sys_class_name>scan_linter_check</sys_class_name>
31+
<sys_created_by>mark.roethof</sys_created_by>
32+
<sys_created_on>2021-10-02 17:26:47</sys_created_on>
33+
<sys_id>0eeac3042f0730103307235df699b6d1</sys_id>
34+
<sys_mod_count>0</sys_mod_count>
35+
<sys_name>Consider using getXMLAnswer instead of getXML</sys_name>
36+
<sys_package display_value="Example Instance Checks" source="x_appe_exa_checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_package>
37+
<sys_policy/>
38+
<sys_scope display_value="Example Instance Checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_scope>
39+
<sys_update_name>scan_linter_check_0eeac3042f0730103307235df699b6d1</sys_update_name>
40+
<sys_updated_by>mark.roethof</sys_updated_by>
41+
<sys_updated_on>2021-10-02 17:26:47</sys_updated_on>
42+
</scan_linter_check>
43+
</record_update>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?><record_update table="scan_linter_check">
2+
<scan_linter_check action="INSERT_OR_UPDATE">
3+
<active>true</active>
4+
<category>manageability</category>
5+
<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>
6+
<documentation_url>https://www.java67.com/2014/08/difference-between-string-literal-and-new-String-object-Java.html</documentation_url>
7+
<finding_type>scan_finding</finding_type>
8+
<name>Don't use new Array()</name>
9+
<priority>4</priority>
10+
<resolution_details>Use [] instead of new Array().</resolution_details>
11+
<run_condition/>
12+
<score_max>100</score_max>
13+
<score_min>0</score_min>
14+
<score_scale>1</score_scale>
15+
<script><![CDATA[(function (engine) {
16+
17+
// Perform Linter Check
18+
engine.rootNode.visit(function(node) {
19+
if(node.getTypeName() === "NAME" &&
20+
node.getNameIdentifier() === "Array" &&
21+
node.getParent().getTypeName() === "NEW") {
22+
// Create scan finding
23+
engine.finding.incrementWithNode(node);
24+
}
25+
});
26+
27+
})(engine);]]></script>
28+
<short_description>Don't use new Array()</short_description>
29+
<sys_class_name>scan_linter_check</sys_class_name>
30+
<sys_created_by>mark.roethof</sys_created_by>
31+
<sys_created_on>2021-10-02 17:23:33</sys_created_on>
32+
<sys_id>2e2a8fc02f0730103307235df699b659</sys_id>
33+
<sys_mod_count>0</sys_mod_count>
34+
<sys_name>Don't use new Array()</sys_name>
35+
<sys_package display_value="Example Instance Checks" source="x_appe_exa_checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_package>
36+
<sys_policy/>
37+
<sys_scope display_value="Example Instance Checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_scope>
38+
<sys_update_name>scan_linter_check_2e2a8fc02f0730103307235df699b659</sys_update_name>
39+
<sys_updated_by>mark.roethof</sys_updated_by>
40+
<sys_updated_on>2021-10-02 17:23:33</sys_updated_on>
41+
</scan_linter_check>
42+
</record_update>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?><record_update table="scan_linter_check">
2+
<scan_linter_check action="INSERT_OR_UPDATE">
3+
<active>true</active>
4+
<category>manageability</category>
5+
<description>In general, you should use the object 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>
6+
<documentation_url>https://www.java67.com/2014/08/difference-between-string-literal-and-new-String-object-Java.html</documentation_url>
7+
<finding_type>scan_finding</finding_type>
8+
<name>Don't use new Object()</name>
9+
<priority>4</priority>
10+
<resolution_details>Use {} instead of new Object().</resolution_details>
11+
<run_condition/>
12+
<score_max>100</score_max>
13+
<score_min>0</score_min>
14+
<score_scale>1</score_scale>
15+
<script><![CDATA[(function (engine) {
16+
17+
// Perform Linter Check
18+
engine.rootNode.visit(function(node) {
19+
if(node.getTypeName() === "NAME" &&
20+
node.getNameIdentifier() === "Object" &&
21+
node.getParent().getTypeName() === "NEW") {
22+
// Create scan finding
23+
engine.finding.incrementWithNode(node);
24+
}
25+
});
26+
27+
})(engine);]]></script>
28+
<short_description>Don't use new Object()</short_description>
29+
<sys_class_name>scan_linter_check</sys_class_name>
30+
<sys_created_by>mark.roethof</sys_created_by>
31+
<sys_created_on>2021-10-02 17:22:22</sys_created_on>
32+
<sys_id>51e943c02f0730103307235df699b64b</sys_id>
33+
<sys_mod_count>0</sys_mod_count>
34+
<sys_name>Don't use new Object()</sys_name>
35+
<sys_package display_value="Example Instance Checks" source="x_appe_exa_checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_package>
36+
<sys_policy/>
37+
<sys_scope display_value="Example Instance Checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_scope>
38+
<sys_update_name>scan_linter_check_51e943c02f0730103307235df699b64b</sys_update_name>
39+
<sys_updated_by>mark.roethof</sys_updated_by>
40+
<sys_updated_on>2021-10-02 17:22:22</sys_updated_on>
41+
</scan_linter_check>
42+
</record_update>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?xml version="1.0" encoding="UTF-8"?><record_update table="scan_linter_check">
2+
<scan_linter_check action="INSERT_OR_UPDATE">
3+
<active>true</active>
4+
<category>manageability</category>
5+
<description>The "gs.log()", "gs.debug()", "console.log()", etc. statements can be used to write information to the system log, while the "gs.print()", etc. statements also sends it as output to the screen. It is generally used when debugging. Using "gs.log()", "gs.debug()", "console.log()", etc. statements on a production instance will pollute the system log, while it is never used as you do not perform debugging on a production instance.</description>
6+
<documentation_url/>
7+
<finding_type>scan_finding</finding_type>
8+
<name>Scripts should not contain debugging statements in production</name>
9+
<priority>3</priority>
10+
<resolution_details>The best practice is to remove (commented) debug statements from scripts or making them conditionally controlled by a property.</resolution_details>
11+
<run_condition/>
12+
<score_max>100</score_max>
13+
<score_min>0</score_min>
14+
<score_scale>1</score_scale>
15+
<script><![CDATA[(function(engine) {
16+
17+
engine.rootNode.visit(function(node) {
18+
// gs.log, gs.info, gs.debug, gs.print
19+
if(node.getTypeName() === "GETPROP") {
20+
var gs_found = false;
21+
var method_found = false;
22+
23+
node.visit(function(childnode) {
24+
if(childnode.getTypeName() != "NAME") {
25+
return;
26+
}
27+
28+
if(childnode.getNameIdentifier() === "log" || childnode.getNameIdentifier() === "info" || childnode.getNameIdentifier() === "debug" || childnode.getNameIdentifier() === "print") {
29+
method_found = true;
30+
return;
31+
}
32+
33+
if(childnode.getNameIdentifier() === "gs") {
34+
gs_found = true;
35+
return;
36+
}
37+
});
38+
39+
// Create scan finding
40+
if(gs_found && method_found) {
41+
engine.finding.incrementWithNode(node);
42+
}
43+
}
44+
45+
// console.log
46+
if(node.getTypeName() === "GETPROP") {
47+
var console_found = false;
48+
var log_found = false;
49+
50+
node.visit(function(childnode) {
51+
if(childnode.getTypeName() != "NAME") {
52+
return;
53+
}
54+
55+
if(childnode.getNameIdentifier() === "log") {
56+
log_found = true;
57+
return;
58+
}
59+
60+
if(childnode.getNameIdentifier() === "console") {
61+
console_found = true;
62+
return;
63+
}
64+
});
65+
66+
// Create scan finding
67+
if(console_found && log_found) {
68+
engine.finding.incrementWithNode(node);
69+
}
70+
}
71+
72+
// jslog
73+
if(node.getNameIdentifier() && node.getTypeName() === 'NAME' && node.getNameIdentifier() === 'jslog' && node.getParent().getTypeName() === 'CALL') {
74+
// Create scan finding
75+
engine.finding.incrementWithNode(node);
76+
}
77+
78+
});
79+
80+
})(engine);]]></script>
81+
<short_description>Scripts should not contain debugging statements in production</short_description>
82+
<sys_class_name>scan_linter_check</sys_class_name>
83+
<sys_created_by>mark.roethof</sys_created_by>
84+
<sys_created_on>2021-10-02 17:24:32</sys_created_on>
85+
<sys_id>b46a4fc02f0730103307235df699b6e0</sys_id>
86+
<sys_mod_count>0</sys_mod_count>
87+
<sys_name>Scripts should not contain debugging statements in production</sys_name>
88+
<sys_package display_value="Example Instance Checks" source="x_appe_exa_checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_package>
89+
<sys_policy/>
90+
<sys_scope display_value="Example Instance Checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_scope>
91+
<sys_update_name>scan_linter_check_b46a4fc02f0730103307235df699b6e0</sys_update_name>
92+
<sys_updated_by>mark.roethof</sys_updated_by>
93+
<sys_updated_on>2021-10-02 17:24:32</sys_updated_on>
94+
</scan_linter_check>
95+
</record_update>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="UTF-8"?><record_update table="scan_script_only_check">
2+
<scan_script_only_check action="INSERT_OR_UPDATE">
3+
<active>true</active>
4+
<category>manageability</category>
5+
<description>In general, for a single record only a few Workflow context will be running. If a high number of Workflow context are active, this often indicates an issue on the starting conditions of your Workflow. More then 10 active Workflow context is considered being a high number. </description>
6+
<documentation_url/>
7+
<finding_type>scan_finding</finding_type>
8+
<name>High number of workflows running for a single record</name>
9+
<priority>2</priority>
10+
<resolution_details>Resolve the high number of triggered Workflow context and investigate the starting conditions of your Workflow and correct where necessary.</resolution_details>
11+
<run_condition/>
12+
<score_max>100</score_max>
13+
<score_min>0</score_min>
14+
<score_scale>1</score_scale>
15+
<script><![CDATA[(function (finding) {
16+
17+
// Count record
18+
var countRecord = new GlideAggregate('wf_context');
19+
countRecord.addEncodedQuery('state=executing');
20+
countRecord.groupBy('id');
21+
countRecord.addAggregate('COUNT');
22+
countRecord._query();
23+
24+
while(countRecord._next()) {
25+
if(countRecord.getAggregate('COUNT') > 10) {
26+
// Get record
27+
var getRecord = new GlideRecord('wf_context');
28+
getRecord.addQuery('id', countRecord.id);
29+
getRecord.setLimit(1);
30+
getRecord._query();
31+
32+
if(getRecord._next()) {
33+
// Create scan finding
34+
var createFinding = new GlideRecord(getRecord.getValue('table'));
35+
36+
if(createFinding.get(getRecord.getValue('id'))) {
37+
finding.setCurrentSource(createFinding);
38+
finding.increment();
39+
}
40+
}
41+
}
42+
}
43+
44+
})(finding);]]></script>
45+
<short_description>High number of workflows running for a single record</short_description>
46+
<sys_class_name>scan_script_only_check</sys_class_name>
47+
<sys_created_by>mark.roethof</sys_created_by>
48+
<sys_created_on>2021-10-04 14:52:29</sys_created_on>
49+
<sys_id>7f8a38342f0330103307235df699b6b3</sys_id>
50+
<sys_mod_count>0</sys_mod_count>
51+
<sys_name>High number of workflows running for a single record</sys_name>
52+
<sys_package display_value="Example Instance Checks" source="x_appe_exa_checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_package>
53+
<sys_policy/>
54+
<sys_scope display_value="Example Instance Checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_scope>
55+
<sys_update_name>scan_script_only_check_7f8a38342f0330103307235df699b6b3</sys_update_name>
56+
<sys_updated_by>mark.roethof</sys_updated_by>
57+
<sys_updated_on>2021-10-04 14:52:29</sys_updated_on>
58+
</scan_script_only_check>
59+
</record_update>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8"?><record_update table="scan_table_check">
2+
<scan_table_check action="INSERT_OR_UPDATE">
3+
<active>true</active>
4+
<advanced>false</advanced>
5+
<category>manageability</category>
6+
<conditions table="ecc_queue">state=ready^sys_created_onRELATIVELT@minute@ago@5^EQ<item display_value="ready" endquery="false" field="state" goto="false" newquery="false" operator="=" or="false" value="ready"/>
7+
<item endquery="false" field="sys_created_on" goto="false" newquery="false" operator="RELATIVE" or="false" value="LT@minute@ago@5"/>
8+
<item endquery="true" field="" goto="false" newquery="false" operator="=" or="false" value=""/>
9+
</conditions>
10+
<description>External Communication Channel (ECC) Queue is a connection point between an instance and the MID Server. Jobs that the MID Server needs to perform are saved in this queue until the MID Server is ready to handle them. The default polling interval is set to 40 seconds. When there are unprocessed queue records, this can indicate a large volume of queue records, a processing issue in general, or a MID Server issue.</description>
11+
<documentation_url/>
12+
<finding_type>scan_finding</finding_type>
13+
<name>Unprocessed queues</name>
14+
<priority>1</priority>
15+
<resolution_details>Investigate the unprocessed queue records.</resolution_details>
16+
<run_condition/>
17+
<score_max>100</score_max>
18+
<score_min>0</score_min>
19+
<score_scale>1</score_scale>
20+
<script><![CDATA[(function (engine) {
21+
22+
// Add your code here
23+
24+
})(engine);]]></script>
25+
<short_description>Unprocessed queues</short_description>
26+
<sys_class_name>scan_table_check</sys_class_name>
27+
<sys_created_by>mark.roethof</sys_created_by>
28+
<sys_created_on>2021-10-04 14:43:47</sys_created_on>
29+
<sys_id>33687cb02f0330103307235df699b685</sys_id>
30+
<sys_mod_count>0</sys_mod_count>
31+
<sys_name>Unprocessed queues</sys_name>
32+
<sys_package display_value="Example Instance Checks" source="x_appe_exa_checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_package>
33+
<sys_policy/>
34+
<sys_scope display_value="Example Instance Checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_scope>
35+
<sys_update_name>scan_table_check_33687cb02f0330103307235df699b685</sys_update_name>
36+
<sys_updated_by>mark.roethof</sys_updated_by>
37+
<sys_updated_on>2021-10-04 14:43:47</sys_updated_on>
38+
<table>ecc_queue</table>
39+
<use_manifest>false</use_manifest>
40+
</scan_table_check>
41+
</record_update>

0 commit comments

Comments
 (0)