OWASP O2 Platform Blog

Extrating OWASP Chapter data via MediaWiki API and viewing it

Here is a script that uses O2’s MediaWiki API to extract OWASP’s chapter information from its WIKI.

Once the data is collected, a mini gui is used to show it:

var topPanel = panel.clear().add_Panel();
var owaspWiki = new OwaspWikiAPI(false);

var treeView = topPanel.add_TreeView();
var textArea = topPanel.insert_Right().add_TextArea();
var webBrowser = textArea.insert_Below().add_WebBrowser_Control();
Action<List<string>,TreeNode, bool> loadArea = null;
var addedCategories = new List<string>();

treeView.afterSelect<string>(
    (page)=>{
                textArea.set_Text(page);
                var wikiText = owaspWiki.wikiText(page);
                var htmlCode = owaspWiki.html(page);
                textArea.set_Text(wikiText);
                webBrowser.open(htmlCode.save());
                
            });
       
loadArea = (pages, parentNode, addChapters) =>
        {                       
            foreach(var page in pages)
            {
                if (page.contains("Category") && addedCategories.contains(page).isFalse())
                {                   
                    addedCategories.add(page);
                    var categoryNode = parentNode.add_Node(page);                   
                    var chaptersInArea = owaspWiki.pagesInCategory(page);       
                   
                    loadArea(chaptersInArea, categoryNode , true);
                   
                }
                else
                    if (addChapters)
                        parentNode.add_Node(page);
            }
        };


var chapters = owaspWiki.pagesInCategory("Category:OWASP Chapter");
//var chapters = @"C:\O2\_tempDir\2-8-2012\tmpA92F.tmp.xml".load<List<string>>();
loadArea(chapters,treeView.rootNode(),false);       

treeView.selectFirst();
//return pages.size();

return "ok";
//O2File:OwaspWikiAPI.cs
//O2Ref:O2_Misc_Microsoft_MPL_Libs.dll

February 8, 2012 - Posted by | MediaWiki, OWASP

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: