The big unknown is the state of the wiring behind the drywall. If it is in conduit (unlikely) then you are in better shape because you can run new wires if you need to. More likely is that this is a cable. If there is enough loose cable inside the wall that you can actually have cable (i.e., outer-sheath still attached) pull through the hole in the drywall, then you can either use a surface-mount box or use a fixture that has a box built into it - i.e., pull the cable all the way into the fixture.
However, if the cable (outer sheath) ends behind the drywall with no extra length available, then you have to cut into the wall and install a box. If the cable (outer sheath) ends too far behind the wall to get it into a box at this location then you have bigger problems.
Assuming the cable sheath ends within a few inches of the wall, you should be able to cut a hole to match a box and install a box. The left edge should be at the stud - mount the box to the stud. The cable will need to go into the box so that the outer sheath fits through a proper clamp. On plastic boxes these are usually part of the box. On metal boxes these are additional (they don't cost much, they just aren't included because a metal box used with conduit will not need them, plus sometimes you need more than one, depending on how you are using the box).