Exemplo n.º 1
0
    def getProjects(self, orgs):
        print(sViews.PROJECTS_SEARCH + f" OF {len(orgs)} ORGANIZATIONS:")
        result = []
        i = 0
        if (self._validateQuantity(len(orgs))):
            for org in orgs:
                endpoint = self.url + "api/components/search_projects"
                getParam = "organization=" + org["key"]
                dataProject = self.request.get(endpoint + "?" + getParam)

                if (len(orgs) > 1000 and i > 10):
                    pg().printProgressBar(i, len(orgs))

                if (dataProject.status_code == 200):
                    info = dataProject.json()
                    sViews.SHOW_PROJECT(i, org["key"], info["paging"]["total"])
                    projects = Utils.paging(info,
                                            endpoint,
                                            self.request,
                                            params="&" + getParam)
                    result += projects
                i += 1
        print(sViews.PROJECTS_TOTAL + str(len(result)))
        self._saveData(result, "projects")
        return result
Exemplo n.º 2
0
 def getVersion(self):
     endpoint = self.url + "api/system/status"
     req = self.request.get(endpoint)
     if (req.status_code == 200):
         data = req.json()
         sViews.SYS_VERSION(data)
     else:
         print(sViews.SYS_ERROR)
Exemplo n.º 3
0
    def loadMenu(self):
        sViews.menuBackdoor()
        print(sViews.QUANTITY_BEGIN, end="")
        opt = int(input("  [|] Input option: "))
        print(sViews.QUANTITY_END, end="")

        if (opt >= 0 and opt <= 4):
            if (opt == 1):
                self.createUser()
            elif (opt == 2):
                self.generateToken()
            elif (opt == 3):
                self.privilageEscalation()
            elif (opt == 4):
                self.changePassword()
            else:
                exit(0)
        else:
            print(sViews.BACKDOOR_MENU_ERROR)
            self.loadMenu()
Exemplo n.º 4
0
    def getSettings(self):
        endpoint = self.url + "api/settings/values"
        dataReq = self.request.get(endpoint)

        if (dataReq.status_code == 200):
            settings = dataReq.json()
            for opt in Config.SONARQUBE_API_SETTINGS:
                print(sViews.SETTINGS_OPT + opt)
                for key in settings["settings"]:
                    if (key["key"] in Config.SONARQUBE_API_SETTINGS[opt]):
                        sViews.ONE_SETTING(key["key"], key["value"])
        else:
            print(sViews.SETTINGS_ERROR)
Exemplo n.º 5
0
    def getOrganizationsMember(self):
        endpoint = self.url + "api/organizations/search"
        reqMember = self.request.get(endpoint + "?member=true")
        result = []
        if (reqMember.status_code == 200):
            dataMember = reqMember.json()
            orgMember = Utils.paging(dataMember, endpoint, self.request,
                                     "&member=true")
            result += orgMember

            print(sViews.ORG_SEARCH_MEMBER, len(orgMember))
            sViews.TOP_LIST(orgMember,
                            "orgs")  # vista top organizaciones miembro
            self._saveData(orgMember, "orgsMember")
        else:
            print(sViews.ORG_SEARCH_MEMBER_ERROR)
        return result
Exemplo n.º 6
0
    def getAuthors(self, orgs):
        print(sViews.AUTHORS_SEARCH)
        tmp = []
        authors = {}
        for org in orgs:
            endpoint = self.url + "api/issues/authors?organization=" + org[
                "key"]
            authorReq = self.request.get(endpoint)
            dataAuthors = authorReq.json()

            authors[org["key"]] = dataAuthors["authors"]
            if (len(tmp) < 10):  # show top
                sViews.AUTHORS_SEARCH_DUMP(org["key"],
                                           dataAuthors["authors"],
                                           t=len(tmp))
            tmp += dataAuthors["authors"]
        self._saveData(authors, "authors")
        return authors
Exemplo n.º 7
0
    def getUsers(self):
        endpoint = self.url + "api/users/search"
        req = self.request.get(endpoint)
        users = []
        if (req.status_code == 200):
            data = req.json()
            print(sViews.USERS_SEARCH_COUNT +
                  str(data["paging"]["total"]))  # TODO: mejorar vista top user

            if (self._validateQuantity(data["paging"]["total"])):
                users = Utils.paging(data,
                                     endpoint,
                                     self.request,
                                     progress=True)
                sViews.TOP_LIST(users, "users")
                self._saveData(users, "users")
        else:
            print(sViews.USERS_SEARCH_ERROR)
        return users
Exemplo n.º 8
0
    def getOrganizationsPublic(self):
        endpoint = self.url + "api/organizations/search"
        reqPublic = self.request.get(endpoint)
        result = []

        if (reqPublic.status_code == 200):
            data = reqPublic.json()
            print(sViews.ORG_SEARCH, data["paging"]["total"])

            if (self._validateQuantity(data["paging"]["total"])):
                orgPublic = Utils.paging(data,
                                         endpoint,
                                         self.request,
                                         progress=True)
                sViews.TOP_LIST(orgPublic,
                                "orgs")  # vista top organizaciones publicas
                self._saveData(orgPublic, "orgs")
                result += orgPublic
        else:
            print(sViews.ORG_SEARCH_ERROR)
        return result