I am currently writing my Master's thesis in Math and part of my results involves using running simulations to test for certain types of algebraic properties of parameterised equations. The theoretical basis for these simulations were derived from a paper, in which the authors published their code online. I wish to copy this code and put it in the appendix. My reason for doing this is that I don't trust the link to always be available and the interested readers of my thesis will always be able to view said code which makes it easier to reader the thesis, as opposed to looking it up.
It depends on the licensing terms of their code. If it's under an open source license, then you might probably be able to use the same by giving due credits to the authors of the same. It would also be better if you could try to contact the author of the paper and ask their permission before using the same if you're not able to find any specific licensing terms.
You will of course be citing this paper in your body text. But in the appendix, you would need to be absolutely clear that the code is reproduced from the paper. If instead you have based your own code on the code in the paper, be clear about which bits are yours and which are from the paper, as well as to what extent your work is derived from the literature.