Heat the oil in saucepan, add the onion, garlic and rosemary and cook over a low heat, stirring frequently, for 5 minutes until the onion is softened.
Stir in the tomatoes, stock, beans and salt and pepper. Bring to the boil, then reduce the heat, cover and simmer gently for 20 minutes. Add the pasta and simmer, covered, for a further 10 minutes until the pasta is al dente.
Meanwhile, make the basil oil. Plunge the basil leaves into a saucepan of boiling water, return to the boil and boil for 30 seconds. Drain the basil, refresh under cold water and dry thoroughly with kitchen paper. Transfer the oil and basil leaves to a blender and blend until really smooth.
Ladle the soup into bowls and spoon a little of the basil oil over each serving. Serve immediately, scattered with some grated Parmesan.