In a perfect world, with perfect electronics, there would be no need for a grounding conductor. It's there to deal with imperfections. The most likely case for a ground fault in this installation would be if the black conductor lost some insulation and shorted itself against the frame of the fan. In such a situation, the casing could become electrified, and a grounded person, touching the fan body could receive a shock.
If it were properly grounded, you'd get a short circuit to the ground wire, and the breaker would trip.
However, the fan is mounted to the ceiling, and the possibility of someone touching it is low. (Unlike, for example, the frame of a fridge or stove, where human contact is part of normal operation.)
So, Is it safe? Quite likely. For added safety, turn the wall switch off when changing bulbs. Is it to code? No. -- Unless, as others have suggested in comments, the mounting box is grounded on the other side.
You can however, locate the breaker, and replace it with a Ground Fault Interrupt breaker, which would trip should a ground fault occur. This isn't something you should do yourself unless you have experience working in the panel.
Another possibility, if your switch happens to be chained off of an outlet, which is quite possible, depending on the routing of the wiring on that circuit, is to replace the outlet with a GFCI outlet, and wire the switch to the load side of it.
There is a junction box somewhere at the end of the cable, best to find it and start your wiring from there.
You can cut the cable, and use the wires, but it is difficult without the right tool, and then you have to hope you have enough length and use the proper fittings to mount it to the new ceiling box.
Best Answer
There is a 3/4" extender sold by Cooper Industries (and maybe others). They call it a cover. This site sells it and it probably can be found elsewhere online.
You need to be sure that the box in the ceiling is firmly attached to the framing, preferably directly screwed into a joist. Fan rated boxes have heavier duty attachments for the fan hanger and use longer screws.
Then you need to make sure that the fan hanger is firmly attached. I would attach it directly to the ceiling box, not just the extender/cover.