def setUpClass(cls): try: cls.config = read_config(CONFIG_FILENAME) cls.gc = gspread.public() except IOError as e: msg = "Can't find %s for reading test configuration. " raise Exception(msg % e.filename)
def connect(self, credential_file): if credential_file: from oauth2client.service_account import ServiceAccountCredentials scope = ['https://spreadsheets.google.com/feeds'] credentials = ServiceAccountCredentials.from_json_keyfile_name(credential_file, scope) self.connection = gspread.authorize(credentials) else: # rely on gspread_public fork self.connection = gspread.public()
def __init__(self, spreadsheet_url): gc = gspread.public() sheet = gc.open_by_url(spreadsheet_url) worksheet_list = sheet.worksheets() self.sheets = dict() self.columns_dict = dict() self.columns_dict["not parse"] = ['README', '_Download', '_Schemes', '_Malware', '_Sources'] self.columns_dict["China"] = ['Common Name', 'CrowdStrike', 'IRL', 'Kaspersky', 'Secureworks', 'Mandiant', 'FireEye', 'Symantec', 'iSight', 'Cisco (Sourcefire/VRT > Talos)', 'Palo Alto Unit 42', 'Targets'] self.columns_dict["Russia"] = ['Common Name', 'Other Name 1', 'Other Name 2', 'Other Name 3', 'Other Name 4', 'Other Name 5', 'Other Name 6', 'Other Name 7', 'Other Name 8', 'Other Name 9', 'Other Name 10', 'Other Name 11', 'Other Name 12', 'Secureworks', 'Operation 1', 'Operation 2', 'Operation 3', 'Operation 4', 'Operation 5', 'Operation 6', 'Operation 7', 'Targets'] self.columns_dict["North Korea"] = ['Common Name', 'CrowdStrike', 'Talos Group', 'Dell Secure Works', 'Other Name 1', 'Other Name 2', 'Other Name 3', 'Other Name 4', 'Other Name 5', 'Other Name 6', 'Other Name 7', 'Other Name 8', 'Rep. of Korea FSI', 'Targets'] self.columns_dict["Iran"] = ['Common Name', 'Other Name 1', 'Other Name 2', 'Other Name 3', 'Other Name 4', 'Other Name 5', 'FireEye Name', 'Cisco Name', 'Secureworks', 'Symantec', 'Targets'] self.columns_dict["Israel"] = ['Common Name', 'Other Name 1', 'Other Name 2', 'Other Name 3', 'NSA', 'Targets'] self.columns_dict["NATO"] = ['Common Name', 'Other Name 1', 'Other Name 2', 'Other Name 3', 'Other Name 4', 'Symantec', 'Kaspersky', 'Targets'] self.columns_dict["Middle East"] = ['Common Name', 'Other Name 1', 'Other Name 2', 'Targets'] self.columns_dict["Others"] = ['Common Name', 'Other Name 1', 'Other Name 2', 'Other Name 3', 'Other Name 4', 'Other Name 5', 'Targets'] self.columns_dict["Unknown"] = ['Common Name', 'Other Name 1', 'Other Name 2', 'Other Name 3', 'Other Name 4', 'Other Name 5', 'NSA', 'Microsoft', 'FireEye', 'Targets'] for sh in worksheet_list: if (sh.title not in self.columns_dict["not parse"]): row_list = sh.get_all_values() df = pd.DataFrame(row_list[2:], columns=row_list[1]) self.sheets[sh.title] = df
else: logging.warning("Unsupported status: %s" % cell) continue # requires different patch id's per mag version, so not usable for automatic parsing if 'APPSEC' in patch: continue patch = patch.replace(' V', ' v') required_patches.add(patch) # sort patches alphabetically on patch version and take the latest (v2 over v1.1) return sorted(required_patches) gc = gspread.public() document = gc.open_by_key(SPREADSHEET_ID) giant_blob = {} for sheet in document.worksheets(): matrix = sheet.get_all_values() if matrix[1][0] != 'Version': # not a M1 CE or EE sheet continue edition = matrix[2][0] # Community or Enterprise patches = matrix[1][2:] # skip first 2 cols giant_blob[edition] = {}
continue # requires different patch id's per mag version, so not usable for automatic parsing if 'APPSEC' in patch: continue patch = patch.replace(' V', ' v') required_patches.add(patch) # sort patches alphabetically on patch version and take the latest (v2 over v1.1) return sorted(required_patches) gc = gspread.public() document = gc.open_by_key(SPREADSHEET_ID) giant_blob = {} for sheet in document.worksheets(): matrix = sheet.get_all_values() assert matrix[1][0] == 'Version' edition = matrix[2][0] # Community or Enterprise patches = matrix[1][2:] # skip first 2 cols giant_blob[edition] = {} for row_id in range(3, 50): version = matrix[row_id][0]