예제 #1
0
 def __init__(self, target_folder=""):
     self.processing_class = ""
     self.apis = []
     self.sensitive_keywords = set()
     self.sensitive_apis = []
     if target_folder == "":
         self.api_folders = get_first_layer_folders(Config.target_folder)
     else:
         self.api_folders = get_first_layer_folders(target_folder)
def process_results():
    result_folders = get_first_layer_folders("." + os.sep + "api_results")
    csv_cnt = 0
    csv_file_cnt = 0
    for res_folder in result_folders:
        csv_files = get_first_layer_files(res_folder, html=False)
        csv_file_cnt += len(csv_files)
        api_sum = 0
        for csv_file in csv_files:
            csv = open(csv_file, "r", encoding="utf-8")
            # print(csv_file)
            lines = csv.readlines()
            csv_name = csv_file.split(os.sep)[-1][:-4]
            sum_cnt = 0
            general_cnt = 0
            for line in lines:
                if "," in line:
                    sum_cnt = sum_cnt + 1
                if "logevent" in line or "GeneralLogEvent" in line or "trackEvent" in line or \
                        "GeneralUserProperty" in line:
                    general_cnt = general_cnt + 1
            api_sum += sum_cnt
            if sum_cnt >= 0:
                if general_cnt >= 0:
                    csv_cnt = csv_cnt + 1
                    # print("CSV_Name=" + csv_name + ", Privacy API=" + str(sum_cnt) + ", General API=" + str(general_cnt))
                    # print(csv_name + "," + str(sum_cnt) + "," + str(general_cnt))
                    # loss = loss + (sum_cnt - general_cnt) / sum_cnt
        if api_sum == 0:
            print("!!!=" + res_folder)
    print("CSV File Count=" + str(csv_file_cnt))
예제 #3
0
def parse_facebook_folder(target_folder):
    # logger.info("Facebook Doc Folder=" + target_folder)
    facebook_folders = get_first_layer_folders(target_folder)
    for facebook_doc in facebook_folders:
        # logger.info("Processing Facebook Doc=" + facebook_doc)
        parser = FacebookDocParser(facebook_doc)
        parser.run()
        parser.print_results()
예제 #4
0
def parse_silverjava_doc(target_folder):
    silverjava_folders = get_first_layer_folders(target_folder)
    for doc_folder in silverjava_folders:
        print("Processing Silver Java Doc=" + doc_folder.split(os.sep)[-1])
        # print(javadoc)
        parser = SilverJavaDocParser(doc_folder)
        parser.run()
        parser.print_results()
        parser.print_to_csv()
예제 #5
0
 def run(self):
     self.sensitive_keywords = get_sensitive_keywords()
     sum_tp = 0
     sum_fp = 0
     sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf8')
     api_folders = get_first_layer_folders(Config.target_folder)
     for api_folder in api_folders:
         (tp, fp) = self.process_api(api_folder)
         sum_tp = sum_tp + tp
         sum_fp = sum_fp + fp
예제 #6
0
 def run(self):
     # print(self.sensitive_keywords)
     sum_tp = 0
     sum_fp = 0
     api_folders = get_first_layer_folders(self.target_folder)
     for api_folder in api_folders:
         # logger.info("Processing Folder:" + str(api_folder))
         (tp, fp) = self.process_api(api_folder)
         sum_tp = sum_tp + tp
         sum_fp = sum_fp + fp
예제 #7
0
def parse_historical_javadoc_folder_(sdk_name, target_folder):
    print("SDK Name=" + sdk_name + "  Java Doc Folder=" + target_folder)
    javadoc_folders = get_first_layer_folders(target_folder)
    for javadoc in javadoc_folders:
        print("Processing JavaDoc=" + javadoc.split("\\")[-1])
        # print(javadoc)
        parser = JavaDocParser(sdk_name, javadoc)
        parser.run()
        parser.print_results()
        parser.print_to_csv()
예제 #8
0
def parse_current_javadoc_folder(target_folder):
    print("Java Doc Folder=" + target_folder)
    javadoc_folders = get_first_layer_folders(target_folder)
    for javadoc in javadoc_folders:
        print("Processing JavaDoc=" + javadoc.split("\\")[-1])
        # print(javadoc)
        parser = SingleJavaDocParser(javadoc)
        parser.run()
        parser.print_results()
        parser.print_to_csv()
예제 #9
0
def parse_javalike_doc(target_folder):
    # logger.info("Javalike Doc Folder=" + target_folder)
    javalike_folders = get_first_layer_folders(target_folder)
    for javalike_doc in javalike_folders:
        # logger.info("Processing Javalike Doc=" + javalike_doc.split("\\")[-1])
        doc_name = javalike_doc.split("\\")[-1]
        print(doc_name)
        parser = JavaLikeDocParser(javalike_doc)
        parser.run()
        # parser.print_results()
        parser.print_to_csv()