  Since first introduced by Sudakov and Vu in 2008, the study of resilience
problems in random graphs received a lot of attention in probabilistic
combinatorics. Of particular interest are resilience problems of spanning
structures. It is known that for spanning structures which contain many
triangles, local resilience cannot prevent an adversary from destroying all
copies of the structure by removing a negligible amount of edges incident to
every vertex. In this paper we generalise the notion of local resilience to
$H$-resilience and demonstrate its usefulness on the containment problem of the
square of a Hamilton cycle. In particular, we show that there exists a constant
$C > 0$ such that if $p \geq C\log^3 n/\sqrt{n}$ then w.h.p. in every subgraph
$G$ of a random graph $G_{n, p}$ there exists the square of a Hamilton cycle,
provided that every vertex of $G$ remains on at least a $(4/9 + o(1))$-fraction
of its triangles from $G_{n, p}$. The constant $4/9$ is optimal and the value
of $p$ slightly improves on the best-known appearance threshold of such a
structure and is optimal up to the logarithmic factor.
