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 

shall I use this code in script only check?

That's not possible since this code is specifically for Column Type Check. You would need to write new code. Also to perform a GlideRecord query on all possible script fields in the instance, that will be a bit of work to create šŸ˜…. For eventually performing a regex if the script field contains the value, you can almost use the same regex.

 

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 

shall I know more about linter check? beacuse in the documentation it is mentioned that Linter is similar to column type. How can i use and when can i use this Linter type check?

Can you first make sure this question is solved as well as all your others before asking new questions?

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn

Hi @Maik Skoddow 

How should I check script fields are gliding against sys_object_source table. can I use any other checks? 

please help me!