What kind of weapon are we dealing with?
A cosmic string is essentially a deformity in spacetime that presents itself as an anisotropy in the spacetime metric; in other words, something left over from the beginning of the Universe that creates a sort of "string" around which circles have fewer than 360 degrees. More specifically, according to the Wikipedia page, "cosmic strings are hypothetical 1-dimensional topological defects which may have formed during a symmetry-breaking phase transition in the early universe when the topology of the vacuum manifold associated to this symmetry breaking was not simply connected."
What does this actually mean for the Solar System if one breaks ten light-years away? It's often said that mass shapes spacetime, but it's actually the reverse: looking at the Einstein field equations,
$$\mathrm{Ric}_{\mu\nu}-\frac{1}{2}Rg_{\mu\nu}+\Lambda g_{\mu\nu}=\frac{8\pi G}{c^4}T_{\mu\nu},$$
it becomes apparent that mass and energy ($T_{\mu\nu}$ is the stress-energy tensor) is actually defined in terms of the deformations of spacetime ($g_{\mu\nu}$ is the metric tensor describing how spacetime curves and $\mathrm{Ric}_{\mu\nu}$ and $R$ are related to the Riemann tensor which describes how much spacetime is different from regular Euclidean spacetime). This is why solving the Einstein field equations is so hard: the intention is to take a metric (a particular configuration of spacetime) and tell you what and where its energy is, not to take a specific arrangement of energy and give you its spacetime metric.
So, what does this mean? That cosmic strings contain a huge amount of energy. In fact, the same Wiki article describing cosmic strings also notes that they contain a large mass: "a circle around the outside of a string would comprise a total angle less than 360° ... From the general theory of relativity such a geometrical defect must be in tension, and would be manifested by mass. Even though cosmic strings are thought to be extremely thin, they would have immense density, and so would represent significant gravitational wave sources. A cosmic string about a kilometer in length may be more massive than the Earth."
So how much power?
So, say a hostile civilization knows about Earth, detests our large-scale production of teddy bears, and decides to break a cosmic string to screw with us. How much energy is released?
Well, this depends on the mass of the string, which is in turn dependent on its length. Here's the thing: they might have practically-infinite length; it's possible that they stretch all the way around the Universe and are thus, for all intents and purposes, infinite.
So, if a civilization is capable of breaking a cosmic string to release its energy in a giant gravitational wave, we might be screwed because they have virtually infinite energy to work with.
So that's an issue. How do we deflect an incoming wave of gargantuan gravitational energy that will instantaneously shred any massive object it comes across? We actually have several options!
How does another advanced civ defend us from it?
Don't worry, another advanced civilization is on the way to save us! They have several options as to how they can prevent the gravitational wave emitted from the broken string from pulverizing our Sun and Earth:
Generate an equal-and-opposite wave in the opposite direction
We actually know something about the aggressor civ that wasn't explicitly stated: they are capable of channeling gravitational waves like lasers channel light. How do we know this? Well, if they were to break a cosmic string without being able to do so, they would be hit with a wave just as strong as the one reaching us. "But what if they aren't an aggressor and wanted to do it for science reasons?" you may ask. My response is that any civilization capable of breaking cosmic strings is probably also capable of detecting bio signatures on nearby stars, so unless they're fine with just annihilating themselves and an entire other species that they know to exist, we can assume that they're an aggressor. Or maybe it was done remotely; still, in that situation, this "aggressor" civ has technology more than powerful enough to channel gravitational waves.
If our "savior" civilization has roughly the same level of technology, there shouldn't be any reason they can't just launch another gravitational wave towards the first. Of course, the issue with that is that they would need to have faster-than-light travel to even be aware of it; gravitational waves like the one the cosmic string emits travel at the speed of light, so from an Earthbound observer watching the string, it breaks and then an instant later everything goes to hell.
So, solution 1: have one of the savior civ's ships get caught in the wave or otherwise detect it, have them jump FTL to our Solar System, and then have them activate another cosmic string and break it, channeling all the gravitational waves towards the first wave. Since energy and momentum are directly related, the two colliding waves will have to conserve their momentum and will therefore turn into a greatly-reduced wave going in either direction. It will probably still be noticeable, but if our savior civ's wave is powerful enough, it might just cancel out the other wave.
Wrap the solar system in an Alcubierre-style bubble
Here's another possible solution: just let the Solar System bypass the wave entirely. Our savior civ, if it is on-par with the aggressor civ, probably has the ability to manipulate spacetime on fundamental levels. If they can generate an Alcubierre-style warp bubble around the entire Solar System, then the very edge of the bubble will absorb much of the incoming gravitational wave's energy.
This is an actual phenomenon of the warp bubble that I personally have studied extensively; near the edge of the bubble, spacetime becomes so deformed that time and space stop having much physical meaning, which causes any and all energy going through it to be shredded at the most fundamental level. If the warp bubble is powerful enough, it can actually withstand perturbation from external gravitational wave sources; the bubble would act kind of like a 99.999%-reflective mirror, absorbing the brunt of the gravitational wave in the very edge of the bubble and allowing only a safe amount of energy through (for some definition of "safe").
If the Alcubierre drive is powerful enough, it would be destabilized by the incoming wave instead of allowing much of it through; the energy density around the edge of the warp bubble would have to be changed to account for the wave, but what it allows the savior civ to do is to take the excess wave energy from one end of the warp bubble and deposit it at the other end to keep the bubble stable and to disperse the wave. If transfer is sufficiently fast, the wave can be circumvented entirely, with the warp bubble acting as a kind of "shield" that allows the wave to flow around it by creating a potential barrier that the wave can move around but not through.
Use a DEW to disrupt the wave before it arrives
Here's another option: use a massive directed energy weapon (DEW) to divert a huge volume of energy from various points across the Solar System's diameter at the gravitational wave. Why? Because in the right configurations, these energy beams will act as interference slits (see the double slit experiment) and cause the incoming gravitational wave to interfere with itself. We don't actually need to stop the whole thing; we just need not to be affected. But why from across the diameter of the Solar System? Well, in order to affect the wave, the beams would have to be comparable in energy, and if they're comparable in energy, then having them all clumped up in one spot would produce a similar effect to the wave itself and be very counterproductive. Simply station energy beams at various points throughout the System and have them converge at the incoming gravitational wave so that their effects are localized there, very far away from us.
With enough energy and precise timing, what happens is that the Solar System can be made to fit inside one of the interference fringes and doesn't feel anything from the gravitational wave. Most of the wave's energy is diffracted outwards, so anyone behind us is still screwed, but honestly we just saved an entire species with a Solar System-sized Death Star so... Still, on astronomical distances, the Solar System will easily fit inside the gravitational wave's interference fringe, so that on either side of us will be Sun-destroying mind-bogglingly-powerful gravitational radiation while everything from Pluto to Mercury will be calm and safe.
Just get out of there
All other options be damned, in order to be aware of the inbound catastrophe our savior civ has to be capable of FTL travel, so they can - as a last-ditch effort to save Humanity - load everyone onto a space yacht and book it away from the Solar System.
Certainly not ideal, but hey, at least Humanity survived.