Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@DinisCruz
Created October 26, 2012 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DinisCruz/3959647 to your computer and use it in GitHub Desktop.
Save DinisCruz/3959647 to your computer and use it in GitHub Desktop.
O2 Script - Get Html transformations of CWE Html from Checkmarx WebService
var cxPortal = new CxPortalWebService();
var sessionId = "cxSessionId".o2Cache(
()=>{
var user = "What user do you want to use".askUser();
var pwd = "What is the pwd for user {0}".format(user).askUser();
var credentials = new Credentials()
{
User = user,
Pass = pwd
};
var result = cxPortal.Login(credentials);
if (result.SessionId.valid())
return result.SessionId;
return result.SessionId;;
});
if(sessionId.isNull())
{
"Login Failed!!".alert("User Message");
return "login fail";
}
var checkMark_Data = "_CheckMark_Data".tempDir(false);
var queryQueryCollection = (CxQueryCollectionResponse)"CxQueryCollectionResponse".o2Cache(
()=>{
"Loading data from GetQueryCollection (its about 2.5Mb".debug();
var queryCollectionFile = checkMark_Data.pathCombine("WS_GetQueryCollection.xml");
var response = cxPortal.GetQueryCollection(sessionId);
response.saveAs(queryCollectionFile);
return queryCollectionFile.load<CxQueryCollectionResponse>();
});
var cweHtmlFolder = checkMark_Data.pathCombine("CweHtml").createFolder();
var uniqueIds = (from queryGroup in queryQueryCollection.QueryGroups
from query in queryGroup.Queries
select (int)query.Cwe).distinct();
var count=0;
foreach(var uniqueId in uniqueIds)
{
"[{0}/{1}] fetching Html for CWE: {2}".info(++count, uniqueIds.size(), uniqueId);
var response = cxPortal.GetQueryDescription(sessionId, uniqueId);
response.QueryDescription.saveAs(cweHtmlFolder.pathCombine(uniqueId + ".html"));
}
cweHtmlFolder.startProcess();
return "done";
//O2File:CxPortalWebService.cs
//O2Ref:System.Web.Services.dll
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment