Jenkins管道扫描编译器警告自定义分析器被阻止 [英] Jenkins Pipeline scan for compiler warnings custom parser blocked

查看:583
本文介绍了Jenkins管道扫描编译器警告自定义分析器被阻止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个管道扫描编译器警告,最近注意到由于脚本安全性批准,发布命令无法执行Manage Jenkins中定义的groovy脚本。
抱怨是针对:

lockquote
Groovy沙箱拒绝解析器GHS的解析脚本MULTI No-Wrap:脚本不允许使用方法java.util.regex.MatchResult组int。您需要手动批准脚本审批UI中的调用。


所以我批准它,但每次构建都会回来。这只会影响我的自定义分析器。



我是否错误地使用了自定义分析器,或者这会成为脚本安全问题?



解析器正则表达式:

  ^+(。*)。* line \(\ d * ):。*(error | warning)\s *#(。*):\s *(。*)

解析器脚本:

  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){
返回新的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 );
}

更新:我发现我得到的错误我相信正在生成通过警告解析器这里



我无法找到任何关于为什么或者我能做些什么来阻止它抛出异常。

解决方案

我发现问题与版本4.62上的警告插件版本有关。这是一个解决一些安全问题的发布。目前,恢复到4.60可以解决问题。


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.

解决方案

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.

这篇关于Jenkins管道扫描编译器警告自定义分析器被阻止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆