We introduce a hierarchy of conditions necessarily satisfied by any distribution P(ab) representing the probabilities for two separate observers to obtain outcomes a and b when making local measurements on a shared quantum state. Each condition in this hierarchy is formulated as a semidefinite program. Our approach can be used to obtain upper-bounds on the quantum violation of an arbitrary Bell inequality. It yields, for instance, tight bounds for the violations of the Collins et al. inequalities.