ChrisF323949498
Tera Explorer

I think Instance Scan is probably one of the underused features of ServiceNow, and it's so powerful and useful.

 

If you've worked in 'Software dev teams' (E.g. Teams whom are building web apps in ReactJS, etc) then lint scans and security scans are the norm before deployments, however I see this less often in the ServiceNow space and this is where Instance scan can help you.

 

The docs can be found here for this tool, but in short, it lets use scan Apps, individual files, and Update Sets, amongst others.

 

This is a huge time saver, if you are constantly reviewing code before release and I would encourage you to spend 1 hour today looking at it, it's saved me weeks of effort.

 

Leverage the out of box checks immediately

ServiceNow out of the box ships with numerous (260+ and counting) checks, these are categorised across

  1. Manageability
  2. Security
  3. User Experience
  4. Performance
  5. Upgradability

and the categorise have no real functional impact, except that they help categorise the findings when its time to check the results of your scan, similarly too for Priority.

 

Create your own custom checks to save hours

Coming back to the intro example, I can create this custom check to look for logging and Instance scan will let me know if it finds a result.

 

This leverages a 'script only check' and the code that can be used is as follows

(function (finding, columnValue) {
	let logStatements = columnValue.match(/gs\.log\s*\(/g);

	if (logStatements) {
            logStatements.forEach(function(foundOne) {
                    finding.increment();
            });
	}
}) (finding, columnValue);

 

This script will be given the column value from the files you are scanning, then it checks that column value for a gs.log and if it finds it just uses the provided 'finding' to increment the count (this just tells the platform to log a result, and the result is linked to the record!)

 

Now I just need to run this against an update set, check the results, and if I begin to build out further checks then code reviews become a lot more efficient! 

 

In future blogs I'll aim to document the functions/methods we have access too as they're not documented in as much depth as they could be, and there are some gems you can utilise in any custom checks you create.

 

I hope this saves you as much time as it did for me!
Have a great day!

 

1 Comment