Jenkins Log parser plugin - parsed console log page is not showing Load denied by X-Frame-Options does not permit framing ERR_BLOCKED_BY_RESPONSE

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 10:31:56

问题


Jenkins version: 1.642.3 or 2.32.3

Jenkins machine Ubuntu 14.04

Log parser plugin: 2.0

Browsing Jenkins from my Mac OS sierra machine.

In Jenkins global configuration, I created a new entry (description and file path (full) where the file contains the following contents).

error /ERROR: Couldn't find any revision to build./
error /SyntaxError: Use of const in strict mode./
error /svn: E220003: /
error /npm ERR! fetch failed/
error /ERROR: Found inconsistencies/
error /ERROR: svn up failed for /
error /rsync error: /

warning /WARNING: /
warning /npm WARN retry/
warning /svn: E200033: /
warning /: binary operator expected/
warning /: too many arguments/
warning /: No such file or directory/

info /rsync: failed to set times on/
info /svn: E170001: /

I created a test job and to catch all these cases (as listed above), inside the job's post-build section, I'm enabled "Console output (build log) parsing" by selecting the same log parsing file entry (list box selection). I ran the build and as expected it failed.

Build step 'Console output (build log) parsing' changed build result to FAILURE

On the Job's dashboard, I see this.

Clicking on the Parsed Console Output (left side bar), takes me to a page without giving me any meaningful information.

When I hover over the above side bar link, it shows Jenkins is looking for https://.../../parsed_console URL for the given job build number (as seen in the above image's address bar).

What am I missing here to get the Parsed Console Output page with all Errors, Warnings and Info dashboard, like what this plugin claims to provide here: https://wiki.jenkins.io/download/attachments/43713289/parsed_console_output_3.JPG?version=1&modificationDate=1271216347000&api=v2

PS:

Inside my $JENKINS_HOME (on master), under plugins folder, I see "log-parser.hpi" file (latest file and SHA matches with what I see if I download it on my local Mac machine). During Jenkins restart, I don't see any error logs either related to this plugin.

In Jenkins job's $JENKINS_HOME/jobs//builds/ folder, I see valid log*.html files with valid size (these are read by this plugin to show the info when you click on "Parsed Console Output" side bar link.

Browsing log_ref.html shows valid links.

jenkins@jenkins-master:/opt/data/jenkins/jobs/testing_log_parser_testing/builds/14$ ls -ltr
total 40
-rw-r--r-- 1 jenkins jenkins    6 Aug 21 13:47 changelog.xml
-rw-r--r-- 1 jenkins jenkins 3145 Aug 21 13:47 log_content.html
-rw-r--r-- 1 jenkins jenkins  945 Aug 21 13:47 logwarningLinks.html
-rw-r--r-- 1 jenkins jenkins 4022 Aug 21 13:47 log_ref.html
-rw-r--r-- 1 jenkins jenkins  267 Aug 21 13:47 loginfoLinks.html
-rw-r--r-- 1 jenkins jenkins  277 Aug 21 13:47 log.html
-rw-r--r-- 1 jenkins jenkins 1130 Aug 21 13:47 logerrorLinks.html
-rw-r--r-- 1 jenkins jenkins 2315 Aug 21 13:47 log
-rw-r--r-- 1 jenkins jenkins 1089 Aug 21 13:47 injectedEnvVars.txt
-rw-r--r-- 1 jenkins jenkins 2391 Aug 21 13:47 build.xml
jenkins@jenkins-master:/opt/data/jenkins/jobs/testing_log_parser_testing/builds/14$ cat -n loginfoLinks.html
     1  <li>1 <a target="content" href="log_content.html#INFO1"><span style="color:blue">rsync: failed to set times on/</span></a></li><br/>
     2  <li>2 <a target="content" href="log_content.html#INFO2"><span style="color:blue">svn: E170001: Auth reqd i guess</span></a></li><br/>
jenkins@jenkins-master:/opt/data/jenkins/jobs/testing_log_parser_testing/builds/14$ cat -n logwarningLinks.html
     1  HEADER HERE: #0
     2  <li>1 <a target="content" href="log_content.html#WARNING1"><span style="color:orange">WARNING: are not that bad actually</span></a></li><br/>
     3  <li>2 <a target="content" href="log_content.html#WARNING2"><span style="color:orange">npm WARN retry -- won't do any good</span></a></li><br/>
     4  <li>3 <a target="content" href="log_content.html#WARNING3"><span style="color:orange">svn: E200033: db locked again?? no way</span></a></li><br/>
     5  <li>4 <a target="content" href="log_content.html#WARNING4"><span style="color:orange">: binary operator expected -- lol</span></a></li><br/>
     6  <li>5 <a target="content" href="log_content.html#WARNING5"><span style="color:orange">: too many arguments - check the usage please</span></a></li><br/>
     7  <li>6 <a target="content" href="log_content.html#WARNING6"><span style="color:orange">: No such file or directory comes whenever you are looking for something which doesn't exist atm</span></a></li><br/>
jenkins@jenkins-master:/opt/data/jenkins/jobs/testing_log_parser_testing/builds/14$ cat log_ref.html 
<!DOCTYPE html>
<html>
        <head>
                <title>log-parser plugin page</title>
                <link type="text/css" rel="stylesheet" href="https://jenkins-master.company.com/jenkins_instance01/css/style.css" />
                <link type="text/css" rel="stylesheet" href="https://jenkins-master.company.com/jenkins_instance01/css/color.css" />
        </head>
        <body>
<script type="text/javascript">
        function toggleList(list){
                element = document.getElementById(list).style;
                element.display == 'none' ? element.display='block' : element.display='none';
        }
</script>
<img src="https://jenkins-master.company.com/jenkins_instance01///static/a8e7a2ad/images/16x16/red.gif" style="margin: 2px;" width="24" alt="Error Icon" height="24" />
<a href="javascript:toggleList('Error')" target="_self"><STRONG>Error (7)</STRONG></a><br />
<ul id="Error" style="display:none; margin-left:0; padding-left:3em">
 <a target="content" href="log_content.html">Beginning of log</a>
<br/>(7 Errors in this section)<br/>
<li>1 <a target="content" href="log_content.html#ERROR1"><span style="color:red">1 ERROR: Couldn't find any revision to build &lt;= this is an error</span></a></li><br/>
<li>2 <a target="content" href="log_content.html#ERROR2"><span style="color:red">SyntaxError: Use of const in strict mode &lt;= this is another type of error (syntax)</span></a></li><br/>
<li>3 <a target="content" href="log_content.html#ERROR3"><span style="color:red">svn: E220003: Unable to connect to a repository at URL</span></a></li><br/>
<li>4 <a target="content" href="log_content.html#ERROR4"><span style="color:red">svn: E220003: Invalid authz configuration</span></a></li><br/>
<li>5 <a target="content" href="log_content.html#ERROR6"><span style="color:red">npm ERR! fetch failed-- fetch may be?</span></a></li><br/>
<li>6 <a target="content" href="log_content.html#ERROR7"><span style="color:red">ERROR: svn up failed for --- well why not switch to Git/Hg</span></a></li><br/>
</ul>
<img src="https://jenkins-master.company.com/jenkins_instance01///static/a8e7a2ad/images/16x16/yellow.gif" style="margin: 2px;" width="24" alt="Warning Icon" height="24" />
<a href="javascript:toggleList('Warning')" target="_self"><STRONG>Warning (6)</STRONG></a><br />
<ul id="Warning" style="display:none; margin-left:0; padding-left:3em">
 <a target="content" href="log_content.html">Beginning of log</a>
<br/>(6 Warnings in this section)<br/>
<li>1 <a target="content" href="log_content.html#WARNING1"><span style="color:orange">WARNING: are not that bad actually</span></a></li><br/>
<li>2 <a target="content" href="log_content.html#WARNING2"><span style="color:orange">npm WARN retry -- won't do any good</span></a></li><br/>
<li>3 <a target="content" href="log_content.html#WARNING3"><span style="color:orange">svn: E200033: db locked again?? no way</span></a></li><br/>
<li>4 <a target="content" href="log_content.html#WARNING4"><span style="color:orange">: binary operator expected -- lol</span></a></li><br/>
<li>5 <a target="content" href="log_content.html#WARNING5"><span style="color:orange">: too many arguments - check the usage please</span></a></li><br/>
<li>6 <a target="content" href="log_content.html#WARNING6"><span style="color:orange">: No such file or directory comes whenever you are looking for something which doesn't exist atm</span></a></li><br/>
</ul>
<img src="https://jenkins-master.company.com/jenkins_instance01///static/a8e7a2ad/images/16x16/blue.gif" style="margin: 2px;" width="24" alt="Info Icon" height="24" />
<a href="javascript:toggleList('Info')" target="_self"><STRONG>Info (2)</STRONG></a><br />
<ul id="Info" style="display:none; margin-left:0; padding-left:3em">
<li>1 <a target="content" href="log_content.html#INFO1"><span style="color:blue">rsync: failed to set times on/</span></a></li><br/>
<li>2 <a target="content" href="log_content.html#INFO2"><span style="color:blue">svn: E170001: Auth reqd i guess</span></a></li><br/>
</ul>
        </body>
</html>

After further investigation into the GitHub source code (LogParserParser.java file)for this plugin and what I have in my Jenkins job's $JENKINS_HOME/jobs//builds// folder, I found the log.html may be incorrect. Not sure why it's referring to build.log (as href) while there's NO such file on the filesystem. PS: <frame src=.... refers to log_ref and log_content.html files and they both render fine).

<frameset cols="270,*">
<frame src="log_ref.html" scrolling=auto name="sidebar">
<frame src="log_content.html" scrolling=auto name="content">
<noframes>
<p>Viewing the build report requires a Frames-enabled browser</p>
<a href='build.log'>build log</a>
</noframes>
</frameset>

This line shows that variable parsedLogURL is pointing to log.html. https://github.com/jenkinsci/log-parser-plugin/blob/1cc883708524e33792d410a109e6cb69a4c0439b/src/main/java/hudson/plugins/logparser/LogParserParser.java#L162

Browsing: https://<jenkins_server>/<instance>/job/<job_name>/<someBuildNumber>/parsed_console (as referred by Parsed Console Output sidebar link gives nothing) and https://<jenkins_server>/<instance>/job/<job_name>/<someBuildNumber>/parsed_console/log.html (renders only the vertical BAR line (it moves) between the 2 frames BUT nothing for the contents within those 2 frames (log_ref.html and log_content.html))

In Firefox: Doing Inspect page on browser on my Mac machine for the "Parsed Console Output" side bar link (referring to: https://<jenkins_server>/<instance>/job/<job_name>/<someBuildNumber>/parsed_console) shows the following lines in the Inspect page > Console section.

Load denied by X-Frame-Options: https://<jenkins_server>/<jenkins_instance>/job/<job_name>/<build_number>/parsed_console/log.html does not permit framing.  (unknown)

If I browse https://<jenkins_server>/<instance>/job/<job_name>/<someBuildNumber>/parsed_console/log.html, then I'm getting the following lines in Inspect page > Console window:

https://<jenkins_server>/<jenkins_instance>/job/<job_name>/<build_number>/parsed_console/log_ref.html does not permit framing.  (unknown)
Load denied by X-Frame-Options: https://<jenkins_server>/<jenkins_instance>/job/<job_name>/<build_number>/parsed_console/log_content.html does not permit framing.  (unknown)

In Chrome, doing Inspect on the page, shows the following errors (Refused to display / frame because it set 'X-Frame-Options' to 'deny' / net::ERR_BLOCKED_BY_RESPONSE):

Refused to display 'https://<jenkins_server>/<jenkins_instance>/job/<jobname>/15/parsed_console/job/<jobname>/15/parsed_console/log.html' in a frame because it set 'X-Frame-Options' to 'deny'.
(index):22 GET https://<jenkins_server>/<jenkins_instance>/job/<jobname>/15/parsed_console/job/<jobname>/15/parsed_console/log.html net::ERR_BLOCKED_BY_RESPONSE

回答1:


The issue was NOT with the plugin.

Using Inspect on the webpage, it was clear that something was set to DENY in either Apache / Nginx.

I modified the my /etc/nginx/sites-enabled/jenkins_https.conf file

   #add_header X-Frame-Options DENY;

Ran

sudo service nginx restart

Plugin is now rendering the output as expected.

Another better solution is:

Replace the following line

#add_header X-Frame-Options DENY;

with the following line in your nginx configuration file:

add_header X-Frame-Options SAMEORIGIN;

Ref: https://geekflare.com/add-x-frame-options-nginx/ or https://www.owasp.org/index.php/Clickjacking_Defense_Cheat_Sheet



来源:https://stackoverflow.com/questions/45806006/jenkins-log-parser-plugin-parsed-console-log-page-is-not-showing-load-denied-b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!