Skip to content

Commit d55b2b4

Browse files
New Instance Scan Check: Identify String Fields with Excessive Max Length (#143)
1 parent 885bb21 commit d55b2b4

File tree

4 files changed

+69
-1
lines changed

4 files changed

+69
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ The Choice table should not be used as the reference table for a Reference type
168168

169169
## Category: Performance
170170

171+
### Identifies string fields with max_length exceeding recommended limits
172+
This scan checks for string fields where the max_length value is set above a recommended limit. Setting a very high max_length can result in unnecessary database storage consumption and may degrade query performance. It is important to use reasonable max_length values based on actual data requirements.
173+
171174
### getMessage() called in Client Script
172175
This is a simple table check to find client scripts with use the getMessage function but do not preload messages using the Messages field. As the check does a simple contains query it could produce false-positives if the getMessage is either commented or from another library.
173176

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated files
2+
This repository contains generated files and a checksum.
3+
4+
If you find yourself unable to import your repository due to the presence of files edited outside an instance of ServiceNow, merge commits that mix files from different revisions, or other data that does not match the checksum, you may recover using either of the following techniques:
5+
* Remove the problem commits:
6+
1. Clone your repository to a personal computer with the git command line tools installed and open a git command prompt in the repository root
7+
2. Run `git log` and take note of the SHA1s of the problem commits
8+
3. Build revert commits using `git revert SHA1` repeatedly, working backward in time, for each commit that introduced changes not generated by a ServiceNow instance
9+
4. Run `git push`
10+
11+
* Overwrite the problem code snapshot with a known good one:
12+
1. Clone your repository to a personal computer with the git command line tools installed and open a git command prompt in the repository root,
13+
2. Locate a known good code snapshot and record its SHA1. For this step, `git log` can be useful.
14+
2. Run `git reset --hard SHA1` to a commit that was generated by a ServiceNow instance
15+
3. Run `git reset HEAD{1}`
16+
4. Run `git add -A`
17+
5. Run `git commit`
18+
6. Run `git push`
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
WWQm_IdWsTxg4URwBle2eXw7sIYuz7QcfROoa5TolyTIo-4kY4yJv9m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9fpgURFU9Ec2BEGbbMfpm7KehrFl0bNOVDTDEWIETdt80lvfR1i0-8Yk1vHWvLdB94dHoPw1a77oWht1HxEMkNzE1m38ANVQVZq2-pbVdIiAYCLeRBdd5i_LrNLpF7iCHBpAawuxX5BQIVKBW3WNTPhWUdV9_a1_394CDBmYswn8XiQSx0Vi0hfjuuMp9J9sQxOVVq2MFyWZiDvhIX2CJutq8xn27shQc7Y5xeZN5SVosFrv3irWYkzJuKoU
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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>performance</category>
6+
<conditions table="sys_dictionary">internal_type=string^ORinternal_type=string_full_utf8^max_length&gt;4000^nameNOT LIKEsys_hub^EQ<item display_table="sys_glide_object" display_value="String" endquery="false" field="internal_type" goto="false" newquery="false" operator="=" or="false" value="string"/>
7+
<item endquery="false" field="internal_type" goto="false" newquery="false" operator="=" or="true" value="string_full_utf8"/>
8+
<item endquery="false" field="max_length" goto="false" newquery="false" operator="&gt;" or="false" value="4000"/>
9+
<item endquery="false" field="name" goto="false" newquery="false" operator="NOT LIKE" or="false" value="sys_hub"/>
10+
<item endquery="true" field="" goto="false" newquery="false" operator="=" or="false" value=""/>
11+
</conditions>
12+
<description>This scan checks for string fields where the max_length value is set above a recommended limit. Setting a very high max_length can result in unnecessary database storage consumption and may degrade query performance. It is important to use reasonable max_length values based on actual data requirements.</description>
13+
<documentation_url>https://support.servicenow.com/kb?id=kb_article_view&amp;sysparm_article=KB0685779</documentation_url>
14+
<finding_type>scan_finding</finding_type>
15+
<name>String Fields with Excessive Max Length</name>
16+
<priority>3</priority>
17+
<resolution_details>Review the identified string fields and adjust the max_length to a value that matches the actual data requirements.&#13;
18+
&#13;
19+
Use lower values for fields that only need to store short text. For fields that may contain longer content, consider using appropriate max_length values, such as 255 for typical text fields. &#13;
20+
&#13;
21+
Avoid setting max_length values unnecessarily high to reduce the impact on storage and performance.</resolution_details>
22+
<run_condition/>
23+
<score_max>100</score_max>
24+
<score_min>0</score_min>
25+
<score_scale>1</score_scale>
26+
<script><![CDATA[(function(finding) {
27+
28+
})(finding);
29+
]]></script>
30+
<short_description>Identifies string fields with max_length exceeding recommended limits</short_description>
31+
<sys_class_name>scan_table_check</sys_class_name>
32+
<sys_created_by>admin</sys_created_by>
33+
<sys_created_on>2024-10-15 21:43:15</sys_created_on>
34+
<sys_id>8b90df49839112107b681390ceaad3be</sys_id>
35+
<sys_mod_count>6</sys_mod_count>
36+
<sys_name>String Fields with Excessive Max Length</sys_name>
37+
<sys_package display_value="Example Instance Checks" source="x_appe_exa_checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_package>
38+
<sys_policy/>
39+
<sys_scope display_value="Example Instance Checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_scope>
40+
<sys_update_name>scan_table_check_8b90df49839112107b681390ceaad3be</sys_update_name>
41+
<sys_updated_by>admin</sys_updated_by>
42+
<sys_updated_on>2024-10-15 22:11:06</sys_updated_on>
43+
<table>sys_dictionary</table>
44+
<use_manifest>false</use_manifest>
45+
</scan_table_check>
46+
<sys_translated_text action="delete_multiple" query="documentkey=8b90df49839112107b681390ceaad3be"/>
47+
</record_update>

0 commit comments

Comments
 (0)