mirror of https://github.com/CIRCL/AIL-framework
				
				
				
			chg: [api] add domain lookup
							parent
							
								
									f93d82eff4
								
							
						
					
					
						commit
						483d49fecf
					
				|  | @ -40,6 +40,7 @@ from packages import Date | |||
| from lib import ail_orgs | ||||
| from lib.ConfigLoader import ConfigLoader | ||||
| from lib.objects.Domains import Domain | ||||
| from lib.objects.Titles import Title | ||||
| from lib.objects import HHHashs | ||||
| from lib.objects.Items import Item | ||||
| 
 | ||||
|  | @ -55,6 +56,34 @@ config_loader = None | |||
| 
 | ||||
| faup = Faup() | ||||
| 
 | ||||
| # # # # # # # # | ||||
| #             # | ||||
| #   DOMAINS   # | ||||
| #             # | ||||
| # # # # # # # # | ||||
| 
 | ||||
| # is safe ??? | ||||
| # TODO FILTER URL ??? | ||||
| 
 | ||||
| def api_get_domain_lookup_meta(domain): | ||||
|     dom = Domain(domain) | ||||
|     if not dom.exists(): | ||||
|         return {'error': 'domain not found', 'domain': domain}, 404 | ||||
|     meta = dom.get_meta(options={'languages'}) | ||||
|     meta['first_seen'] = meta['first_seen'].replace('/', '-') | ||||
|     meta['last_seen'] = meta['last_check'].replace('/', '-') | ||||
|     meta['languages'] = list(meta['languages']) | ||||
|     del meta['domain'] | ||||
|     del meta['last_check'] | ||||
|     del meta['type'] | ||||
|     del meta['status'] | ||||
|     meta['titles'] = [] | ||||
|     for h in dom.get_correlation('title').get('title', []): | ||||
|         t = Title(h[1:]) | ||||
|         meta['titles'].append(t.get_content()) | ||||
|     return meta | ||||
| 
 | ||||
| 
 | ||||
| # # # # # # # # | ||||
| #             # | ||||
| #   COMMON    # | ||||
|  |  | |||
|  | @ -221,7 +221,7 @@ class Domain(AbstractObject): | |||
| 
 | ||||
|     # options: set of optional meta fields | ||||
|     def get_meta(self, options=set()): | ||||
|         meta = {'type': self.domain_type, | ||||
|         meta = {'type': self.domain_type,  # TODO RENAME ME -> Fix template | ||||
|                 'id': self.id, | ||||
|                 'domain': self.id, # TODO Remove me -> Fix templates | ||||
|                 'first_seen': self.get_first_seen(), | ||||
|  |  | |||
|  | @ -214,6 +214,15 @@ def objects_chat_thread_messages(): | |||
|     r = chats_viewer.api_thread_messages(obj_subtype, obj_id) | ||||
|     return create_json_response(r[0], r[1]) | ||||
| 
 | ||||
| # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||||
| # # # # # # # # # # # # # # #      DOMAINS      # # # # # # # # # # # # # # # # # # | ||||
| # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||||
| 
 | ||||
| @api_rest.route("api/v1/domain/lookup/<domain>", methods=['GET']) | ||||
| @token_required('user') | ||||
| def api_domain_lookup(domain): | ||||
|     return create_json_response(crawlers.api_get_domain_lookup_meta(domain), 200) | ||||
| 
 | ||||
| # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||||
| # # # # # # # # # # # # # # #      TITLES       # # # # # # # # # # # # # # # # # # # TODO TO REVIEW | ||||
| # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 terrtia
						terrtia