示例#1
0
    def enrichment(self, en_path):
        """Nothing here yet"""

        print("[*] Populating Enrichments...")
        if en_path:
            en_list = glob.glob(en_path + '*.yml')
        else:
            en_dir = ATCconfig.get('enrichments_dir')
            en_list = glob.glob(en_dir + '/*.yml')

        for en_file in en_list:
            try:
                en = Enrichment(en_file,
                                apipath=self.apipath,
                                auth=self.auth,
                                space=self.space)
                en.render_template("confluence")

                confluence_data = {
                    "title":
                    en.en_parsed_file['title'],
                    "spacekey":
                    self.space,
                    "parentid":
                    str(
                        DATAutils.confluence_get_page_id(
                            self.apipath, self.auth, self.space,
                            "Enrichments")),
                    "confluencecontent":
                    en.content,
                }

                res = DATAutils.push_to_confluence(confluence_data,
                                                   self.apipath, self.auth)
                if res == 'Page updated':
                    print("==> updated page: EN '" +
                          en.en_parsed_file['title'] + "'")
                # print("Done: ", en.en_parsed_file['title'])
            except Exception as err:
                print(en_file + " failed")
                print("Err message: %s" % err)
                print('-' * 60)
                traceback.print_exc(file=sys.stdout)
                print('-' * 60)
        print("[+] Enrichments populated!")
示例#2
0
    def data_needed(self, dn_path):
        """Desc"""

        print("[*] Populating Data Needed...")
        if dn_path:
            dn_list = glob.glob(dn_path + '*.yml')
        else:
            dn_dir = ATCconfig.get('data_needed_dir')
            dn_list = glob.glob(dn_dir + '/*.yml')

        for dn_file in dn_list:
            try:
                dn = DataNeeded(dn_file,
                                apipath=self.apipath,
                                auth=self.auth,
                                space=self.space)
                dn.render_template("confluence")
                confluence_data = {
                    "title":
                    dn.dn_fields["title"],
                    "spacekey":
                    self.space,
                    "parentid":
                    str(
                        DATAutils.confluence_get_page_id(
                            self.apipath, self.auth, self.space,
                            "Data Needed")),
                    "confluencecontent":
                    dn.content,
                }

                res = DATAutils.push_to_confluence(confluence_data,
                                                   self.apipath, self.auth)
                if res == 'Page updated':
                    print("==> updated page: DN '" + dn.dn_fields['title'] +
                          "'")
                # print("Done: ", dn.dn_fields['title'])
            except Exception as err:
                print(dn_file + " failed")
                print("Err message: %s" % err)
                print('-' * 60)
                traceback.print_exc(file=sys.stdout)
                print('-' * 60)
        print("[+] Data Needed populated!")
示例#3
0
    def logging_policy(self, lp_path):
        """Desc"""

        print("[*] Populating Logging Policies...")
        if lp_path:
            lp_list = glob.glob(lp_path + '*.yml')
        else:
            lp_dir = ATCconfig.get('logging_policies_dir')
            lp_list = glob.glob(lp_dir + '/*.yml')

        for lp_file in lp_list:
            try:
                lp = LoggingPolicy(lp_file)
                lp.render_template("confluence")
                confluence_data = {
                    "title":
                    lp.fields["title"],
                    "spacekey":
                    self.space,
                    "parentid":
                    str(
                        DATAutils.confluence_get_page_id(
                            self.apipath, self.auth, self.space,
                            "Logging Policies")),
                    "confluencecontent":
                    lp.content,
                }

                res = DATAutils.push_to_confluence(confluence_data,
                                                   self.apipath, self.auth)
                if res == 'Page updated':
                    print("==> updated page: LP '" + lp.fields['title'] + "'")
                # print("Done: ", lp.fields['title'])
            except Exception as err:
                print(lp_file + " failed")
                print("Err message: %s" % err)
                print('-' * 60)
                traceback.print_exc(file=sys.stdout)
                print('-' * 60)
        print("[+] Logging Policies populated!")
示例#4
0
def main(c_auth=None):

    try:
        ATCconfig = DATAutils.load_config("config.yml")
        confluence_space_name = ATCconfig.get('confluence_space_name')
        confluence_space_home_page_name = ATCconfig.get(
            'confluence_space_home_page_name')
        confluence_rest_api_url = ATCconfig.get('confluence_rest_api_url')
        confluence_name_of_root_directory = ATCconfig.get(
            'confluence_name_of_root_directory')

    except Exception as e:
        raise e
        pass

    if not c_auth:
        mail = input("Login: "******""

    print("[*] Creating ATC root page...")

    data = {
        "title":
        confluence_name_of_root_directory,
        "spacekey":
        confluence_space_name,
        "parentid":
        str(
            DATAutils.confluence_get_page_id(url, auth, confluence_space_name,
                                             confluence_space_home_page_name)),
        "confluencecontent":
        content,
    }

    if not DATAutils.push_to_confluence(data, url, auth):
        raise Exception("[-] Could not create or update the page. " +
                        "Is the parent name correct?")

    pages = ["Logging Policies", "Data Needed", "Enrichments"]

    for page in pages:
        print("Creating %s..." % page)
        data = {
            "title":
            page,
            "spacekey":
            confluence_space_name,
            "parentid":
            str(
                DATAutils.confluence_get_page_id(
                    url, auth, confluence_space_name,
                    confluence_name_of_root_directory)),
            "confluencecontent":
            content,
        }

        if not DATAutils.push_to_confluence(data, url, auth):
            raise Exception("[-] Could not create or update the page. " +
                            "Is the parent name correct?")
    print("[+] Initial Confluence page structure created!")
    return True