Created
October 11, 2012 02:50
-
-
Save DinisCruz/3869882 to your computer and use it in GitHub Desktop.
O2 Script - Create TM Library from CheckMarx CWE data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var tmSite = "http://localhost.:3187/"; | |
| var adminPwd = "{admin_pwd}"; | |
| var checkMark_XmlDumps = @"{path_to_folder_with}\_CheckMark_XmlDumps"; | |
| var teamMentor = "__teammentor".o2Cache<API_TeamMentor_WebServices>( | |
| ()=>{ | |
| var tm = new API_TeamMentor_WebServices(tmSite); | |
| tm.login("admin", adminPwd); | |
| return tm; | |
| }); | |
| if (teamMentor.loggedIn().isFalse()) | |
| return "NOT Logged in".error(); | |
| //load Checkmarx CWE data | |
| var xRoot = "cweData_".o2Cache<XElement>(()=> checkMark_XmlDumps.pathCombine("CWE.xml").xRoot()); | |
| var library = teamMentor.library("Checkmarx").delete().library("Checkmarx"); | |
| var view = library.view("CWE Data"); | |
| var count = 0; | |
| var cweEntries = xRoot.elements().toList(); | |
| foreach(var cweEntry in cweEntries) | |
| { | |
| //add entry as TM article | |
| var cweId = cweEntry.elements().first().value(); | |
| var cweHtml = cweEntry.elements().second().value(); | |
| var technology = "Any"; | |
| var phase = "Report"; | |
| var type = "CWE"; | |
| var category = "CheckMarx DB"; | |
| var title = cweId; | |
| if (cweId=="-1") // handle special case where they embeded the css on the item with id -1 | |
| { | |
| type = "css"; | |
| title = "main.css"; | |
| cweHtml = cweHtml.subString_After("<style>").trim(); | |
| } | |
| var content = cweHtml; | |
| view.add_Article(title, content, technology, phase, type, category); | |
| if (count++.mod0(20)) | |
| "[{0} / {1}]".debug(count, cweEntries.size()); | |
| } | |
| return "Created {0} TeamMentor articles".format(count).info(); | |
| //O2File:..\TM_UnitTests\APIs\API_TeamMentor_WebServices.cs | |
| //using SecurityInnovation.TeamMentor; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment