  In dimensions $\geq 3$, we prove that the X-ray transform of symmetric
tensors of arbitrary degree is generically injective with respect to the metric
on closed Anosov manifolds and on manifolds with spherical strictly convex
boundary, no conjugate points and a hyperbolic trapped set. This has two
immediate corollaries: local spectral rigidity, and local marked length
spectrum rigidity (building on earlier work by Guillarmou, Knieper and the
second author [arXiv:1806.04218], [arXiv:1909.08666]), in a neighbourhood of a
generic Anosov metric. In both cases, this is the first work going beyond the
negatively curved assumption or dimension $2$.
  Our method, initiated in [arXiv:2008.09191] and fully developed in the
present paper, is based on a perturbative argument of the $0$-eigenvalue of
elliptic operators via microlocal analysis which turn the analytic problem of
injectivity into an algebraic problem of representation theory. When the
manifold is equipped with a Hermitian vector bundle together with a unitary
connection, we also show that the twisted X-ray transform of symmetric tensors
(with values in that bundle) is generically injective with respect to the
connection. This property turns out to be crucial when solving the
$\textit{holonomy inverse problem}$, as studied in a subsequent article
[arXiv:2105.06376].
