コード例 #1
0
    def run(self, cmd):
        threads = []
        (credential_list,
         err_msg) = cputils.processAuthFile(cmd.auth_filename, cmd.progdir)
        if err_msg:
            print >> sys.stderr, err_msg
            return False
        if len(credential_list) < 1:
            return False
        # print credentials
        credentials = credential_list[0]
        self.api.base_url = cmd.url_base
        self.api.key_id = credentials['id']
        self.api.secret = credentials['secret']
        resp = self.api.authenticateClient()
        if not resp:
            return False

        print "Start archiving issues."
        LOGGER.info("start archiving issues.")
        server_list = self.list_servers()
        print "--- %s servers ---" % (len(server_list))
        LOGGER.info("--- %s servers ---" % (len(server_list)))
        server_chuncks = self.chunk(server_list, 10)
        for server_chunck in server_chuncks:
            temp = self.multi_threading(self.get_server_module, server_chunck,
                                        'sca')
            temp = self.multi_threading(self.get_server_module, server_chunck,
                                        'svm')
コード例 #2
0
ファイル: getIssues.py プロジェクト: apurvasingh/v2_issues_ga
 def run(self,cmd):
     (credentialList, errMsg) = cputils.processAuthFile(cmd.authFilename, cmd.progdir)
     if (errMsg != None):
         print >> sys.stderr, errMsg
         return False
     if len(credentialList) < 1:
         return False
     # print credentials
     credentials = credentialList[0]
     self.api.base_url = cmd.base
     self.api.key_id = credentials['id']
     self.api.secret = credentials['secret']
     resp = self.api.authenticateClient()
     if (not resp):
         return False
     ( groupListObj, authError ) = self.listGroups()
     groupListCount = groupListObj['count']
     if (cmd.verbose):
         print >>  sys.stderr, "Found %d groups in list" % groupListCount
     if 'groups' in groupListObj:
         grplist = groupListObj['groups']
         for group in grplist:
             if ((cmd.groupName == None) and (group['parent_id'] == None)):
                 # self.dumpGroup(group,'',grplist,cmd.recurse)
                 self.processGroup(group,grplist,cmd)
             elif (cmd.groupName == group['name']):
                 # self.dumpGroup(group,'',grplist,cmd.recurse)
                 self.processGroup(group,grplist,cmd)
     return True
コード例 #3
0
ファイル: Archive.py プロジェクト: mong2/Archive_v2
    def run(self, cmd):
        threads = []
        (credential_list, err_msg) = cputils.processAuthFile(cmd.auth_filename, cmd.progdir)
        if err_msg:
            print >> sys.stderr, err_msg
            return False
        if len(credential_list) < 1:
            return False
        # print credentials
        credentials = credential_list[0]
        self.api.base_url = cmd.url_base
        self.api.key_id = credentials['id']
        self.api.secret = credentials['secret']
        resp = self.api.authenticateClient()
        if not resp:
            return False

        print "Start archiving issues."
        LOGGER.info("start archiving issues.")
        server_list = self.list_servers()
        print "--- %s servers ---" % (len(server_list))
        LOGGER.info("--- %s servers ---" % (len(server_list)))
        server_chuncks = self.chunk(server_list, 10)
        for server_chunck in server_chuncks:
            temp = self.multi_threading(self.get_server_module, server_chunck, 'sca')
            temp = self.multi_threading(self.get_server_module, server_chunck, 'svm')
コード例 #4
0
def getHaloConnection(authFilename,progDir):
    credentials = cputils.processAuthFile(authFilename,progDir)
    credential = credentials[0][0]
    haloConn = cpapi.CPAPI()
    (haloConn.key_id, haloConn.secret) = (credential['id'], credential['secret'])
    if ((not haloConn.key_id) or (not haloConn.secret)):
        print >> sys.stderr, "Unable to read auth file %s. Exiting..." % authFilename
        print >> sys.stderr, "Requires lines of the form \"<API-id>|<secret>\""
        sys.exit(1)
    resp = haloConn.authenticateClient()
    if (not resp):
        # no error message here, rely on cpapi.authenticate client for error message
        sys.exit(1)
    return haloConn
コード例 #5
0
ファイル: archive.py プロジェクト: mong2/Archive_10k
 def run (self, cmd):
     (credentialList, errMsg) = cputils.processAuthFile(cmd.authFilename, cmd.progdir)
     if (errMsg != None):
         print >> sys.stderr, errMsg
         return False
     if len(credentialList) < 1:
         return False
     # print credentials
     credentials = credentialList[0]
     self.api.base_url = cmd.url_base
     self.api.key_id = credentials['id']
     self.api.secret = credentials['secret']
     resp = self.api.authenticateClient()
     if (not resp):
         return False
     self.getScanData()
コード例 #6
0
ファイル: archive.py プロジェクト: mong2/Archive_issues
 def run (self, cmd):
     (credentialList, errMsg) = cputils.processAuthFile(cmd.authFilename, cmd.progdir)
     if (errMsg != None):
         print >> sys.stderr, errMsg
         return False
     if len(credentialList) < 1:
         return False
     # print credentials
     credentials = credentialList[0]
     self.api.base_url = cmd.url_base
     self.api.key_id = credentials['id']
     self.api.secret = credentials['secret']
     resp = self.api.authenticateClient()
     if (not resp):
         return False
     serverList = self.listServer()
     print "--- %s servers ---" % (len(serverList))
     logger.info("--- %s servers ---" % (len(serverList)))
     print "Start archiving configuration scan result"
     self.getServer_csm(serverList)
     print "Start archiving software vulnerablility scan result"
     self.getServer_sva(serverList)
コード例 #7
0
ファイル: archive.py プロジェクト: mong2/Archive_issues
 def run(self, cmd):
     (credentialList,
      errMsg) = cputils.processAuthFile(cmd.authFilename, cmd.progdir)
     if (errMsg != None):
         print >> sys.stderr, errMsg
         return False
     if len(credentialList) < 1:
         return False
     # print credentials
     credentials = credentialList[0]
     self.api.base_url = cmd.url_base
     self.api.key_id = credentials['id']
     self.api.secret = credentials['secret']
     resp = self.api.authenticateClient()
     if (not resp):
         return False
     serverList = self.listServer()
     print "--- %s servers ---" % (len(serverList))
     logger.info("--- %s servers ---" % (len(serverList)))
     print "Start archiving configuration scan result"
     self.getServer_csm(serverList)
     print "Start archiving software vulnerablility scan result"
     self.getServer_sva(serverList)
コード例 #8
0
atexit.register(processExit)
progDir = os.path.dirname(sys.argv[0])

if processCmdLineArgs(sys.argv):
    sys.exit(0)

cputils.verbose = verbose
cputils.checkLockFile(pidFilename)

if len(authFilenameList) == 0:
    authFilenameList = [authFilenameDefault]

# was a for/loop in haloEvents.py, but we'll never need that here
authFilename = authFilenameList[0]
(credentialList, errMsg) = cputils.processAuthFile(authFilename, progDir)
credential = credentialList[0]

apiCon = cpapi.CPAPI()
(apiCon.key_id, apiCon.secret) = (credential["id"], credential["secret"])

if (not apiCon.key_id) or (not apiCon.secret):
    print >> sys.stderr, "Unable to read auth file %s. Exiting..." % authFilename
    print >> sys.stderr, 'Requires lines of the form "<API-id>|<secret>"'
    sys.exit(1)

resp = apiCon.authenticateClient()
if not resp:
    print >> sys.stderr, "Failed to retrieve authentication token. Exiting..."
    sys.exit(1)