def scan_and_find_dependencies(ecosystem, manifests):
     """Scan the dependencies files to fetch transitive deps."""
     if ecosystem == "golang":
         # TODO remove the logic for golang. Add the golang logic in utils
         return DependencyFinder.get_dependencies_from_ecosystem_list(
             ecosystem, manifests)
     return Df.scan_and_find_dependencies(ecosystem, manifests)
Exemple #2
0
    def execute(self, arguments):
        """Perform the git operations."""
        self.log.info("Worker flow initiated for git operations")
        self._strict_assert(arguments.get('git_url'))
        self._strict_assert(arguments.get('ecosystem'))
        self._strict_assert(arguments.get('is_scan_enabled'))
        self._strict_assert(arguments.get('request_id'))
        self._strict_assert(arguments.get('gh_token'))

        giturl = arguments.get('git_url')
        ecosystem = arguments.get('ecosystem')
        request_id = arguments.get('request_id')
        is_modified_flag = arguments.get('is_modified_flag')
        check_license = arguments.get('check_license')
        auth_key = arguments.get('auth_key')
        gh_token = arguments.get('gh_token')
        is_scan_enabled = arguments.get('is_scan_enabled')

        manifests = self.create_repo_and_generate_files(
            giturl, ecosystem, gh_token)
        if len(manifests) == 0:
            self.log.error("No dependency files found or generated.")
            return None
        repo_name = giturl.split("/")[-1]
        path = _dir_path + "/" + repo_name
        data_object = []
        for manifest in manifests:
            temp = {
                'filename': manifest.filename,
                'content': manifest.read(),
                'filepath': path
            }
            data_object.append(temp)

        deps = DependencyFinder.scan_and_find_dependencies(
            ecosystem, data_object)
        # Call to the Gemini Server
        if is_scan_enabled == "true":
            self.log.info("Scan is enabled.Gemini scan call in progress")
            try:
                self.gemini_call_for_cve_scan(giturl, deps, auth_key)
            except Exception:
                self.log.exception("Failed to call the gemini scan.")

        # Call to the Backbone
        self.log.debug(deps)
        if len(deps) == 0:
            self.log.error(
                "Dependencies not generated properly.Backbone wont be called.")
            return None

        try:
            self.log.info("Calling backbone for stack analyses")
            self.backbone_for_stack_analysis(deps, request_id,
                                             is_modified_flag, check_license)

        except Exception:
            self.log.exception("Failed to call the backbone.")
        os.system("rm -rf " + path)
 def scan_and_find_dependencies(ecosystem, manifests, show_transitive):
     """Scan the dependencies files to fetch transitive deps."""
     return Df.scan_and_find_dependencies(ecosystem, manifests,
                                          show_transitive)