예제 #1
0
def create_codebase_resources(project, image):
    """
    Create the CodebaseResource for an `image` in `project`.
    """
    for layer_resource in image.get_layers_resources():
        pipes.make_codebase_resource(
            project=project,
            location=layer_resource.location,
            rootfs_path=layer_resource.path,
        )
예제 #2
0
def create_codebase_resources(project, rootfs):
    """
    Create the CodebaseResource for a `rootfs` in `project`.
    """
    for resource in rootfs.get_resources():
        pipes.make_codebase_resource(
            project=project,
            location=resource.location,
            rootfs_path=resource.rootfs_path,
        )
예제 #3
0
    def test_scanpipe_pipes_make_codebase_resource(self):
        p1 = Project.objects.create(name="Analysis")
        resource_location = str(self.data_location / "notice.NOTICE")

        with self.assertRaises(AssertionError) as cm:
            make_codebase_resource(p1, resource_location)

        self.assertIn("is not under project/codebase/", str(cm.exception))

        copy_inputs([resource_location], p1.codebase_path)
        resource_location = str(p1.codebase_path / "notice.NOTICE")
        make_codebase_resource(p1, resource_location)

        resource = p1.codebaseresources.get()
        self.assertEqual(1178, resource.size)
        self.assertEqual("4bd631df28995c332bf69d9d4f0f74d7ee089598",
                         resource.sha1)
        self.assertEqual("90cd416fd24df31f608249b77bae80f1", resource.md5)
        self.assertEqual("text/plain", resource.mime_type)
        self.assertEqual("ASCII text", resource.file_type)
        self.assertEqual("", resource.status)
        self.assertEqual(CodebaseResource.Type.FILE, resource.type)

        # Duplicated path: skip the creation and no project error added
        make_codebase_resource(p1, resource_location)
        self.assertEqual(1, p1.codebaseresources.count())
        self.assertEqual(0, p1.projecterrors.count())