How to install a flush ceiling light with a poorly placed hole
IMHO, (but that's opinion, and everybody has one...) the quick and easy fix for this half-fast (not up to code) job is to mount a round box in the hole and use a fixture or trim ring that hides the protruding box. And then look at the rest of the wiring, becasue it's probably not the only code violation.

Otherwise, for a better fix, patch the hole and put a new hole in a better place, then have fun matching the ceiling texture job - not that it's impossible, just that it's one of those things that's out of most people's comfort zone, but really you should actually have fun with it. Play with mud until you can make that sort of pattern and have at it. Don't be afraid to make a big hole to work in - if you're patching 4 inches of textured drywall, 4 square feet is barely a blip more effort, and it gives you the opportunity to use "new work" rather than "old work" fixtures/boxes.