The JavaScript to run the JobAssignment Task

Three variables will be passed to the Javascript as built-in variables

Issue Datatype

Return TypeMethod NameDescription
voidsetAssignedUser(String user)Assign a particular issue to a particular user
voidaddComment(String comment)Append Threaded Comment to the issue
StringgetInstanceId()Instacne Id, e.g. 9099D33FE61D0D1287401FB105FD341F
StringgetAssignedUser()Get the existing assigned user loginID
intgetRevision()
List<Tag>getTag()
booleanisSuppressed()Always false, because the issue list does not contain any suppressed item
List<String>getThreadComments()Get all threaded comments as a List of String, each line is in the format of Username Timestamp: Content
StringgetAnalysisEngine()e.g. SCA, RTA, PTA
StringgetAnalyzer()e.g. Dataflow, Controlflow, etc..
StringgetCategory()e.g. SQL Injection
StringgetCWE()
StringgetKingdom()
StringgetOWASP2004()
StringgetOWASP2007()
StringgetRuleId()
StringgetSubType()For Cross Site Scripting, this can be "Reflected" or "Persistent"
StringgetType()
StringgetWASC24And2()
doublegetConfidence()A floating point between 0.0 to 5.0
doublegetSeverity()A integer from 1 to 5, 5 meaning very important
StringgetSinkFunction()
StringgetSourceFunction()
StringgetClassName()
StringgetFilePath()
StringgetFunction()
intgetLineNumber()The priminary line number, -1 if unknown
StringgetPackage()Package name, e.g. com.mypackage1.project1
StringgetSourceFilePath()
StringgetURL()

Exampe:


var size = issues.size();
for(var i=0; i<size; i++) {
	var instance = issues.get(i);
	// only assign if it is not aissigned 
	if ( null == instance.getAssignedUser() ) {
		var filepath = instance.getFilePath();
		// need to prefixe with "/trunk/" for SVN...
		var lastUser = changeLog.get("/trunk/" + filepath);
		// and make sure this user is an authorized user in F360 server
		if ( null != lastUser && users.contains(lastUser) ) {
			instance.setAssignedUser(lastUser);
			instance.addComment("Auto-assigned to " + lastUser + " since the file is last modified by the user");
		} else {
			print(lastUser + " modified " + filepath + " but is not an authorized developer\n");
		}
	}
}