lucasbrendel
lucasbrendel

Reputation: 506

Jenkins Pipeline scan for compiler warnings custom parser blocked

I have a pipeline to scan for compiler warnings and recently noticed that the publishing command is not able to execute the groovy scripts defined in Manage Jenkins due to script security approval. The complaint is against:

Groovy sandbox rejected the parsing script for parser GHS MULTI No-Wrap: Scripts not permitted to use method java.util.regex.MatchResult group int. You will need to manually approve the call in the Script Approval UI.

So i approve it, but it comes back with every build. This only affects my custom parsers.

Am I using the custom parser incorrectly, or would this be a problem script security?

Parser Regex:

^"+(.*)".*line\s(\d*):.*(error|warning)\s*#(.*):\s*(.*)$

Parser Script:

import hudson.plugins.warnings.parser.Warning
import hudson.plugins.analysis.util.model.Priority

String fileName = matcher.group(1)
String lineNumber = matcher.group(2)
String category = matcher.group(3)
String typeID    = matcher.group(4)
String message = matcher.group(5)

if(category == "warning"){
    return new Warning(fileName, Integer.parseInt(lineNumber), typeID, 
    category, message, Priority.NORMAL);
}
else if(category == "error"){
    return new Warning(fileName, Integer.parseInt(lineNumber), typeID, 
    category, message, Priority.HIGH);
}

Update: I have found that the error i am getting I believe is being generated by the warnings parser here

I cannot find anything as to why or what I can do about preventing it from throwing that exception.

Upvotes: 4

Views: 2236

Answers (1)

lucasbrendel
lucasbrendel

Reputation: 506

I have found that the issue is related to a release on the Warnings plugin on version 4.62. It was a release to fix some security issues. For the time being, reverting to 4.60 fixes the problem.

Upvotes: 4

Related Questions