Skip to content

Commit d8e75f8

Browse files
authored
Merge pull request #28 from hrobarikt/rootScope-listener
add $rootScope listener check
2 parents 54567c5 + 394ab9c commit d8e75f8

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,21 @@ Using getRowCount method of GlideRecord can cause performance issues while queri
104104
### Query business rules should not use query() on GlideRecord
105105
Query business rules that query themselves will continue to loop indefinitely until being caught by the platforms recursion limit. This can build up to an excessive response time and possibly cause the transaction to time out or create performance issues.
106106

107+
### Always deregister $rootScope.$on listeners on the scope $destory event
108+
$rootScope.$on listeners will remain in memory if not properly cleaned up. This will create a memory leak if the controller falls out of scope.
109+
```javascript
110+
api.controller = function ($rootScope, $scope) {
111+
/* widget controller */
112+
var c = this;
113+
114+
var deregister = $rootScope.$on("someevent", function () {});
115+
116+
$scope.$on("$destroy", function destroyScope() {
117+
deregister();
118+
});
119+
};
120+
```
121+
107122
## Category: Security
108123

109124
### Tables without ACLs
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pAcfdvfkVBvdcNK_HZ6Siz27BK483rysXEEssjGG27O7HfaiuDjvSeRhd0EZeVUudSzZU3oflCzpya9lTPGvDX8xgLV8BWFmL28KpbfEO9wDhxF3vjVDzgTvgZvMxTWLDKnni98ffRF_Fq1G8VDsxnVPHbv_zZSqg_uHdNPqSkKQFMJqID-neTU1JafKdsy5ugT-D7ES8hizMmLyhvApTtXYOArMEjy20glEcvh5TjcIA1u5bCRdoykZ2x79e0zcKCE76z3i7OO2ryCkiYpkIApRPOu3Z_tTcYnzQHssAekDqNtqWnsHt_QBTA9Jcpjlg48GXm47o13_1EiTQeO6XV-gl-ahpZdlBsqBIwMDiLKSveC9m2Un5s8kIz0Jq8tdhiJgiqmyP8MR2yPyYT5NkcB8OCDSn-MyIHI0ROLvKZd88WhN-jU4YGmGMdL2D-QQHnir6CXIW-uXOZ00FF6snv89TqARUGM7DJg3VL1t1uVCa8nmJQ53YKNg9C-3hC4fdZ_uB1ynKFcoAKROPTyCD58PnQHfMjDYG3BqEa-apGBAo3XsU0zI1wdS00Ia4kS1TcV4kozt_SZJZVYIPEpJ262IKgnxuOQQjDN4J6DVitEeBuefiClEGRCbIHzdyUiLvoI8Wv2gQ0a00MRkmi3ReOT1MNSYL3ODnvaNL_gdZho
1+
pAcfdvfkVBvdcNK_HZ6Siz27BK483rysXEEssjGG27O7HfaiuDjvSeRhd0EZeVUudSzZU3oflCzpya9lTPGvDX8xgLV8BWFmL28KpbfEO9wDhxF3vjVDzgTvgZvMxTWLDKnni98ffRF_Fq1G8VDsxnVPHbv_zZSqg_uHdNPqSkKQFMJqID-neTU1JafKdsy5ugT-D7ES8hizMmLyhvApTtXYOArMEjy20glEcvh5TjcIA1u5bCRdoykZ2x79e0zcKCE76z3i7OO2ryCkiYpkIApRPOu3Z_tTcYnzQHssAekDqNtqWnsHt_QBTA9Jcpjlg48GXm47o13_1EiTQeO6XV-gl-ahpZdlBsqBIwMDiLKSveC9m2Un5s8kIz0Jq8tdhiJgiqmyP8MR2yPyYT5NkcB8OCDSn-MyIHI0ROLvKZd88WhN-jU4YGmGMdL2D-QQHnir6CXIW-uXOZ00FF6snv89TqARUGM7DJg3VL1t1uVCa8nmJQ53YKNg9C-3hC4fdZ_uB1ynKFcoAKROPTyCD58PnQHfMjDYG3BqEa-apGBAo3XsU0zI1wdS00Ia4kS1TcV4kozt_SZJZVYIPEpJ262IKgnxuOQQjDN4J6DVitEeBuefiClEGRCbIHzdyUiLvoI8Wv2gQ0a00MRkmi3ReOT1MNSYL3ODnvaNL_gdZho
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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="sp_widget">client_scriptLIKE$rootScope.$on^client_scriptNOT LIKE$scope.$on('destroy'^ORclient_scriptNOT LIKE$scope.$on("destroy"^EQ<item endquery="false" field="client_script" goto="false" newquery="false" operator="LIKE" or="false" value="$rootScope.$on"/>
7+
<item endquery="false" field="client_script" goto="false" newquery="false" operator="NOT LIKE" or="false" value="$scope.$on('destroy'"/>
8+
<item endquery="false" field="client_script" goto="false" newquery="false" operator="NOT LIKE" or="true" value="$scope.$on(&quot;destroy&quot;"/>
9+
<item endquery="true" field="" goto="false" newquery="false" operator="=" or="false" value=""/>
10+
</conditions>
11+
<description>$rootScope.$on listeners will remain in memory if not properly cleaned up. This will create a memory leak if the controller falls out of scope.</description>
12+
<documentation_url/>
13+
<finding_type>scan_finding</finding_type>
14+
<name>$rootScope.$on listener</name>
15+
<priority>1</priority>
16+
<resolution_details>api.controller = function ($rootScope, $scope) {&#13;
17+
/* widget controller */&#13;
18+
var c = this;&#13;
19+
&#13;
20+
var deregister = $rootScope.$on("someevent", function () {});&#13;
21+
&#13;
22+
$scope.$on("$destroy", function destroyScope() {&#13;
23+
deregister();&#13;
24+
});&#13;
25+
};</resolution_details>
26+
<run_condition/>
27+
<score_max>100</score_max>
28+
<score_min>0</score_min>
29+
<score_scale>1</score_scale>
30+
<script><![CDATA[(function (finding, current) {
31+
32+
33+
34+
})(finding, current);]]></script>
35+
<short_description>Always deregister $rootScope.$on listeners on the scope $destory event</short_description>
36+
<sys_class_name>scan_table_check</sys_class_name>
37+
<sys_created_by>admin</sys_created_by>
38+
<sys_created_on>2021-10-27 20:20:15</sys_created_on>
39+
<sys_id>f0e1a8581b27705088d943fddc4bcbc3</sys_id>
40+
<sys_mod_count>8</sys_mod_count>
41+
<sys_name>$rootScope.$on listener</sys_name>
42+
<sys_package display_value="Example Instance Checks" source="x_appe_exa_checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_package>
43+
<sys_policy/>
44+
<sys_scope display_value="Example Instance Checks">ca8467c41b9abc10ce0f62c3b24bcbaa</sys_scope>
45+
<sys_update_name>scan_table_check_f0e1a8581b27705088d943fddc4bcbc3</sys_update_name>
46+
<sys_updated_by>admin</sys_updated_by>
47+
<sys_updated_on>2021-10-27 21:53:56</sys_updated_on>
48+
<table>sp_widget</table>
49+
<use_manifest>false</use_manifest>
50+
</scan_table_check>
51+
</record_update>

0 commit comments

Comments
 (0)