Exemplo n.º 1
0
	def _buildGolangPackageLevelGraph(self, dataset):
		# get nodes
		nodes = dataset.alphabet()
		# get edges from labels

		labels = dataset.labels()

		missing = []
		edges = []
		for category in labels:
			for edge in labels[category]:
				a, b = edge
				if b == "":
					missing = missing + list(set(map(lambda (a,b): b, labels[category][edge])))
				else:
					edges = edges + labels[category][edge]

		self._missing_packages = list(set(missing))

		# mixing all categories we can get repeating edges
		edges = list(set(edges))

		# convert edges to adjacent list
		edges = GraphUtils.edges2adjacentList(edges)

		# TODO(jchaloup): integrate parent mapping as well so one can join packages from the same rpm
		return Graph(nodes, edges)
Exemplo n.º 2
0
	def _detectIndirectDependencies(self, ipprefix, commit_timestamp):
		nodes = []
		next_projects = {}
		for prefix in self.unscanned_projects:
			# get dataset
			dataset = ProjectDatasetBuilder(
				self.unscanned_projects[prefix]["provider_prefix"],
				self.unscanned_projects[prefix]["commit"]
			).build()

			# construct dependency graph from the dataset
			graph = DatasetDependencyGraphBuilder().build(dataset, LEVEL_GOLANG_PACKAGES)

			# get the subgraph of evolved dependency's packages
			subgraph = GraphUtils.truncateGraph(graph, self.unscanned_projects[prefix]["paths"])

			# get dependencies from the subgraph
			package_nodes = filter(lambda l: l.startswith(self.unscanned_projects[prefix]["ipprefix"]), subgraph.nodes())
			label_edges = dataset.getLabelEdges()
			for node in package_nodes:
				nodes = nodes + label_edges[node]

		nodes = list(set(nodes))

		next_projects = self._detectNextDependencies(nodes, ipprefix, commit_timestamp)
		if next_projects == {}:
			return False

		# update packages to scan
		one_at_least = False
		self.unscanned_projects = {}

		for prefix in next_projects:
			# prefix already covered? Just extend the current coverage
			if prefix in self.detected_projects:
				for ip in next_projects[prefix]["paths"]:
					if str(ip) not in self.detected_projects[prefix]:
						self.detected_projects[prefix].append(ip)
						self.scanned_projects[prefix]["paths"].append(ip)
				continue

			one_at_least = True
			self.unscanned_projects[prefix] = copy.deepcopy(next_projects[prefix])
			self.scanned_projects[prefix] = copy.deepcopy(next_projects[prefix])
			self.detected_projects[prefix] = copy.deepcopy(next_projects[prefix]["paths"])

		return one_at_least
Exemplo n.º 3
0
	def _buildRpmLevelGraph(self, dataset):
		# get nodes and edges
		nodes = dataset.nodes()
		edges = dataset.edges()

		# get missing packages
		labels = dataset.labels()

		missing = []
		for category in labels:
			# TODO(jchaloup): make distinction among devel, main and tests
			for edge in labels[category]:
				a, b = edge
				if b == "":
					missing = missing + list(set(map(lambda (a,b): b, labels[category][edge])))

		self._missing_packages = list(set(missing))

		# convert edges to adjacent list
		edges = GraphUtils.edges2adjacentList(edges)

		return Graph(nodes, edges)
Exemplo n.º 4
0
	def _getLeafNodes(self, graph):
		return GraphUtils.getLeafNodes(graph)
Exemplo n.º 5
0
	def _getRootNodes(self, graph):
		return GraphUtils.getRootNodes(graph)
Exemplo n.º 6
0
	def _getCyclicDependencies(self, graph):
		return GraphUtils.getSCCs(graph)