-- @path ANO=/AnalysisOfSecurityAspectsInManifest/metamodels/ANO.ecore
-- @path ASEC=/AnalysisOfSecurityAspectsInManifest/metamodels/ASEC.ecore

module AnalysisOfCategory;
create OUT : ANO from IN : ASEC;


--Check list for Malicious Categories:
helper def:all_categories_of_malicious_intentfilter:Sequence(OclAny)=
	Sequence{'android.intent.category.HOME',
	         'android.intent.category.BROWSABLE'
	        };

	helper context ASEC!Category def:isMalicious: Boolean=
		if thisModule.all_categories_of_malicious_intentfilter.includes(self.name)  then
			true
		   else
		  false
	   endif;

--for detection Malicious Categories:	
helper context ASEC!Category def:getMaliciousCategory :Sequence(String) =
		let output : Sequence(String) = Sequence{} in 
		if thisModule.all_categories_of_malicious_intentfilter.includes(self.name) then
			output->including(': The Application is Malicous because exist a IntentFilter with Malicous Category : ' + self.name )
			 else
			output->including('the application is safe')
		endif
		;
													
		
		


--for transfer Category to MaliciousCategory
rule Category2MaliciousCategory{
	
	from
	    s:ASEC!Category (s.isMalicious)
	to
	   t:ANO!MaliciousCategory(
	   	

	   description <- s.getMaliciousCategory->iterate(ac; output: String = '' | output->concat(ac)+'\n')
	       
	   
	   )
	   do {
	t.trace<-Sequence{s};
}
}