It looks like rooting a device require using uncertified app, are any of these app open source ? how do we know they are safe to use ?
The best method would be this way: unlock bootloader>flash custom recovery from fastboot>flash super SU .zip file from recovery if this is possible, on some phones it isn't.. If you by safe way mean "the way that won't screw your device" then there is no way, in every possible way of rooting it's possible that something goes wrong but in most times flashing stock firmware resolve trouble.
As previously mentioned, there are many different methods on how to root your device. The one crucial thing is to find out exactly what phone model do you have, and with that in mind do some research about it.
Usually a good place to start is: https://forum.xda-developers.com/
They have some pretty good tutorials on rooting/customizing phones, unlocking bootloaders etc.
I am not quiet sure what do u exactly mean by "app" and if it is open source, but the usually safe practice is not to install anything from that is not coming from the Play Store itself. If u however wish to risk it, at least make sure it is verified by developers as open source, meaning it has community of developers behind it that are trusted and are working on the app constantly. Hope this helps.