Instance scan - Column type check

shivaadapa
Tera Expert

shivaadapa_0-1705052827227.png

Hi 

I am trying to serach for querying against 'sys_object_source' table in all the script fields in the instance. But the above code is not working please help me.
Help me to provide how to keep correct regular expressions.

1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron
Tera Patron

O really small though essential typo I made, here is working tested code:

 

(function (engine) {

	// Remove code comments
	var commentsRegEx = /\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm;
	var commentsRemovedValue = engine.columnValue.replace(commentsRegEx, '');

	var search_regex = /\bGlideRecord\(['"]sys_object_source['"]\)/gm;

	// Create scan finding
	if(search_regex.test(commentsRemovedValue)) {
		engine.finding.increment();
	}

})(engine);

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

24 REPLIES 24

Hi @Mark Roethof 

maximum of them are custom, but i am not getting all of those records as findings.

Please share details.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi @Mark Roethof 

In my instance i checked in one of the table script contains GlideRecord("sys_object_source
i am having these records but these are not getting as findings using your code:

shivaadapa_0-1705662030470.png

please help me!

These look out-of-the-box, can you confirm? Because (as also mentioned in one of your other questions which is still open): this check won't create findings on out-of-the-box records, only on modified/custom records.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Like I mentioned in one of your other questions: if you want out-of-the-box findings also to appear: Script Only Check is your goto.

 

Please do handle also your other posts. Follow-up, mark an answer as helpful if so, mark an answer as correct if so. So far you are not showing any appreciation at all.

 

We all are doing this for free in our own time just to help. Show some appreciation in return.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn