Closed DinisCruz closed 10 years ago
Here is is a script that confirms this timeout (note-to-self: run this on all TM Articles)
tmProxy.admin_Assert();
tmProxy = nUnitTests_Cassini.tmProxy();
Func<Panel> getRightPanel = ()=>
{
if (ie.HostControl.parent().parent().controls<Panel>(true).size() != 4)
return ie.HostControl.insert_Right();
return ie.HostControl.parent().parent().controls<Panel>(true).fourth().clear();
};
var panel = getRightPanel();
//var textArea = panel.clear().add_TextArea();
var dataGridView = panel.add_DataGridView().add_Columns("#","Id", "Title", "Status", "Html Render time", "Article Size", "Article Render Time");
var index = 0;
foreach(var article in tmProxy.articles().take(550))
{
var article_Id = article.Metadata.Id.str();
var article_Title = article.Metadata.Title;
var start = DateTime.Now;
ie.div("Title").innerHtml("");
//ie.open_ASync(ieTeamMentor.siteUri.append("article/".append(article_Id)).str());
ie.open_ASync(ieTeamMentor.siteUri.append("html/".append(article_Id)).str());
index++;
var title = "";
try
{
for(int i=0; i< 10; i++) // give it about 1 sec
{
// title = ie.div("Title").innerHtml();
title = ie.div("title").innerHtml();
if(title == article_Title)
break;
else
100.sleep();
}
var article_Time = start.duration_To_Now();
if (title != article_Title)
{
dataGridView.add_Row(index,article_Id, article_Title,"TIMEOUT", "", 0, article_Time);
// return "Problem getting {0} - {1} != {2}".format(article_Id, article_Title, title);
}
else
{
var article_Render = ie.div("guidanceItem").innerHtml();
var article_Size = article_Render.size().str();
dataGridView.add_Row(index,article_Id, article_Title, "OK", "", article_Size, article_Time);
}
}
catch(Exception ex)
{
dataGridView.add_Row(index, article_Id, article_Title, "ERROR: " + ex.Message, "", "0", "");
}
}
//O2Ref:TeamMentor.UnitTests.Cassini
Note top row (# = 305) of the execution results below:
other articles that don't load on WikiCreole:
Html 5 Library:
This is a great and interesting finding Dinis. I was able to reproduce it in my environment and I got the same results, in fact I ran their (Algorithm.WikiCreole) unit test against this article and it is still trying to parse it. It lead us to always test a bit better third party libraries with Unit Test, something similar to what needs to be done for regular expressions.
In fact, I got a OutofMemory Exception.
Test method Tests.Algorim.CreoleWiki.CreoleParserTests.Parser_Si threw exception: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown
So how do we fix it? Remove the article? Delete each line one at a time to see what fixes it? On Aug 6, 2014 9:35 AM, "Michael Hidalgo" notifications@github.com wrote:
This is a great and interesting finding Dinis. I was able to reproduce it in my environment and I got the same results, in fact I ran their (Algorithm.WikiCreole) unit test against this article and it is still trying to parse it. It lead us to always test a bit better third party libraries with Unit Test, something similar to what needs to be done for regular expressions.
In fact, I got a OutofMemory Exception.
Test method Tests.Algorim.CreoleWiki.CreoleParserTests.Parser_Si threw exception: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown
— Reply to this email directly or view it on GitHub https://github.com/TeamMentor/Master/issues/870#issuecomment-51334628.
This is fixed with https://github.com/TeamMentor/Dev/commit/9e914c112700d722b888cadafcf532e881a3a7ad
Like the comment says, it is a hack (I fix the wiki text only for WikiCreole), but it seems to do the trick.
I looked at reverting the code to how 3.4 used to do it, but that would introduce too many code changes: both html
rendering (needed for checkmarx/others) and main UI Preview used the same WebService Method
Sorry, the comment above is wrong (it was meant for #833)
That said, that fix is correct for this issue, since it introduces a change where there is a Thread created for rendering the HTML (which is given 2sec to complete)
I just added a 'friendly error message'
It seems like the friendly error message does not always work. I tried it with the All Password Fields Are Masked : https://localhost:3187/html/1513a133-0a53-46b5-b0b1-79b6dcb52ca2
And it just stays that way. No unusual CPU activity
Original offending article - XML Injection attack in the Vulnerabilities library - ae392dbb-fdb4-443f-9d17-78240b4acc95. The friendly error message works fine.
The interesting part is when I access the article directly, by using this link:
http://127.0.0.1:12120/article/ae392dbb-fdb4-443f-9d17-78240b4acc95
It opens up pretty much instantaneously.
However, when I double click on the article from the article list, it takes about a second or two to load. And there is a noticeable spike in the CPU at that time.
I am not really sure how much more time we should spend on this one. Check the friendly message in my first example, see if there is an easy reason you can pinpoint why it doesn't work. Otherwise I think lets leave it for now. This will get fixed eventually when all the articles move to markdown.
I am marking it as P3 since it is no longer a security risk, with the implemented timeouts.
The problem with https://tm-dinis.azurewebsites.net/article/1513a133-0a53-46b5-b0b1-79b6dcb52ca2 is that it throws an internal Algorim.CreoleWiki.CreoleParser error
see
You can replicate the problem (empty result) here:
https://tm-dinis.azurewebsites.net/html/1513a133-0a53-46b5-b0b1-79b6dcb52ca2
Fixed with https://github.com/TeamMentor/Dev/commit/22cb6c20249174c9bc264fbeaf443e04aee77597
here it the fix on the dev box
Here is the fix on the test Azure server
Error message also shows the Markup that failed to parse:
Btw, Michael, here is a simple script that I used to quickly try the C# Wiki transformation
var creoleParser = new CreoleParser();
var topPanel = panel.clear().add_Panel();
var wikiText = topPanel.add_TextBox(true);
var html = topPanel.insert_Right().add_TextArea();
var browser = html.insert_Below().add_WebBrowser();
wikiText.onTextChange(
text =>{
var parsedWikiText = creoleParser.Parse(text);
html.set_Text(parsedWikiText);
O2Thread.mtaThread(()=>browser.set_Html(parsedWikiText));
});
//using Algorim.CreoleWiki;
//O2Ref:E:\TeamMentor\TM_Dev Repos\TM_Dev\Source_Code\packages\Algorim.CreoleWiki.1.0.4335.37128\lib\net40\Algorim.CreoleWiki.dll
Looks like this when executed from the O2's C# REPL environment:
Great, this is working fine. Michael, can you run this script on all the articles to see which ones will cause this to happen.
After Michael's review all but one article (5.Article: XML Injection Attack) had been converted to markdown. The last article issue is tracked at: https://github.com/TeamMentor/Master/issues/882 Closing.
After doing a review, I found that 5 out of 875 wiki text articles have the problem with the server side Wiki Creole library :
1.Article:All Password Fields Are Masked , Id 1513a133-0a53-46b5-b0b1-79b6dcb52ca2 , Technology Web Application URL: https://tmqa-dev.teammentor.net/html/1513a133-0a53-46b5-b0b1-79b6dcb52ca2 2.Article: Use Mapping Values When Redirecting , Id 39a0a4e5-080d-444a-9789-b406a0aef602 , Technology Web Application URL: https://tmqa-dev.teammentor.net/html/39a0a4e5-080d-444a-9789-b406a0aef602 3.Article: Mapping Values Are Used when Redirecting , Id a5dee3ea-30a0-433c-bbb3-22444d35c5a2 , Technology Web Application URL: https://tmqa-dev.teammentor.net/html/a5dee3ea-30a0-433c-bbb3-22444d35c5a2 4.Article: Mask All Password Fields , Id f24d1109-4dd5-4360-867f-2be446baf6c9 , Technology Web Application URL :https://tmqa-dev.teammentor.net/html/f24d1109-4dd5-4360-867f-2be446baf6c9 5.Article: XML Injection Attack , Id ae392dbb-fdb4-443f-9d17-78240b4acc95 , Technology Any URL :https://tmqa-dev.teammentor.net/html/ae392dbb-fdb4-443f-9d17-78240b4acc95
while running the script that you can see at https://github.com/TeamMentor/Master/issues/833#issuecomment-51229485 I noticed that there was one article that was 'hanging' the UI. Initially I thought this was just an IE/WatiN issue, but after close look, I was able to pin it down to the
This is what the article view (http://127.0.0.1:32768/article/ae392dbb-fdb4-443f-9d17-78240b4acc95) looks like this (this view uses the Javascript Wiki Creole parser)
This is what the html view (http://127.0.0.1:32768/html/ae392dbb-fdb4-443f-9d17-78240b4acc95) looks like this (this view uses the .NET Wiki Creole parser)
and eventually (after a good number of minutes) it does this:
The end result is
... with the same happening if this article is viewed on the main TM UI
Editing the article is fine:
So there must be something on this source file that WikiCreole doesn't like:
Roman, I'm marking this as P0, since it is a nasty bug which brings TM down to its knees